trusty-cms 6.0.5 → 6.1.1

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: 5e18272551dce1a329a35f2392d27ab7db0a2b5add8a97817675566af694c574
4
- data.tar.gz: eceba4ff32ac87ce60d9a3a09d4293bc8c5b492ca4054a377ffa9cf80839b1c8
3
+ metadata.gz: 671322333fab02c719cde7aea5380c77b1cfc2147f4aea0aae7ff9639d1d338e
4
+ data.tar.gz: f869d02b2cdd5d7ed704fce3cfdd07b13441d86f7f7049ec8d66f9d7ca68d711
5
5
  SHA512:
6
- metadata.gz: 42b6a79322a0316b30e3b47f8fcb59854fa5b9aff6c93c6fe0bbdf07191cb38887cc70b46461cc5dd9a51443c0f41f08d0f8900a5fdea360cd7cc2e8f8d24252
7
- data.tar.gz: 29a6abd9a87189113fe66ca8680e26bcddea84af5582eafd991c5de2cd7ee581553308ff259249e52100cc456e45f461adadc5af90971b4b425f258b7a20e32a
6
+ metadata.gz: fe78c7df0cc233522d05ccc4de80261567d49635d89aa69a472e1a59a288a7b1790979fb3b76358ef75934763d223472ee9095a84c0220dad682f652d31024b4
7
+ data.tar.gz: d7efa654ff5b117c031b447100a3c599a3090f40549b4b96cf32bf1329ced4f967d5ca7a5be45a3911d3b29d2f071e3534a545a7a4a6595ac05d5417e4fea279
data/Gemfile CHANGED
@@ -23,6 +23,7 @@ group :development, :test do
23
23
  gem 'pry-byebug'
24
24
  gem 'psych', '5.1.1.1'
25
25
  gem 'rails-observers'
26
+ gem 'ransack'
26
27
  gem 'rspec-rails'
27
28
  gem 'simplecov'
28
29
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (6.0.4)
4
+ trusty-cms (6.1.0)
5
5
  RedCloth (= 4.3.2)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.2.0)
@@ -22,6 +22,7 @@ PATH
22
22
  radius (~> 0.7)
23
23
  rails
24
24
  rake (< 14.0)
25
+ ransack
25
26
  rdoc (>= 5.1, < 7.0)
26
27
  roadie-rails
27
28
  sass-rails
@@ -265,6 +266,10 @@ GEM
265
266
  rake (>= 12.2)
266
267
  thor (~> 1.0)
267
268
  rake (13.1.0)
269
+ ransack (4.1.1)
270
+ activerecord (>= 6.1.5)
271
+ activesupport (>= 6.1.5)
272
+ i18n
268
273
  rdoc (6.5.0)
269
274
  psych (>= 4.0.0)
270
275
  regexp_parser (2.1.1)
@@ -362,6 +367,7 @@ DEPENDENCIES
362
367
  pry-byebug
363
368
  psych (= 5.1.1.1)
364
369
  rails-observers
370
+ ransack
365
371
  rspec-rails
366
372
  simplecov
367
373
  trusty-cms!
@@ -1,268 +1,285 @@
1
1
  Assets = {
2
- attachEvents: function() {
3
- $('a.attach_asset').off('click').click(function(e){
4
- e.preventDefault();
5
- var link = $(this);
6
- var container = link.parents('li.asset');
7
- var title = link.parents('div.title').html();
8
- var image = link.parents('img');
9
- container.addClass('waiting');
10
- $.ajax({
11
- url: link.attr('href'),
12
- success: function(data, textStatus, jqXHR) {
13
- container.removeClass('waiting');
14
- Assets.addToList(data);
15
- }
16
- });
17
- });
18
-
19
- $('a.detach_asset').off('click').click(function(e){
20
- e.preventDefault();
21
- var link = $(this);
22
- Assets.removeFromList(link.parents('li.asset'));
23
- });
2
+ attachEvents: function () {
3
+ $('a.attach_asset').off('click').click(function (e) {
4
+ e.preventDefault();
5
+ var link = $(this);
6
+ var container = link.parents('li.asset');
7
+ var title = link.parents('div.title').html();
8
+ var image = link.parents('img');
9
+ container.addClass('waiting');
10
+ $.ajax({
11
+ url: link.attr('href'),
12
+ success: function (data, textStatus, jqXHR) {
13
+ container.removeClass('waiting');
14
+ Assets.addToList(data);
15
+ }
16
+ });
17
+ });
18
+
19
+ $('a.detach_asset').off('click').click(function (e) {
20
+ e.preventDefault();
21
+ var link = $(this);
22
+ Assets.removeFromList(link.parents('li.asset'));
23
+ });
24
+
25
+ $('a.insert_asset').off('click').click(function (e) {
26
+ e.preventDefault();
27
+ var part_name = $("a.tab.here").children('span').html();
28
+ if (part_name.indexOf(' ')) part_name = part_name.replace(' ', '-').toLowerCase();
29
+ part_name = part_name.replace('_', '-');
30
+ var part_id = 'part_' + part_name + '_content';
31
+ var tag_parts = $(this).attr('rel').split('_');
32
+ var tag_name = tag_parts[0];
33
+ var asset_size = tag_parts[1];
34
+ var asset_id = tag_parts[2];
35
+ var radius_tag = '<r:asset:' + tag_name;
36
+ if (asset_size != '') radius_tag = radius_tag + ' size="' + asset_size + '"';
37
+ radius_tag = radius_tag + ' id="' + asset_id + '" />';
38
+ Assets.insertAtCursor(part_id, radius_tag);
39
+
40
+ });
41
+
42
+ $(".pagination a").off('click').click(function (e) {
43
+ e.preventDefault();
44
+ $.ajax({
45
+ method: 'get',
46
+ url: $(this).attr('href') + Assets.assetFilterParameters(),
47
+ complete: function (data, textStatus, jqXHR) {
48
+ Assets.updateTable(data.responseText);
49
+ Assets.attachEvents();
50
+ }
51
+ });
52
+ });
24
53
 
25
- $('a.insert_asset').off('click').click(function(e){
26
- e.preventDefault();
27
- var part_name = $("a.tab.here").children('span').html();
28
- if (part_name.indexOf(' ')) part_name = part_name.replace(' ', '-').toLowerCase();
29
- part_name = part_name.replace('_', '-');
30
- var part_id = 'part_' + part_name + '_content';
31
- var tag_parts = $(this).attr('rel').split('_');
32
- var tag_name = tag_parts[0];
33
- var asset_size = tag_parts[1];
34
- var asset_id = tag_parts[2];
35
- var radius_tag = '<r:asset:' + tag_name;
36
- if (asset_size != '') radius_tag = radius_tag + ' size="' + asset_size + '"';
37
- radius_tag = radius_tag +' id="' + asset_id + '" />';
38
- Assets.insertAtCursor(part_id, radius_tag);
54
+ },
39
55
 
40
- });
56
+ assetFilterParameters: function () {
57
+ var parameters = [];
58
+ if ($('#filesearchforminput').val() !== '') {
59
+ parameters.push([ 'search[title_cont]', $('#filesearchforminput').val() ]);
60
+ }
41
61
 
42
- $(".pagination a").off('click').click(function(e){
43
- e.preventDefault();
44
- $.ajax({
45
- method: 'get',
46
- url: $(this).attr('href') + Assets.assetFilterParameters(),
47
- complete: function(data, textStatus, jqXHR) {
48
- Assets.updateTable(data.responseText);
49
- Assets.attachEvents();
62
+ if ($('#page_id').val() !== undefined) {
63
+ parameters.push([ 'page_id', $('#page_id').val() ]);
50
64
  }
51
- });
52
- });
53
65
 
54
- },
66
+ var filters = [];
67
+ var url_params = "";
68
+ $('a.selective.pressed').each(function () {
69
+ filters.push($(this).attr('rel'));
70
+ });
55
71
 
56
- assetFilterParameters: function() {
57
- var parameters = [];
58
- if ($('#filesearchforminput').val() !== '') {
59
- parameters.push(['search', $('#filesearchforminput').val()]);
60
- }
72
+ if (filters.length > 0) {
73
+ parameters.push([ 'filter', filters.toString() ])
74
+ }
61
75
 
62
- if ($('#page_id').val() !== undefined) {
63
- parameters.push(['page_id', $('#page_id').val()]);
64
- }
76
+ for (var i = 0; i < parameters.length; i++) {
77
+ if (i > 0) {
78
+ url_params = url_params + '&'
79
+ }
80
+ url_params = url_params + parameters[i][0] + '=' + parameters[i][1];
81
+ }
82
+ return url_params + '&pp=50';
83
+ },
65
84
 
66
- var filters = [];
67
- var url_params = "";
68
- $('a.selective.pressed').each(function(){
69
- filters.push($(this).attr('rel'));
70
- });
85
+ activateUpload: function () {
86
+ $('#upload-controls').hide();
87
+ $('#update-controls').show();
88
+ $('#asset_title').prop("disabled", false);
89
+ $('#new_asset input[name="commit"]').prop("disabled", false);
90
+ },
91
+ activateUpdate: function () {
92
+ $('#upload-controls').show();
93
+ $('#update-controls').hide();
94
+ $('#asset_title').prop("disabled", true);
95
+ $('#new_asset input[name="commit"]').prop("disabled", true);
96
+ },
71
97
 
72
- if (filters.length > 0) {parameters.push(['filter', filters.toString()])}
98
+ insertAtCursor: function (part_id, insertion) {
99
+ if (CKEDITOR.instances[part_id].mode == 'wysiwyg') {
100
+ CKEDITOR.instances[part_id].insertText(insertion);
101
+ } else {
102
+ var textbox = $("textarea.cke_source[title~=" + part_id + "]");
103
+ var caretPos = textbox[0].selectionStart;
104
+ var textAreaTxt = textbox.val();
105
+ textbox.val(textAreaTxt.substring(0, caretPos) + insertion + textAreaTxt.substring(caretPos));
106
+ }
107
+ },
108
+ filterAssets: function () {
109
+ var url = $("#filesearchform").attr('action');
110
+ var parameters = Assets.assetFilterParameters();
111
+
112
+ url = url + "?" + parameters;
113
+ $.ajax({
114
+ url: url,
115
+ complete: function (data, textStatus, jqXHR) {
116
+ Assets.updateTable(data.responseText);
117
+ }
118
+ });
119
+ },
120
+ updateTable: function (html) {
121
+ $("#assets_table").html(html);
122
+ Assets.attachEvents();
123
+ },
124
+ addToList: function (html) {
125
+ var list = $('#attachment_fields');
126
+ list.append(html);
127
+ Assets.showListIfHidden();
128
+ Assets.notify('Save page to commit changes');
129
+ Assets.attachEvents();
130
+ // I'm not sure what Sortable does and can't find any example of
131
+ // its use in current Trusty, so I'm going to comment it out for now.
73
132
 
74
- for(var i = 0; i < parameters.length; i++) {
75
- if (i > 0) {url_params = url_params + '&'}
76
- url_params = url_params + parameters[i][0] + '=' + parameters[i][1];
77
- }
78
- return url_params + '&pp=20';
79
- },
80
-
81
- activateUpload: function(){
82
- $('#upload-controls').hide();
83
- $('#update-controls').show();
84
- $('#asset_title').prop( "disabled", false );
85
- $('#new_asset input[name="commit"]').prop( "disabled", false );
86
- },
87
- activateUpdate: function() {
88
- $('#upload-controls').show();
89
- $('#update-controls').hide();
90
- $('#asset_title').prop( "disabled", true );
91
- $('#new_asset input[name="commit"]').prop( "disabled", true );
92
- },
93
-
94
- insertAtCursor: function(part_id, insertion) {
95
- if (CKEDITOR.instances[part_id].mode == 'wysiwyg') {
96
- CKEDITOR.instances[part_id].insertText( insertion );
97
- } else {
98
- var textbox = $("textarea.cke_source[title~=" + part_id +"]");
99
- var caretPos = textbox[0].selectionStart;
100
- var textAreaTxt = textbox.val();
101
- textbox.val(textAreaTxt.substring(0, caretPos) + insertion + textAreaTxt.substring(caretPos) );
102
- }
103
- },
104
- filterAssets: function() {
105
- var url = $("#filesearchform").attr('action');
106
- var parameters = Assets.assetFilterParameters();
107
-
108
- url = url + "?" + parameters;
109
- $.ajax({
110
- url: url,
111
- complete: function(data, textStatus, jqXHR) {
112
- Assets.updateTable(data.responseText);
113
- }
114
- });
115
- },
116
- updateTable: function(html) {
117
- $("#assets_table").html(html);
118
- Assets.attachEvents();
119
- },
120
- addToList: function(html){
121
- var list = $('#attachment_fields');
122
- list.append(html);
123
- Assets.showListIfHidden();
124
- Assets.notify('Save page to commit changes');
125
- Assets.attachEvents();
126
- // I'm not sure what Sortable does and can't find any example of
127
- // its use in current Trusty, so I'm going to comment it out for now.
128
-
129
- //Assets.makeSortable(list);
130
-
131
- },
132
- removeFromList: function(container) {
133
- container.children('input.attacher').remove();
134
- container.children('input.pos').remove();
135
- container.children('input.destroyer').val(1);
136
- container.fadeOut();
137
- container.addClass('detached');
138
- },
139
- showListIfHidden: function() {
140
- var list = $('#attachment_fields');
141
- if (list.hasClass('empty')) {
142
- list.removeClass('empty');
133
+ //Assets.makeSortable(list);
134
+
135
+ },
136
+ removeFromList: function (container) {
137
+ container.children('input.attacher').remove();
138
+ container.children('input.pos').remove();
139
+ container.children('input.destroyer').val(1);
140
+ container.fadeOut();
141
+ container.addClass('detached');
142
+ },
143
+ showListIfHidden: function () {
144
+ var list = $('#attachment_fields');
145
+ if (list.hasClass('empty')) {
146
+ list.removeClass('empty');
147
+ }
148
+ },
149
+ notify: function (message) {
150
+ $('#attachment_list span.message').html(message).addClass('important');
143
151
  }
144
- },
145
- notify: function(message){
146
- $('#attachment_list span.message').html(message).addClass('important');
147
- }
148
152
 
149
153
  };
150
154
 
151
155
 
152
- $(function() {
156
+ $(function () {
153
157
 
154
- $('a.selective').click(function(e){
155
- e.preventDefault();
156
- var element = $(this);
157
- var type_id = element.attr('rel');
158
- var type_check = $('#' + type_id + '-check');
158
+ $('a.selective').click(function (e) {
159
+ e.preventDefault();
160
+ var element = $(this);
161
+ var type_id = element.attr('rel');
162
+ var type_check = $('#' + type_id + '-check');
163
+
164
+ if (element.hasClass('pressed')) {
165
+ element.removeClass('pressed');
166
+ $(type_check).prop('checked', false);
167
+ if ($('a.selective.pressed').length == 0) $('#select_all').addClass('pressed');
168
+ } else {
169
+ element.addClass('pressed');
170
+ $('a.deselective').each(function () {
171
+ $(this).removeClass('pressed');
172
+ });
173
+ $(type_check).prop('checked', true);
174
+ }
175
+ Assets.filterAssets();
176
+ Assets.attachEvents();
159
177
 
160
- if(element.hasClass('pressed')) {
161
- element.removeClass('pressed');
162
- $(type_check).prop('checked', false);
163
- if ($('a.selective.pressed').length == 0) $('#select_all').addClass('pressed');
164
- }
165
- else {
166
- element.addClass('pressed');
167
- $('a.deselective').each(function() { $(this).removeClass('pressed'); });
168
- $(type_check).prop('checked', true);
169
- }
170
- Assets.filterAssets();
171
- Assets.attachEvents();
178
+ });
172
179
 
173
- });
174
-
175
- $('a.deselective').click(function(e){
176
- e.preventDefault();
177
- var element = $(this);
178
- if(!element.hasClass('pressed')) {
179
- $('a.selective').each(function() { $(this).removeClass('pressed'); });
180
- $('input.selective').each(function() { $(this).prop('checked', false); });
181
- element.addClass('pressed');
182
- Assets.filterAssets();
183
- Assets.attachEvents();
184
- }
185
- });
180
+ $('a.deselective').click(function (e) {
181
+ e.preventDefault();
182
+ var element = $(this);
183
+ if (!element.hasClass('pressed')) {
184
+ $('a.selective').each(function () {
185
+ $(this).removeClass('pressed');
186
+ });
187
+ $('input.selective').each(function () {
188
+ $(this).prop('checked', false);
189
+ });
190
+ element.addClass('pressed');
191
+ Assets.filterAssets();
192
+ Assets.attachEvents();
193
+ }
194
+ });
186
195
 
187
- $('#filesearchforminput').keyup(function(){
188
- Assets.filterAssets();
189
- Assets.attachEvents();
190
- });
191
-
192
- $("#attach_assets").click(function(e) {
193
- e.preventDefault();
194
- Popup.show('attach_asset');
195
- $('.close_popup').click(function(e){
196
- e.preventDefault();
197
- Popup.close();
198
- $('#attach_asset').hide();
196
+ $('#filesearchforminput').keyup(function () {
197
+ clearTimeout($(this).data('timeout'));
198
+ var timeout = setTimeout(function () {
199
+ Assets.filterAssets();
200
+ Assets.attachEvents();
201
+ }, 500);
202
+ $(this).data('timeout', timeout);
199
203
  });
200
- });
201
-
202
- $('#filesearchforminput').keyup(function(){
203
- Assets.filterAssets();
204
- });
205
-
206
- $("#upload_asset_link").click(function(e) {
207
- e.preventDefault();
208
- Popup.close();
209
- $('#attach_asset').hide();
210
- Assets.activateUpdate();
211
- Popup.show('upload_asset');
212
-
213
- $("#attach-popup").click(function(e) {
214
- e.preventDefault();
215
- Popup.close();
216
- $('#upload_asset').hide();
217
- Popup.show('attach_asset');
218
- $('.close_popup').click(function(e){
204
+
205
+ $("#attach_assets").click(function (e) {
219
206
  e.preventDefault();
220
- Popup.close();
221
- $('#attach_asset').hide();
222
- });
207
+ Popup.show('attach_asset');
208
+ $('.close_popup').click(function (e) {
209
+ e.preventDefault();
210
+ Popup.close();
211
+ $('#attach_asset').hide();
212
+ });
223
213
  });
224
214
 
225
- $('.close_popup').click(function(e){
226
- e.preventDefault();
227
- Popup.close();
228
- $('#upload_asset').hide();
215
+ $('#filesearchforminput').keyup(function () {
216
+ clearTimeout($(this).data('timeout'));
217
+ var timeout = setTimeout(function () {
218
+ Assets.filterAssets();
219
+ }, 500);
220
+ $(this).data('timeout', timeout);
229
221
  });
230
- });
231
-
232
- $('#update_asset').submit(function(e){
233
- e.preventDefault();
234
- $("#update-asset").attr("disabled", true);
235
- $('#update-status').show();
236
- $.ajax({
237
- method: 'put',
238
- url: $(this).attr('action') + $("#asset_id").val(),
239
- data: $(this).serialize(),
240
- complete: function(data, textStatus, jqXHR) {
222
+
223
+ $("#upload_asset_link").click(function (e) {
224
+ e.preventDefault();
241
225
  Popup.close();
242
- $('#upload_asset').hide();
243
- $('#update-status').hide();
244
- $("#update-asset").attr("disabled", false);
245
- $('#update_asset').trigger("reset");
246
- }
226
+ $('#attach_asset').hide();
227
+ Assets.activateUpdate();
228
+ Popup.show('upload_asset');
229
+
230
+ $("#attach-popup").click(function (e) {
231
+ e.preventDefault();
232
+ Popup.close();
233
+ $('#upload_asset').hide();
234
+ Popup.show('attach_asset');
235
+ $('.close_popup').click(function (e) {
236
+ e.preventDefault();
237
+ Popup.close();
238
+ $('#attach_asset').hide();
239
+ });
240
+ });
241
+
242
+ $('.close_popup').click(function (e) {
243
+ e.preventDefault();
244
+ Popup.close();
245
+ $('#upload_asset').hide();
246
+ });
247
247
  });
248
- });
249
248
 
250
- $('#asset_asset').fileupload({
251
- add: function(e, data) {
252
- $("#asset_asset").attr("disabled", true);
253
- $('#upload-status').show();
254
- data.submit();
255
- },
256
- done: function (e, data) {
257
- $("#asset_id").val($(data.result).find(".attacher").val());
258
- Assets.addToList($(data.result));
259
- Assets.activateUpload();
260
- $("#asset_asset").attr("disabled", false);
261
- $('#upload-status').hide();
262
- $("#popup_window").hide();
263
- }
264
- });
249
+ $('#update_asset').submit(function (e) {
250
+ e.preventDefault();
251
+ $("#update-asset").attr("disabled", true);
252
+ $('#update-status').show();
253
+ $.ajax({
254
+ method: 'put',
255
+ url: $(this).attr('action') + $("#asset_id").val(),
256
+ data: $(this).serialize(),
257
+ complete: function (data, textStatus, jqXHR) {
258
+ Popup.close();
259
+ $('#upload_asset').hide();
260
+ $('#update-status').hide();
261
+ $("#update-asset").attr("disabled", false);
262
+ $('#update_asset').trigger("reset");
263
+ }
264
+ });
265
+ });
266
+
267
+ $('#asset_asset').fileupload({
268
+ add: function (e, data) {
269
+ $("#asset_asset").attr("disabled", true);
270
+ $('#upload-status').show();
271
+ data.submit();
272
+ },
273
+ done: function (e, data) {
274
+ $("#asset_id").val($(data.result).find(".attacher").val());
275
+ Assets.addToList($(data.result));
276
+ Assets.activateUpload();
277
+ $("#asset_asset").attr("disabled", false);
278
+ $('#upload-status').hide();
279
+ $("#popup_window").hide();
280
+ }
281
+ });
265
282
 
266
- Assets.attachEvents();
283
+ Assets.attachEvents();
267
284
 
268
285
  });
@@ -40,8 +40,8 @@ input[type="submit"], input[type="button"] {
40
40
  input[type="text"], input[type="search"], input[type="password"], input[type="email"] {
41
41
  border: 0.5px solid $gray;
42
42
  margin: 0.5em;
43
+ max-width: 75%;
43
44
  padding: 0.25em;
44
- width: 75%;
45
45
  }
46
46
 
47
47
  select {
@@ -8,9 +8,8 @@ class Admin::AssetsController < Admin::ResourceController
8
8
  def index
9
9
  assets = Asset.order('created_at DESC')
10
10
  @page = Page.find(params[:page_id]) if params[:page_id]
11
-
12
- @term = params[:search] || ''
13
- assets = assets.matching(@term) if @term && !@term.blank?
11
+ @term = assets.ransack(params[:search] || '')
12
+ assets = @term.result(distinct: true)
14
13
 
15
14
  @types = params[:filter] ? params[:filter].split(',') : []
16
15
  if @types.include?('all')
@@ -20,6 +19,7 @@ class Admin::AssetsController < Admin::ResourceController
20
19
  end
21
20
 
22
21
  @assets = paginated? ? assets.paginate(pagination_parameters) : assets.all
22
+
23
23
  respond_to do |format|
24
24
  format.js do
25
25
  @page = Page.find_by_id(params[:page_id])
@@ -54,7 +54,7 @@ class Admin::AssetsController < Admin::ResourceController
54
54
  end
55
55
  end
56
56
  end
57
-
57
+
58
58
  if asset_params[:for_attachment]
59
59
  render partial: 'admin/page_attachments/attachment', collection: @page_attachments
60
60
  else
@@ -32,6 +32,13 @@ class Admin::PagesController < Admin::ResourceController
32
32
  response_for :new
33
33
  end
34
34
 
35
+ def edit
36
+ assets = Asset.order('created_at DESC')
37
+ @term = assets.ransack(params[:search] || '')
38
+ @term.result(distinct: true)
39
+ response_for :edit
40
+ end
41
+
35
42
  def preview
36
43
  render_preview
37
44
  rescue PreviewStop => e
data/app/models/asset.rb CHANGED
@@ -56,6 +56,10 @@ class Asset < ActiveRecord::Base
56
56
  asset_type.icon(style_name.to_s)
57
57
  end
58
58
 
59
+ def self.ransackable_attributes(auth_object = nil)
60
+ %w[asset_content_type asset_file_name asset_file_size caption created_at created_by_id id original_extension original_height original_width title updated_at updated_by_id uuid]
61
+ end
62
+
59
63
  def render_original(style_name)
60
64
  style_name.to_s == 'original' && asset.key.include?('culturaldistrict')
61
65
  end
@@ -1,18 +1,19 @@
1
- = form_tag(admin_assets_path, :id=>'filesearchform', :method => 'get', :class=>"search") do
2
- - if @page
3
- = hidden_field_tag "page_id", @page.id
1
+ = search_form_for term, url: admin_assets_path, class: 'search', id: 'filesearchform' do |f|
2
+ - if page
3
+ = hidden_field_tag "page_id", page.id
4
4
  = hidden_field_tag "p", params['p'] || 1
5
- = hidden_field_tag "pp", params['pp'] || 20
5
+ = hidden_field_tag "pp", params['pp'] || 50
6
6
 
7
7
  .asset_filters
8
8
  = link_to t("asset_types.all"), admin_assets_url, :id => "select_all", :class => params[:filter].blank? ? "deselective pressed" : "deselective"
9
9
  - AssetType.all.each do |type|
10
10
  - unless type.name == :other
11
11
  = link_to t("asset_types.#{type.plural}"), admin_assets_url(:filter => type.name), :rel => type.name.to_s, :class => params[:filter] == type.name.to_s ? "selective pressed" : "selective"
12
+
12
13
  .asset_search
13
14
  %i.fas.fa-search
14
- %input{:type=>"search", :id => 'filesearchforminput', :class=>"search", :name=>"search", :value=>h(params[:search]), :placeholder=>"Search", :results=>0, :size=>30}
15
-
15
+ = f.search_field :title_cont, placeholder: 'Search Asset Title', class: 'search', id: 'filesearchforminput', size: '30'
16
+ Sort By #{sort_link(term, :title)} or #{sort_link(term, :created_at)}
16
17
  #type_boxes{:style => "display: none"}
17
18
  - AssetType.all.each do |type|
18
19
  = check_box_tag 'filter[]', type.name.to_s, false, :id => "#{type.name}-check", :class => 'selective'
@@ -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|
@@ -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.5'.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.5
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-20 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