trusty-cms 7.0.48 → 7.1.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +1 -1
  4. data/app/assets/builds/trusty_cms/ckeditor5.css +459 -81
  5. data/app/assets/builds/trusty_cms/ckeditor5.css.map +3 -3
  6. data/app/assets/builds/trusty_cms/ckeditor5.js +11247 -7722
  7. data/app/assets/builds/trusty_cms/ckeditor5.js.map +4 -4
  8. data/app/controllers/admin/assets_controller.rb +1 -12
  9. data/app/javascript/plugins/asset_tags/asset_tag_builder.js +7 -2
  10. data/app/models/asset.rb +107 -38
  11. data/app/models/asset_type.rb +29 -25
  12. data/app/views/admin/assets/_search_results.html.haml +2 -3
  13. data/app/views/admin/assets/edit.html.haml +2 -2
  14. data/app/views/admin/assets/remove.html.haml +1 -1
  15. data/config/initializers/trusty_cms_config.rb +1 -49
  16. data/config/locales/en.yml +1 -1
  17. data/config/routes.rb +0 -2
  18. data/db/migrate/20110606111250_update_configuration.rb +0 -16
  19. data/lib/trusty_cms/geometry.rb +117 -0
  20. data/lib/trusty_cms/version.rb +1 -1
  21. data/package.json +1 -1
  22. data/spec/lib/trusty_cms/geometry_spec.rb +28 -0
  23. data/spec/models/asset_spec.rb +66 -0
  24. data/vendor/extensions/clipped-extension/clipped_extension.rb +3 -7
  25. data/vendor/extensions/clipped-extension/lib/asset_tags.rb +10 -4
  26. data/vendor/extensions/clipped-extension/lib/generators/templates/clipped_config.rb +9 -34
  27. data/vendor/extensions/clipped-extension/lib/tasks/active_storage_tasks.rake +66 -0
  28. data/vendor/extensions/clipped-extension/lib/tasks/clipped_extension_tasks.rake +5 -2
  29. data/vendor/extensions/clipped-extension/lib/trusty_cms_clipped_extension/cloud.rb +32 -27
  30. data/yarn.lock +731 -727
  31. metadata +6 -6
  32. data/lib/trusty_cms/deprecation.rb +0 -15
  33. data/vendor/extensions/clipped-extension/lib/paperclip/frame_grab.rb +0 -73
  34. data/vendor/extensions/clipped-extension/lib/paperclip/geometry_transformation.rb +0 -80
  35. data/vendor/extensions/clipped-extension/lib/tasks/paperclip_tasks.rake +0 -79
@@ -40,7 +40,7 @@ class Admin::AssetsController < Admin::ResourceController
40
40
  @page_attachments << (@page_attachment = @asset.page_attachments.build(page: @page))
41
41
  end
42
42
 
43
- render json: { url: @asset.asset.url }
43
+ render json: { url: @asset.public_url }
44
44
  else
45
45
  flash[result.fetch(:flash_type, :error)] = result[:error]
46
46
  render json: { error: result[:error] }, status: result.fetch(:status, :unprocessable_entity)
@@ -74,17 +74,6 @@ class Admin::AssetsController < Admin::ResourceController
74
74
  end
75
75
  end
76
76
 
77
- def refresh
78
- if asset_params[:id]
79
- @asset = Asset.find(params[:id])
80
- @asset.asset.reprocess!
81
- flash[:notice] = t('clipped_extension.thumbnails_refreshed')
82
- redirect_to edit_admin_asset_path(@asset)
83
- else
84
- render
85
- end
86
- end
87
-
88
77
  private
89
78
 
90
79
  def process_uploaded_asset(uploaded_asset)
@@ -20,13 +20,12 @@ export default class AssetTagBuilder extends Plugin {
20
20
  allowWhere: '$text',
21
21
  isInline: true,
22
22
  isObject: true,
23
- allowAttributes: [ 'id', 'size', 'alt', 'height', 'width' ]
23
+ allowAttributes: [ 'id', 'class', 'size', 'alt', 'height', 'width', 'linkHref', 'linkTarget', 'linkRel' ]
24
24
  } );
25
25
  }
26
26
 
27
27
  _defineConverters() {
28
28
  const conversion = this.editor.conversion;
29
-
30
29
  const upcast = conversion.for( 'upcast' );
31
30
  const dataDowncast = conversion.for( 'dataDowncast' );
32
31
  const editingDowncast = conversion.for( 'editingDowncast' );
@@ -38,12 +37,14 @@ export default class AssetTagBuilder extends Plugin {
38
37
  model: ( viewElement, { writer } ) => {
39
38
  const attrs = {};
40
39
  const id = viewElement.getAttribute( 'id' );
40
+ const klass = viewElement.getAttribute( 'class' );
41
41
  const size = viewElement.getAttribute( 'size' );
42
42
  const alt = viewElement.getAttribute( 'alt' );
43
43
  const height = viewElement.getAttribute( 'height' );
44
44
  const width = viewElement.getAttribute( 'width' );
45
45
 
46
46
  if ( id ) attrs.id = id;
47
+ if ( klass ) attrs.class = klass;
47
48
  if ( size ) attrs.size = size;
48
49
  if ( alt ) attrs.alt = alt;
49
50
  if ( height ) attrs.height = height;
@@ -60,12 +61,14 @@ export default class AssetTagBuilder extends Plugin {
60
61
  view: ( modelElement, { writer } ) => {
61
62
  const attrs = {};
62
63
  const id = modelElement.getAttribute( 'id' );
64
+ const klass = modelElement.getAttribute( 'class' );
63
65
  const size = modelElement.getAttribute( 'size' );
64
66
  const alt = modelElement.getAttribute( 'alt' );
65
67
  const height = modelElement.getAttribute( 'height' );
66
68
  const width = modelElement.getAttribute( 'width' );
67
69
 
68
70
  if ( id ) attrs.id = id;
71
+ if ( klass ) attrs.class = klass;
69
72
  if ( size ) attrs.size = size;
70
73
  if ( alt ) attrs.alt = alt;
71
74
  if ( height ) attrs.height = height;
@@ -81,12 +84,14 @@ export default class AssetTagBuilder extends Plugin {
81
84
  view: ( modelElement, { writer } ) => {
82
85
  const attrs = {};
83
86
  const id = modelElement.getAttribute( 'id' );
87
+ const klass = modelElement.getAttribute( 'class' );
84
88
  const size = modelElement.getAttribute( 'size' );
85
89
  const alt = modelElement.getAttribute( 'alt' );
86
90
  const height = modelElement.getAttribute( 'height' );
87
91
  const width = modelElement.getAttribute( 'width' );
88
92
 
89
93
  if ( id ) attrs.id = id;
94
+ if ( klass ) attrs.class = klass;
90
95
  if ( size ) attrs.size = size;
91
96
  if ( alt ) attrs.alt = alt;
92
97
  if ( height ) attrs.height = height;
data/app/models/asset.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'trusty_cms/geometry'
2
+
1
3
  class Asset < ActiveRecord::Base
2
4
  APPROVED_CONTENT_TYPES = %w[application/zip image/jpg image/jpeg image/png image/gif application/pdf text/css text/calendar].freeze
3
5
 
@@ -16,11 +18,13 @@ class Asset < ActiveRecord::Base
16
18
 
17
19
  scope :of_types, lambda { |types|
18
20
  mimes = AssetType.slice(*types).map(&:mime_types).flatten
19
- Asset.select { |x| mimes.include?(x.asset_content_type) }
21
+ return none if mimes.empty?
22
+
23
+ joins(asset_attachment: :blob).where(active_storage_blobs: { content_type: mimes })
20
24
  }
21
25
 
22
26
  scope :matching, lambda { |term|
23
- where(['LOWER(assets.asset_file_name) LIKE (:term) OR LOWER(title) LIKE (:term) OR LOWER(caption) LIKE (:term)', { term: "%#{term.downcase}%" }])
27
+ joins(asset_attachment: :blob).where(['LOWER(active_storage_blobs.filename) LIKE (:term) OR LOWER(title) LIKE (:term) OR LOWER(caption) LIKE (:term)', { term: "%#{term.downcase}%" }])
24
28
  }
25
29
 
26
30
  scope :excepting, lambda { |assets|
@@ -41,6 +45,7 @@ class Asset < ActiveRecord::Base
41
45
  content_type: APPROVED_CONTENT_TYPES,
42
46
  size_range: 1..10.megabytes,
43
47
  }
48
+ before_validation :sync_attachment_metadata
44
49
  before_save :assign_title
45
50
  before_save :assign_uuid
46
51
 
@@ -48,57 +53,86 @@ class Asset < ActiveRecord::Base
48
53
  AssetType.for(asset)
49
54
  end
50
55
 
51
- delegate :paperclip_processors, :paperclip_styles, :active_storage_styles, :style_dimensions, :style_format,
56
+ def filename
57
+ return asset.filename.to_s if asset.attached?
58
+
59
+ self[:asset_file_name]
60
+ end
61
+
62
+ def content_type
63
+ return asset.content_type if asset.attached?
64
+
65
+ self[:asset_content_type]
66
+ end
67
+
68
+ def byte_size
69
+ return asset.blob.byte_size if asset.attached?
70
+
71
+ self[:asset_file_size]
72
+ end
73
+
74
+ delegate :active_storage_styles, :style_dimensions, :style_format,
52
75
  to: :asset_type
53
76
 
54
- def thumbnail(style_name = 'original')
55
- return asset.url if style_name.to_s == 'original' || render_original(style_name)
56
- return asset_variant(style_name.to_s).processed.url if asset.variable?
77
+ def thumbnail(style_name = 'normal')
78
+ variant = asset_variant(style_name.to_s)
79
+ return rewrite_cloud_url(variant.processed.url) if variant
57
80
 
58
81
  asset_type.icon(style_name.to_s)
59
82
  end
60
83
 
84
+ def public_url(style_name = 'normal')
85
+ if style_name.to_s == 'original' || render_original(style_name)
86
+ return rewrite_cloud_url(asset.url)
87
+ end
88
+
89
+ variant = asset_variant(style_name.to_s)
90
+ return rewrite_cloud_url(variant.processed.url) if variant
91
+
92
+ rewrite_cloud_url(asset.url)
93
+ end
94
+
61
95
  def self.ransackable_attributes(auth_object = nil)
62
96
  %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]
63
97
  end
64
98
 
65
99
  def render_original(style_name)
66
- style_name.to_s == 'original' && asset.key.include?('culturaldistrict')
100
+ style_name.to_s == 'original' && asset.attached? && asset.key.include?('culturaldistrict')
67
101
  end
68
102
 
69
103
  def asset_variant(style_name)
70
- case style_name
71
- when 'thumbnail'
72
- asset.variant(gravity: 'Center', resize: '100x100^', crop: '100x100+0+0')
73
- when 'small'
74
- asset.variant(gravity: 'Center', resize: '320x320^')
75
- when 'normal'
76
- asset.variant(gravity: 'Center', resize_to_limit: [asset.metadata[:width], asset.metadata[:height]])
77
- when 'icon'
78
- asset.variant(gravity: 'Center', resize: '50x50^')
104
+ style = active_storage_styles[style_name.to_sym]
105
+ return unless style
106
+
107
+ transformations = active_storage_transformations(style[:geometry])
108
+ transformations[:format] = style[:format] if style[:format]
109
+ if asset.variable?
110
+ asset.variant(transformations)
111
+ elsif asset.previewable?
112
+ asset.preview(transformations)
79
113
  end
80
114
  end
81
115
 
82
116
  def style?(style_name = 'original')
83
- style_name == 'original' || paperclip_styles.keys.include?(style_name.to_sym)
117
+ style_name == 'original' || active_storage_styles.keys.include?(style_name.to_sym)
84
118
  end
85
119
 
86
120
  def basename
87
- File.basename(asset_file_name, '.*') if asset_file_name
121
+ File.basename(filename, '.*') if filename
88
122
  end
89
123
 
90
124
  def extension(style_name = 'original')
91
125
  if style_name == 'original'
92
126
  original_extension
93
- elsif style = paperclip_styles[style_name.to_sym]
94
- style.format
127
+ elsif style = active_storage_styles[style_name.to_sym]
128
+ style[:format]
95
129
  else
96
130
  original_extension
97
131
  end
98
132
  end
99
133
 
100
134
  def original_extension
101
- return asset_file_name.split('.').last.downcase if asset_file_name
135
+ return filename.split('.').last.downcase if filename
102
136
  end
103
137
 
104
138
  def attached_to?(page)
@@ -106,12 +140,12 @@ class Asset < ActiveRecord::Base
106
140
  end
107
141
 
108
142
  def original_geometry
109
- @original_geometry ||= Paperclip::Geometry.new(original_width, original_height)
143
+ @original_geometry ||= TrustyCms::Geometry.new(*original_dimensions)
110
144
  end
111
145
 
112
146
  def geometry(style_name = 'original')
113
147
  unless style?(style_name)
114
- raise Paperclip::StyleError,
148
+ raise TrustyCms::StyleError,
115
149
  "Requested style #{style_name} is not defined for this asset."
116
150
  end
117
151
 
@@ -120,11 +154,11 @@ class Asset < ActiveRecord::Base
120
154
  @geometry[style_name] ||= if style_name.to_s == 'original'
121
155
  original_geometry
122
156
  else
123
- style = asset.styles[style_name.to_sym]
124
- original_geometry.transformed_by(style.geometry)
157
+ style = active_storage_styles[style_name.to_sym]
158
+ original_geometry.transformed_by(style[:geometry])
125
159
  # this can return dimensions for fully specified style sizes but not for relative sizes when there are no original dimensions
126
160
  end
127
- rescue Paperclip::TransformationError => e
161
+ rescue TrustyCms::TransformationError => e
128
162
  Rails.logger.warn "geometry transformation error: #{e}"
129
163
  original_geometry # returns a blank geometry if the real geometry cannot be calculated
130
164
  end
@@ -168,26 +202,55 @@ class Asset < ActiveRecord::Base
168
202
  end
169
203
 
170
204
  def dimensions_known?
171
- original_width? && original_height?
205
+ original_dimensions.all?(&:positive?)
172
206
  end
173
207
 
174
208
  private
175
209
 
176
- # at this point the file queue will not have been written
177
- # but the upload should be in place. We read dimensions from the
178
- # original file and calculate thumbnail dimensions later, on demand.
210
+ def original_dimensions
211
+ width = original_width.presence
212
+ height = original_height.presence
213
+ if asset.attached?
214
+ width ||= asset.metadata[:width] || asset.metadata['width']
215
+ height ||= asset.metadata[:height] || asset.metadata['height']
216
+ end
217
+ [width.to_i, height.to_i]
218
+ end
219
+
220
+ def active_storage_transformations(geometry)
221
+ return {} unless geometry.present?
179
222
 
180
- def read_dimensions
181
- if image? && file = asset.queued_for_write[:original]
182
- geometry = Paperclip::Geometry.from_file(file)
183
- self.original_width = geometry.width
184
- self.original_height = geometry.height
185
- self.original_extension = File.extname(file.path)
223
+ parsed = TrustyCms::Geometry.parse(geometry)
224
+ width = parsed.width.positive? ? parsed.width : nil
225
+ height = parsed.height.positive? ? parsed.height : nil
226
+ return {} unless width && height
227
+
228
+ case parsed.modifier
229
+ when '#', '^', '!'
230
+ { resize_to_fill: [width, height].compact }
231
+ when '>', '<'
232
+ { resize_to_limit: [width, height].compact }
233
+ else
234
+ { resize_to_limit: [width, height].compact }
235
+ end
236
+ end
237
+
238
+ def sync_attachment_metadata
239
+ return unless asset.attached?
240
+
241
+ self.asset_file_name = asset.filename.to_s
242
+ self.asset_content_type = asset.content_type
243
+ self.asset_file_size = asset.blob.byte_size
244
+ self.original_extension = asset.filename.extension&.downcase
245
+ if asset.metadata[:width].present? && asset.metadata[:height].present?
246
+ self.original_width = asset.metadata[:width]
247
+ self.original_height = asset.metadata[:height]
186
248
  end
187
- true
188
249
  end
189
250
 
190
251
  def assign_title
252
+ return unless asset.attached?
253
+
191
254
  self.title = asset.filename.base
192
255
  end
193
256
 
@@ -195,6 +258,12 @@ class Asset < ActiveRecord::Base
195
258
  self.uuid = SecureRandom.uuid unless uuid?
196
259
  end
197
260
 
261
+ def rewrite_cloud_url(url)
262
+ return url unless defined?(TrustyCmsClippedExtension::Cloud)
263
+
264
+ TrustyCmsClippedExtension::Cloud.rewrite_url(url)
265
+ end
266
+
198
267
  class << self
199
268
  def known_types
200
269
  AssetType.known_types
@@ -230,7 +299,7 @@ class Asset < ActiveRecord::Base
230
299
 
231
300
  # for backwards compatibility
232
301
  def self.thumbnail_sizes
233
- AssetType.find(:image).paperclip_styles
302
+ AssetType.find(:image).active_storage_styles
234
303
  end
235
304
 
236
305
  def self.thumbnail_names
@@ -3,8 +3,7 @@ class AssetType
3
3
  # Conventionally this would a sensible category like 'image' or 'video'
4
4
  # that should be processed and presented in a particular way.
5
5
  # An AssetType currently provides:
6
- # * processor definitions for paperclip
7
- # * styles definitions for paperclip
6
+ # * processing and variant definitions for ActiveStorage
8
7
  # * mime type list for file recognition
9
8
  # * selectors and scopes for retrieving this (or not this) category of asset
10
9
  # * radius tags for those subsets of assets (temporarily removed pending discussion of interface)
@@ -30,7 +29,7 @@ class AssetType
30
29
  @mimes.each { |mimetype| @@mime_lookup[mimetype] ||= self }
31
30
 
32
31
  this = self
33
- Asset.send :define_method, "#{name}?".intern do this.mime_types.include?(asset_content_type) end
32
+ Asset.send :define_method, "#{name}?".intern do this.mime_types.include?(content_type) end
34
33
  Asset.send :define_class_method, "#{name}_condition".intern do this.condition; end
35
34
  Asset.send :define_class_method, "not_#{name}_condition".intern do this.non_condition; end
36
35
  Asset.send :scope, plural.to_sym, -> { where(conditions: condition) }
@@ -85,27 +84,22 @@ class AssetType
85
84
  @mimes
86
85
  end
87
86
 
88
- def paperclip_processors
89
- TrustyCms.config["assets.create_#{name}_thumbnails?"] ? processors : []
87
+ def processing_enabled?
88
+ TrustyCms.config["assets.create_#{name}_thumbnails?"]
90
89
  end
91
90
 
92
- # Parses and combines the various ways in which paperclip styles can be defined, and normalises them into
93
- # the format that paperclip expects. Note that :styles => :standard has already been replaced with the
91
+ # Parses and combines the various ways in which ActiveStorage styles can be defined, and normalises them into
92
+ # the format that ActiveStorage expects. Note that :styles => :standard has already been replaced with the
94
93
  # results of a call to standard_styles.
95
- # Styles are passed to paperclip as a hash and arbitrary keys can be passed through from configuration.
94
+ # Styles are passed as a hash and arbitrary keys can be passed through from configuration.
96
95
  #
97
- def paperclip_styles
98
- # Styles are not relevant if processors are not defined.
99
- @paperclip_styles ||= if paperclip_processors.any?
100
- normalize_style_rules(configured_styles.merge(styles))
101
- else
102
- {}
103
- end
104
- @paperclip_styles
105
- end
106
-
107
96
  def active_storage_styles
108
- @active_storage_styles ||= normalize_style_rules(configured_styles.merge(styles))
97
+ @active_storage_styles ||= if processing_enabled?
98
+ normalize_style_rules(configured_styles.merge(styles))
99
+ else
100
+ {}
101
+ end
102
+ @active_storage_styles
109
103
  end
110
104
 
111
105
  # Takes a motley collection of differently-defined styles and renders them into the standard hash-of-hashes format.
@@ -128,13 +122,15 @@ class AssetType
128
122
 
129
123
  def standard_styles
130
124
  {
125
+ icon: { geometry: '50x50#', format: :png },
131
126
  thumbnail: { geometry: '100x100#', format: :png },
127
+ original: {},
132
128
  }
133
129
  end
134
130
 
135
- # Paperclip styles are defined in the config entry `assets.thumbnails.asset_type`, with the format:
131
+ # ActiveStorage styles are defined in the config entry `assets.thumbnails.asset_type`, with the format:
136
132
  # foo:key-x,key=y,key=z|bar:key-x,key=y,key=z
137
- # where 'key' can be any parameter understood by your paperclip processors. Usually they include :geometry and :format.
133
+ # where 'key' can be any parameter understood by your variant processor. Usually they include :geometry and :format.
138
134
  # A typical entry would be:
139
135
  #
140
136
  # standard:geometry=640x640>,format=jpg
@@ -153,8 +149,14 @@ class AssetType
153
149
  end
154
150
 
155
151
  def style_dimensions(style_name)
156
- if style = paperclip_styles[style_name.to_sym]
157
- style[:size]
152
+ if style = active_storage_styles[style_name.to_sym]
153
+ style[:geometry]
154
+ end
155
+ end
156
+
157
+ def style_format(style_name)
158
+ if style = active_storage_styles[style_name.to_sym]
159
+ style[:format]
158
160
  end
159
161
  end
160
162
 
@@ -173,8 +175,10 @@ class AssetType
173
175
  # class methods
174
176
 
175
177
  def self.for(attachment)
176
- extension = attachment.record.original_extension
177
- from_extension(extension) || from_mimetype(attachment.content_type) || catchall
178
+ return catchall unless attachment&.attached?
179
+
180
+ extension = attachment.blob&.filename&.extension&.downcase || attachment.record.original_extension
181
+ from_extension(extension) || from_mimetype(attachment.blob&.content_type) || catchall
178
182
  end
179
183
 
180
184
  def self.from_extension(extension)
@@ -1,8 +1,7 @@
1
1
  %ul#search_list
2
2
  - unless @assets.empty?
3
3
  - @assets.each do |asset|
4
- =# render :partial => 'asset', :locals => { :asset => asset, :page => @page }
5
- = render :partial => 'admin/assets/asset', :locals => { :asset_url => asset.asset.url, :asset_id => asset.id, :asset_type => 'image', :asset_title => asset.title, :asset_thumbnail => asset.thumbnail(:thumbnail), :page => @page }
4
+ = render :partial => 'admin/assets/asset', :locals => { :asset_url => asset.public_url, :asset_id => asset.id, :asset_type => 'image', :asset_title => asset.title, :asset_thumbnail => asset.thumbnail(:thumbnail), :page => @page }
6
5
 
7
6
  - else
8
7
  %li
@@ -12,4 +11,4 @@
12
11
  %script
13
12
  Asset.MakeDroppables();
14
13
  Asset.MakeDraggables();
15
- Event.addBehavior({ '.asset a' : Asset.DisableLinks, 'a.add_asset' : Asset.AddToPage });
14
+ Event.addBehavior({ '.asset a' : Asset.DisableLinks, 'a.add_asset' : Asset.AddToPage });
@@ -14,10 +14,10 @@
14
14
  %div.content
15
15
  %fieldset
16
16
  %label.filename
17
- = "#{t("clipped_extension.filename")}: #{@asset.asset_file_name unless @asset.new_record?}"
17
+ = "#{t("clipped_extension.filename")}: #{@asset.filename unless @asset.new_record?}"
18
18
  %br
19
19
  %label.url
20
- = "#{t("clipped_extension.asset_url")}: #{image_path @asset.asset.url unless @asset.new_record?}"
20
+ = "#{t("clipped_extension.asset_url")}: #{@asset.public_url unless @asset.new_record?}"
21
21
  %br
22
22
  %label.id
23
23
  = "#{t("clipped_extension.asset_id")}: #{@asset.id unless @asset.new_record?}"
@@ -7,7 +7,7 @@
7
7
  %table.index#assets{:cellpadding => "0", :cellspacing => "0", :border => "0"}
8
8
  %tbody
9
9
  %tr[@asset]
10
- %td.icon= image_tag @asset.thumbnail(:icon), :title => @asset.asset_file_name
10
+ %td.icon= image_tag @asset.thumbnail(:icon), :title => @asset.filename
11
11
  %td.name= @asset.title
12
12
 
13
13
  = form_for [:admin, @asset], :html => { :method => 'delete' } do
@@ -17,54 +17,6 @@ Rails.application.reloader.to_prepare do
17
17
  end
18
18
 
19
19
  TrustyCms.config do |config|
20
- config.namespace 'paperclip' do |pc|
21
- pc.define 'url', default: '/system/:attachment/:id/:style/:basename:no_original_style.:extension', allow_change: true
22
- pc.define 'path', default: ':rails_root/public/system/:attachment/:id/:style/:basename:no_original_style.:extension', allow_change: true
23
- pc.define 'skip_filetype_validation', default: true, type: :boolean
24
- pc.define 'storage', default: 'filesystem',
25
- select_from: {
26
- 'File System' => 'filesystem',
27
- 'Amazon S3' => 'fog',
28
- 'Google Storage' => 'fog',
29
- 'Rackspace Cloud Files' => 'fog',
30
- },
31
- allow_blank: false,
32
- allow_display: false
33
-
34
- pc.namespace 'fog' do |fog|
35
- fog.define 'provider', select_from: {
36
- 'Amazon S3' => 'AWS',
37
- 'Google Storage' => 'Google',
38
- 'Rackspace Cloud Files' => 'Rackspace',
39
- }
40
- fog.define 'directory'
41
- fog.define 'public?', default: true
42
- fog.define 'host'
43
- end
44
-
45
- pc.namespace 'google_storage' do |gs|
46
- gs.define 'access_key_id'
47
- gs.define 'secret_access_key'
48
- end
49
-
50
- pc.namespace 'rackspace' do |rs|
51
- rs.define 'username'
52
- rs.define 'api_key'
53
- end
54
-
55
- pc.namespace 's3' do |s3|
56
- s3.define 'key'
57
- s3.define 'secret'
58
- s3.define 'region', select_from: {
59
- 'Asia North East' => 'ap-northeast-1',
60
- 'Asia South East' => 'ap-southeast-1',
61
- 'EU West' => 'eu-west-1',
62
- 'US East' => 'us-east-1',
63
- 'US West' => 'us-west-1',
64
- }
65
- end
66
- end
67
-
68
20
  config.namespace 'assets', allow_display: false do |assets|
69
21
  assets.define 'create_image_thumbnails?', default: 'true'
70
22
  assets.define 'create_video_thumbnails?', default: 'true'
@@ -89,4 +41,4 @@ Rails.application.reloader.to_prepare do
89
41
 
90
42
  Admin::LayoutsController.send :helper, MultiSite::SiteChooserHelper
91
43
  Admin::SnippetsController.send :helper, MultiSite::SiteChooserHelper
92
- end
44
+ end
@@ -109,7 +109,7 @@ en:
109
109
  remove_from_page: 'Remove from page'
110
110
  reorder: 'Reorder'
111
111
  remove: 'Remove'
112
- refresh_assets_rake_task: 'For better results please log into your server and run <code>rake paperclip:refresh class=Asset</code>.'
112
+ refresh_assets_rake_task: 'For better results please log into your server and run <code>rake active_storage:refresh class=Asset</code>.'
113
113
  replace_file: 'Replace File'
114
114
  save_and_upload: 'Save and Upload'
115
115
  search_assets: 'Search for assets'
data/config/routes.rb CHANGED
@@ -27,8 +27,6 @@ TrustyCms::Application.routes.draw do
27
27
 
28
28
  resources :assets do
29
29
  get :remove, on: :member
30
- get :refresh, on: :collection
31
- put :refresh, on: :member
32
30
  collection do
33
31
  post :uploader
34
32
  end
@@ -2,22 +2,6 @@ class UpdateConfiguration < ActiveRecord::Migration[5.2]
2
2
  def self.up
3
3
  if TrustyCms.config.table_exists?
4
4
 
5
- puts "Importing paperclip configuration"
6
- %w{url path skip_filetype_validation storage}.select{|k| !!TrustyCms.config["assets.#{k}"] }.each do |k|
7
- begin
8
- TrustyCms.config["paperclip.#{k}"] = TrustyCms.config["assets.#{k}"]
9
- rescue ActiveRecord::RecordInvalid => e
10
- print "Oops! There was trouble setting #{k} to '#{TrustyCms.config["assets.#{k}"]}'"
11
- print "\nSetting it to 'fog'. Please see the clipped extension README for more details."
12
- TrustyCms.config["paperclip.#{k}"] = 'fog'
13
- end
14
- end
15
-
16
- puts "Importing s3 storage configuration"
17
- %w{bucket key secret host_alias}.select{|k| !!TrustyCms.config["assets.s3.#{k}"] }.each do |k|
18
- TrustyCms.config["paperclip.s3.#{k}"] = TrustyCms.config["assets.s3.#{k}"]
19
- end
20
-
21
5
  puts "Importing thumbnail configuration"
22
6
  if thumbnails = TrustyCms.config["assets.additional_thumbnails"]
23
7
  old_styles = thumbnails.to_s.gsub(' ','').split(',').collect{|s| s.split('=')}.inject({}) {|ha, (k, v)| ha[k.to_sym] = v; ha}