trusty-cms 7.0.23 → 7.0.25

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 513881146859a4dab77456b9db5c763511c56ef9aed99a9bbc3ad45674076b28
4
- data.tar.gz: cb2331a2f2adc22be478f0fd6786faf3d126f56c36f93291ae0a052e4ddaa203
3
+ metadata.gz: 185eb1c3a53672bca444539bfcbb360549c22e9158be57c5463b404f0f705f57
4
+ data.tar.gz: c45948714f364615ac757a3ae19784bd61e1e059e0617aedc012060b2606c054
5
5
  SHA512:
6
- metadata.gz: 2782c6e5eb865a8c878a4e16ce5b05c5f3e0f072095b8ebbd7ca33647041ccac24b90eedd12f652fd24d515190b93903d877e7475a3b2782d4086e0182625be5
7
- data.tar.gz: 70798e27b9404a6d96559d7bfcbb3731670c9d8b2a80f92aa8b03c10b0c4a28c2fd8ca83b12ba44b67512abef82a51471bd61adf135570865980d62e3cd7c3d6
6
+ metadata.gz: 2bba25302dd2febb18847d30e00daeeb45421e919cb191e64894ce09d0d328a426ac041e1a13f581ede3ff6aa936f90407190d9c3653858c56139a3342a49019
7
+ data.tar.gz: 1d6e40435e549b2046440cff8aa1178057388b10e98a70b16fdfd42d3da4041b15f7ccb7059eafa66f7d47b09ff831040f9a73602718b1ebbdbe62cc04d3a598
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.23)
4
+ trusty-cms (7.0.25)
5
5
  RedCloth (= 4.3.3)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.3.0)
data/README.md CHANGED
@@ -77,13 +77,17 @@ Steps:
77
77
 
78
78
  rspec
79
79
 
80
- ### Page Type Routes Setup
81
- If your TrustyCMS project includes custom Page models, additional configuration is required to ensure proper URL formatting in the Admin interface. This setup allows TrustyCMS to determine the live URL of a page while editing, and to display it conveniently in the Edit Page dropdown menu.
80
+ ### Custom Page Type Routes Setup
81
+ Additional configuration is required to ensure correct URL generation in the admin interface specifically for the "Edit Page" dropdown and the "Save and View Draft" functionality.
82
82
 
83
- To enable this, create the following initializer file: `config/initializers/page_type_routes.rb`
83
+ To enable this, create the following initializer: `config/initializers/page_type_routes.rb`
84
+
85
+ In this file, define a `CUSTOM_PAGE_TYPE_ROUTES` hash constant that maps custom Page model class names to the corresponding route segments defined in your `config/routes.rb` file. For example, the BlogPage model maps to the route `get 'blog/:slug'`, so its route segment is `'blog'`.
86
+
87
+ For custom Page models that rely on default routing behavior, define a `DEFAULT_PAGE_TYPE_ROUTES` array listing their class names. TrustyCMS will use these mappings to correctly build page URLs for use in the admin UI.
84
88
 
85
89
  ```ruby
86
- PAGE_TYPE_ROUTES = {
90
+ CUSTOM_PAGE_TYPE_ROUTES = {
87
91
  BlogPage: 'blog',
88
92
  DonationPage: 'donate',
89
93
  ExhibitionPage: 'exhibit',
@@ -93,9 +97,14 @@ PAGE_TYPE_ROUTES = {
93
97
  ProductionPage: 'production',
94
98
  VenuePage: 'venues',
95
99
  }.freeze
96
- ```
97
100
 
98
- This `PAGE_TYPE_ROUTES` constant maps custom Page model names to their corresponding route segments as defined in `config/routes.rb`. TrustyCMS will use these mappings to generate URLs for pages in the admin interface.
101
+ DEFAULT_PAGE_TYPE_ROUTES = %w[
102
+ ConstituencyPage
103
+ FacilityPage
104
+ FileNotFoundPage
105
+ RailsPage
106
+ ].freeze
107
+ ```
99
108
 
100
109
  ### Page Status Refresh Setup
101
110
 
@@ -2,7 +2,6 @@ class Admin::PagesController < Admin::ResourceController
2
2
  before_action :initialize_meta_rows_and_buttons, only: %i[new edit create update]
3
3
  before_action :count_deleted_pages, only: [:destroy]
4
4
  before_action :set_page, only: %i[edit restore]
5
- before_action :generate_view_page_url, only: [:edit]
6
5
  rescue_from ActiveRecord::RecordInvalid, with: :validation_error
7
6
  include Admin::NodeHelper
8
7
  include Admin::PagesHelper
@@ -75,10 +74,6 @@ class Admin::PagesController < Admin::ResourceController
75
74
  @page = Page.find(params[:id])
76
75
  end
77
76
 
78
- def generate_view_page_url
79
- @view_page_url = generate_page_url(request.url, @page)
80
- end
81
-
82
77
  def set_site_and_homepage
83
78
  @site ||= Page.current_site
84
79
  @homepage = @site&.homepage || Page.homepage
@@ -202,19 +202,9 @@ class Admin::ResourceController < ApplicationController
202
202
  end
203
203
 
204
204
  def redirect_url
205
- return edit_admin_page_url(model) if params[:continue]
206
205
  return "#{edit_admin_page_url(model)}?view_page=true" if params[:save_and_view]
207
206
 
208
- admin_pages_url(site_id: model.site.id)
209
- end
210
-
211
- def index_page_for_model
212
- parts = { action: 'index' }
213
- if paginated? && model && i = model_class.all.index(model)
214
- p = (i / pagination_parameters[:per_page].to_i) + 1
215
- parts[:p] = p if p && p > 1
216
- end
217
- parts
207
+ params[:continue] ? { action: 'edit', id: model.id } : { action: 'index' }
218
208
  end
219
209
 
220
210
  def edit_model_path
@@ -1,13 +1,18 @@
1
1
  module Admin::UrlHelper
2
2
  require 'uri'
3
3
 
4
+ def generate_page_url(url, page)
5
+ base_url = extract_base_url(url)
6
+ build_url(base_url, page)
7
+ end
8
+
4
9
  def build_url(base_url, page)
5
- if page.class.name == 'Page'
6
- "#{base_url}#{page.path}"
7
- else
8
- path = lookup_page_path(page)
9
- path ? "#{base_url}/#{path}/#{page.slug}" : nil
10
- end
10
+ return "#{base_url}#{page.path}" if default_route?(page)
11
+
12
+ path = lookup_page_path(page)
13
+ return nil unless path
14
+
15
+ "#{base_url}/#{path}/#{page.slug}"
11
16
  end
12
17
 
13
18
  def extract_base_url(url)
@@ -19,15 +24,14 @@ module Admin::UrlHelper
19
24
  "#{scheme}://#{host}"
20
25
  end
21
26
 
22
- def generate_page_url(url, page)
23
- base_url = extract_base_url(url)
24
- build_url(base_url, page)
27
+ def default_route?(page)
28
+ page_class_name = page.class.name
29
+ page_class_name == 'Page' || (defined?(DEFAULT_PAGE_TYPE_ROUTES) && DEFAULT_PAGE_TYPE_ROUTES.include?(page_class_name))
25
30
  end
26
31
 
27
32
  def lookup_page_path(page)
28
- # Use the globally defined PAGE_TYPE_ROUTES from the parent application
29
- return nil unless defined?(PAGE_TYPE_ROUTES) && PAGE_TYPE_ROUTES.is_a?(Hash)
33
+ return nil unless defined?(CUSTOM_PAGE_TYPE_ROUTES) && CUSTOM_PAGE_TYPE_ROUTES.is_a?(Hash)
30
34
 
31
- PAGE_TYPE_ROUTES[page.class.name.to_sym]
35
+ CUSTOM_PAGE_TYPE_ROUTES[page.class.name.to_sym]
32
36
  end
33
37
  end
data/app/models/page.rb CHANGED
@@ -119,11 +119,9 @@ class Page < ActiveRecord::Base
119
119
  end
120
120
 
121
121
  def path
122
- if parent?
123
- parent.child_path(self)
124
- else
125
- clean_path(slug)
126
- end
122
+ return '' if slug.blank?
123
+
124
+ parent? ? parent.child_path(self) : clean_path(slug)
127
125
  end
128
126
 
129
127
  alias_method :url, :path
@@ -76,7 +76,7 @@
76
76
  = save_model_and_view_page_button(@page)
77
77
  = t('or')
78
78
  = link_to t('cancel'), admin_pages_url(site_id: @site_id), class: 'alt'
79
- #view-page-url-data{ data: { url: @view_page_url } }
79
+ #view-page-url-data{ data: { url: @page_url } }
80
80
  - form_bottom.edit_timestamp do
81
81
  = updated_stamp @page
82
82
 
@@ -1,3 +1,3 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.23'.freeze
2
+ VERSION = '7.0.25'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.23
4
+ version: 7.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator