public
Description: Radiant Image and Assets Extension
Homepage: http://github.com/kbingman/assets_extension/wikis
Clone URL: git://github.com/kbingman/assets_extension.git
Keith Bingman (author)
Sun Mar 30 02:58:11 -0700 2008
assets_extension / assets_extension.rb
100644 55 lines (44 sloc) 2.343 kb
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
53
54
55
class AssetsExtension < Radiant::Extension
  version "0.4"
  description "Describe your extension here"
  url "http://keithbingman.com/assets"
  
  define_routes do |map|
 
    map.with_options(:controller => 'admin/asset') do |asset|
      asset.asset_index 'admin/assets', :action => 'index'
      asset.asset_edit 'admin/assets/edit/:id', :action => 'edit'
      asset.asset_new 'admin/assets/new', :action => 'new'
      asset.asset_remove 'admin/assets/remove/:id', :action => 'remove'
      asset.asset_reorder 'admin/assets/reorder/:id', :action => 'reorder'
      asset.add_bucket 'admin/assets/add_bucket/:id', :action => 'add_bucket'
      asset.clear_bucket 'admin/assets/clear_bucket/:id', :action => 'clear_bucket'
      asset.attach_asset 'admin/assets/attach/:asset/page/:page', :action => 'attach_asset'
      asset.remove_asset 'admin/assets/remove/:asset/page/:page', :action => 'remove_asset'
    end
    map.with_options(:controller => 'image') do |image|
      image.images_show 'images/:id/:size/:filename.:ext', :action => 'show'
    end
  end
  
  def activate
    raise "The Shards extension is required and must be loaded first!" unless defined?(Shards)
    admin.page.index.add :sitemap_head, 'assets_extra_th', :after => "status_column_header"
    admin.page.index.add :node, 'assets_extra_td', :after => "status_column"
    admin.page.edit.add :form_bottom, '/admin/asset/assets_container', :before => "edit_buttons"
    
    require_dependency 'application'
    
    AssetDisplayPage
    AssetListingPage
    
    Page.class_eval {
      include PageAssetAssociations
      include AssetTags
    }
    UserActionObserver.send :include, ObserveAssets
    # Admin::PageController.send :include, AssetsInterface
    
    # Default sizes for the images used in the admin views. Other sizes can be added in the Config table using
    # "assets.foo" = "[width]x[height]". You can also use RMagick flags for cropping.
    
    Radiant::Config["assets.icon"] = '42x42!'
    Radiant::Config["assets.thumbnail"] = '100x100'
    
    admin.tabs.add "Assets", "/admin/assets", :after => "Pages", :visibility => [:all]
  end
  
  def deactivate
    admin.tabs.remove "Assets"
  end
  
end