-
Notifications
You must be signed in to change notification settings - Fork 3
/
assets_extension.rb
39 lines (35 loc) · 1.33 KB
/
assets_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application_controller'
require 'radiant-assets-extension/version'
require 'radiant-assets-extension/s3_store'
class AssetsExtension < Radiant::Extension
version RadiantAssetsExtension::VERSION
description 'Simple asset management (images and other uploads) for Radiant.'
url 'http://ext.radiantcms.org/extensions/269-assets'
extension_config do |config|
path = '/assets'
dragonfly = Dragonfly[:assets]
dragonfly.configure_with(:imagemagick)
dragonfly.configure_with(:rails)
dragonfly.define_macro(ActiveRecord::Base, :image_accessor)
dragonfly.url_path_prefix = path
if RadiantAssetsExtension::S3Store.enabled?
dragonfly.datastore = RadiantAssetsExtension::S3Store.new
dragonfly.datastore.configure do |c|
c.use_filesystem = false
end
end
config.middleware.insert_after 'Rack::Lock', 'Dragonfly::Middleware', :assets, path
end
def activate
tab 'Content' do
add_item 'Assets', '/admin/assets', :after => 'Pages'
end
admin.page.edit.add :main, 'admin/assets/attachments', :after => :form
ApplicationController.helper(:assets)
Page.class_eval do
include AssetTags
has_many :attachments, :include => :asset, :order => :position
end
end
end