radiant-clipped-extension-add-group 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +184 -0
  3. data/Rakefile +109 -0
  4. data/app/controllers/admin/assets_controller.rb +66 -0
  5. data/app/controllers/admin/page_attachments_controller.rb +18 -0
  6. data/app/helpers/admin/assets_helper.rb +16 -0
  7. data/app/helpers/admin/page_attachments_helper.rb +2 -0
  8. data/app/models/asset.rb +237 -0
  9. data/app/models/asset_type.rb +241 -0
  10. data/app/models/old_page_attachment.rb +26 -0
  11. data/app/models/page_attachment.rb +20 -0
  12. data/app/views/admin/assets/_asset.html.haml +12 -0
  13. data/app/views/admin/assets/_asset_table.html.haml +33 -0
  14. data/app/views/admin/assets/_errors.html.haml +3 -0
  15. data/app/views/admin/assets/_form.html.haml +25 -0
  16. data/app/views/admin/assets/_page_assets.html.haml +12 -0
  17. data/app/views/admin/assets/_search.html.haml +17 -0
  18. data/app/views/admin/assets/_search_results.html.haml +17 -0
  19. data/app/views/admin/assets/edit.html.haml +41 -0
  20. data/app/views/admin/assets/index.html.haml +19 -0
  21. data/app/views/admin/assets/new.html.haml +24 -0
  22. data/app/views/admin/assets/refresh.html.haml +14 -0
  23. data/app/views/admin/assets/remove.html.haml +16 -0
  24. data/app/views/admin/configuration/_clipped_edit.html.haml +8 -0
  25. data/app/views/admin/configuration/_clipped_show.html.haml +12 -0
  26. data/app/views/admin/page_attachments/_attachment.html.haml +25 -0
  27. data/app/views/admin/page_parts/_page_part.html.haml +21 -0
  28. data/app/views/admin/pages/_asset_popups.html.haml +42 -0
  29. data/app/views/admin/pages/_assets.html.haml +11 -0
  30. data/app/views/admin/removed/_assets_bucket.html.haml +8 -0
  31. data/app/views/admin/removed/_assets_container.html.haml +58 -0
  32. data/app/views/admin/removed/_bucket.html.haml +11 -0
  33. data/app/views/admin/removed/_bucket_asset.html.haml +9 -0
  34. data/app/views/admin/removed/_show_bucket_link.html.haml +4 -0
  35. data/app/views/admin/removed/_upload_to_page.html.haml +12 -0
  36. data/app/views/admin/removed/bucket/_iframe.html.haml +1 -0
  37. data/artwork/icons.png +0 -0
  38. data/clipped_extension.rb +52 -0
  39. data/config/initializers/interpolation.rb +6 -0
  40. data/config/initializers/processors.rb +43 -0
  41. data/config/initializers/radiant_config.rb +65 -0
  42. data/config/locales/de.yml +109 -0
  43. data/config/locales/en.yml +110 -0
  44. data/config/locales/nl.yml +107 -0
  45. data/config/locales/ru.yml +110 -0
  46. data/config/routes.rb +8 -0
  47. data/cucumber.yml +1 -0
  48. data/db/migrate/001_create_assets.rb +12 -0
  49. data/db/migrate/002_create_paperclip_attributes.rb +13 -0
  50. data/db/migrate/003_create_user_observer.rb +13 -0
  51. data/db/migrate/004_create_page_attachments.rb +19 -0
  52. data/db/migrate/005_rename_users.rb +13 -0
  53. data/db/migrate/20110513205050_asset_uuid.rb +11 -0
  54. data/db/migrate/20110606111250_update_configuration.rb +34 -0
  55. data/db/migrate/20110609101438_dimensions.rb +13 -0
  56. data/db/migrate/20121024064452_add_group_to_assets.rb +9 -0
  57. data/features/support/env.rb +11 -0
  58. data/features/support/paths.rb +22 -0
  59. data/lib/asset_tags.rb +350 -0
  60. data/lib/clipped_admin_ui.rb +32 -0
  61. data/lib/cloud.rb +41 -0
  62. data/lib/generators/templates/clipped_config.rb +53 -0
  63. data/lib/page_asset_associations.rb +13 -0
  64. data/lib/paperclip/frame_grab.rb +73 -0
  65. data/lib/paperclip/geometry_transformation.rb +80 -0
  66. data/lib/radiant-clipped-extension.rb +8 -0
  67. data/lib/tasks/clipped_extension_tasks.rake +124 -0
  68. data/lib/tasks/paperclip_tasks.rake +79 -0
  69. data/public/flash/ZeroClipboard.swf +0 -0
  70. data/public/images/admin/assets/add.png +0 -0
  71. data/public/images/admin/assets/archive_icon.png +0 -0
  72. data/public/images/admin/assets/audio_icon.png +0 -0
  73. data/public/images/admin/assets/audio_thumbnail.png +0 -0
  74. data/public/images/admin/assets/c_icon.png +0 -0
  75. data/public/images/admin/assets/copy.png +0 -0
  76. data/public/images/admin/assets/css_icon.png +0 -0
  77. data/public/images/admin/assets/database_icon.png +0 -0
  78. data/public/images/admin/assets/delete.png +0 -0
  79. data/public/images/admin/assets/document_icon.png +0 -0
  80. data/public/images/admin/assets/document_thumbnail.png +0 -0
  81. data/public/images/admin/assets/flash_icon.png +0 -0
  82. data/public/images/admin/assets/flash_thumbnail.png +0 -0
  83. data/public/images/admin/assets/font_icon.png +0 -0
  84. data/public/images/admin/assets/gzip_icon.png +0 -0
  85. data/public/images/admin/assets/html_icon.png +0 -0
  86. data/public/images/admin/assets/image_icon.png +0 -0
  87. data/public/images/admin/assets/image_thumbnail.png +0 -0
  88. data/public/images/admin/assets/java_icon.png +0 -0
  89. data/public/images/admin/assets/page_edit.png +0 -0
  90. data/public/images/admin/assets/perl_icon.png +0 -0
  91. data/public/images/admin/assets/php_icon.png +0 -0
  92. data/public/images/admin/assets/presentation_icon.png +0 -0
  93. data/public/images/admin/assets/python_icon.png +0 -0
  94. data/public/images/admin/assets/reorder_assets.png +0 -0
  95. data/public/images/admin/assets/ruby_icon.png +0 -0
  96. data/public/images/admin/assets/script_icon.png +0 -0
  97. data/public/images/admin/assets/spreadsheet_icon.png +0 -0
  98. data/public/images/admin/assets/tar_icon.png +0 -0
  99. data/public/images/admin/assets/unknown_icon.png +0 -0
  100. data/public/images/admin/assets/unknown_thumbnail.png +0 -0
  101. data/public/images/admin/assets/video_icon.png +0 -0
  102. data/public/images/admin/assets/video_thumbnail.png +0 -0
  103. data/public/images/admin/assets/xml_icon.png +0 -0
  104. data/public/images/admin/assets/zip_icon.png +0 -0
  105. data/public/javascripts/admin/assets.js +297 -0
  106. data/public/stylesheets/sass/admin/assets.sass +224 -0
  107. data/radiant-clipped-extension.gemspec +29 -0
  108. data/spec/ci/before_script +23 -0
  109. data/spec/ci/script +2 -0
  110. data/spec/controllers/admin/assets_controller_spec.rb +50 -0
  111. data/spec/controllers/admin/page_attachments_controller_spec.rb +50 -0
  112. data/spec/datasets/assets_dataset.rb +36 -0
  113. data/spec/fixtures/5k.png +0 -0
  114. data/spec/fixtures/test.flv +0 -0
  115. data/spec/lib/asset_tags_spec.rb +107 -0
  116. data/spec/lib/frame_grab_spec.rb +17 -0
  117. data/spec/lib/geometry_transformation_spec.rb +63 -0
  118. data/spec/models/asset_spec.rb +72 -0
  119. data/spec/models/asset_type_spec.rb +70 -0
  120. data/spec/models/post_processing_spec.rb +62 -0
  121. data/spec/spec.opts +7 -0
  122. data/spec/spec_helper.rb +36 -0
  123. data/wireframes/edit-page-assets-2.bmml +453 -0
  124. data/wireframes/edit-page-assets-2.png +0 -0
  125. data/wireframes/edit-page-assets-3.bmml +454 -0
  126. data/wireframes/edit-page-assets-3.png +0 -0
  127. data/wireframes/edit-page-assets.bmml +433 -0
  128. data/wireframes/edit-page-assets.png +0 -0
  129. data/wireframes/edit-page.bmml +174 -0
  130. data/wireframes/edit-page.png +0 -0
  131. metadata +281 -0
@@ -0,0 +1,19 @@
1
+ - include_stylesheet 'admin/assets'
2
+ - include_javascript 'admin/assets'
3
+
4
+ - content_for :toolbar do
5
+ = render 'search'
6
+
7
+ .outset
8
+ #assets_table.assets
9
+ = render :partial => 'asset_table', :locals => { :assets => @assets }
10
+ %p{:style => 'clear: both; height: 2em'}  
11
+
12
+ - render_region :bottom do |bottom|
13
+ #actions
14
+ = pagination_for @assets, :depaginate => false
15
+ %ul
16
+ %li= link_to((image('upload') + ' ' + t('clipped_extension.upload_asset')), new_admin_asset_path)
17
+ - if current_user.admin?
18
+ %li
19
+ = link_to t('clipped_extension.regenerate_thumbnails'), refresh_admin_assets_path
@@ -0,0 +1,24 @@
1
+ - include_stylesheet 'admin/assets'
2
+ = render_region :top
3
+
4
+ - render_region :main do |main|
5
+ - main.edit_header do
6
+ %h1= t("clipped_extension.new_asset")
7
+
8
+ - main.edit_form do
9
+ - form_for :asset, :url => admin_assets_path, :html => { :method => "post", :multipart => true } do |f|
10
+
11
+ = render :partial => "form", :locals => { :f => f }
12
+
13
+ %p
14
+ %label= t("clipped_extension.choose_file")
15
+ = f.file_field :asset, :style => "width: 100%", :multiple => true
16
+
17
+ .buttons
18
+ = save_model_button(@asset)
19
+ = save_model_and_continue_editing_button(@asset)
20
+ = t("or")
21
+ = link_to t("cancel"), admin_assets_path
22
+
23
+ - main.edit_regenerate do
24
+  
@@ -0,0 +1,14 @@
1
+ - include_stylesheet 'admin/assets'
2
+
3
+ %h1
4
+ = t("clipped_extension.refresh_assets")
5
+ %p.confirmation
6
+ = t("clipped_extension.confirm_refresh_assets")
7
+ %p.confirmation
8
+ =t('clipped_extension.refresh_assets_rake_task')
9
+
10
+ %form{:action => regenerate_admin_assets_path, :method => :post}
11
+ .buttons
12
+ %input.button{:type => "submit", :value => t("clipped_extension.refresh_assets")}
13
+ = t("or")
14
+ = link_to t("cancel"), admin_assets_path
@@ -0,0 +1,16 @@
1
+ - include_stylesheet 'admin/assets'
2
+
3
+ %h1= t("clipped_extension.remove_asset")
4
+ %p= t("clipped_extension.confirm_remove_asset")
5
+
6
+ %table.index#assets{:cellpadding => "0", :cellspacing => "0", :border => "0"}
7
+ %tbody
8
+ %tr[@asset]
9
+ %td.icon= image_tag @asset.thumbnail(:icon), :title => @asset.asset_file_name
10
+ %td.name= @asset.title
11
+
12
+ - form_for [:admin, @asset], :html => { :method => 'delete' } do
13
+ .buttons
14
+ %input.button{:type => "submit", :value => t("clipped_extension.delete_asset")}
15
+ = t("or")
16
+ = link_to t("cancel"), admin_assets_path
@@ -0,0 +1,8 @@
1
+ %fieldset
2
+ %h3
3
+ = t('clipped_extension.assets')
4
+ %p= edit_config 'assets.max_asset_size'
5
+ %p= edit_config 'assets.display_size'
6
+ %p= edit_config 'assets.insertion_size'
7
+ - %w{image video pdf}.each do |type|
8
+ %p= edit_config "assets.create_#{type}_thumbnails?"
@@ -0,0 +1,12 @@
1
+ %h4
2
+ = t('clipped_extension.assets')
3
+ %p.ruled
4
+ = show_config 'assets.max_asset_size'
5
+ %p.ruled
6
+ = show_config 'assets.display_size'
7
+ %p.ruled
8
+ = show_config 'assets.insertion_size'
9
+ - %w{image video pdf}.each do |type|
10
+ %p.ruled
11
+ = show_config "assets.create_#{type}_thumbnails?"
12
+
@@ -0,0 +1,25 @@
1
+ - attachment ||= @page_attachment
2
+
3
+ - page = attachment.page
4
+ - asset = attachment.asset
5
+ - asset_type = asset.image? ? "image" : "link"
6
+ - css_class = "#{asset_type} asset"
7
+ - css_class += ' unsaved' if attachment.new_record?
8
+
9
+ %li{:class => css_class, :id => "attachment_#{asset.uuid}"}
10
+ - fields_for :page, @page do |f|
11
+ - f.fields_for :page_attachments, attachment, :child_index => asset.uuid do |paf|
12
+ - if attachment.new_record?
13
+ = paf.hidden_field :asset_id, :class => 'attacher'
14
+ - else
15
+ = paf.hidden_field :_destroy, :class => 'destroyer'
16
+ = paf.hidden_field :position, :class => 'pos'
17
+ .front
18
+ .thumbnail= image_tag asset.thumbnail(:thumbnail)
19
+ .back
20
+ .title= asset.title
21
+ %ul.actions
22
+ %li
23
+ = asset_insertion_link(asset)
24
+ %li
25
+ = link_to t('clipped_extension.detach'), '#', :class => 'detach_asset'
@@ -0,0 +1,21 @@
1
+ .page{:id => "page_#{page_part.name.to_slug}", 'data-caption'=>h(page_part.name)}
2
+ .part{:id => "part-#{page_part.name.to_slug}"}
3
+ = hidden_field_tag "page[parts_attributes][#{page_part_counter}][name]", page_part.name, :id => "part_#{page_part.name.to_slug}_name"
4
+ = hidden_field_tag "page[parts_attributes][#{page_part_counter}][id]", page_part.id, :id => "part_#{page_part_counter}_id", :class => "id_input" unless page_part.new_record?
5
+ = hidden_field_tag "page[parts_attributes][#{page_part_counter}][_destroy]", page_part._destroy, :class => "delete_input"
6
+ %p
7
+ %label{:for => "part_#{page_part.name.to_slug}_filter_id"}
8
+ = t('filter')
9
+ = select_tag "page[parts_attributes][#{page_part_counter}][filter_id]", filter_options_for_select(page_part.filter_id), :id => "part_#{page_part.name.to_slug}_filter_id"
10
+ / bring this back when the new toolbar ui arrives
11
+ / %span.toolbar
12
+ / = link_to t('clipped_extension.assets'), '#attach_asset', :class => 'popup', :style => 'color: #666'
13
+ %span.reference_links
14
+ = t('reference')
15
+ %span{:id => "filter_reference_link_#{page_part.name.to_slug}"}
16
+ = link_to_function t('filter'), "loadFilterReference('#{page_part.name.to_slug}');"
17
+ %span{:id => "tag_reference_link_#{page_part.name.to_slug}"}
18
+ = link_to_function t('available_tags'), "loadTagReference('#{page_part.name.to_slug}');"
19
+ = render_region :part_controls, :locals => {:page_part => page_part}
20
+ %div
21
+ ~ text_area_tag "page[parts_attributes][#{page_part_counter}][content]", page_part.content, :class => "textarea large", :style => "width: 100%", :id => "part_#{page_part.name.to_slug}_content"
@@ -0,0 +1,42 @@
1
+ - render_region :asset_popups do |popups|
2
+ - popups.upload_asset do
3
+ #upload_asset.popup.textured{:style => "display: none; width: 28em"}
4
+ #upload_asset_busy.busy{:style => "display: none"}= image('spinner.gif', :alt => "")
5
+
6
+ .popup_title= t('clipped_extension.upload_asset')
7
+
8
+ - form_for([:admin, Asset.new], :html => {:method => 'post', :multipart => true, :class => 'upload_asset'}) do |f|
9
+ = hidden_field_tag "for_attachment", 1
10
+ = hidden_field_tag "page_id", @page.id
11
+
12
+ %p
13
+ = f.label :asset, t("clipped_extension.choose_file")
14
+ = f.file_field :asset, :class => 'file', :multiple => true
15
+
16
+ %p
17
+ = f.label :title, t("clipped_extension.alt_text_or_title")
18
+ = f.text_field :title, :class => "textbox big"
19
+
20
+ .buttons
21
+ = f.submit t("clipped_extension.upload"), :class => "button"
22
+ = t('or')
23
+ %a.cancel.close_popup{:href=>"javascript:void(0)"}= t('cancel')
24
+ %a.popup{:href=>"#attach_asset", :style => 'color: #666; float: left'}= t('clipped_extension.attach_existing')
25
+ #upload_holders
26
+
27
+ - popups.attach_asset do
28
+ #attach_asset.popup.textured{:style=>"display: none;"}
29
+
30
+ .popup_title= t('clipped_extension.find_assets')
31
+
32
+ .toolbar
33
+ = render :partial => 'admin/assets/search'
34
+
35
+ #assets_table.assets.viewport{:style=>"height: 320px; width: 610px"}
36
+ - assets = Asset.all.paginate(:per_page => 20)
37
+ = render :partial => 'admin/assets/asset_table', :locals => {:assets => assets, :with_pagination => true}
38
+
39
+ .busy{:style => "display: none"}= image('spinner.gif', :alt => "")
40
+ .buttons
41
+ %a.cancel.close_popup{:href=>"javascript:void(0)"}= t('close')
42
+ %a.popup{:href=>"#upload_asset", :style => 'color: #666; float: left'}= t('clipped_extension.upload_asset')
@@ -0,0 +1,11 @@
1
+ - include_stylesheet 'admin/assets'
2
+ - include_javascript 'admin/assets'
3
+
4
+ #attachment_list.assets
5
+ %ul#attachment_fields{:class => @page.page_attachments.empty? ? 'empty' : ''}
6
+ = render :partial => 'admin/page_attachments/attachment', :collection => @page.page_attachments
7
+ %p.note
8
+ = link_to t('clipped_extension.assets'), '#attach_asset', :class => 'popup'
9
+ %span.message
10
+ - if @page.page_attachments.empty?
11
+ = t('clipped_extension.no_attached_assets')
@@ -0,0 +1,8 @@
1
+ #asset-bucket{ :style => "display: none" }
2
+ = render :partial => "/admin/assets/assets_container"
3
+
4
+ %p.note
5
+ = automatic_size_descriptions
6
+ = t('clipped_extension.images_automatically_created')
7
+ #close-link
8
+ = link_to t("close"), "#"
@@ -0,0 +1,58 @@
1
+ - @stylesheets << 'admin/assets'
2
+ - include_javascript 'ZeroClipboard'
3
+ - include_javascript 'admin/assets'
4
+ - include_javascript 'admin/dragdrop'
5
+
6
+ #assets-container
7
+ #asset-tabs
8
+ - render_region :asset_tabs do |asset_tabs|
9
+ - if @page && !@page.new_record?
10
+ - asset_tabs.attachment_tab do
11
+ %a.asset-tab{ :href => "#page-attachments", :id => "tab_page-attachments" }
12
+ = t("clipped_extension.attached_assets")
13
+ - asset_tabs.upload_tab do
14
+ %a.asset-tab{ :href => "#upload_assets", :id => "tab_upload_assets" }
15
+ = t("clipped_extension.upload")
16
+ - asset_tabs.bucket_tab do
17
+ %a.asset-tab{ :href => "#bucket", :id => "tab_bucket" }
18
+ = t("clipped_extension.bucket")
19
+ - asset_tabs.search_tab do
20
+ %a.asset-tab{ :href => "#search-assets" }
21
+ = t("clipped_extension.search")
22
+ - else
23
+ - asset_tabs.bucket_tab do
24
+ %a.asset-tab.here{ :href => "#" }
25
+ = t("clipped_extension.bucket")
26
+
27
+ - if @page && !@page.new_record?
28
+ - render_region :asset_panes do |asset_panes|
29
+
30
+ - asset_panes.page_attachments do
31
+ #page-attachments.pane
32
+ %p
33
+ %span.note
34
+ != t("clipped_extension.asset_note")
35
+ %ul#attachments
36
+ = render :partial => "admin/assets/page_assets"
37
+ .clear
38
+
39
+ - asset_panes.upload do
40
+ #upload_assets.pane
41
+ %p
42
+ %span.note
43
+ != t("clipped_extension.asset_page_upload_note")
44
+ = render :partial => "admin/assets/upload_to_page"
45
+ .clear
46
+
47
+ - asset_panes.search do
48
+ #search-assets.pane
49
+ - form_tag do
50
+ %p
51
+ %label.note{ :for => 'search' }
52
+ = t("clipped_extension.search_assets")
53
+ %input{ :type => "hidden", :name => "search", :value => @page.id }
54
+ %input{ :type => "search", :id => "search", :name => "search" }
55
+ = submit_tag t("clipped_extension.search")
56
+ #search-results
57
+ .clear
58
+ = observe_field 'search', :frequency => 1, :update => 'search-results', :url => admin_assets_path(:asset_page => @page), :method => 'get', :with => "'search=' + escape(value)"
@@ -0,0 +1,11 @@
1
+ %ul#bucket_list
2
+ - if session[:bucket]
3
+ - session[:bucket].each do |url, info|
4
+ = render :partial => 'admin/assets/bucket_asset', :locals => { :asset_url => url, :asset_id => info[:id], :asset_type => info[:type], :asset_title => info[:title], :asset_thumbnail =>info[:thumbnail], :page => @page }
5
+ - else
6
+ %li
7
+ %p.note
8
+ = t("clipped_extension.empty_bucket")
9
+
10
+
11
+
@@ -0,0 +1,9 @@
1
+ %li
2
+
3
+ %div{ :class => "#{asset_type} asset", :id => "bucket_#{asset_id}" }
4
+ = link_to image_tag(asset_thumbnail), asset_url, :title => asset_title, :class => "bucket_link"
5
+
6
+ .info{ :id => "#{asset_id}_info" }
7
+ = link_to image('assets/edit'), edit_admin_asset_url(asset_id), :class => "edit_asset", :title => t("clipped_extension.edit_asset", :asset => asset_title)
8
+ - if page && !page.new_record?
9
+ = link_to image('assets/add'), attach_page_asset_url(:asset => asset_id, :page => page.id), :class => "add_asset", :title => t("clipped_extension.attach_to_page")
@@ -0,0 +1,4 @@
1
+ - unless @page.nil? || @page.new_record?
2
+ %span#show-bucket
3
+ = t('clipped_extension.bucket')
4
+ = link_to t("clipped_extension.show_assets_bucket"), "#"
@@ -0,0 +1,12 @@
1
+ #upload-form
2
+ - form_for :asset, :url => admin_assets_path(:page => @page, :format => 'js'), :html => { :id => 'asset-upload', :method => "post", :multipart => true, :target => 'ulframe' } do |form|
3
+ %div.file
4
+ %label.upload
5
+ = t("clipped_extension.choose_upload")
6
+ = form.file_field :asset, :class => "", :style => "width: 100%"
7
+
8
+ .upload-buttons
9
+ = form.submit t("clipped_extension.save_and_upload"), :class => "button"
10
+ %div.spinner
11
+
12
+ %iframe{:id => 'ulframe', :name => "ulframe", :src => "about:blank"}
@@ -0,0 +1 @@
1
+ = render :partial => 'admin/assets/asset', :object => asset, :locals => {:dom_id => "attachment_#{asset.id}" }
data/artwork/icons.png ADDED
Binary file
@@ -0,0 +1,52 @@
1
+ require 'radiant-clipped-extension'
2
+ require 'acts_as_list'
3
+ require 'uuidtools'
4
+ require 'cloud'
5
+
6
+ class ClippedExtension < Radiant::Extension
7
+ version RadiantClippedExtension::VERSION
8
+ description RadiantClippedExtension::DESCRIPTION
9
+ url RadiantClippedExtension::URL
10
+
11
+ migrate_from 'Paperclipped', 20100327111216
12
+
13
+ def activate
14
+ require 'paperclip/geometry_transformation'
15
+ if Asset.table_exists?
16
+ Page.send :include, PageAssetAssociations # defines page-asset associations. likely to be generalised soon.
17
+ Radiant::AdminUI.send :include, ClippedAdminUI unless defined? admin.asset # defines shards for extension of the asset-admin interface
18
+ Admin::PagesController.send :helper, Admin::AssetsHelper # currently only provides a description of asset sizes
19
+ Page.send :include, AssetTags # radius tags for selecting sets of assets and presenting each one
20
+ UserActionObserver.instance.send :add_observer!, Asset # the usual creator- and updater-stamping
21
+
22
+ 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]
23
+ 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]
24
+ AssetType.new :audio, :icon => 'audio', :mime_types => %w[audio/mpeg audio/mpg audio/ogg application/ogg audio/x-ms-wma audio/vnd.rn-realaudio audio/x-wav]
25
+ AssetType.new :font, :icon => 'font', :extensions => %w[ttf otf eot woff]
26
+ AssetType.new :flash, :icon => 'flash', :default_radius_tag => 'flash', :extensions => %w{swf}, :mime_types => %w[application/x-shockwave-flash]
27
+ AssetType.new :pdf, :icon => 'pdf', :processors => [:thumbnail], :extensions => %w{pdf}, :mime_types => %w[application/pdf application/x-pdf], :styles => :standard
28
+ 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]
29
+ AssetType.new :other, :icon => 'unknown'
30
+
31
+ admin.asset ||= Radiant::AdminUI.load_default_asset_regions # loads the shards defined in AssetsAdminUI
32
+ admin.page.edit.add :form, 'assets', :after => :edit_page_parts # adds the asset-attachment picker to the page edit view
33
+ admin.page.edit.add :main, 'asset_popups', :after => :edit_popups # adds the asset-attachment picker to the page edit view
34
+ admin.page.edit.asset_popups.concat %w{upload_asset attach_asset}
35
+ admin.configuration.show.add :config, 'admin/configuration/clipped_show', :after => 'defaults'
36
+ admin.configuration.edit.add :form, 'admin/configuration/clipped_edit', :after => 'edit_defaults'
37
+
38
+ if Radiant::Config.table_exists? && Radiant::config["paperclip.command_path"] # This is needed for testing if you are using mod_rails
39
+ Paperclip.options[:command_path] = Radiant::config["paperclip.command_path"]
40
+ end
41
+
42
+ tab "Assets", :after => "Content" do
43
+ add_item "All", "/admin/assets/"
44
+ end
45
+ end
46
+ end
47
+
48
+ def deactivate
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,6 @@
1
+ require 'paperclip'
2
+
3
+ Paperclip.interpolates :no_original_style do |attachment, style|
4
+ style ||= :original
5
+ style == attachment.default_style ? nil : "_#{style}"
6
+ end
@@ -0,0 +1,43 @@
1
+ require 'paperclip'
2
+
3
+ if Radiant.config.table_exists?
4
+ if Radiant.config['assets.create_image_thumbnails?']
5
+ # Check that we can run convert
6
+ begin
7
+ output = Paperclip.run('convert', '-version')
8
+ Rails.logger.info %{[Clipped] Using image thumbnailer: #{output.split("\n").first.sub(/^Version: /i, '')}}
9
+ rescue Cocaine::CommandNotFoundError
10
+ Radiant.config['assets.create_image_thumbnails?'] = false
11
+ Radiant.config['assets.create_pdf_thumbnails?'] = false
12
+ Rails.logger.warn "ImageMagick 'convert' executable not found: image and pdf thumbnailing disabled."
13
+ rescue Cocaine::ExitStatusError => e
14
+ Rails.logger.warn "ImageMagick is present but calling 'convert -version' returns an error: #{e}"
15
+ end
16
+ end
17
+
18
+ if Radiant.config['assets.create_pdf_thumbnails?']
19
+ # Check that we can run ghostscript
20
+ begin
21
+ output = Paperclip.run('gs', '-v')
22
+ Rails.logger.info %{[Clipped] Using PDF thumbnailer: #{output.split("\n").first}}
23
+ rescue Cocaine::CommandNotFoundError
24
+ Radiant.config['assets.create_pdf_thumbnails?'] = false
25
+ Rails.logger.warn "Ghostscript 'gs' executable not found: pdf thumbnailing disabled."
26
+ rescue Cocaine::ExitStatusError => e
27
+ Rails.logger.warn "Ghostscript is present but calling 'gs -v' returns an error: #{e}"
28
+ end
29
+ end
30
+
31
+ if Radiant.config['assets.create_video_thumbnails?']
32
+ # Check that we can run ffmpeg
33
+ begin
34
+ output = Paperclip.run('ffmpeg', '-version 2> /dev/null')
35
+ Rails.logger.info %{[Clipped] Using video frame grabber: #{output.split("\n").first}}
36
+ rescue Cocaine::CommandNotFoundError
37
+ Radiant.config['assets.create_video_thumbnails?'] = false
38
+ Rails.logger.warn "FFmpeg executable not found: video thumbnailing disabled."
39
+ rescue Cocaine::ExitStatusError => e
40
+ Rails.logger.warn "FFmpeg is present but calling 'ffmpeg -L' returns an error: #{e}"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,65 @@
1
+ Radiant.config do |config|
2
+ config.namespace 'paperclip' do |pc|
3
+ pc.define 'url', :default => '/system/:attachment/:id/:style/:basename:no_original_style.:extension', :allow_change => true
4
+ pc.define 'path', :default => ':rails_root/public/system/:attachment/:id/:style/:basename:no_original_style.:extension', :allow_change => true
5
+ pc.define 'skip_filetype_validation', :default => true, :type => :boolean
6
+ pc.define 'storage', :default => 'filesystem',
7
+ :select_from => {
8
+ 'File System' => 'filesystem',
9
+ 'Amazon S3' => 'fog',
10
+ 'Google Storage' => 'fog',
11
+ 'Rackspace Cloud Files' => 'fog'
12
+ },
13
+ :allow_blank => false,
14
+ :allow_display => false
15
+
16
+ pc.namespace 'fog' do |fog|
17
+ fog.define 'provider', :select_from => {
18
+ 'Amazon S3' => 'AWS',
19
+ 'Google Storage' => 'Google',
20
+ 'Rackspace Cloud Files' => 'Rackspace'
21
+ }
22
+ fog.define 'directory'
23
+ fog.define 'public?', :default => true
24
+ fog.define 'host'
25
+ end
26
+
27
+ pc.namespace 'google_storage' do |gs|
28
+ gs.define 'access_key_id'
29
+ gs.define 'secret_access_key'
30
+ end
31
+
32
+ pc.namespace 'rackspace' do |rs|
33
+ rs.define 'username'
34
+ rs.define 'api_key'
35
+ end
36
+
37
+ pc.namespace 's3' do |s3|
38
+ s3.define 'key'
39
+ s3.define 'secret'
40
+ s3.define 'region', :select_from => {
41
+ 'Asia North East' => 'ap-northeast-1',
42
+ 'Asia South East' => 'ap-southeast-1',
43
+ 'EU West' => 'eu-west-1',
44
+ 'US East' => 'us-east-1',
45
+ 'US West' => 'us-west-1'
46
+ }
47
+ end
48
+ end
49
+
50
+ config.namespace 'assets', :allow_display => false do |assets|
51
+ assets.define 'create_image_thumbnails?', :default => 'true'
52
+ assets.define 'create_video_thumbnails?', :default => 'true'
53
+ assets.define 'create_pdf_thumbnails?', :default => 'true'
54
+
55
+ assets.namespace 'thumbnails' do |thumbs| # NB :icon and :thumbnail are already defined as fixed formats for use in the admin interface and can't be changed
56
+ thumbs.define 'image', :default => 'normal:size=640x640>|small:size=320x320>'
57
+ thumbs.define 'video', :default => 'normal:size=640x640>,format=jpg|small:size=320x320>,format=jpg'
58
+ thumbs.define 'pdf', :default => 'normal:size=640x640>,format=jpg|small:size=320x320>,format=jpg'
59
+ end
60
+
61
+ assets.define 'max_asset_size', :default => 5, :type => :integer, :units => 'MB'
62
+ assets.define 'display_size', :default => 'normal', :allow_blank => true
63
+ assets.define 'insertion_size', :default => 'normal', :allow_blank => true
64
+ end
65
+ end