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.
@@ -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])
@@ -53,11 +53,12 @@ class Admin::AssetsController < Admin::ResourceController
53
53
  flash[:error] = error
54
54
  end
55
55
  end
56
- if asset_params[:for_attachment]
57
- render partial: 'admin/page_attachments/attachment', collection: @page_attachments
58
- else
59
- response_for :create
60
- end
56
+ end
57
+
58
+ if asset_params[:for_attachment]
59
+ render partial: 'admin/page_attachments/attachment', collection: @page_attachments
60
+ else
61
+ response_for :create
61
62
  end
62
63
  end
63
64
 
@@ -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,4 +1,8 @@
1
1
  class FileNotFoundPage < Page
2
+ def cache_timeout
3
+ 5.minutes
4
+ end
5
+
2
6
  def allowed_children
3
7
  []
4
8
  end
@@ -23,8 +27,4 @@ class FileNotFoundPage < Page
23
27
  def response_code
24
28
  404
25
29
  end
26
-
27
- def cache?
28
- false
29
- end
30
30
  end
data/app/models/user.rb CHANGED
@@ -44,6 +44,10 @@ class User < ActiveRecord::Base
44
44
  content_editor
45
45
  end
46
46
 
47
+ def scoped?
48
+ site_id.present?
49
+ end
50
+
47
51
  def locale
48
52
  'en'
49
53
  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'