trusty-cms 7.0.8 → 7.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 170bd1825c9f7ff25e1bcf51d8ac424e32612d8415a7d640fc441195e9bddb4c
4
- data.tar.gz: 2c367de40351f12fd2d71e2f4fb9ff842a0379fe07f313c8e040a43979bc5e8e
3
+ metadata.gz: 90afffae83c31538f9db86d664a6cf86d4a29b1e910a7bd9644d795949908a8a
4
+ data.tar.gz: 2ed58dea81ef5468bf67ccbac8af93e0fee4918a4937cce840ef39846306e886
5
5
  SHA512:
6
- metadata.gz: 1247c66e283d00de5c30181d53d356271c165401a40de6c8ffbf6d4cbc9dcb31d96e980daea0ac150b64abccd4101dc027b7484f8dfa965db74c36628e0089a6
7
- data.tar.gz: eb1e804f9a828378cc4cf4553c0761753c08b133011409cbc514f79dae86ef377a69c74ef20125f3d472f997d68dc772f291126cd8413b803f775b76e249d5f6
6
+ metadata.gz: 9c7197a1dde572a4b5280165ea6fcfa13be02c3830ff4bd3e5b0038d1ea4ddede69739b76f9373d575517b85fc3925022e357e0aa7efc3678de50aa5ed17faf3
7
+ data.tar.gz: 99658f3bbb7c65c3fdb2e02ddbc2eab6f6cf02b757a332211b81a154eb45e0080c3b61d93d07497d38e4d0f2daa5b74425434cf18875b4ab69358a20d70ffa92
data/Gemfile CHANGED
@@ -7,9 +7,6 @@ source 'https://rubygems.org'
7
7
  # requires trusty and therefore pulls in every
8
8
  # dependency mentioned in trusty.gemspec.
9
9
 
10
- gem 'paper_trail', '~> 16.0.0'
11
- gem 'paper_trail-association_tracking', '~> 2.2.1'
12
- gem 'psych', '5.2.2'
13
10
  gem 'trustygems', '~> 0.2.0'
14
11
 
15
12
  gemspec
@@ -22,8 +19,11 @@ group :development, :test do
22
19
  gem 'file_validators'
23
20
  gem 'launchy', '~> 3.0.1'
24
21
  gem 'mysql2'
22
+ gem 'paper_trail', '~> 16.0.0'
23
+ gem 'paper_trail-association_tracking', '~> 2.2.1'
25
24
  gem 'poltergeist', '~> 1.18.1'
26
25
  gem 'pry-byebug'
26
+ gem 'psych', '5.2.2'
27
27
  gem 'rails-observers'
28
28
  gem 'ransack'
29
29
  gem 'rspec-rails'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.8)
4
+ trusty-cms (7.0.9)
5
5
  RedCloth (= 4.3.3)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.3.0)
@@ -23,12 +23,13 @@ PATH
23
23
  mysql2
24
24
  paper_trail (~> 16.0.0)
25
25
  paper_trail-association_tracking (~> 2.2.1)
26
+ psych (= 5.2.2)
26
27
  rack (>= 2.0.1, < 3.2.0)
27
28
  rack-cache (~> 1.7)
28
29
  radius (~> 0.7)
29
30
  rails (~> 7.0.0)
30
31
  rake (< 14.0)
31
- ransack
32
+ ransack (~> 4.2.1)
32
33
  rdoc (>= 5.1, < 7.0)
33
34
  roadie-rails
34
35
  sass-rails
