trusty-cms 6.0.4 → 6.1.1

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.
@@ -3,11 +3,11 @@
3
3
  - body_classes << 'reversed'
4
4
 
5
5
  - content_for :toolbar do
6
- = render 'search'
6
+ = render partial: 'search', locals: { term: @term, page: @page }
7
7
 
8
8
  .outset
9
9
  #assets_table.assets
10
- = render :partial => 'asset_table', :locals => { assets: @assets, with_pagination: true }
10
+ = render partial: 'asset_table', locals: { assets: @assets, with_pagination: true }
11
11
  %p{style: 'clear: both; height: 2em'} &nbsp;
12
12
 
13
13
  - render_region :bottom do |bottom|
@@ -1,4 +1,4 @@
1
- - if current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
1
+ - if current_user.admin? && !current_user.scoped? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
2
2
  .site_chooser
3
3
  %ul.nav
4
4
  %li
@@ -24,7 +24,7 @@
24
24
  .popup_title= t('clipped_extension.find_assets')
25
25
 
26
26
  .toolbar
27
- = render :partial => 'admin/assets/search'
27
+ = render :partial => 'admin/assets/search', locals: { term: @term, page: @page }
28
28
 
29
29
  #assets_table.assets.viewport
30
30
  - assets = Asset.all.paginate(:per_page => 20, page: params[:p])
@@ -0,0 +1,5 @@
1
+ Ransack.configure do |c|
2
+ # Change default search parameter key name.
3
+ # Default key name is :q
4
+ c.search_key = :search
5
+ end
@@ -21,4 +21,5 @@ end
21
21
 
22
22
  require 'ckeditor'
23
23
  require 'devise'
24
+ require 'ransack'
24
25
 
data/lib/trusty_cms.rb CHANGED
@@ -2,7 +2,7 @@ TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) unle
2
2
 
3
3
  unless defined? TrustyCms::VERSION
4
4
  module TrustyCms
5
- VERSION = '6.0.4'.freeze
5
+ VERSION = '6.1.1'.freeze
6
6
  end
7
7
  end
8
8
 
data/trusty_cms.gemspec CHANGED
@@ -43,6 +43,7 @@ a general purpose content management system--not merely a blogging engine.'
43
43
  s.add_dependency 'radius', '~> 0.7'
44
44
  s.add_dependency 'rails'
45
45
  s.add_dependency 'rake', '< 14.0'
46
+ s.add_dependency 'ransack'
46
47
  s.add_dependency 'rdoc', '>= 5.1', '< 7.0'
47
48
  s.add_dependency 'RedCloth', '4.3.2'
48
49
  s.add_dependency 'roadie-rails'
@@ -5,10 +5,10 @@ class ClippedExtension < TrustyCms::Extension
5
5
  def activate
6
6
  if database_exists?
7
7
  if Asset.table_exists?
8
- Page.send :include, PageAssetAssociations # defines page-asset associations. likely to be generalised soon.
9
- TrustyCms::AdminUI.send :include, ClippedAdminUI unless defined? admin.asset # defines shards for extension of the asset-admin interface
10
- Admin::PagesController.send :helper, Admin::AssetsHelper # currently only provides a description of asset sizes
11
- Page.send :include, AssetTags # radius tags for selecting sets of assets and presenting each one
8
+ Page.send :include, PageAssetAssociations # defines page-asset associations. likely to be generalised soon.
9
+ TrustyCms::AdminUI.send :include, ClippedAdminUI unless defined? admin.asset # defines shards for extension of the asset-admin interface
10
+ Admin::PagesController.send :helper, Admin::AssetsHelper # currently only provides a description of asset sizes
11
+ Page.send :include, AssetTags # radius tags for selecting sets of assets and presenting each one
12
12
  AssetType.new :image, :icon => 'image', :default_radius_tag => 'image', :processors => [:thumbnail], :styles => :standard, :extensions => %w[jpg jpeg png gif], :mime_types => %w[image/png image/x-png image/jpeg image/pjpeg image/jpg image/gif]
13
13
  AssetType.new :video, :icon => 'video', :processors => [:frame_grab], :styles => :standard, :mime_types => %w[application/x-mp4 video/mpeg video/quicktime video/x-la-asf video/x-ms-asf video/x-msvideo video/x-sgi-movie video/x-flv flv-application/octet-stream video/3gpp video/3gpp2 video/3gpp-tt video/BMPEG video/BT656 video/CelB video/DV video/H261 video/H263 video/H263-1998 video/H263-2000 video/H264 video/JPEG video/MJ2 video/MP1S video/MP2P video/MP2T video/mp4 video/MP4V-ES video/MPV video/mpeg4 video/mpeg4-generic video/nv video/parityfec video/pointer video/raw video/rtx video/ogg video/webm]
14
14
  AssetType.new :audio, :icon => 'audio', :mime_types => %w[audio/mpeg audio/mpg audio/ogg application/ogg audio/x-ms-wma audio/vnd.rn-realaudio audio/x-wav]
@@ -16,19 +16,19 @@ class ClippedExtension < TrustyCms::Extension
16
16
  AssetType.new :document, :icon => 'document', :mime_types => %w[application/msword application/rtf application/vnd.ms-excel application/vnd.ms-powerpoint application/vnd.ms-project application/vnd.ms-works text/plain text/html]
17
17
  AssetType.new :other, :icon => 'unknown'
18
18
 
19
- admin.asset ||= TrustyCms::AdminUI.load_default_asset_regions # loads the shards defined in AssetsAdminUI
20
- admin.page.edit.add :form, 'assets', :after => :edit_page_parts # adds the asset-attachment picker to the page edit view
21
- admin.page.edit.add :main, 'asset_popups', :after => :edit_popups # adds the asset-attachment picker to the page edit view
19
+ admin.asset ||= TrustyCms::AdminUI.load_default_asset_regions # loads the shards defined in AssetsAdminUI
20
+ admin.page.edit.add :form, 'assets', :after => :edit_page_parts # adds the asset-attachment picker to the page edit view
21
+ admin.page.edit.add :main, 'asset_popups', :after => :edit_popups # adds the asset-attachment picker to the page edit view
22
22
  admin.page.edit.asset_popups.concat %w{upload_asset attach_asset}
23
23
  admin.configuration.show.add :trusty_config, 'admin/configuration/clipped_show', :after => 'defaults'
24
- admin.configuration.edit.add :form, 'admin/configuration/clipped_edit', :after => 'edit_defaults'
24
+ admin.configuration.edit.add :form, 'admin/configuration/clipped_edit', :after => 'edit_defaults'
25
25
 
26
- if TrustyCms::Config.table_exists? && TrustyCms::config["paperclip.command_path"] # This is needed for testing if you are using mod_rails
26
+ if TrustyCms::Config.table_exists? && TrustyCms::config["paperclip.command_path"] # This is needed for testing if you are using mod_rails
27
27
  Paperclip.options[:command_path] = TrustyCms::config["paperclip.command_path"]
28
28
  end
29
29
 
30
30
  tab "Assets", :after => "Content" do
31
- add_item "All", "/admin/assets/"
31
+ add_item "All", "/admin/assets"
32
32
  end
33
33
  end
34
34
  end
@@ -2,34 +2,34 @@ module AssetTags
2
2
  include TrustyCms::Taggable
3
3
  include ActionView::Helpers::TagHelper
4
4
  include ActionView::Helpers::AssetTagHelper
5
-
5
+
6
6
  class TagError < StandardError; end
7
-
7
+
8
8
  %w{top_padding width height caption asset_file_name asset_content_type asset_file_size id filename image flash thumbnail url link extension if_content_type page:title page:url}.each do |name|
9
9
  deprecated_tag "assets:#{name}", :substitute => "asset:#{name}", :deadline => '2.0'
10
10
  end
11
-
11
+
12
12
  desc %{
13
13
  The namespace for referencing images and assets.
14
14
 
15
15
  *Usage:*
16
16
  <pre><code><r:asset [name="asset name"]>...</r:asset></code></pre>
17
- }
17
+ }
18
18
  tag 'asset' do |tag|
19
19
  tag.locals.asset = find_asset(tag, tag.attr) unless tag.attr.empty?
20
- tag.expand
20
+ tag.expand
21
21
  end
22
22
 
23
23
  desc %{
24
24
  Cycles through all assets attached to the current page.
25
- This tag does not require the name atttribute, nor do any of its children.
25
+ This tag does not require the name attribute, nor do any of its children.
26
26
  Use the @limit@ and @offset@ attribute to render a specific number of assets.
27
27
  Use @by@ and @order@ attributes to control the order of assets.
28
28
  Use @extensions@ attribute to specify which assets to be rendered.
29
29
 
30
30
  *Usage:*
31
31
  <pre><code><r:assets:each [limit=0] [offset=0] [order="asc|desc"] [by="position|title|..."] [extensions="png|pdf|doc"]>...</r:assets:each></code></pre>
32
- }
32
+ }
33
33
  tag 'assets' do |tag|
34
34
  tag.expand
35
35
  end
@@ -58,7 +58,7 @@ module AssetTags
58
58
  end
59
59
  result
60
60
  end
61
-
61
+
62
62
  desc %{
63
63
  References the first asset attached to the current page.
64
64
 
@@ -84,7 +84,7 @@ module AssetTags
84
84
  assets = tag.locals.page.assets.count(:conditions => assets_find_options(tag)[:conditions])
85
85
  tag.expand if assets >= count
86
86
  end
87
-
87
+
88
88
  desc %{
89
89
  The opposite of @<r:if_assets/>@.
90
90
  }
@@ -93,7 +93,7 @@ module AssetTags
93
93
  assets = tag.locals.page.assets.count(:conditions => assets_find_options(tag)[:conditions])
94
94
  tag.expand unless assets >= count
95
95
  end
96
-
96
+
97
97
  # Resets the page Url and title within the asset tag
98
98
  [:title, :url].each do |method|
99
99
  tag "asset:page:#{method.to_s}" do |tag|
@@ -127,10 +127,10 @@ module AssetTags
127
127
  size = options['size'] ? options.delete('size') : 'icon'
128
128
  raise TagError, "asset #{tag.locals.asset.title} has no '#{size}' thumbnail" unless tag.locals.asset.style?(size)
129
129
  container = options.delete('container')
130
- ((container.to_i - asset.height(size).to_i)/2).to_s
130
+ ((container.to_i - asset.height(size).to_i) / 2).to_s
131
131
  end
132
-
133
- ['height','width'].each do |dimension|
132
+
133
+ ['height', 'width'].each do |dimension|
134
134
  desc %{
135
135
  Renders the #{dimension} of the asset.
136
136
  }
@@ -180,11 +180,11 @@ module AssetTags
180
180
  tag 'asset:if_content_type' do |tag|
181
181
  options = tag.attr.dup
182
182
  # XXX build_regexp_for comes from StandardTags
183
- regexp = build_regexp_for(tag,options)
183
+ regexp = build_regexp_for(tag, options)
184
184
  asset_content_type = tag.locals.asset.asset_content_type
185
185
  tag.expand unless asset_content_type.match(regexp).nil?
186
186
  end
187
-
187
+
188
188
  [:title, :caption, :asset_file_name, :extension, :asset_content_type, :asset_file_size, :id].each do |method|
189
189
  desc %{
190
190
  Renders the @#{method.to_s}@ attribute of the asset
@@ -194,16 +194,16 @@ module AssetTags
194
194
  asset.send(method) rescue nil
195
195
  end
196
196
  end
197
-
197
+
198
198
  tag 'asset:name' do |tag|
199
199
  tag.render('asset:title', tag.attr.dup)
200
- end
201
-
200
+ end
201
+
202
202
  tag 'asset:filename' do |tag|
203
203
  asset, options = asset_and_options(tag)
204
204
  asset.asset_file_name rescue nil
205
205
  end
206
-
206
+
207
207
  desc %{
208
208
  Renders an image tag for the asset.
209
209
 
@@ -213,7 +213,7 @@ module AssetTags
213
213
 
214
214
  *Usage:*
215
215
  <pre><code><r:asset:image [name="asset name" or id="asset id"] [size="icon|thumbnail|whatever"]></code></pre>
216
- }
216
+ }
217
217
  tag 'asset:image' do |tag|
218
218
  tag.locals.asset, options = image_asset_and_options(tag)
219
219
  return "Error: This image cannot be found" if tag.locals.asset == nil
@@ -223,20 +223,20 @@ module AssetTags
223
223
  url = tag.locals.asset.thumbnail(size)
224
224
  ActionController::Base.helpers.image_tag(url, options)
225
225
  end
226
-
226
+
227
227
  desc %{
228
228
  Renders the url for the asset. If the asset is an image, the <code>size</code> attribute can be used to
229
229
  generate the url for that size.
230
230
 
231
231
  *Usage:*
232
232
  <pre><code><r:url [name="asset name" or id="asset id"] [size="icon|thumbnail"]></code></pre>
233
- }
233
+ }
234
234
  tag 'asset:url' do |tag|
