refinerycms-pages 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/refinery/admin/page_parts_controller.rb +2 -1
  3. data/app/controllers/refinery/admin/pages_controller.rb +12 -11
  4. data/app/controllers/refinery/admin/pages_dialogs_controller.rb +8 -8
  5. data/app/controllers/refinery/pages/admin/preview_controller.rb +7 -0
  6. data/app/controllers/refinery/pages_controller.rb +4 -1
  7. data/app/helpers/refinery/admin/pages_helper.rb +29 -7
  8. data/app/models/refinery/page.rb +39 -51
  9. data/app/models/refinery/page_part.rb +12 -6
  10. data/app/presenters/refinery/pages/menu_presenter.rb +2 -2
  11. data/app/views/refinery/admin/pages/_form.html.erb +10 -10
  12. data/app/views/refinery/admin/pages/_page.html.erb +17 -45
  13. data/app/views/refinery/admin/pages/_sortable_list.html.erb +1 -1
  14. data/app/views/refinery/admin/pages/children.html.erb +1 -1
  15. data/app/views/refinery/admin/pages_dialogs/_page_link.html.erb +1 -1
  16. data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +28 -21
  17. data/config/locales/en.yml +3 -3
  18. data/config/locales/sk.yml +4 -2
  19. data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +27 -30
  20. data/db/seeds.rb +1 -1
  21. data/lib/generators/refinery/pages/pages_generator.rb +1 -1
  22. data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +10 -3
  23. data/lib/refinery/pages/configuration.rb +8 -5
  24. data/lib/refinery/pages/engine.rb +2 -1
  25. data/lib/refinery/pages/finder.rb +95 -96
  26. data/lib/refinery/pages/instance_methods.rb +6 -4
  27. data/lib/refinery/pages.rb +3 -3
  28. data/lib/refinerycms/pages.rb +1 -0
  29. data/refinerycms-pages.gemspec +16 -22
  30. data/spec/controllers/refinery/pages_controller_spec.rb +23 -6
  31. data/spec/factories/page_parts.rb +2 -2
  32. data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +8 -18
  33. data/spec/models/refinery/page_menu_spec.rb +2 -2
  34. data/spec/models/refinery/page_url_spec.rb +4 -4
  35. data/spec/support/refinery/pages/caching_helpers.rb +1 -1
  36. data/spec/support/selector_helpers.rb +43 -0
  37. data/spec/{features → system}/refinery/admin/pages_spec.rb +164 -155
  38. data/spec/{features → system}/refinery/pages_spec.rb +10 -10
  39. metadata +48 -102
  40. checksums.yaml.gz.sig +0 -3
  41. data.tar.gz.sig +0 -0
  42. metadata.gz.sig +0 -2
@@ -13,7 +13,7 @@
13
13
  <input type="radio" name="link_to" value="email_address" id="link_to_email_address" <%= 'checked="true"'.html_safe if @email_address_area_selected %> />
14
14
  <label for="link_to_email_address" class="stripped"><%= t('tab_name', :scope => 'refinery.admin.pages_dialogs.link_to.email_address') %></label>
15
15
  </span>
16
- <% if ::Refinery::Plugins.registered.names.include?("refinery_files") and @resources.any? %>
16
+ <% if ::Refinery::Plugins.registered.names.include?("refinery_files") && (@resources.any? || searching?) %>
17
17
  <span id="resource_file_radio" class="radio<%= ' selected_radio' if @resource_area_selected %>">
18
18
  <input type="radio" name="link_to" value="resource_file" id="link_to_resource_file" <%= 'checked="true"'.html_safe if @resource_area_selected %> />
19
19
  <label for="link_to_resource_file" class="stripped"><%= t('tab_name', :scope => 'refinery.admin.pages_dialogs.link_to.your_resource') %></label>
@@ -27,10 +27,10 @@
27
27
  <div id="your_page_content" class="clearfix">
28
28
  <div id="pages_list" class="pages_list">
29
29
  <ul class="link_list">
