-
Notifications
You must be signed in to change notification settings - Fork 18
/
clipped_extension.rb
52 lines (42 loc) · 3.85 KB
/
clipped_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
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'radiant-clipped-extension'
require 'acts_as_list'
require 'uuidtools'
require 'cloud'
class ClippedExtension < Radiant::Extension
version RadiantClippedExtension::VERSION
description RadiantClippedExtension::DESCRIPTION
url RadiantClippedExtension::URL
migrate_from 'Paperclipped', 20100327111216
def activate
require 'paperclip/geometry_transformation'
if Asset.table_exists?
Page.send :include, PageAssetAssociations # defines page-asset associations. likely to be generalised soon.
Radiant::AdminUI.send :include, ClippedAdminUI unless defined? admin.asset # defines shards for extension of the asset-admin interface
Admin::PagesController.send :helper, Admin::AssetsHelper # currently only provides a description of asset sizes
Page.send :include, AssetTags # radius tags for selecting sets of assets and presenting each one
UserActionObserver.instance.send :add_observer!, Asset # the usual creator- and updater-stamping
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]
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]
AssetType.new :audio, :icon => 'audio', :mime_types => %w[audio/mp3 audio/mpeg audio/mpg audio/ogg application/ogg audio/x-ms-wma audio/vnd.rn-realaudio audio/x-wav]
AssetType.new :font, :icon => 'font', :extensions => %w[ttf otf eot woff]
AssetType.new :flash, :icon => 'flash', :default_radius_tag => 'flash', :extensions => %w{swf}, :mime_types => %w[application/x-shockwave-flash]
AssetType.new :pdf, :icon => 'pdf', :processors => [:thumbnail], :extensions => %w{pdf}, :mime_types => %w[application/pdf application/x-pdf], :styles => :standard
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]
AssetType.new :other, :icon => 'unknown'
admin.asset ||= Radiant::AdminUI.load_default_asset_regions # loads the shards defined in AssetsAdminUI
admin.page.edit.add :form, 'assets', :after => :edit_page_parts # adds the asset-attachment picker to the page edit view
admin.page.edit.add :main, 'asset_popups', :after => :edit_popups # adds the asset-attachment picker to the page edit view
admin.page.edit.asset_popups.concat %w{upload_asset attach_asset}
admin.configuration.show.add :config, 'admin/configuration/clipped_show', :after => 'defaults'
admin.configuration.edit.add :form, 'admin/configuration/clipped_edit', :after => 'edit_defaults'
if Radiant::Config.table_exists? && Radiant::config["paperclip.command_path"] # This is needed for testing if you are using mod_rails
Paperclip.options[:command_path] = Radiant::config["paperclip.command_path"]
end
tab "Assets", :after => "Content" do
add_item "All", "/admin/assets/"
end
end
end
def deactivate
end
end