235
235
  asset, options = asset_and_options(tag)
236
236
  size = options['size'] ? options.delete('size') : 'original'
237
237
  asset.thumbnail(size) rescue nil
238
238
  end
239
-
239
+
240
240
  desc %{
241
241
  Renders a link to the asset. If the asset is an image, the <code>size</code> attribute can be used to
242
242
  generate a link to that size.
@@ -255,8 +255,9 @@ module AssetTags
255
255
  url = asset.thumbnail(size)
256
256
  %{<a href="#{url }#{anchor}"#{attributes}>#{text}</a>} rescue nil
257
257
  end
258
-
259
- private
258
+
259
+ private
260
+
260
261
  def asset_and_options(tag)
261
262
  options = tag.attr.dup
262
263
  [find_asset(tag, options), options]
@@ -269,19 +270,19 @@ private
269
270
 
270
271
  def find_asset(tag, options)
271
272
  tag.locals.asset ||= if title = (options.delete('name') || options.delete('title'))
272
- Asset.find_by_title(title)
273
- elsif id = options.delete('id')
274
- Asset.find_by_id(id)
275
- end
273
+ Asset.find_by_title(title)
274
+ elsif id = options.delete('id')
275
+ Asset.find_by_id(id)
276
+ end
276
277
  tag.locals.asset || raise(TagError, "Asset not found.")
277
278
  end
278
279
 
279
280
  def find_image_asset(tag, options)
280
281
  tag.locals.asset ||= if title = (options.delete('name') || options.delete('title'))
281
- Asset.find_by_title(title)
282
- elsif id = options.delete('id')
283
- Asset.find_by_id(id)
284
- end
282
+ Asset.find_by_title(title)
283
+ elsif id = options.delete('id')
284
+ Asset.find_by_id(id)
285
+ end
285
286
  tag.locals.asset || nil
286
287
  end
287
288
 
@@ -289,16 +290,16 @@ private
289
290
  attr = tag.attr.symbolize_keys
290
291
  extensions = attr[:extensions] && attr[:extensions].split('|') || []
291
292
  conditions = unless extensions.blank?
292
- # this is soon to be removed in favour of asset types
293
- [ extensions.map { |ext| "assets.asset_file_name LIKE ?"}.join(' OR '),
294
- *extensions.map { |ext| "%.#{ext}" } ]
295
- else
296
- nil
297
- end
298
-
293
+ # this is soon to be removed in favour of asset types
294
+ [extensions.map { |ext| "assets.asset_file_name LIKE ?" }.join(' OR '),
295
+ *extensions.map { |ext| "%.#{ext}" }]
296
+ else
297
+ nil
298
+ end
299
+
299
300
  by = attr[:by] || 'page_attachments.position'
300
301
  order = attr[:order] || 'asc'
301
-
302
+
302
303
  options = {
303
304
  :order => "#{by} #{order}",
304
305
  :limit => attr[:limit] || nil,
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: 6.0.4
4
+ version: 6.1.1
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: 2023-11-01 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator
@@ -312,6 +312,20 @@ dependencies:
312
312
  - - "<"
313
313
  - !ruby/object:Gem::Version
314
314
  version: '14.0'
315
+ - !ruby/object:Gem::Dependency
316
+ name: ransack
317
+ requirement: !ruby/object:Gem::Requirement
318
+ requirements:
319
+ - - ">="
320
+ - !ruby/object:Gem::Version
321
+ version: '0'
322
+ type: :runtime
323
+ prerelease: false
324
+ version_requirements: !ruby/object:Gem::Requirement
325
+ requirements:
326
+ - - ">="
327
+ - !ruby/object:Gem::Version
328
+ version: '0'
315
329
  - !ruby/object:Gem::Dependency
316
330
  name: rdoc
317
331
  requirement: !ruby/object:Gem::Requirement
@@ -781,6 +795,7 @@ files:
781
795
  - config/initializers/assets.rb
782
796
  - config/initializers/devise.rb
783
797
  - config/initializers/kraken.rb
798
+ - config/initializers/ransack.rb
784
799
  - config/initializers/response_cache_timeout.rb
785
800
  - config/initializers/secret_token.rb
786
801
  - config/initializers/tmp.rb
@@ -1133,51 +1148,51 @@ specification_version: 4
1133
1148
  summary: A no-fluff content management system designed for small teams.
1134
1149
  test_files:
1135
1150
  - spec/models/layout_spec.rb
1136
- - spec/features/layouts_spec.rb
1137
- - spec/features/config_spec.rb
1138
- - spec/features/pages_spec.rb
1139
- - spec/support/custom_actions.rb
1140
- - spec/ci/database.mysql.yml
1141
- - spec/controllers/users_controller_spec.rb
1142
- - spec/controllers/application_controller_spec.rb
1143
1151
  - spec/rails_helper.rb
1144
1152
  - spec/spec_helper.rb
1153
+ - spec/controllers/users_controller_spec.rb
1154
+ - spec/controllers/application_controller_spec.rb
1155
+ - spec/support/custom_actions.rb
1156
+ - spec/dummy/db/schema.rb
1157
+ - spec/dummy/yarn.lock
1158
+ - spec/dummy/app/assets/config/manifest.js
1159
+ - spec/dummy/package.json
1145
1160
  - spec/dummy/config.ru
1146
- - spec/dummy/config/application.rb
1147
- - spec/dummy/config/routes.rb
1148
- - spec/dummy/config/initializers/inflections.rb
1161
+ - spec/dummy/config/initializers/wrap_parameters.rb
1162
+ - spec/dummy/config/initializers/assets.rb
1149
1163
  - spec/dummy/config/initializers/filter_parameter_logging.rb
1150
1164
  - spec/dummy/config/initializers/mime_types.rb
1151
1165
  - spec/dummy/config/initializers/cookies_serializer.rb
1152
- - spec/dummy/config/initializers/wrap_parameters.rb
1153
- - spec/dummy/config/initializers/trusty_cms_config.rb
1154
1166
  - spec/dummy/config/initializers/session_store.rb
1167
+ - spec/dummy/config/initializers/trusty_cms_config.rb
1155
1168
  - spec/dummy/config/initializers/backtrace_silencers.rb
1156
- - spec/dummy/config/initializers/assets.rb
1157
- - spec/dummy/config/locales/en.yml
1158
- - spec/dummy/config/environment.rb
1159
- - spec/dummy/config/secrets.yml
1160
- - spec/dummy/config/environments/development.rb
1169
+ - spec/dummy/config/initializers/inflections.rb
1170
+ - spec/dummy/config/application.rb
1161
1171
  - spec/dummy/config/environments/production.rb
1172
+ - spec/dummy/config/environments/development.rb
1162
1173
  - spec/dummy/config/environments/test.rb
1174
+ - spec/dummy/config/locales/en.yml
1163
1175
  - spec/dummy/config/database.yml
1164
1176
  - spec/dummy/config/boot.rb
1165
- - spec/dummy/db/schema.rb
1166
- - spec/dummy/yarn.lock
1177
+ - spec/dummy/config/routes.rb
1178
+ - spec/dummy/config/environment.rb
1179
+ - spec/dummy/config/secrets.yml
1167
1180
  - spec/dummy/README.rdoc
1168
- - spec/dummy/bin/bundle
1169
1181
  - spec/dummy/bin/rails
1182
+ - spec/dummy/bin/bundle
1170
1183
  - spec/dummy/bin/setup
1171
1184
  - spec/dummy/bin/rake
1172
- - spec/dummy/Rakefile
1173
- - spec/dummy/app/assets/config/manifest.js
1174
- - spec/dummy/package.json
1175
1185
  - spec/dummy/public/favicon.ico
1176
- - spec/dummy/public/500.html
1177
1186
  - spec/dummy/public/404.html
1178
1187
  - spec/dummy/public/422.html
1188
+ - spec/dummy/public/500.html
1189
+ - spec/dummy/Rakefile
1190
+ - spec/fixtures/users.yml
1179
1191
  - spec/factories/page.rb
1180
- - spec/factories/user.rb
1181
- - spec/factories/layout.rb
1182
1192
  - spec/factories/page_part.rb
1183
- - spec/fixtures/users.yml
1193
+ - spec/factories/layout.rb
1194
+ - spec/factories/user.rb
1195
+ - spec/features/pages_spec.rb
1196
+ - spec/features/config_spec.rb
1197
+ - spec/features/layouts_spec.rb
1198
+ - spec/ci/database.mysql.yml