@@ -1,26 +1,47 @@
1
1
  (function(Dropdown, $) {
2
2
  Dropdown.setup = function(link) {
3
- var menuToWrap = Dropdown.findMenu(link);
4
- if ($(menuToWrap).parent("div").length == 0) {
5
- menuToWrap.wrap("<div class='dropdown_wrapper' style='position: absolute; display: none'></div>");
3
+ var menu = Dropdown.findMenu(link);
6
4
 
7
- $(link).on('click', function (event) {
8
- event.preventDefault();
9
- $(this).toggleClass('selected');
10
- Dropdown.findMenu(this).closest('.dropdown_wrapper').slideToggle();
11
- })
12
- }
13
- }
5
+ // Attach click handler to toggle dropdown
6
+ $(link).off('click').on('click', function(event) {
7
+ event.preventDefault();
8
+ event.stopPropagation();
9
+ var $link = $(this);
10
+ var $menuWrapper = $link.siblings("div.dropdown_wrapper");
11
+
12
+ if ($menuWrapper.is(':visible')) {
13
+ // If already visible, hide it
14
+ $menuWrapper.css('z-index', '').slideUp();
15
+ $link.removeClass('selected');
16
+ } else {
17
+ // Close other dropdowns
18
+ $('.dropdown_wrapper').css('z-index', '').slideUp();
19
+ $('a.dropdown').removeClass('selected');
20
+
21
+ // Show the current dropdown with priority z-index
22
+ $menuWrapper.css('z-index', '1000').slideDown();
23
+ $link.addClass('selected');
24
+ }
25
+ });
26
+ };
14
27
 
15
28
  Dropdown.findMenu = function(link) {
16
29
  var match = $(link).attr('href').match(/#(.+)$/)[1];
17
30
  return $('#' + match);
18
- }
31
+ };
32
+
33
+ // Close dropdown when clicking anywhere else
34
+ $(document).on('click', function(event) {
35
+ if (!$(event.target).closest('.dropdown_wrapper, a.dropdown').length) {
36
+ $('.dropdown_wrapper').css('z-index', '').slideUp();
37
+ $('a.dropdown').removeClass('selected');
38
+ }
39
+ });
19
40
 
20
41
  }(window.Dropdown = window.Dropdown || {}, jQuery));
21
42
 
22
43
  $(function () {
23
- $('a.dropdown').each(function(){
44
+ $('a.dropdown').each(function() {
24
45
  Dropdown.setup(this);
25
46
  });
26
47
  });
@@ -12,7 +12,9 @@
12
12
 
13
13
  .button {
14
14
  @include button;
15
+ display: inline-block;
15
16
  font-size: 1em;
17
+ margin: 0 0.25em 0 0.25em;
16
18
  text-decoration: none;
17
19
  }
18
20
 
@@ -103,3 +103,11 @@ textarea {
103
103
  display: none;
104
104
  }
105
105
  }
106
+
107
+ .search-form {
108
+ margin-left: 0.5em;
109
+ }
110
+
111
+ #search-input {
112
+ max-width: 25em;
113
+ }
@@ -1,7 +1,7 @@
1
1
  class Admin::LayoutsController < Admin::ResourceController
2
2
  paginate_models
3
3
  before_action :authorize_role
4
- only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
4
+ only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy, :search,
5
5
  when: %i[designer admin],
6
6
  denied_url: { controller: 'admin/pages', action: 'index' },
7
7
  denied_message: 'You must have at least editor privileges to perform this action.'
@@ -23,10 +23,19 @@ class Admin::PagesController < Admin::ResourceController
23
23
  end
24
24
 
25
25
  def index
26
- @homepage = Page.find_by_parent_id(nil)
26
+ set_site_and_homepage
27
+ @q = initialize_search
27
28
  response_for :plural
28
29
  end
29
30
 
31
+ def search
32
+ @site_id = params[:site_id] || Page.current_site.id
33
+ @q = initialize_search
34
+
35
+ @pages = fetch_search_results if search_title_present?
36
+ render
37
+ end
38
+
30
39
  def new
31
40
  assets = Asset.order('created_at DESC')
32
41
  @term = assets.ransack(params[:search] || '')
@@ -67,6 +76,25 @@ class Admin::PagesController < Admin::ResourceController
67
76
  @page = Page.find(params[:id])
68
77
  end
69
78
 
79
+ def set_site_and_homepage
80
+ @site ||= Page.current_site
81
+ @homepage = @site&.homepage || Page.homepage
82
+ @site_id = @site&.id
83
+ end
84
+
85
+ def initialize_search
86
+ Page.ransack(params[:search] || '')
87
+ end
88
+
89
+ def fetch_search_results
90
+ @title = params.dig(:search, :title)
91
+ Page.ransack(title_cont: @title, site_id_eq: @site_id).result
92
+ end
93
+
94
+ def search_title_present?
95
+ params.dig(:search, :title).present?
96
+ end
97
+
70
98
  def validation_error(e)
71
99
  flash[:error] = e.message
72
100
  render :new
@@ -7,13 +7,15 @@ module Admin::NodeHelper
7
7
 
8
8
  def render_node(page, index, parent_index = nil, simple = false)
9
9
  @current_node = prepare_page(page)
10
-
11
- @rendered_html += (render partial: 'admin/pages/node',
12
- locals: { level: index, index: index, parent_index: parent_index,
13
- page: page, simple: simple, branch: (page.children.count.positive?) })
10
+ @rendered_html += render_partial(page, index:, parent_index:, simple:)
14
11
  index
15
12
  end
16
13
 
14
+ def render_search_node(page)
15
+ @current_node = prepare_page(page)
16
+ @rendered_html = render_partial(page, index: 0, parent_index: nil, simple: false)
17
+ end
18
+
17
19
  def prepare_page(page)
18
20
  page.extend MenuRenderer
19
21
  page.view = self
@@ -90,4 +92,18 @@ module Admin::NodeHelper
90
92
  alt: '', title: '',
91
93
  style: 'display: none;')
92
94
  end
95
+
96
+ private
97
+
98
+ def render_partial(page, index:, parent_index:, simple:)
99
+ render partial: 'admin/pages/node',
100
+ locals: {
101
+ level: index,
102
+ index: index,
103
+ parent_index: parent_index,
104
+ page: page,
105
+ simple: simple,
106
+ branch: page.children.count.positive?,
107
+ }
108
+ end
93
109
  end
@@ -62,7 +62,9 @@ module MenuRenderer
62
62
  end
63
63
 
64
64
  def menu_list
65
- view.content_tag :ul, menu_items.join.html_safe, class: 'menu', id: "allowed_children_#{id}"
65
+ view.content_tag :div, class: 'dropdown_wrapper', style: 'position: absolute; display: none' do
66
+ view.content_tag :ul, menu_items.join.html_safe, class: 'menu', id: "allowed_children_#{id}"
67
+ end
66
68
  end
67
69
 
68
70
  def remove_link
data/app/models/page.rb CHANGED
@@ -155,6 +155,10 @@ class Page < ActiveRecord::Base
155
155
  end
156
156
  end
157
157
 
158
+ def self.ransackable_attributes(auth_object = nil)
159
+ ['site_id', 'title']
160
+ end
161
+
158
162
  private :set_response_headers
159
163
 
160
164
  def set_content_type(response)
@@ -1,4 +1,4 @@
1
- - if current_user.scoped_site? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
1
+ - if current_user.scoped_site? && defined?(Site) && defined?(controller) && controller.sited_model? && Site.several?
2
2
  .site_chooser
3
3
  %ul.nav
4
4
  %li
@@ -0,0 +1,8 @@
1
+ = search_form_for @q, url: search_admin_pages_path, html: { method: :get, class: 'search-form' } do |f|
2
+ = hidden_field_tag :site_id, @site_id
3
+ .page-search
4
+ %i.fas.fa-search
5
+ = f.search_field :title, value: title, placeholder: 'Search by Page Title', id: 'search-input'
6
+ %input.button{ type: 'submit', value: 'Search' }
7
+ - if show_view_all_button
8
+ = link_to t("view_all_pages"), admin_pages_path, class: 'button'
@@ -2,7 +2,8 @@
2
2
 
3
3
  .outset
4
4
  = render_region :top
5
- %table.index.tablesaw#pages{:summary=>t('page_hierarchy')}
5
+ = render 'search_form', title: nil, show_view_all_button: false
6
+ %table.index.tablesaw#pages{ :summary => t('page_hierarchy') }
6
7
  %thead
7
8
  %tr
8
9
  - render_region :sitemap_head do |sitemap_head|
@@ -17,13 +18,13 @@
17
18
  = render_nodes(@homepage, 0).html_safe
18
19
  - else
19
20
  %tr.sortable
20
- %td.empty{:colspan => admin.page.index.node.length}= t('no_pages')
21
+ %td.empty{ :colspan => admin.page.index.node.length }= t('no_pages')
21
22
  = render_region :bottom
22
23
 
23
24
  - unless @homepage
24
25
  #actions
25
26
  %ul
26
27
  %li
27
- = link_to new_admin_page_path, :class => 'action_button' do
28
+ = link_to admin_pages_path, :class => 'action_button' do
28
29
  %i.fas.fa-plus-circle
29
30
  = t("new_homepage")
