trusty-cms 7.0.22 → 7.0.23

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: 6d89a9b9e2dcf23e551b41e9e59acebc8f1d7326bb856bc5273be76749eae4c1
4
- data.tar.gz: af9ab2fcfab265ffa26c21508744d1216116b0d66b40c96128d702d6cff8ecc2
3
+ metadata.gz: 513881146859a4dab77456b9db5c763511c56ef9aed99a9bbc3ad45674076b28
4
+ data.tar.gz: cb2331a2f2adc22be478f0fd6786faf3d126f56c36f93291ae0a052e4ddaa203
5
5
  SHA512:
6
- metadata.gz: 7875257d4fee723579c5a3505ef55cdf321ef58bc2223ce6d55c207704d93d88a10af8598abf94520a83167dfdb5443d0fd5e999c4222698e8aefbc996c6ea39
7
- data.tar.gz: 3a9184e0283f7dec02b4a5dc54cb63423ca5d41d38384cc0e89b630c77a75e86bec33a3358d568905c77baad4120d4252f27c2dc9c0644a24e7bbc450a9c01a8
6
+ metadata.gz: 2782c6e5eb865a8c878a4e16ce5b05c5f3e0f072095b8ebbd7ca33647041ccac24b90eedd12f652fd24d515190b93903d877e7475a3b2782d4086e0182625be5
7
+ data.tar.gz: 70798e27b9404a6d96559d7bfcbb3731670c9d8b2a80f92aa8b03c10b0c4a28c2fd8ca83b12ba44b67512abef82a51471bd61adf135570865980d62e3cd7c3d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.22)
4
+ trusty-cms (7.0.23)
5
5
  RedCloth (= 4.3.3)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.3.0)
@@ -28,7 +28,6 @@
28
28
  //= require 'admin/page-edit'
29
29
  //= require 'admin/pagefield'
30
30
  //= require 'admin/popup'
31
- //= require 'admin/preview'
32
31
  //= require 'admin/tabcontrol'
33
32
  //= require 'admin/utilities'
34
33
  //= require 'admin/tags'
@@ -3,7 +3,6 @@
3
3
  margin-bottom: 1em;
4
4
 
5
5
  .drawer_contents {
6
- //display: none;
7
6
  table.fieldset {
8
7
  margin: 0;
9
8
  padding: 0;
@@ -32,7 +31,7 @@
32
31
  td {
33
32
  &.field {
34
33
  padding-left: 0px;
35
- padding-right: 10px;
34
+ padding-right: 0px;
36
35
  text-align: right;
37
36
  width: auto;
38
37
 
@@ -55,6 +54,15 @@
55
54
  }
56
55
  }
57
56
  }
57
+
58
+ .url-textbox {
59
+ border: 0.5px solid #919191;
60
+ font-size: 110%;
61
+ margin: 0.5em;
62
+ padding: 0.25em;
63
+ text-align: left;
64
+ width: 99.5%;
65
+ }
58
66
  }
59
67
  }
60
68
 
@@ -2,6 +2,7 @@ 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]
5
6
  rescue_from ActiveRecord::RecordInvalid, with: :validation_error
6
7
  include Admin::NodeHelper
7
8
  include Admin::PagesHelper
@@ -62,12 +63,6 @@ class Admin::PagesController < Admin::ResourceController
62
63
  redirect_to edit_admin_page_path(@page)
63
64
  end
64
65
 
65
- def preview
66
- render_preview
67
- rescue PreviewStop => e
68
- render text: e.message unless @performed_render
69
- end
70
-
71
66
  def save_table_position
72
67
  new_position = params[:new_position]
73
68
  Page.save_order(new_position)
@@ -80,6 +75,10 @@ class Admin::PagesController < Admin::ResourceController
80
75
  @page = Page.find(params[:id])
81
76
  end
82
77
 
78
+ def generate_view_page_url
79
+ @view_page_url = generate_page_url(request.url, @page)
80
+ end
81
+
83
82
  def set_site_and_homepage
84
83
  @site ||= Page.current_site
85
84
  @homepage = @site&.homepage || Page.homepage
@@ -158,25 +157,6 @@ class Admin::PagesController < Admin::ResourceController
158
157
  end
159
158
  end
160
159
 
161
- def render_preview
162
- params.permit!
163
- Page.transaction do
164
- page_class = Page.descendants.include?(model_class) ? model_class : Page
165
- if request.referer =~ %r{/admin/pages/(\d+)/edit}
166
- page = Page.find($1).becomes(page_class)
167
- layout_id = page.layout_id
168
- page.update(params[:page])
169
- page.published_at ||= Time.now
170
- else
171
- page = page_class.new(params[:page])
172
- page.published_at = page.updated_at = page.created_at = Time.now
173
- page.parent = Page.find($1) if request.referer =~ %r{/admin/pages/(\d+)/children/new}
174
- end
175
- page.pagination_parameters = pagination_parameters
176
- process_with_exception(page)
177
- end
178
- end
179
-
180
160
  def process_with_exception(page)
181
161
  page.process(request, response)
182
162
  @performed_render = true
@@ -36,13 +36,13 @@ class Admin::ResourceController < ApplicationController
36
36
  r.stale.default { announce_update_conflict; render action: template_name }
37
37
 
38
38
  r.create.publish(:xml, :json) { render format_symbol => model, :status => :created, :location => url_for(format: format_symbol, id: model) }
39
- r.create.default { redirect_to continue_url(params) }
39
+ r.create.default { redirect_to redirect_url }
40
40
 
41
41
  r.update.publish(:xml, :json) { head :ok }
42
- r.update.default { redirect_to continue_url(params) }
42
+ r.update.default { redirect_to redirect_url }
43
43
 
44
44
  r.destroy.publish(:xml, :json) { head :deleted }
45
- r.destroy.default { redirect_to continue_url(params) }
45
+ r.destroy.default { redirect_to redirect_url }
46
46
  end
47
47
 
48
48
  def index
@@ -201,8 +201,11 @@ class Admin::ResourceController < ApplicationController
201
201
  t(model_name.underscore.downcase)
202
202
  end
203
203
 
204
- def continue_url(options)
205
- options[:redirect_to] || (params[:continue] ? { action: 'edit', id: model.id } : index_page_for_model)
204
+ def redirect_url
205
+ return edit_admin_page_url(model) if params[:continue]
206
+ return "#{edit_admin_page_url(model)}?view_page=true" if params[:save_and_view]
207
+
208
+ admin_pages_url(site_id: model.site.id)
206
209
  end
207
210
 
208
211
  def index_page_for_model
@@ -41,7 +41,7 @@ class SiteController < ApplicationController
41
41
  end
42
42
 
43
43
  def cacheable_request?
44
- (request.head? || request.get?) && live?
44
+ (request.head? || request.get?) && !Rails.env.development?
45
45
  end
46
46
 
47
47
  # hide_action :cacheable_request?
@@ -78,8 +78,7 @@ class SiteController < ApplicationController
78
78
  end
79
79
 
80
80
  def find_page(url)
81
- found = Page.find_by_path(url, live?)
82
- found if found && (found.published? || dev?)
81
+ Page.find_by_path(url, can_view_drafts?)
83
82
  end
84
83
 
85
84
  def process_page(page)
@@ -87,11 +86,7 @@ class SiteController < ApplicationController
87
86
  page.process(request, response)
88
87
  end
89
88
 
90
- def dev?
91
- request.host == @trusty_config['dev.host'] || request.host =~ /^dev\./
92
- end
93
-
94
- def live?
95
- not dev?
89
+ def can_view_drafts?
90
+ user_signed_in? # CMS users can view drafts
96
91
  end
97
92
  end
@@ -1,5 +1,6 @@
1
1
  module ApplicationHelper
2
2
  include Admin::RegionsHelper
3
+ include Admin::UrlHelper
3
4
 
4
5
  def trusty_config
5
6
  TrustyCms::Config
@@ -41,6 +42,16 @@ module ApplicationHelper
41
42
  submit_tag t('buttons.save_and_continue'), name: 'continue', class: 'button', accesskey: 's', id: 'save-and-continue-button'
42
43
  end
43
44
 
45
+ def save_model_and_view_page_button(model, options = {})
46
+ return nil unless generate_page_url(request.url, model)
47
+
48
+ options[:label] ||= model.published? ? t('buttons.save_and_view_page') : t('buttons.save_and_view_draft')
49
+ options[:class] ||= 'button'
50
+ options[:name] ||= 'save_and_view'
51
+ options[:id] ||= 'save-and-view-button'
52
+ submit_tag options.delete(:label), options
53
+ end
54
+
44
55
  def current_item?(item)
45
56
  if item.tab&.many? { |i| current_url?(i.relative_url) }
46
57
  # Accept only stricter URL matches if more than one matches
data/app/models/page.rb CHANGED
@@ -201,21 +201,21 @@ class Page < ActiveRecord::Base
201
201
  parse_object(snippet)
202
202
  end
203
203
 
204
- def find_by_path(path, live = true, clean = true)
204
+ def find_by_path(path, can_view_drafts = false, clean = true)
205
205
  return nil if virtual?
206
206
 
207
207
  path = clean_path(path) if clean
208
208
  my_path = self.path
209
- if (my_path == path) && ((not live) || published?)
209
+ if (my_path == path) && (published? || can_view_drafts)
210
210
  return self
211
211
  elsif path =~ /^#{Regexp.quote(my_path)}([^\/]*)/
212
212
  slug_child = children.find_by_slug($1)
213
213
  if slug_child
214
- found = slug_child.find_by_path(path, live, clean)
214
+ found = slug_child.find_by_path(path, can_view_drafts, clean)
215
215
  return found if found
216
216
  end
217
217
  children.each do |child|
218
- found = child.find_by_path(path, live, clean)
218
+ found = child.find_by_path(path, can_view_drafts, clean)
219
219
  return found if found
220
220
  end
221
221
  end
@@ -224,7 +224,7 @@ class Page < ActiveRecord::Base
224
224
  file_not_found_types = ([FileNotFoundPage] + FileNotFoundPage.descendants)
225
225
  file_not_found_names = file_not_found_types.collect { |x| x.name }
226
226
  condition = (['class_name = ?'] * file_not_found_names.length).join(' or ')
227
- condition = "status_id = #{Status[:published].id} and (#{condition})" if live
227
+ condition = "status_id = #{Status[:published].id} and (#{condition})" unless can_view_drafts
228
228
  return children.where([condition] + file_not_found_names).first
229
229
  end
230
230
  slug_child
@@ -251,10 +251,10 @@ class Page < ActiveRecord::Base
251
251
  find_by_parent_id(nil)
252
252
  end
253
253
 
254
- def find_by_path(path, live = true)
254
+ def find_by_path(path, can_view_drafts = false)
255
255
  raise MissingRootPageError unless root
256
256
 
257
- root.find_by_path(path, live)
257
+ root.find_by_path(path, can_view_drafts)
258
258
  end
259
259
 
260
260
  def date_column_names
@@ -2,7 +2,7 @@ class RailsPage < Page
2
2
  display_name 'Application'
3
3
  attr_accessor :breadcrumbs
4
4
 
5
- def find_by_path(url, live = true, clean = true)
5
+ def find_by_path(url, can_view_draft = false, clean = true)
6
6
  found_page = super
7
7
  if found_page.nil? || found_page.is_a?(FileNotFoundPage)
8
8
  url = clean_url(url) if clean
data/app/models/site.rb CHANGED
@@ -63,13 +63,6 @@ class Site < ActiveRecord::Base
63
63
  uri.to_s
64
64
  end
65
65
 
66
- # Returns the fully specified web address for the development version of this site and the supplied path, or the root of this site if no path is given.
67
-
68
- def dev_url(path = '/')
69
- uri = URI.join("http://#{TrustyCms::Config['dev.host'] || 'dev'}.#{base_domain}", path)
70
- uri.to_s
71
- end
72
-
73
66
  def create_homepage
74
67
  if homepage_id.blank?
75
68
  self.homepage = build_homepage(title: "#{name} Homepage",
@@ -711,7 +711,6 @@ module StandardTags
711
711
  tag 'find' do |tag|
712
712
  required_attr(tag, 'path', 'url')
713
713
  path = tag.attr['path'] || tag.attr['url']
714
-
715
714
  found = Page.find_by_path(absolute_path_for(tag.locals.page.path, path))
716
715
  if page_found?(found)
717
716
  tag.locals.page = found
@@ -903,12 +902,6 @@ module StandardTags
903
902
  tag 'site:host' do |_tag|
904
903
  TrustyCms::Config['site.host']
905
904
  end
906
- desc %{
907
- Returns TrustyCms::Config['dev.host'] as configured under the Settings tab.
908
- }
909
- tag 'site:dev_host' do |_tag|
910
- TrustyCms::Config['dev.host']
911
- end
912
905
 
913
906
  tag 'meta' do |tag|
914
907
  if tag.double?
@@ -1012,7 +1005,7 @@ module StandardTags
1012
1005
  end
1013
1006
  options[:order] = order_string
1014
1007
 
1015
- status = (attr[:status] || (dev?(tag.globals.page.request) ? 'all' : 'published')).downcase
1008
+ status = attr[:status]
1016
1009
  if status == 'all'
1017
1010
  options[:conditions] = ['virtual = ?', false]
1018
1011
  else
@@ -1108,14 +1101,4 @@ module StandardTags
1108
1101
  attr_collection = attribute_names.map { |a| "`#{a}'" }.join(' or ')
1109
1102
  raise TagError.new("`#{tag.name}' tag must contain a #{attr_collection} attribute.") if (tag.attr.keys & attribute_names).blank?
1110
1103
  end
1111
-
1112
- def dev?(request)
1113
- return false if request.nil?
1114
-
1115
- if dev_host = TrustyCms::Config['dev.host']
1116
- dev_host == request.host
1117
- else
1118
- request.host =~ /^dev\./
1119
- end
1120
- end
1121
1104
  end
@@ -50,7 +50,6 @@ module TrustyCms
50
50
  # defaults.page.filter :: the default filter to use on new page parts
51
51
  # defaults.page.fields :: a comma separated list of the default page fields
52
52
  # defaults.snippet.filter :: the default filter to use on new snippets
53
- # dev.host :: the hostname where draft pages are viewable
54
53
  # local.timezone :: the timezone name (`rake -D time` for full list)
55
54
  # used to correct displayed times
56
55
  # page.edit.published_date? :: when true, shows the datetime selector
@@ -139,7 +138,7 @@ module TrustyCms
139
138
  end
140
139
 
141
140
  def site_settings
142
- @site_settings ||= %w{site.title site.host dev.host local.timezone}
141
+ @site_settings ||= %w{site.title site.host local.timezone}
143
142
  end
144
143
 
145
144
  def default_settings
@@ -73,12 +73,23 @@
73
73
  .page-actions
74
74
  = save_model_button(@page)
75
75
  = save_model_and_continue_editing_button(@page)
76
- = submit_tag(t('preview', :default => 'Preview'), :class => 'button', :id => 'show-preview')
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
- #preview_panel.fullcover.grey_out{:style => 'display: none;'}
80
- %iframe{:id => 'page-preview', :class => 'fullcover', :name => 'page-preview', :src => ActionController::Base.relative_url_root.to_s + '/loading-iframe.html', :frameborder => 0, :scrolling => 'auto'}
81
- .preview_tools
82
- =link_to(t('edit_page'), {}, :class => 'button cancel')
79
+ #view-page-url-data{ data: { url: @view_page_url } }
83
80
  - form_bottom.edit_timestamp do
84
81
  = updated_stamp @page
82
+
83
+ -# Opens a new tab with the page URL when "Save and View Page" is selected
84
+ :javascript
85
+ document.addEventListener("DOMContentLoaded", function() {
86
+ let params = new URLSearchParams(window.location.search);
87
+ let dataDiv = document.getElementById("view-page-url-data");
88
+
89
+ if (params.get("view_page") === "true" && dataDiv) {
90
+ let newTabUrl = dataDiv.dataset.url;
91
+ if (newTabUrl) {
92
+ window.open(newTabUrl, '_blank');
93
+ }
94
+ }
95
+ });
@@ -2,4 +2,5 @@
2
2
  %th.label
3
3
  %label{ :for => "page_url" }= t('url')
4
4
  %td.field
5
- = text_field_tag "page[url]", page_url, :id => "page_url_content", :class => 'textbox', :maxlength => 200, disabled: true
5
+ .url-textbox
6
+ = link_to page_url, page_url, target: "_blank"
@@ -1,7 +1,6 @@
1
1
  Rails.application.reloader.to_prepare do
2
2
  TrustyCms.config do |config|
3
3
  config.define 'admin.title', default: 'TrustyCms CMS'
4
- config.define 'dev.host'
5
4
  config.define 'local.timezone', allow_change: true, select_from: lambda { ActiveSupport::TimeZone::MAPPING.keys.sort }
6
5
  config.define 'defaults.locale', select_from: lambda { TrustyCms::AvailableLocales.locales }, allow_blank: true
7
6
  config.define 'defaults.page.parts', default: 'Body,Extended'
@@ -52,6 +52,8 @@ en:
52
52
  buttons:
53
53
  create: 'Create %{name}'
54
54
  save_and_continue: 'Save and Continue Editing'
55
+ save_and_view_draft: 'Save and View Draft'
56
+ save_and_view_page: 'Save and View Page'
55
57
  save_changes: 'Save Changes'
56
58
  cancel: 'Cancel'
57
59
  change: 'Change'
data/config/routes.rb CHANGED
@@ -41,7 +41,6 @@ TrustyCms::Application.routes.draw do
41
41
  end
42
42
  end
43
43
 
44
- match 'admin/preview' => 'admin/pages#preview', :as => :preview, :via => %i[post put]
45
44
  get 'admin' => 'admin/pages#index'
46
45
 
47
46
  namespace :admin do
@@ -1,3 +1,3 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.22'.freeze
2
+ VERSION = '7.0.23'.freeze
3
3
  end
@@ -13,11 +13,11 @@ module MultiSite::PageExtensions
13
13
  base.extend ClassMethods
14
14
  class << base
15
15
 
16
- def find_by_path(path, live=true)
16
+ def find_by_path(path, can_view_drafts = false)
17
17
  root = homepage
18
18
  raise Page::MissingRootPageError unless root
19
19
  path = root.path if clean_path(path) == "/"
20
- result = root.find_by_path(path, live)
20
+ result = root.find_by_path(path, can_view_drafts)
21
21
 
22
22
  # If the result is a FileNotFoundPage and it
23
23
  # doesn't match the current site, try to find one that does.
@@ -6,19 +6,11 @@ module MultiSite::PagesControllerExtensions
6
6
 
7
7
  alias_method :index_without_site, :index
8
8
 
9
- alias_method :continue_url_without_site, :continue_url
10
- alias_method :continue_url, :continue_url_with_site
11
-
12
9
  alias_method :remove_without_back, :remove
13
10
  alias_method :remove, :remove_with_back
14
11
  responses.destroy.default do
15
- return_url = session[:came_from]
16
12
  session[:came_from] = nil
17
- if model.class == Page or model.class < Page
18
- redirect_to return_url || admin_pages_url(:site_id => model.site.id)
19
- else
20
- redirect_to continue_url(params)
21
- end
13
+ redirect_to admin_pages_url(site_id: model.site.id)
22
14
  end
23
15
  }
24
16
  end
@@ -40,8 +32,4 @@ module MultiSite::PagesControllerExtensions
40
32
  session[:came_from] = request.env["HTTP_REFERER"]
41
33
  remove_without_back
42
34
  end
43
-
44
- def continue_url_with_site(options={})
45
- options[:redirect_to] || (params[:continue] ? edit_admin_page_url(model) : admin_pages_url(:site_id => model.site.id))
46
- end
47
35
  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.22
4
+ version: 7.0.23
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 00:00:00.000000000 Z
11
+ date: 2025-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator
@@ -702,7 +702,6 @@ files:
702
702
  - app/assets/javascripts/admin/pagefield.js
703
703
  - app/assets/javascripts/admin/persist.min.js
704
704
  - app/assets/javascripts/admin/popup.js
705
- - app/assets/javascripts/admin/preview.js
706
705
  - app/assets/javascripts/admin/sortable.js
707
706
  - app/assets/javascripts/admin/tabcontrol.js.erb
708
707
  - app/assets/javascripts/admin/tags.js
@@ -1123,7 +1122,6 @@ files:
1123
1122
  - public/dispatch.fcgi
1124
1123
  - public/dispatch.rb
1125
1124
  - public/favicon.ico
1126
- - public/loading-iframe.html
1127
1125
  - public/robots.txt
1128
1126
  - script/extension
1129
1127
  - script/rails
@@ -1,40 +0,0 @@
1
- (function(Preview, $) {
2
- Preview.showPreview = function(form){
3
- var oldTarget = form.target;
4
- var oldAction = form.action;
5
-
6
- var $previewer = $('#preview_panel');
7
- var $preview_tools = $previewer.find('.preview_tools');
8
- var $frame = $('#page-preview');
9
-
10
- $(window).scrollTop(0);
11
- $previewer.show();
12
- $preview_tools.css('opacity', 1);
13
- $('body').addClass('clipped');
14
- form.target = $frame.attr('id');
15
- form.action = relative_url_root + '/admin/preview';
16
- form.submit();
17
-
18
- form.target = oldTarget;
19
- form.action = oldAction;
20
- }
21
-
22
- }(window.Preview = window.Preview || {}, jQuery));
23
-
24
- $(function () {
25
- $('#show-preview').on('click', function(event){
26
- event.preventDefault();
27
- Preview.showPreview(this.form);
28
- });
29
-
30
- $('.preview_tools a.cancel').on('click', function(event){
31
- event.preventDefault();
32
- $('#preview_panel').hide();
33
- $('body').removeClass('clipped');
34
- $('#page-preview').attr('src', '');
35
- });
36
-
37
- $('iframe').on('load', function(event){
38
- $('#preview_panel .preview_tools').css('opacity', null);
39
- });
40
- });
@@ -1,11 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-Equiv="Cache-Control" Content="no-cache">
4
- <meta http-Equiv="Pragma" Content="no-cache">
5
- <meta http-Equiv="Expires" Content="0">
6
- <title>Loading...</title>
7
- </head>
8
- <body>
9
- <p>Loading Preview...</p>
10
- </body>
11
- </html>