trusty-cms 7.0.24 → 7.0.26

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: 3380e3eea06aeafbcf42ad8bcfbeb6d7aab6b62289265fbc81b74430c4a9c0c0
4
- data.tar.gz: c6cac4b877f787958f03862fe734754a08d6f15173579c32c4ec82f6dae90a12
3
+ metadata.gz: d45d76c458d982e12e398501691b9c80786772ae9a752b2476bcababf4f97ceb
4
+ data.tar.gz: c5ff04b23662c3df08191e9780008c1f28b7eaffcb6f54a912dda3521f2bf22e
5
5
  SHA512:
6
- metadata.gz: 353a1a00a9298e3eeec76e1cc0c5785c0be100cc72ac1cba77ed04a23ddefa3e288a606fd2201c54a9fc12dcc8e00ed5216013c773a167e0bf478e10ed283d61
7
- data.tar.gz: cbf06b90eb40e47bca28107fc9a3b67dd2c5ab9a8117add664271962730fb04d6eda6631c0408d30e980672c0ac0cb34cff26035d41cfe338e677b29869447a3
6
+ metadata.gz: 9b73ce6f51a809957d30ca3a51a67f2496db293b1160438608029d3a6e3ec40ea6aea40adad0d60374212a3475a508e900505b957890c486e505d47b15a3a69c
7
+ data.tar.gz: 0b72e9b00f8dd0b2b5964f4d00f6d6cc085052a7c0e9635f48a6aee8325460d2890449b0a65200b490087c4b3d82c589d63987e987954c9e5278f92a4e315134
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.24)
4
+ trusty-cms (7.0.26)
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
@@ -106,6 +106,11 @@ DEFAULT_PAGE_TYPE_ROUTES = %w[
106
106
  ].freeze
107
107
  ```
108
108
 
109
+ ### Save and View Draft Caching
110
+ To ensure that pages and drafts under development are not cached by the browser or content delivery networks (such as CloudFront), the CMS appends a `trusty-no-cache` URL parameter containing the current date and time when a user selects **Save and View Draft** or **Save and View Page**.
111
+
112
+ Because the `trusty-no-cache` parameter is always unique, it effectively bypasses caching mechanisms at both the CDN and browser levels, ensuring the user receives the most up-to-date version of the content with every request. Note that additional CDN configuration may be required to ensure query parameters are respected.
113
+
109
114
  ### Page Status Refresh Setup
110
115
 
111
116
  To ensure **Scheduled Pages** automatically update their status to **Published** after their designated **Publish Date & Time**, follow these steps to set up an automated refresh using **AWS Lambda** and **EventBridge**.
@@ -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
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,20 +76,22 @@
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
 
83
83
  -# Opens a new tab with the page URL when "Save and View Page" is selected
84
84
  :javascript
85
85
  document.addEventListener("DOMContentLoaded", function() {
86
- let params = new URLSearchParams(window.location.search);
87
- let dataDiv = document.getElementById("view-page-url-data");
86
+ const params = new URLSearchParams(window.location.search);
87
+ const dataDiv = document.getElementById("view-page-url-data");
88
+ const baseUrl = dataDiv?.dataset?.url;
88
89
 
89
- if (params.get("view_page") === "true" && dataDiv) {
90
- let newTabUrl = dataDiv.dataset.url;
91
- if (newTabUrl) {
92
- window.open(newTabUrl, '_blank');
93
- }
90
+ if (params.get("view_page") === "true" && baseUrl) {
91
+ const now = new Date().toISOString();
92
+ const separator = baseUrl.includes("?") ? "&" : "?";
93
+ const newTabUrl = `${baseUrl}${separator}trusty-no-cache=${encodeURIComponent(now)}`;
94
+ window.open(newTabUrl, '_blank');
94
95
  }
95
96
  });
97
+
@@ -1,3 +1,3 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.24'.freeze
2
+ VERSION = '7.0.26'.freeze
3
3
  end
@@ -36,10 +36,15 @@ module ShareLayouts
36
36
  end
37
37
 
38
38
  def find_page
39
- page = Page.find_by_path(request.path) rescue nil
39
+ page = Page.find_by_path(request.path, can_view_drafts?) rescue nil
40
40
  page.is_a?(RailsPage) ? page : RailsPage.new(:class_name => "RailsPage")
41
41
  end
42
-
42
+
43
+ private
44
+
45
+ def can_view_drafts?
46
+ user_signed_in? # CMS users can view drafts
47
+ end
43
48
  end
44
49
  end
45
50
 
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.24
4
+ version: 7.0.26
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-31 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator