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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -6
- data/app/controllers/admin/pages_controller.rb +0 -5
- data/app/controllers/admin/resource_controller.rb +1 -11
- data/app/helpers/admin/url_helper.rb +16 -12
- data/app/models/page.rb +3 -5
- data/app/views/admin/pages/_fields.html.haml +1 -1
- data/lib/trusty_cms/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 185eb1c3a53672bca444539bfcbb360549c22e9158be57c5463b404f0f705f57
|
4
|
+
data.tar.gz: c45948714f364615ac757a3ae19784bd61e1e059e0617aedc012060b2606c054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bba25302dd2febb18847d30e00daeeb45421e919cb191e64894ce09d0d328a426ac041e1a13f581ede3ff6aa936f90407190d9c3653858c56139a3342a49019
|
7
|
+
data.tar.gz: 1d6e40435e549b2046440cff8aa1178057388b10e98a70b16fdfd42d3da4041b15f7ccb7059eafa66f7d47b09ff831040f9a73602718b1ebbdbe62cc04d3a598
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -77,13 +77,17 @@ Steps:
|
|
77
77
|
|
78
78
|
rspec
|
79
79
|
|
80
|
-
### Page Type Routes Setup
|
81
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
-
|
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
|
123
|
-
|
124
|
-
|
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: @
|
79
|
+
#view-page-url-data{ data: { url: @page_url } }
|
80
80
|
- form_bottom.edit_timestamp do
|
81
81
|
= updated_stamp @page
|
82
82
|
|
data/lib/trusty_cms/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2025-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage-validator
|