30
- <%= render :partial => 'page_link', :collection => @pages,
31
- :locals => {
32
- :child => 0,
33
- :link_to_arguments => {}
30
+ <%= render partial: '/refinery/admin/pages_dialogs/page_link', collection: @pages, cached: true,
31
+ locals: {
32
+ child: 0,
33
+ link_to_arguments: {}
34
34
  } %>
35
35
  </ul>
36
36
  <%= will_paginate @pages, :id => 'pages_paginate' %>
@@ -86,24 +86,31 @@
86
86
  </ol>
87
87
  </div>
88
88
  </div>
89
- <% if ::Refinery::Plugins.registered.names.include?("refinery_files") and @resources.any? %>
89
+ <% if ::Refinery::Plugins.registered.names.include?("refinery_files") && (@resources.any? || searching?) %>
90
90
  <div id="resource_file_area"<%= ' style="display:none"'.html_safe unless @resource_area_selected %> class="dialog_area">
91
+ <%= render '/refinery/admin/search', url: refinery.insert_admin_resources_path(params.to_unsafe_h.dup.except('resource')) %>
92
+
91
93
  <div id="resources_list" class="pages_list">
92
- <ul class="link_list">
93
- <% @resources.each do |resource| -%>
94
- <% resource_linked = (resource.url == params[:current_link]) unless params[:current_link].blank? %>
95
- <li<%= ' class="linked"'.html_safe if resource_linked %>>
96
- <%= link_to "#{resource.title}.#{resource.ext}", path_to_asset(resource.url),
97
- :title => t('link_to_this_resource', :scope => 'refinery.admin.pages_dialogs.link_to.your_resource'),
98
- :rel => resource.title,
99
- :class => "page_link #{resource.ext}" %>
100
- </li>
101
- <% end %>
102
- </ul>
103
- <%= will_paginate @resources,
104
- :param_name => :resource_page,
105
- :params => {:paginating => "resource_file"},
106
- :id => 'resouces_paginate' %>
94
+ <% if @resources.any? %>
95
+ <ul class="link_list">
96
+ <% @resources.each do |resource| -%>
97
+ <% resource_linked = (resource.url == params[:current_link]) unless params[:current_link].blank? %>
98
+ <li<%= ' class="linked"'.html_safe if resource_linked %>>
99
+ <%= link_to "#{resource.title}.#{resource.ext}", path_to_asset(resource.url),
100
+ :title => t('link_to_this_resource', :scope => 'refinery.admin.pages_dialogs.link_to.your_resource'),
101
+ :rel => resource.title,
102
+ :class => "page_link #{resource.ext}" %>
103
+ </li>
104
+ <% end %>
105
+ </ul>
106
+
107
+ <%= will_paginate @resources,
108
+ :param_name => :resource_page,
109
+ :params => {:paginating => "resource_file"},
110
+ :id => 'resouces_paginate' %>
111
+ <% elsif searching? %>
112
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
113
+ <% end %>
107
114
  </div>
108
115
  </div>
109
116
  <% end %>
@@ -32,15 +32,15 @@ en:
32
32
  tab_name: Your file
33
33
  link_to_this_resource: Link to this file
34
34
  pages:
35
- delete: Remove this page forever
36
- edit: Edit this page
37
- new: Add a new child page
38
35
  expand_collapse: Expand or collapse sub pages
39
36
  page:
40
37
  draft: draft
41
38
  hidden: hidden
42
39
  redirected: Redirected
43
40
  skip_to_first_child: Skip to first child
41
+ delete: Remove this page forever
42
+ edit: Edit this page
43
+ new: Add a new child page
44
44
  view_live_html: View this page live <br/><em>(opens in a new window)</em>
45
45
  form:
46
46
  preview: Preview
@@ -37,9 +37,11 @@ sk:
37
37
  new: Pridať novú podstránku
38
38
  expand_collapse: Rozbaliť alebo zbaliť podstránky
39
39
  page:
40
- view_live_html: Zobraziť stránku <br/><em>(otvorí sa v novom okne)</em>
41
- hidden: skrytá
42
40
  draft: pracovná verzia
41
+ hidden: skrytá
42
+ redirected: Presmerovanie
43
+ skip_to_first_child: Presmerovať na prvú substránku
44
+ view_live_html: Zobraziť stránku <br/><em>(otvorí sa v novom okne)</em>
43
45
  form:
44
46
  preview: Náhľad
45
47
  preview_changes: Zobraziť náhľad s vykonanými zmenami
@@ -1,5 +1,5 @@
1
1
  class CreateRefinerycmsPagesSchema < ActiveRecord::Migration[4.2]
2
- def up
2
+ def change
3
3
  create_table :refinery_page_parts do |t|
4
4
  t.integer :refinery_page_id
5
5
  t.string :title
@@ -38,38 +38,35 @@ class CreateRefinerycmsPagesSchema < ActiveRecord::Migration[4.2]
38
38
  add_index :refinery_pages, :parent_id
39
39
  add_index :refinery_pages, :rgt
40
40
 
41
- begin
42
- ::Refinery::PagePart.create_translation_table!({
43
- :body => :text
44
- })
45
- rescue NameError
46
- warn "Refinery::PagePart was not defined!"
47
- end
41
+ create_table :refinery_page_part_translations do |t|
48
42
 
49
- begin
50
- ::Refinery::Page.create_translation_table!({
51
- :title => :string,
52
- :custom_slug => :string,
53
- :menu_title => :string,
54
- :slug => :string
55
- })
56
- rescue NameError
57
- warn "Refinery::Page was not defined!"
58
- end
59
- end
43
+ # Translated attribute(s)
44
+ t.text :body
60
45
 
61
- def down
62
- drop_table :refinery_page_parts
63
- drop_table :refinery_pages
64
- begin
65
- ::Refinery::PagePart.drop_translation_table!
66
- rescue NameError
67
- warn "Refinery::PagePart was not defined!"
46
+ t.string :locale, null: false
47
+ t.integer :refinery_page_part_id, null: false
48
+
49
+ t.timestamps null: false
68
50
  end
69
- begin
70
- ::Refinery::Page.drop_translation_table! if defined?(::Refinery::Page)
71
- rescue NameError
72
- warn "Refinery::Page was not defined!"
51
+
52
+ add_index :refinery_page_part_translations, :locale, name: :index_refinery_page_part_translations_on_locale
53
+ add_index :refinery_page_part_translations, [:refinery_page_part_id, :locale], name: :index_93b7363baf444ecab114aab0bbdedc79d0ec4f4b, unique: true
54
+
55
+ create_table :refinery_page_translations do |t|
56
+
57
+ # Translated attribute(s)
58
+ t.string :title
59
+ t.string :custom_slug
60
+ t.string :menu_title
61
+ t.string :slug
62
+
63
+ t.string :locale, null: false
64
+ t.integer :refinery_page_id, null: false
65
+
66
+ t.timestamps null: false
73
67
  end
68
+
69
+ add_index :refinery_page_translations, :locale, name: :index_refinery_page_translations_on_locale
70
+ add_index :refinery_page_translations, [:refinery_page_id, :locale], name: :index_refinery_page_t10s_on_refinery_page_id_and_locale, unique: true
74
71
  end
75
72
  end
data/db/seeds.rb CHANGED
@@ -51,7 +51,7 @@ Refinery::I18n.frontend_locales.each do |lang|
51
51
  'about' => 'About'
52
52
  }.each do |slug, title|
53
53
  Refinery::Page.by_title(title).each do |page|
54
- page.update_attributes slug: slug
54
+ page.update slug: slug
55
55
  end
56
56
  end
57
57
  end
@@ -15,7 +15,7 @@ module Refinery
15
15
  end
16
16
 
17
17
  def append_load_seed_data
18
- create_file "db/seeds.rb" unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
18
+ create_file "db/seeds.rb" unless File.exist?(File.join(destination_root, 'db', 'seeds.rb'))
19
19
  append_file 'db/seeds.rb', :verbose => true do
20
20
  <<-EOH
21
21
 
@@ -18,6 +18,9 @@ Refinery::Pages.configure do |config|
18
18
  # This only applies when marketable_urls is enabled.
19
19
  # config.friendly_id_reserved_words = <%= Refinery::Pages.friendly_id_reserved_words.inspect %>
20
20
 
21
+ # You can specify reserved paths that won't interfere with others routes like ActiveStorage route
22
+ # config.reserved_paths = <%= Refinery::Pages.reserved_paths.inspect %>
23
+
21
24
  # Configure how many pages per page should be displayed when a dialog is presented that contains a links to pages
22
25
  # config.pages_per_dialog = <%= Refinery::Pages.pages_per_dialog.inspect %>
23
26
 
@@ -67,12 +70,16 @@ Refinery::Pages.configure do |config|
67
70
  # config.show_title_in_body = <%= Refinery::Pages.show_title_in_body.inspect %>
68
71
 
69
72
  # You can add new HTML elements not already supported by Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS
70
- # For more information on whitelist see ALLOWED_ELEMENTS
73
+ # For more information on whitelist see ALLOWED_ELEMENTS
71
74
  # (https://github.com/flavorjones/loofah/blob/v2.0.3/lib/loofah/html5/whitelist.rb#L151)
72
75
  # config.add_whitelist_elements = <%= Refinery::Pages.add_whitelist_elements.inspect %>
73
-
76
+
74
77
  # You can add new HTML attributes not already supported by Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
75
- # For more information on whitelist see ALLOWED_ATTRIBUTES
78
+ # For more information on whitelist see ALLOWED_ATTRIBUTES
76
79
  # (https://github.com/flavorjones/loofah/blob/v2.0.3/lib/loofah/html5/whitelist.rb#L152)
77
80
  # config.add_whitelist_attributes = <%= Refinery::Pages.add_whitelist_attributes.inspect %>
81
+
82
+ # You can configure the site so that the home page is a model-index page
83
+ # config.home_page_path = <%= Refinery::Pages.home_page_path.inspect %>
84
+
78
85
  end
@@ -8,8 +8,9 @@ module Refinery
8
8
  :cache_pages_full, :layout_template_whitelist,
9
9
  :use_layout_templates, :page_title, :absolute_page_links, :types,
10
10
  :auto_expand_admin_tree, :show_title_in_body,
11
- :friendly_id_reserved_words, :layout_templates_pattern, :view_templates_pattern,
12
- :add_whitelist_elements, :add_whitelist_attributes, :whitelist_elements, :whitelist_attributes
11
+ :friendly_id_reserved_words, :reserved_paths, :layout_templates_pattern, :view_templates_pattern,
12
+ :add_whitelist_elements, :add_whitelist_attributes, :whitelist_elements, :whitelist_attributes,
13
+ :home_page_path
13
14
 
14
15
  self.pages_per_dialog = 14
15
16
  self.pages_per_admin_index = 20
@@ -25,15 +26,16 @@ module Refinery
25
26
  self.add_whitelist_elements = %w[ source track ]
26
27
  # Note: "data-" attributes are whitelisted by default. See https://github.com/refinery/refinerycms/pull/3187
27
28
  self.add_whitelist_attributes = %w[ kind srclang placeholder controls required ]
29
+ self.home_page_path = "/"
28
30
 
29
31
 
30
32
  class << self
31
33
  def whitelist_elements
32
- Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS.merge(config.add_whitelist_elements)
34
+ Loofah::HTML5::SafeList::ALLOWED_ELEMENTS.merge(config.add_whitelist_elements)
33
35
  end
34
36
 
35
37
  def whitelist_attributes
36
- Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES.merge(config.add_whitelist_attributes)
38
+ Loofah::HTML5::SafeList::ALLOWED_ATTRIBUTES.merge(config.add_whitelist_attributes)
37
39
  end
38
40
 
39
41
  def layout_template_whitelist
@@ -59,9 +61,10 @@ module Refinery
59
61
  self.absolute_page_links = false
60
62
  self.types = Types.registered
61
63
  self.auto_expand_admin_tree = true
64
+ self.reserved_paths = %w(/rails/active_storage)
62
65
  self.friendly_id_reserved_words = %w(
63
66
  index new session login logout users refinery admin images
64
- )
67
+ ) | self.reserved_paths.map { |path| path.split('/').reject(&:blank?).first}.flatten.uniq
65
68
  self.layout_templates_pattern = 'app', 'views', '{layouts,refinery/layouts}', '*html*'
66
69
  self.view_templates_pattern = 'app', 'views', '{pages,refinery/pages}', '*html*'
67
70
  end
@@ -48,7 +48,8 @@ module Refinery
48
48
 
49
49
  def append_marketable_routes
50
50
  Refinery::Core::Engine.routes.append do
51
- get '*path', :to => 'pages#show', :as => :marketable_page
51
+ get '*path', :to => 'pages#show', :as => :marketable_page,
52
+ constraints: lambda { |request| !Refinery::Pages.config.reserved_paths.any? { |path| request.path.start_with?(path) } }
52
53
  end
53
54
  end
54
55
 
@@ -17,7 +17,7 @@ module Refinery
17
17
  FinderBySlug.new(slug, conditions).find
18
18
  end
19
19
 
20
- def self.with_globalize(conditions = {})
20
+ def self.with_mobility(conditions = {})
21
21
  Finder.new(conditions).find
22
22
  end
23
23
 
@@ -26,15 +26,15 @@ module Refinery
26
26
  end
27
27
 
28
28
  def find
29
- with_globalize
29
+ with_mobility
30
30
  end
31
31
 
32
- def with_globalize
33
- globalized_conditions = {:locale => ::Globalize.locale.to_s}.merge(conditions)
34
- translations_conditions = translations_conditions(globalized_conditions)
32
+ def with_mobility
33
+ mobility_conditions = {:locale => ::Mobility.locale.to_s}.merge(conditions)
34
+ translations_conditions = translations_conditions(mobility_conditions)
35
35
 
36
36
  # A join implies readonly which we don't really want.
37
- Page.where(globalized_conditions).
37
+ Page.i18n.where(mobility_conditions).
38
38
  joins(:translations).
39
39
  where(translations_conditions).
40
40
  readonly(false)
@@ -44,136 +44,135 @@ module Refinery
44
44
  attr_accessor :conditions
45
45
 
46
46
  def translated_attributes
47
- Page.translated_attribute_names.map(&:to_s) | %w(locale)
47
+ [*Page.mobility_attributes, 'locale']
48
48
  end
49
49
 
50
50
  def translations_conditions(original_conditions)
51
51
  translations_conditions = {}
52
52
  original_conditions.keys.each do |key|
53
53
  if translated_attributes.include? key.to_s
54
- translations_conditions["#{Page.translation_class.table_name}.#{key}"] = original_conditions.delete(key)
54
+ translations_conditions["#{Page::Translation.table_name}.#{key}"] = original_conditions.delete(key)
55
55
  end
56
56
  end
57
57
  translations_conditions
58
58
  end
59
59
 
60
- end
60
+ class FinderByTitle < Finder
61
+ def initialize(title)
62
+ @title = title
63
+ @conditions = default_conditions
64
+ end
61
65
 
62
- class FinderByTitle < Finder
63
- def initialize(title)
64
- @title = title
65
- @conditions = default_conditions
66
- end
66
+ def default_conditions
67
+ { :title => title }
68
+ end
67
69
 
68
- def default_conditions
69
- { :title => title }
70
+ private
71
+ attr_accessor :title
70
72
  end
71
73
 
72
- private
73
- attr_accessor :title
74
- end
74
+ class FinderBySlug < Finder
75
+ def initialize(slug, conditions)
76
+ @slug = slug
77
+ @conditions = default_conditions.merge(conditions)
78
+ end
75
79
 
76
- class FinderBySlug < Finder
77
- def initialize(slug, conditions)
78
- @slug = slug
79
- @conditions = default_conditions.merge(conditions)
80
- end
80
+ def default_conditions
81
+ {
82
+ :locale => Refinery::I18n.frontend_locales.map(&:to_s),
83
+ :slug => slug
84
+ }
85
+ end
81
86
 
82
- def default_conditions
83
- {
84
- :locale => Refinery::I18n.frontend_locales.map(&:to_s),
85
- :slug => slug
86
- }
87
+ private
88
+ attr_accessor :slug
87
89
  end
88
90
 
89
- private
90
- attr_accessor :slug
91
- end
92
-
93
- class FinderByPath
94
- def initialize(path)
95
- @path = path
96
- end
91
+ class FinderByPath
92
+ def initialize(path)
93
+ @path = path
94
+ end
97
95
 
98
- def find
99
- if slugs_scoped_by_parent?
100
- FinderByScopedPath.new(path).find
101
- else
102
- FinderByUnscopedPath.new(path).find
96
+ def find
97
+ if slugs_scoped_by_parent?
98
+ FinderByScopedPath.new(path).find
99
+ else
100
+ FinderByUnscopedPath.new(path).find
101
+ end
103
102
  end
104
- end
105
103
 
106
- private
107
- attr_accessor :path
104
+ private
105
+ attr_accessor :path
108
106
 
109
- def slugs_scoped_by_parent?
110
- ::Refinery::Pages.scope_slug_by_parent
111
- end
107
+ def slugs_scoped_by_parent?
108
+ ::Refinery::Pages.scope_slug_by_parent
109
+ end
112
110
 
113
- def by_slug(slug_path, conditions = {})
114
- Finder.by_slug(slug_path, conditions)
111
+ def by_slug(slug_path, conditions = {})
112
+ Finder.by_slug(slug_path, conditions)
113
+ end
115
114
  end
116
- end
117
115
 
118
- class FinderByScopedPath < FinderByPath
119
- def find
120
- # With slugs scoped to the parent page we need to find a page by its full path.
121
- # For example with about/example we would need to find 'about' and then its child
122
- # called 'example' otherwise it may clash with another page called /example.
123
- page = parent_page
124
- while page && path_segments.any? do
125
- page = next_page(page)
116
+ class FinderByScopedPath < FinderByPath
117
+ def find
118
+ # With slugs scoped to the parent page we need to find a page by its full path.
119
+ # For example with about/example we would need to find 'about' and then its child
120
+ # called 'example' otherwise it may clash with another page called /example.
121
+ page = parent_page
122
+ while page && path_segments.any? do
123
+ page = next_page(page)
124
+ end
125
+ page
126
126
  end
127
- page
128
- end
129
127
 
130
- private
128
+ private
131
129
 
132
- def path_segments
133
- @path_segments ||= path.split('/').select(&:present?)
134
- end
130
+ def path_segments
131
+ @path_segments ||= path.split('/').select(&:present?)
132
+ end
135
133
 
136
- def parent_page
137
- parent_page_segment = path_segments.shift
138
- if parent_page_segment.friendly_id?
139
- by_slug(parent_page_segment, :parent_id => nil).first
140
- else
141
- Page.find(parent_page_segment)
134
+ def parent_page
135
+ parent_page_segment = path_segments.shift
136
+ if parent_page_segment.friendly_id?
137
+ by_slug(parent_page_segment, :parent_id => nil).first
138
+ else
139
+ Page.find(parent_page_segment)
140
+ end
142
141
  end
143
- end
144
142
 
145
- def next_page(page)
146
- slug_or_id = path_segments.shift
147
- page.children.by_slug(slug_or_id).first || page.children.find(slug_or_id)
143
+ def next_page(page)
144
+ slug_or_id = path_segments.shift
145
+ page.children.by_slug(slug_or_id).first || page.children.find(slug_or_id)
146
+ end
148
147
  end
149
- end
150
148
 
151
- class FinderByUnscopedPath < FinderByPath
152
- def find
153
- by_slug(path).first
149
+ class FinderByUnscopedPath < FinderByPath
150
+ def find
151
+ by_slug(path).first
152
+ end
154
153
  end
155
- end
156
154
 
157
- class FinderByPathOrId
158
- def initialize(path, id)
159
- @path = path
160
- @id = id
161
- end
155
+ class FinderByPathOrId
156
+ def initialize(path, id)
157
+ @path = path
158
+ @id = id
159
+ end
162
160
 
163
- def find
164
- if path.present?
165
- if path.friendly_id?
166
- FinderByPath.new(path).find
167
- else
168
- Page.friendly.find(path)
161
+ def find
162
+ if path.present?
163
+ if path.friendly_id?
164
+ FinderByPath.new(path).find
165
+ else
166
+ Page.friendly.find(path)
167
+ end
168
+ elsif id.present?
169
+ Page.friendly.find(id)
169
170
  end
170
- elsif id.present?
171
- Page.friendly.find(id)
172
171
  end
173
- end
174
172
 
175
- private
176
- attr_accessor :id, :path
173
+ private
174
+ attr_accessor :id, :path
175
+ end
177
176
  end
178
177
  end
179
178
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Refinery
2
4
  module Pages
3
5
  module InstanceMethods
4
6
 
5
7
  def error_404(exception = nil)
6
- if (@page = ::Refinery::Page.where(:menu_match => "^/404$").includes(:parts).first).present?
8
+ if (@page = ::Refinery::Page.where(menu_match: "^/404$").includes(:parts).first).present?
7
9
  # render the application's custom 404 page with layout and meta.