@@ -0,0 +1,24 @@
1
+ - @page_title = t('pages') + ' - ' + default_page_title
2
+
3
+ .outset
4
+ = render_region :top
5
+ = render 'search_form', title: @title, show_view_all_button: true
6
+ %table.index.tablesaw#pages{ :summary => t('page_hierarchy') }
7
+ %thead
8
+ %tr
9
+ - render_region :sitemap_head do |sitemap_head|
10
+ - sitemap_head.title_column_header do
11
+ %th.name= t('page')
12
+ - sitemap_head.status_column_header do
13
+ %th.status= t('status')
14
+ - sitemap_head.actions_column_header do
15
+ %th.actions= t('modify')
16
+ %tbody
17
+ - if @pages.present?
18
+ - @pages.each do |page|
19
+ = render_search_node(page).html_safe
20
+ - else
21
+ %tr.sortable
22
+ %td.empty{ :colspan => admin.page.index.node.length }= t('no_pages_found')
23
+
24
+ = render_region :bottom
@@ -216,6 +216,7 @@ en:
216
216
  'no': 'No'
217
217
  no_layouts: 'No Layouts'
218
218
  no_pages: 'No Pages'
219
+ no_pages_found: 'No Pages Found'
219
220
  normal_page: 'Normal Page'
220
221
  notes: 'Notes'
221
222
  optional: 'Optional'
@@ -326,6 +327,7 @@ en:
326
327
  users_controller:
327
328
  cannot_delete_self: 'You cannot delete yourself.'
328
329
  version: 'Version'
330
+ view_all_pages: 'View All Pages'
329
331
  view_site: 'View Site'
330
332
  warning: 'Warning'
331
333
  website: 'Website'
data/config/routes.rb CHANGED
@@ -14,6 +14,7 @@ TrustyCms::Application.routes.draw do
14
14
  resources :children, controller: 'pages'
15
15
  get 'remove', on: :member
16
16
  put 'restore/:version_index', on: :member, to: 'pages#restore', as: :restore_version
17
+ get 'search', on: :collection, to: 'pages#search', as: :search
17
18
  end
18
19
  resources :layouts do
19
20
  get 'remove', on: :member
@@ -177,6 +177,10 @@ module TrustyCms
177
177
  index.sitemap_head.concat %w{title_column_header status_column_header actions_column_header}
178
178
  index.node.concat %w{title_column status_column actions_column}
179
179
  end
180
+ page.search = RegionSet.new do |search|
181
+ search.sitemap_head.concat %w{title_column_header status_column_header actions_column_header}
182
+ search.node.concat %w{title_column status_column actions_column}
183
+ end
180
184
  page.remove = page.children = page.index
181
185
  page.new = page._part = page.edit
182
186
  end
@@ -1,4 +1,4 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.8'.freeze
2
+ VERSION = '7.0.9'.freeze
3
3
  end
4
4
 
data/trusty_cms.gemspec CHANGED
@@ -45,12 +45,13 @@ a general purpose content management system--not merely a blogging engine.'
45
45
  s.add_dependency 'mysql2'
46
46
  s.add_dependency 'paper_trail', '~> 16.0.0'
47
47
  s.add_dependency 'paper_trail-association_tracking', '~> 2.2.1'
48
+ s.add_dependency 'psych', '5.2.2'
48
49
  s.add_dependency 'rack', '>= 2.0.1', '< 3.2.0'
49
50
  s.add_dependency 'rack-cache', '~> 1.7'
50
51
  s.add_dependency 'radius', '~> 0.7'
51
52
  s.add_dependency 'rails', '~> 7.0.0'
52
53
  s.add_dependency 'rake', '< 14.0'
53
- s.add_dependency 'ransack'
54
+ s.add_dependency 'ransack', '~> 4.2.1'
54
55
  s.add_dependency 'rdoc', '>= 5.1', '< 7.0'
55
56
  s.add_dependency 'RedCloth', '4.3.3'
56
57
  s.add_dependency 'roadie-rails'
@@ -5,7 +5,6 @@ module MultiSite::PagesControllerExtensions
5
5
  alias_method :discover_current_site, :discover_current_site_with_root
6
6
 
7
7
  alias_method :index_without_site, :index
8
- alias_method :index, :index_with_site
9
8
 
10
9
  alias_method :continue_url_without_site, :continue_url
11
10
  alias_method :continue_url, :continue_url_with_site
@@ -37,13 +36,6 @@ module MultiSite::PagesControllerExtensions
37
36
  end
38
37
  end
39
38
 
40
- def index_with_site
41
- @site ||= Page.current_site
42
- @homepage ||= @site.homepage if @site
43
- @homepage ||= Page.homepage
44
- response_for :plural
45
- end
46
-
47
39
  def remove_with_back
48
40
  session[:came_from] = request.env["HTTP_REFERER"]
49
41
  remove_without_back
@@ -1,7 +1,7 @@
1
1
  module MultiSite::SiteChooserHelper
2
2
 
3
3
  def sites_chooser_thing
4
- return "" unless current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
4
+ return "" unless current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && Site.several?
5
5
  options = Site.all.map { |site| "<li>" + link_to(site.name, "#{request.path}?site_id=#{site.id}", :class => site == current_site ? 'fg' : '') + "</li>" }.join("")
6
6
  chooser = %{<div id="site_chooser">}
7
7
  # chooser << link_to("sites", admin_sites_url, {:id => 'show_site_list', :class => 'expandable'})
@@ -24,6 +24,7 @@ class MultiSiteExtension < TrustyCms::Extension
24
24
  admin.layouts.index.add(:before_nav, "admin/layouts/site_chooser")
25
25
  admin.pages.index.add(:before_nav, "admin/layouts/site_chooser")
26
26
  admin.snippets.index.add(:before_nav, "admin/layouts/site_chooser")
27
+ admin.pages.search.add(:before_nav, "admin/layouts/site_chooser")
27
28
  Layout.send :is_site_scoped
28
29
  Snippet.send :is_site_scoped
29
30
  User.send :is_site_scoped, :shareable => true
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.8
4
+ version: 7.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-09 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator
@@ -320,6 +320,20 @@ dependencies:
320
320
  - - "~>"
321
321
  - !ruby/object:Gem::Version
322
322
  version: 2.2.1
323
+ - !ruby/object:Gem::Dependency
324
+ name: psych
325
+ requirement: !ruby/object:Gem::Requirement
326
+ requirements:
327
+ - - '='
328
+ - !ruby/object:Gem::Version
329
+ version: 5.2.2
330
+ type: :runtime
331
+ prerelease: false
332
+ version_requirements: !ruby/object:Gem::Requirement
333
+ requirements:
334
+ - - '='
335
+ - !ruby/object:Gem::Version
336
+ version: 5.2.2
323
337
  - !ruby/object:Gem::Dependency
324
338
  name: rack
325
339
  requirement: !ruby/object:Gem::Requirement
@@ -400,16 +414,16 @@ dependencies:
400
414
  name: ransack
401
415
  requirement: !ruby/object:Gem::Requirement
402
416
  requirements:
403
- - - ">="
417
+ - - "~>"
404
418
  - !ruby/object:Gem::Version
405
- version: '0'
419
+ version: 4.2.1
406
420
  type: :runtime
407
421
  prerelease: false
408
422
  version_requirements: !ruby/object:Gem::Requirement
409
423
  requirements:
410
- - - ">="
424
+ - - "~>"
411
425
  - !ruby/object:Gem::Version
412
- version: '0'
426
+ version: 4.2.1
413
427
  - !ruby/object:Gem::Dependency
414
428
  name: rdoc
415
429
  requirement: !ruby/object:Gem::Requirement
@@ -819,11 +833,13 @@ files:
819
833
  - app/views/admin/pages/_node.html.haml
820
834
  - app/views/admin/pages/_popups.html.haml
821
835
  - app/views/admin/pages/_previous_versions.haml
836
+ - app/views/admin/pages/_search_form.html.haml
822
837
  - app/views/admin/pages/children.html.haml
823
838
  - app/views/admin/pages/edit.html.haml
824
839
  - app/views/admin/pages/index.html.haml
825
840
  - app/views/admin/pages/new.html.haml
826
841
  - app/views/admin/pages/remove.html.haml
842
+ - app/views/admin/pages/search.html.haml
827
843
  - app/views/admin/preferences/edit.html.haml
828
844
  - app/views/admin/references/_tag_reference.haml
829
845
  - app/views/admin/references/filters.haml
@@ -1193,7 +1209,7 @@ homepage: https://github.com/pgharts/trusty-cms
1193
1209
  licenses:
1194
1210
  - MIT
1195
1211
  metadata: {}
1196
- post_install_message:
1212
+ post_install_message:
1197
1213
  rdoc_options:
1198
1214
  - "--title"
1199
1215
  - TrustyCms -- Content Management You Can Trust
@@ -1242,7 +1258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1242
1258
  version: 1.3.1
1243
1259
  requirements: []
1244
1260
  rubygems_version: 3.2.33
1245
- signing_key:
1261
+ signing_key:
1246
1262
  specification_version: 4
1247
1263
  summary: A no-fluff content management system designed for small teams.
1248
1264
  test_files: