refinerycms-pages 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/refinery/admin/page_parts_controller.rb +6 -1
- data/app/controllers/refinery/admin/pages_controller.rb +53 -45
- data/app/controllers/refinery/pages/admin/preview_controller.rb +12 -3
- data/app/controllers/refinery/pages_controller.rb +12 -12
- data/app/helpers/refinery/admin/pages_helper.rb +5 -4
- data/app/helpers/refinery/pages/content_pages_helper.rb +6 -1
- data/app/models/refinery/page.rb +115 -141
- data/app/models/refinery/page_part.rb +32 -7
- data/app/presenters/refinery/pages/content_presenter.rb +7 -5
- data/app/presenters/refinery/pages/menu_presenter.rb +41 -15
- data/app/presenters/refinery/pages/page_part_section_presenter.rb +1 -7
- data/app/presenters/refinery/pages/section_presenter.rb +2 -6
- data/app/views/refinery/admin/pages/_actions.html.erb +4 -13
- data/app/views/refinery/admin/pages/_form.html.erb +7 -10
- data/app/views/refinery/admin/pages/_form_advanced_options.html.erb +5 -3
- data/app/views/refinery/admin/pages/_form_extra_fields_for_more_options.html.erb +1 -0
- data/app/views/refinery/admin/pages/_form_new_page_parts.html.erb +8 -0
- data/app/views/refinery/admin/pages/_form_page_parts.html.erb +10 -21
- data/app/views/refinery/admin/pages/_page.html.erb +31 -31
- data/app/views/refinery/admin/pages/_page_part_field.html.erb +2 -1
- data/app/views/refinery/admin/pages/_records.html.erb +3 -3
- data/app/views/refinery/admin/pages/_save_and_continue_callback.html.erb +1 -0
- data/app/views/refinery/admin/pages/index.html.erb +2 -4
- data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +1 -1
- data/config/locales/bg.yml +1 -2
- data/config/locales/ca.yml +85 -0
- data/config/locales/cs.yml +13 -3
- data/config/locales/da.yml +1 -2
- data/config/locales/de.yml +0 -1
- data/config/locales/el.yml +41 -29
- data/config/locales/en.yml +2 -2
- data/config/locales/es.yml +2 -4
- data/config/locales/fi.yml +1 -4
- data/config/locales/fr.yml +2 -2
- data/config/locales/hu.yml +1 -2
- data/config/locales/it.yml +15 -16
- data/config/locales/ja.yml +1 -3
- data/config/locales/ko.yml +1 -4
- data/config/locales/lt.yml +1 -3
- data/config/locales/lv.yml +0 -2
- data/config/locales/nb.yml +1 -4
- data/config/locales/nl.yml +1 -2
- data/config/locales/pl.yml +1 -13
- data/config/locales/pt-BR.yml +1 -3
- data/config/locales/pt.yml +1 -2
- data/config/locales/rs.yml +1 -3
- data/config/locales/ru.yml +8 -5
- data/config/locales/sk.yml +1 -2
- data/config/locales/sl.yml +1 -3
- data/config/locales/sv.yml +1 -3
- data/config/locales/tr.yml +1 -2
- data/config/locales/uk.yml +1 -5
- data/config/locales/vi.yml +1 -3
- data/config/locales/zh-CN.yml +1 -4
- data/config/locales/zh-TW.yml +1 -3
- data/config/routes.rb +16 -16
- data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +28 -11
- data/db/migrate/20140105190324_add_custom_slug_to_refinery_pages.rb +20 -0
- data/db/migrate/20150130044643_add_slug_to_refinery_page_parts.rb +6 -0
- data/db/migrate/20150720155305_update_slug_and_title_in_refinery_page_parts.rb +13 -0
- data/db/seeds.rb +42 -36
- data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +12 -0
- data/lib/refinery/pages.rb +4 -3
- data/lib/refinery/pages/admin/instance_methods.rb +3 -3
- data/lib/refinery/pages/configuration.rb +7 -1
- data/lib/refinery/pages/engine.rb +19 -18
- data/lib/refinery/pages/finder.rb +179 -0
- data/lib/refinery/pages/instance_methods.rb +3 -14
- data/lib/refinery/pages/tab.rb +2 -2
- data/lib/refinery/pages/types.rb +1 -1
- data/lib/refinery/pages/url.rb +15 -3
- data/license.md +1 -1
- data/refinerycms-pages.gemspec +8 -5
- data/spec/controllers/refinery/admin/pages_controller_spec.rb +53 -0
- data/spec/controllers/refinery/pages_controller_spec.rb +1 -1
- data/spec/factories/pages.rb +1 -1
- data/spec/features/refinery/admin/pages_spec.rb +274 -290
- data/spec/features/refinery/pages_spec.rb +123 -138
- data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +15 -11
- data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +11 -11
- data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +1 -1
- data/spec/lib/pages_spec.rb +2 -2
- data/spec/lib/refinery/pages/tab_spec.rb +9 -9
- data/spec/lib/refinery/pages/url_spec.rb +12 -12
- data/spec/models/refinery/page_finder_spec.rb +72 -0
- data/spec/models/refinery/page_menu_spec.rb +107 -0
- data/spec/models/refinery/page_meta_data_spec.rb +49 -0
- data/spec/models/refinery/page_part_spec.rb +67 -0
- data/spec/models/refinery/page_spec.rb +16 -534
- data/spec/models/refinery/page_url_spec.rb +320 -0
- data/spec/presenters/refinery/pages/content_page_presenter_spec.rb +9 -9
- data/spec/presenters/refinery/pages/content_presenter_spec.rb +20 -20
- data/spec/presenters/refinery/pages/menu_presenter_spec.rb +44 -6
- data/spec/presenters/refinery/pages/page_part_section_presenter_spec.rb +12 -12
- data/spec/presenters/refinery/pages/section_presenter_spec.rb +22 -22
- data/spec/presenters/refinery/pages/title_section_presenter_spec.rb +4 -4
- data/spec/support/refinery/pages/caching_helpers.rb +2 -2
- metadata +55 -25
- data/app/helpers/refinery/admin/page_parts_helper.rb +0 -6
- data/app/helpers/refinery/admin/pages_dialogs_helper.rb +0 -6
- data/app/sweepers/refinery/pages/page_sweeper.rb +0 -29
- data/lib/refinery/pages/caching.rb +0 -60
- data/spec/lib/refinery/pages/caching_spec.rb +0 -90
- data/spec/support/refinery/pages/caching.rb +0 -19
@@ -1,29 +0,0 @@
|
|
1
|
-
module Refinery
|
2
|
-
module Pages
|
3
|
-
class PageSweeper < ActionController::Caching::Sweeper
|
4
|
-
observe Page
|
5
|
-
|
6
|
-
def after_save(page)
|
7
|
-
expire_cache!
|
8
|
-
end
|
9
|
-
|
10
|
-
def after_destroy(page)
|
11
|
-
expire_cache!
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
def cache_directory
|
16
|
-
page_cache_directory
|
17
|
-
end
|
18
|
-
|
19
|
-
def caching
|
20
|
-
@caching ||= Caching.new(cache_directory)
|
21
|
-
end
|
22
|
-
|
23
|
-
def expire_cache!
|
24
|
-
caching.expire!
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Refinery
|
2
|
-
module Pages
|
3
|
-
class Caching
|
4
|
-
|
5
|
-
attr_reader :cache_dir
|
6
|
-
|
7
|
-
def initialize(cache_dir = nil)
|
8
|
-
@cache_dir = cache_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def expire!
|
12
|
-
clear_caching!
|
13
|
-
delete_static_files!
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
delegate :cache, :to => Rails
|
18
|
-
|
19
|
-
def cache_dir_valid?
|
20
|
-
cache_dir.present? && cache_dir_path.directory?
|
21
|
-
end
|
22
|
-
|
23
|
-
def cache_dir_path
|
24
|
-
Pathname.new cache_dir.to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
def clear_caching!
|
28
|
-
begin
|
29
|
-
cache.delete_matched(/.*pages.*/)
|
30
|
-
rescue NoMethodError, NotImplementedError
|
31
|
-
warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched - clearing entire cache instead ***"
|
32
|
-
cache.clear
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def delete_static_files!
|
37
|
-
return unless cache_dir_valid?
|
38
|
-
|
39
|
-
delete_page_cache_directory!
|
40
|
-
delete_page_cache_index_file!
|
41
|
-
end
|
42
|
-
|
43
|
-
def delete_page_cache_directory!
|
44
|
-
page_cache_root.rmtree if page_cache_root.directory?
|
45
|
-
end
|
46
|
-
|
47
|
-
def delete_page_cache_index_file!
|
48
|
-
page_cache_index_file.delete if page_cache_index_file.file?
|
49
|
-
end
|
50
|
-
|
51
|
-
def page_cache_index_file
|
52
|
-
Pathname.new "#{page_cache_root}.html"
|
53
|
-
end
|
54
|
-
|
55
|
-
def page_cache_root
|
56
|
-
cache_dir_path.join 'refinery', 'cache', 'pages'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require 'refinery/pages/caching'
|
3
|
-
|
4
|
-
module Refinery
|
5
|
-
module Pages
|
6
|
-
describe Caching, :caching do
|
7
|
-
let(:cache_path) { "/tmp"}
|
8
|
-
let(:refinery_cache_path) { "/tmp/refinery/cache/pages"}
|
9
|
-
let(:refinery_cache_file) { refinery_cache_path + ".html"}
|
10
|
-
before do
|
11
|
-
FileUtils.mkpath refinery_cache_path
|
12
|
-
FileUtils.touch refinery_cache_file
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
FileUtils.rm_rf refinery_cache_path
|
17
|
-
FileUtils.rm_rf refinery_cache_file
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:cache) { Caching.new(cache_path) }
|
21
|
-
|
22
|
-
describe "#expire!" do
|
23
|
-
it "should call #clear_caching! and #delete_static_files!" do
|
24
|
-
cache.should_receive(:clear_caching!)
|
25
|
-
cache.should_receive(:delete_static_files!)
|
26
|
-
cache.expire!
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#clear_caching!" do
|
30
|
-
context "rails cache store supports #delete_matched" do
|
31
|
-
before { Rails.cache.stub(:delete_matched)}
|
32
|
-
|
33
|
-
it "should clear rails cache that matched namespace" do
|
34
|
-
Rails.cache.should_receive(:delete_matched).with(/.*pages.*/)
|
35
|
-
cache.expire!
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "rails cache store does not supports #delete_matched" do
|
40
|
-
before { Rails.cache.stub(:delete_matched).and_raise(NotImplementedError) }
|
41
|
-
|
42
|
-
it "should clear rails cache that matched namespace" do
|
43
|
-
Rails.cache.should_receive(:clear)
|
44
|
-
silence_warnings do
|
45
|
-
cache.expire!
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#delete_static_files!" do
|
52
|
-
context "valid cache directory" do
|
53
|
-
before { cache.should_receive(:cache_dir_valid?).and_return(true) }
|
54
|
-
|
55
|
-
it "should call #delete_page_cache_directory! and #delete_page_cache_index_file!" do
|
56
|
-
cache.should_receive(:delete_page_cache_directory!)
|
57
|
-
cache.should_receive(:delete_page_cache_index_file!)
|
58
|
-
cache.expire!
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should remove page cache directory" do
|
62
|
-
File.exists?(refinery_cache_path).should be_true
|
63
|
-
cache.expire!
|
64
|
-
File.exists?(refinery_cache_path).should be_false
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should remove home page cache file" do
|
68
|
-
File.exists?(refinery_cache_file).should be_true
|
69
|
-
cache.expire!
|
70
|
-
File.exists?(refinery_cache_file).should be_false
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
context "invalid cache directory" do
|
76
|
-
let(:cache) { Caching.new() }
|
77
|
-
before { cache.should_receive(:cache_dir_valid?).and_return(false) }
|
78
|
-
|
79
|
-
it "should not call #delete_page_cache_directory! and #delete_page_cache_index_file!" do
|
80
|
-
cache.should_not_receive(:delete_page_cache_directory!)
|
81
|
-
cache.should_not_receive(:delete_page_cache_index_file!)
|
82
|
-
cache.expire!
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
RSpec.configure do |config|
|
2
|
-
config.before(:each) do
|
3
|
-
Refinery::Pages::PageSweeper.any_instance.stub(:expire_cache!)
|
4
|
-
end
|
5
|
-
|
6
|
-
config.before(:each, :caching => true) do
|
7
|
-
FileUtils.rm_rf "spec/dummy/public/refinery/cache"
|
8
|
-
ActionController::Base.perform_caching = true
|
9
|
-
Refinery::Pages.cache_pages_full = true
|
10
|
-
Refinery::Pages::PageSweeper.any_instance.stub(:cache_directory).and_return(ActionController::Base.page_cache_directory)
|
11
|
-
Refinery::Pages::PageSweeper.any_instance.unstub(:expire_cache!)
|
12
|
-
end
|
13
|
-
|
14
|
-
config.after(:each, :caching => true) do
|
15
|
-
FileUtils.rm_rf "spec/dummy/public/refinery/cache"
|
16
|
-
ActionController::Base.perform_caching = false
|
17
|
-
Refinery::Pages.cache_pages_full = false
|
18
|
-
end
|
19
|
-
end
|