8
10
  if self.respond_to? :render_with_templates?, true
9
- render_with_templates? @page, :status => 404
11
+ render_with_templates? @page, status: 404
10
12
  else
11
- render :template => '/refinery/pages/show', :formats => [:html], :status => 404
13
+ render template: '/refinery/pages/show', format: :html, status: 404
12
14
  end
13
15
  return false
14
16
  else
@@ -16,7 +18,7 @@ module Refinery
16
18
  end
17
19
  end
18
20
 
19
- def render(*args)
21
+ def render(*args, &block)
20
22
  present @page unless admin? || @meta
21
23
  super
22
24
  end
@@ -1,5 +1,5 @@
1
- require 'refinerycms-core'
2
- require 'globalize'
1
+ require 'refinerycms/core'
2
+ require 'mobility'
3
3
 
4
4
  module Refinery
5
5
  autoload :PagesGenerator, 'generators/refinery/pages/pages_generator'
@@ -51,4 +51,4 @@ end
51
51
  require 'friendly_id'
52
52
  require 'seo_meta'
53
53
  require 'babosa'
54
- require 'speakingurl-rails'
54
+ require 'speakingurl-rails'
@@ -0,0 +1 @@
1
+ require_relative '../refinery/pages'
@@ -1,38 +1,32 @@
1
- # Encoding: UTF-8
2
- require File.expand_path('../../core/lib/refinery/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../core/lib/refinery/version', __dir__)
3
4
 
4
5
  version = Refinery::Version.to_s
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.platform = Gem::Platform::RUBY
8
- s.name = %q{refinerycms-pages}
9
+ s.name = 'refinerycms-pages'
9
10
  s.version = version
10
- s.summary = %q{Pages extension for Refinery CMS}
11
- s.description = %q{The default content extension of Refinery CMS. This extension handles the administration and display of user-editable pages.}
12
- s.email = %q{refinerycms@p.arndt.io}
13
- s.homepage = %q{https://www.refinerycms.com}
14
- s.rubyforge_project = %q{refinerycms}
15
- s.authors = ['Philip Arndt', 'Uģis Ozols', 'Rob Yurkowski']
16
- s.license = %q{MIT}
17
- s.require_paths = %w(lib)
11
+ s.summary = 'Pages extension for Refinery CMS'
12
+ s.description = 'The default content extension of Refinery CMS. This extension handles the administration and display of user-editable pages.'
13
+ s.email = 'gems@p.arndt.io'
14
+ s.homepage = 'https://www.refinerycms.com'
15
+ s.authors = ['Philip Arndt', 'David Jones', 'Uģis Ozols', 'Brice Sanchez']
16
+ s.license = 'MIT'
17
+ s.require_paths = %w[lib]
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- spec/*`.split("\n")
21
21
 
22
- s.add_dependency 'friendly_id', ['>= 5.1.0', '< 5.3']
23
- s.add_dependency 'globalize', ['>= 5.1.0.beta1', '< 5.2']
24
- s.add_dependency 'activemodel-serializers-xml', '~> 1.0', '>= 1.0.1'
25
22
  s.add_dependency 'awesome_nested_set', '~> 3.1', '>= 3.1.0'
26
- s.add_dependency 'seo_meta', '~> 3.0', '>= 3.0.0'
23
+ s.add_dependency 'babosa', '~> 1.0'
24
+ s.add_dependency 'diffy', '~> 3.1', '>= 3.1.0'
25
+ s.add_dependency 'friendly_id', '>= 5.4.0'
26
+ s.add_dependency 'friendly_id-mobility', '~> 1.0.4'
27
27
  s.add_dependency 'refinerycms-core', version
28
- s.add_dependency 'babosa', '!= 0.3.6'
28
+ s.add_dependency 'seo_meta', '~> 3.0', '>= 3.0.0'
29
29
  s.add_dependency 'speakingurl-rails', '~> 8.0', '>= 8.0.0'
30
- s.add_dependency 'diffy', '~> 3.1', '>= 3.1.0'
31
30
 
32
31
  s.required_ruby_version = Refinery::Version.required_ruby_version
33
-
34
- s.cert_chain = [File.expand_path("../../certs/parndt.pem", __FILE__)]
35
- if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__)
36
- s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
37
- end
38
32
  end