radiant-assets-extension 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ Supports uploading of images as well as other files.
7
7
 
8
8
  == Radius Tags
9
9
 
10
- <r:images size="300x" />
10
+ <r:image size="300x" />
11
11
 
12
12
  Proportionally resizes an image to 300px width. Supports imagemagick geometry
13
13
  strings to do advanced resizing straight in Radius tags. Resized images are
@@ -17,4 +17,6 @@ request.
17
17
  == Todo
18
18
 
19
19
  - Attaching Assets to Pages
20
- - Easy/Automatic migration from paperclipped
20
+ - Easy/Automatic migration from paperclipped (currently this extension should
21
+ only be used on “fresh” radiant sites w/o an asset management solution
22
+ already in place)
data/Rakefile CHANGED
@@ -96,17 +96,17 @@ namespace :spec do
96
96
  end
97
97
  end
98
98
 
99
- desc 'Generate documentation for the images extension.'
99
+ desc 'Generate documentation for the assets extension.'
100
100
  Rake::RDocTask.new(:rdoc) do |rdoc|
101
101
  rdoc.rdoc_dir = 'rdoc'
102
- rdoc.title = 'ImagesExtension'
102
+ rdoc.title = 'AssetsExtension'
103
103
  rdoc.options << '--line-numbers' << '--inline-source'
104
104
  rdoc.rdoc_files.include('README')
105
105
  rdoc.rdoc_files.include('lib/**/*.rb')
106
106
  end
107
107
 
108
108
  # For extensions that are in transition
109
- desc 'Test the images extension.'
109
+ desc 'Test the assets extension.'
110
110
  Rake::TestTask.new(:test) do |t|
111
111
  t.libs << 'lib'
112
112
  t.pattern = 'test/**/*_test.rb'
@@ -1,28 +1,11 @@
1
1
  class Admin::AssetsController < Admin::ResourceController
2
+ include Admin::UploadHandler
2
3
  paginate_models
3
- helper :assets
4
4
 
5
5
  def create
6
- # HACK: depends on javascript being present and packaging each file
7
- # in its own request
8
- # TODO: handle non-js situations with several files in one request
9
- @asset = Asset.create! :upload => Array(params[:asset][:upload]).first
10
- @asset.save!
11
- render_hacky_json(:markup => @template.asset_listing(@asset))
12
- rescue => e
13
- logger.warn(e.to_s)
14
- render_hacky_json(:markup => "Error: #{e.to_s}")
15
- end
16
-
17
- private
18
- # HACK: sending JSON as text/html
19
- # (https://github.com/blueimp/jQuery-File-Upload/wiki/Setup)
20
- # jquery.fileupload makes use of iframes for browsers like Microsoft
21
- # Internet Explorer and Opera, which do not yet support XMLHTTPRequest
22
- # uploads. They will only register a load event if the Content-type of the
23
- # response is set to text/plain or text/html, not if it is set to
24
- # application/json.
25
- def render_hacky_json(data)
26
- render :json => data, :content_type => 'text/html'
6
+ rendering_upload_response do
7
+ @asset = Asset.create! params[:asset]
8
+ @template.content_tag(:li, @template.asset_listing(@asset))
9
+ end
27
10
  end
28
11
  end
@@ -0,0 +1,21 @@
1
+ class Admin::AttachmentsController < Admin::ResourceController
2
+ include Admin::UploadHandler
3
+
4
+ def create
5
+ rendering_upload_response do
6
+ @page = Page.find(params[:page_id])
7
+ attachment = @page.attachments.create!(params[:attachment])
8
+ render_to_string(:partial => 'admin/assets/attachment', :locals => {:attachment => attachment})
9
+ end
10
+ end
11
+
12
+ # Gets called after successful update
13
+ # only used when attachment update form not submitted using javascript
14
+ def index
15
+ redirect_to edit_admin_page_path(params[:page_id])
16
+ end
17
+
18
+ def positions
19
+ render :json => Attachment.reorder(params[:attachment])
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module Admin::UploadHandler
2
+ private
3
+ # HACK: sending JSON as text/html
4
+ # (https://github.com/blueimp/jQuery-File-Upload/wiki/Setup)
5
+ # jquery.fileupload makes use of iframes for browsers like Microsoft
6
+ # Internet Explorer and Opera, which do not yet support XMLHTTPRequest
7
+ # uploads. They will only register a load event if the Content-type of the
8
+ # response is set to text/plain or text/html, not if it is set to
9
+ # application/json.
10
+ def render_hacky_json(data)
11
+ render :json => data, :content_type => 'text/html'
12
+ end
13
+
14
+ # Renders a response appropriate for use with jquery.fileupload.js
15
+ # Takes a block that should return an HTML string
16
+ def rendering_upload_response
17
+ render_hacky_json(:markup => yield)
18
+ rescue => e
19
+ logger.warn(e.to_s)
20
+ render_hacky_json(:markup => "Error: #{e.to_s}")
21
+ end
22
+ end
@@ -1,10 +1,16 @@
1
1
  module AssetsHelper
2
2
  def asset_listing(asset)
3
- icon(asset) +
3
+ asset_icon(asset) +
4
4
  content_tag(:span, asset.to_s, :class=>'title')
5
5
  end
6
6
 
7
- def icon(asset, size=30)
7
+ def asset_grid_item(asset)
8
+ asset_icon(asset, 120) +
9
+ content_tag(:span, "ID: #{asset.id}", :class => 'id') +
10
+ content_tag(:span, asset.to_s, :class => 'caption')
11
+ end
12
+
13
+ def asset_icon(asset, size=30)
8
14
  asset.image? ? square_thumb(asset, size) : text_icon(asset, size)
9
15
  end
10
16
 
data/app/models/asset.rb CHANGED
@@ -1,16 +1,30 @@
1
1
  class Asset < ActiveRecord::Base
2
+ has_many :attachments, :include => :page, :dependent => :destroy
2
3
  # HACK: incomplete
3
4
  AUDIO_FORMATS = [:wav, :mp3, :m4a, :ogg]
4
5
  VIDEO_FORMATS = [:mp4, :avi]
5
6
 
6
7
  image_accessor :upload
7
8
  validates_presence_of :upload
9
+ delegate :url, :width, :height, :landscape, :portrait, :to => :upload
10
+
11
+ def uploads
12
+ []
13
+ end
14
+
15
+ def uploads=(new_uploads)
16
+ # HACK: depends on javascript being present and packaging each file
17
+ # in its own request
18
+ # TODO: handle non-js situations with several files in one request
19
+ # see Admin::AttachmentsController#create and Admin::AssetsController#create
20
+ self.upload = Array(new_uploads).first
21
+ end
8
22
 
9
23
  def format
10
24
  # HACK: relying on extension instead of using analyser and upload.format
11
25
  # analyser can throw us into very long loop when trying to identify
12
26
  # non-image files like word docs
13
- upload.ext && upload.ext.to_sym
27
+ upload.ext ? upload.ext.to_sym : :generic
14
28
  rescue Dragonfly::FunctionManager::UnableToHandle
15
29
  :generic
16
30
  end
@@ -32,6 +46,6 @@ class Asset < ActiveRecord::Base
32
46
  end
33
47
 
34
48
  def to_s
35
- caption || upload.name
49
+ caption || upload.name || ''
36
50
  end
37
51
  end
@@ -27,26 +27,37 @@ module AssetTags
27
27
  # TODO: accept width/height attributes and do something sensible like
28
28
  # resizing proportionally
29
29
  tag 'image' do |tag|
30
- assert_id_given(tag)
31
- image = find_asset(tag)
32
- %{<img src="#{image.url}" width="#{image.width}" height="#{image.height}">}
30
+ asset = find_asset(tag)
31
+ options = tag.attr.dup
32
+ image = resized_or_original_image(asset, options.delete('size'))
33
+ %{<img src="#{image.url}"#{html_attributes(options)}>}
33
34
  end
34
35
 
35
36
  desc %{
36
37
  Selects an asset. Does not render anything itself but gives access to the
37
38
  asset's attributes such as size
38
39
 
39
- Accepts optional @size@ attribute, see documentation for r:image
40
-
41
- <r:asset id="22" [size="200"]><r:url /></r:asset>
40
+ <r:asset id="22"><r:url /></r:asset>
42
41
  }
43
42
  tag 'asset' do |tag|
44
- assert_id_given(tag)
45
43
  tag.locals.asset = find_asset(tag)
46
44
  tag.expand
47
45
  end
48
46
 
49
- %w[url width height].each do |attribute|
47
+ desc %{
48
+ Renders the URL of an asset
49
+
50
+ Accepts optional size parameter in which case, if the asset is an image,
51
+ the URL to a resized version of the image will be returned
52
+
53
+ <r:asset:url [size="200x200"] id="22" />
54
+ }
55
+ tag 'asset:url' do |tag|
56
+ image = resized_or_original_image(tag.locals.asset, tag.attr['size'])
57
+ (image && image.url) || tag.locals.asset.url
58
+ end
59
+
60
+ %w[caption width height].each do |attribute|
50
61
  desc %{
51
62
  Renders the #{attribute} of the current asset
52
63
  }
@@ -55,13 +66,6 @@ module AssetTags
55
66
  end
56
67
  end
57
68
 
58
- desc %{
59
- Renders the caption of the current asset
60
- }
61
- tag 'asset:caption' do |tag|
62
- tag.locals.asset.caption
63
- end
64
-
65
69
  desc %{
66
70
  Renders contents if the current asset is an image
67
71
  }
@@ -92,17 +96,45 @@ module AssetTags
92
96
  end
93
97
  end
94
98
 
95
- private
96
- def assert_id_given(tag)
97
- raise TagError, 'Please supply an id attribute' unless tag.attr['id']
99
+ # Namespace only
100
+ tag 'attachments' do |tag|
101
+ tag.expand
98
102
  end
99
-
103
+
104
+ desc %{
105
+ Selects the first attached asset of the page and renders the tag's contents.
106
+ If there are no assets on the page, nothing is rendered.
107
+ }
108
+ tag 'attachments:first' do |tag|
109
+ if attachment = tag.locals.page.attachments.first
110
+ tag.locals.asset = attachment.asset
111
+ tag.expand
112
+ end
113
+ end
114
+
115
+ tag 'attachments:each' do |tag|
116
+ tag.locals.page.attachments.collect do |attachment|
117
+ tag.locals.attachment = attachment
118
+ tag.locals.asset = attachment.asset
119
+ tag.expand
120
+ end
121
+ end
122
+
123
+ private
100
124
  def find_asset(tag)
101
- asset = Asset.find(tag.attr['id'])
102
- if(tag.attr['size'])
103
- asset.upload.process(:resize, tag.attr['size'])
104
- else
105
- asset.upload
125
+ tag.locals.asset || Asset.find(tag.attr['id'])
126
+ rescue ActiveRecord::RecordNotFound
127
+ raise TagError, 'Please supply an id attribute'
128
+ end
129
+
130
+ def resized_or_original_image(asset, size)
131
+ if asset.image?
132
+ size ? asset.upload.process(:resize, size) : asset.upload
106
133
  end
107
134
  end
135
+
136
+ def html_attributes(options)
137
+ attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
138
+ " #{attributes}" unless attributes.empty?
139
+ end
108
140
  end
@@ -0,0 +1,23 @@
1
+ require 'acts_as_list'
2
+
3
+ class Attachment < ActiveRecord::Base
4
+ belongs_to :asset, :autosave => true
5
+ belongs_to :page
6
+
7
+ acts_as_list :scope => :page_id
8
+
9
+ def self.reorder(new_order)
10
+ new_order.each_with_index do |id, index|
11
+ find(id).update_attributes! :position => index+1
12
+ end
13
+ new_order
14
+ end
15
+
16
+ def uploads=(new_uploads)
17
+ (asset || build_asset).uploads=new_uploads
18
+ end
19
+
20
+ def uploads
21
+ (asset || build_asset).uploads
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ <% content_tag_for(:li, attachment) do %>
2
+ <%= asset_grid_item(attachment.asset) %>
3
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <h2>Attachments</h2>
2
+
3
+ <%= render :partial => 'admin/assets/upload', :locals => {:record => @page.attachments.build, :url => admin_page_attachments_path(@page)} %>
4
+
5
+ <ul id="assets">
6
+ <%= render :partial => 'admin/assets/attachment', :collection => @page.attachments.reject(&:new_record?) %>
7
+ </ul>
8
+
9
+ <script type="text/javascript">
10
+ (function($) {
11
+ $(function() {
12
+ $('#assets').sortable({
13
+ update: function(event, ui) {
14
+ $.ajax({
15
+ type: "POST",
16
+ url: '<%= positions_admin_page_attachments_path(@page) %>',
17
+ data: '_method=PUT&'+$(this).sortable('serialize'),
18
+ });
19
+ }
20
+ }).disableSelection();
21
+ });
22
+ }(jQuery));
23
+ </script>
@@ -1,11 +1,9 @@
1
1
  <ul id="assets">
2
- <% unless @assets.empty? %>
3
- <% @assets.each do |asset| %>
2
+ <% unless assets.empty? %>
3
+ <% assets.each do |asset| %>
4
4
  <li>
5
5
  <% link_to edit_admin_asset_path(asset) do %>
6
- <%= icon(asset, 120) %>
7
- <span class="id">ID: <%= asset.id %></span>
8
- <span class="caption"><%= asset %></span>
6
+ <%= asset_grid_item(asset) %>
9
7
  <% end %>
10
8
  <%= link_to_remove(asset) %>
11
9
  </li>
@@ -3,6 +3,7 @@
3
3
  <th class="name">Name</th>
4
4
  <th class="format">Type</th>
5
5
  <th class="size">Size</th>
6
+ <th class="updated_at">Last Changed</th>
6
7
  <th class="actions">Modify</th>
7
8
  </thead>
8
9
  <tbody>
@@ -12,6 +13,7 @@
12
13
  <td class="name"><%= asset_listing(asset) %></td>
13
14
  <td class="format"><%= asset.format.to_s.mb_chars.upcase %></td>
14
15
  <td class="size"><%= number_to_human_size(asset.upload.size) %></td>
16
+ <td class="updated_at"><%= time_ago_in_words asset.updated_at %> ago</td>
15
17
  <td class="actions"><%= link_to_remove(asset) %></td>
16
18
  </tr>
17
19
  <% end %>
@@ -0,0 +1,40 @@
1
+ <% include_stylesheet 'admin/extensions/assets/assets' %>
2
+
3
+ <% form_for record, :url => url, :html => {:multipart => true, :id => 'asset_upload', 'data-onsubmit_status'=>'Uploading Asset&#8230;'} do |f| %>
4
+ <p>Click or drag files here to upload</p>
5
+ <%= f.file_field :uploads, :multiple => true %>
6
+
7
+ <p class="buttons">
8
+ <%= f.submit 'Upload Asset', :class=>'button' %>
9
+ or <%= link_to 'Cancel', admin_assets_path %>
10
+ </p>
11
+ <% end %>
12
+
13
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
14
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>
15
+ <% include_stylesheet 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css' %>
16
+ <script type="text/javascript">jQuery.noConflict();</script>
17
+ <script src="/jquery.fileupload/jquery.fileupload.js" type="text/javascript"></script>
18
+ <script src="/jquery.fileupload/jquery.fileupload-ui.js" type="text/javascript"></script>
19
+ <% include_stylesheet '/jquery.fileupload/jquery.fileupload-ui.css' %>
20
+ <script type="text/javascript">
21
+ (function($) {
22
+ $(function () {
23
+ $('form#asset_upload').fileUploadUI({
24
+ uploadTable: $('#assets'),
25
+ downloadTable: $('#assets'),
26
+ buildUploadRow: function (files, index) {
27
+ return $('<li>' + files[index].name +
28
+ '<span class="file_upload_progress"><div><\/div><\/span>' +
29
+ '<span class="file_upload_cancel">' +
30
+ '<button class="ui-state-default ui-corner-all" title="Cancel">' +
31
+ '<span class="ui-icon ui-icon-cancel">Cancel<\/span>' +
32
+ '<\/button><\/span><\/li>');
33
+ },
34
+ buildDownloadRow: function (file) {
35
+ return $(file.markup);
36
+ }
37
+ });
38
+ });
39
+ }(jQuery));
40
+ </script>
@@ -18,6 +18,14 @@
18
18
  </table>
19
19
  <%= f.file_field :upload %>
20
20
  <%= display(@asset) %>
21
+ <%- if @asset.attachments.any? -%>
22
+ <h2>Included on <%= pluralize(@asset.attachments.size, 'this page', 'these pages') %>:</h2>
23
+ <ul>
24
+ <%- @asset.attachments.each do |attachment| -%>
25
+ <li><%= link_to attachment.page.title, edit_admin_page_path(attachment.page) %></li>
26
+ <%- end -%>
27
+ </ul>
28
+ <%- end -%>
21
29
  </div>
22
30
  <p class="buttons">
23
31
  <%= save_model_button(@asset) %>
@@ -1,7 +1,7 @@
1
1
  <% include_stylesheet 'admin/extensions/assets/assets' %>
2
2
 
3
3
  <div class="outset">
4
- <%= render :partial => list_view? ? 'list' : 'grid' %>
4
+ <%= render :partial => (list_view? ? 'list' : 'grid'), :locals => {:assets => @assets} %>
5
5
  </div>
6
6
 
7
7
  <div id="actions">
@@ -1,45 +1,6 @@
1
- <% include_stylesheet 'admin/extensions/assets/assets' %>
2
-
3
1
  <h1>Upload New Assets</h1>
4
- <table id="files">
5
- <tbody></tbody>
6
- </table>
7
2
 
8
- <p>You can select multiple files</p>
9
- <% form_for [:admin, @asset], :html => {:multipart => true, 'data-onsubmit_status'=>'Uploading Asset&#8230;'} do |f| %>
10
- <%= f.file_field :upload, :multiple => true %>
11
-
12
- <!-- <p class="buttons">
13
- <%= f.submit 'Upload Asset', :class=>'button' %>
14
- or <%= link_to 'Cancel', admin_assets_path %>
15
- </p> -->
16
- <% end %>
3
+ <ul id="assets">
4
+ </ul>
17
5
 
18
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
19
- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>
20
- <% include_stylesheet 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css' %>
21
- <script type="text/javascript">jQuery.noConflict();</script>
22
- <script src="/jquery.fileupload/jquery.fileupload.js" type="text/javascript"></script>
23
- <script src="/jquery.fileupload/jquery.fileupload-ui.js" type="text/javascript"></script>
24
- <% include_stylesheet '/jquery.fileupload/jquery.fileupload-ui.css' %>
25
- <script type="text/javascript">
26
- (function($) {
27
- $(function () {
28
- $('form.new_asset').fileUploadUI({
29
- uploadTable: $('#files'),
30
- downloadTable: $('#files'),
31
- buildUploadRow: function (files, index) {
32
- return $('<tr><td>' + files[index].name + '<\/td>' +
33
- '<td class="file_upload_progress"><div><\/div><\/td>' +
34
- '<td class="file_upload_cancel">' +
35
- '<button class="ui-state-default ui-corner-all" title="Cancel">' +
36
- '<span class="ui-icon ui-icon-cancel">Cancel<\/span>' +
37
- '<\/button><\/td><\/tr>');
38
- },
39
- buildDownloadRow: function (file) {
40
- return $('<tr><td>' + file.markup + '<\/td><\/tr>');
41
- }
42
- });
43
- });
44
- }(jQuery));
45
- </script>
6
+ <%= render :partial => 'upload', :locals => {:record => @asset, :url => admin_assets_path} %>
@@ -8,6 +8,18 @@
8
8
 
9
9
  <table class="index" id="assets">
10
10
  <tr><td class="name"><%= asset_listing(@asset) %></td></tr>
11
+ <% if @asset.attachments.any? %>
12
+ <tr>
13
+ <th>
14
+ It's being used on the following
15
+ <%= pluralize(@asset.attachments.size, 'page') %> and will be removed from
16
+ there as well:
17
+ </th>
18
+ </tr>
19
+ <% @asset.attachments.each do |attachment| %>
20
+ <tr><td><%= attachment.page.title %></td></tr>
21
+ <% end %>
22
+ <% end %>
11
23
  </table>
12
24
 
13
25
  <% form_for [:admin, @asset], :html => {:method => :delete, 'data-onsubmit_status'=>'Removing asset&#8230;'} do |f| %>
data/assets_extension.rb CHANGED
@@ -29,6 +29,11 @@ class AssetsExtension < Radiant::Extension
29
29
  tab 'Content' do
30
30
  add_item 'Assets', '/admin/assets', :after => 'Pages'
31
31
  end
32
- Page.send :include, AssetTags
32
+ admin.page.edit.add :main, 'admin/assets/attachments', :after => :form
33
+ ApplicationController.helper(:assets)
34
+ Page.class_eval do
35
+ include AssetTags
36
+ has_many :attachments, :include => :asset, :order => :position
37
+ end
33
38
  end
34
39
  end
data/config/routes.rb CHANGED
@@ -2,4 +2,9 @@ ActionController::Routing::Routes.draw do |map|
2
2
  map.namespace :admin, :member => { :remove => :get } do |admin|
3
3
  admin.resources :assets
4
4
  end
5
+ map.namespace :admin do |admin|
6
+ admin.resources :pages do |pages|
7
+ pages.resources :attachments, :collection => { :positions => :put }
8
+ end
9
+ end
5
10
  end
@@ -0,0 +1,26 @@
1
+ class AddCachingColumnsToAsset < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :upload_name, :string
4
+ add_column :assets, :upload_ext, :string
5
+ add_column :assets, :upload_size, :integer
6
+ add_column :assets, :upload_width, :integer
7
+ add_column :assets, :upload_height, :integer
8
+ puts "Updating existing assets…"
9
+ Asset.all.each do |asset|
10
+ asset.upload_name = asset.upload.name
11
+ asset.upload_ext = asset.upload.ext
12
+ asset.upload_size = asset.upload.size
13
+ asset.upload_width = asset.upload.width
14
+ asset.upload_height = asset.upload.height
15
+ asset.save!
16
+ end
17
+ end
18
+
19
+ def self.down
20
+ remove_column :assets, :upload_name
21
+ remove_column :assets, :upload_ext
22
+ remove_column :assets, :upload_size
23
+ remove_column :assets, :upload_width
24
+ remove_column :assets, :upload_height
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ class AddAttachmentToPages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :attachments do |t|
4
+ t.belongs_to :asset
5
+ t.belongs_to :page
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ drop_table :attachments
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ class AddTimestampsAndLockingToAssets < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :lock_version, :integer, :default => 0
4
+ add_column :assets, :created_at, :datetime
5
+ add_column :assets, :updated_at, :datetime
6
+ puts 'Updating current assets with dates'
7
+ Asset.all.each do |asset|
8
+ asset.created_at = Time.now
9
+ asset.updated_at = Time.now
10
+ asset.save!
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ remove_column :assets, :lock_version
16
+ add_column :assets, :created_at
17
+ add_column :assets, :updated_at
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ class AddPositionToAttachments < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :attachments, :position, :integer
4
+ Page.all(:include => :attachments).each do |page|
5
+ page.attachments.each_with_index do |attachment, index|
6
+ attachment.update_attributes :position => index+1
7
+ end
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ remove_column :attachments, :position
13
+ end
14
+ end
@@ -1,4 +1,5 @@
1
1
  require 'dragonfly'
2
+ require 'aws/s3'
2
3
 
3
4
  module RadiantAssetsExtension
4
5
  # Subclass that allows connecting to S3 regions other than US-Standard
@@ -1,3 +1,3 @@
1
1
  module RadiantAssetsExtension
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -17,32 +17,41 @@ table.index .size {
17
17
  padding-right: 5px;
18
18
  }
19
19
 
20
+ table#assets .icon,
21
+ table#assets .thumbnail {
22
+ margin-right: 5px;
23
+ }
24
+
20
25
  #assets .icon {
26
+ float: left;
27
+ font-size: 75%;
21
28
  display: block;
22
29
  text-align: center;
23
30
  background: #ccc;
24
31
  text-transform: uppercase;
32
+ overflow: hidden;
25
33
  }
26
34
 
27
- table#assets .icon {
28
- display: block;
29
- float: left;
35
+ table#assets th.name,
36
+ table#assets td.name {
37
+ width: auto;
30
38
  }
31
39
 
32
- table#assets .icon, table#assets .thumbnail {
33
- margin-right: 5px;
40
+ table#assets th.actions {
41
+ /* min-width: 7em;*/
42
+ min-width: auto;
34
43
  }
35
44
 
36
- table#assets .icon {
37
- font-size: 75%;
38
- float: left;
39
- }
45
+ /*table#assets th.size {*/
46
+ /* min-width: 5em;*/
47
+ /*}*/
40
48
 
41
- #assets, #assets li {
49
+ ul#assets, #assets li {
42
50
  display: block;
43
51
  list-style: none;
44
52
  margin: 0;
45
53
  padding: 0;
54
+ overflow: hidden;
46
55
  }
47
56
 
48
57
  #assets li {
@@ -51,7 +60,6 @@ table#assets .icon {
51
60
  margin-right: 1px;
52
61
  margin-bottom: 1px;
53
62
  position: relative;
54
- overflow: hidden;
55
63
  }
56
64
 
57
65
  #assets li a {
@@ -73,6 +81,10 @@ table#assets .icon {
73
81
  display: block;
74
82
  }
75
83
 
84
+ #assets li .action {
85
+ right: 2px;
86
+ }
87
+
76
88
  #assets li .caption {
77
89
  top: auto;
78
90
  bottom: 0;
@@ -92,7 +104,6 @@ table#assets .remove::before {
92
104
  }
93
105
 
94
106
  #assets li .remove {
95
- right: 2px;
96
107
  width: 12px;
97
108
  height: 12px;
98
109
  text-indent: -1000em;
@@ -114,3 +125,28 @@ table#assets .remove::before,
114
125
  #actions .new a::before {
115
126
  background: url('/images/admin/plus.png') no-repeat left bottom;
116
127
  }
128
+
129
+ /*
130
+ Overriding values from jquery.fileupload-ui.css
131
+ Need higher specificity as that file is only loaded later
132
+ */
133
+
134
+ html .file_upload {
135
+ width: auto;
136
+ height: auto;
137
+ margin: 1em 0;
138
+ }
139
+
140
+ html .file_upload .buttons {display: none}
141
+
142
+
143
+ html .file_upload,
144
+ html .file_upload_small,
145
+ html .file_upload_large {
146
+ background: #F5F1E2;
147
+ border-color: #ccc;
148
+ }
149
+
150
+ html .file_upload_highlight {
151
+ background: lawngreen;
152
+ }
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'dragonfly', '~>0.8.2'
16
16
  s.add_dependency 'aws-s3', '~>0.6.2'
17
+ s.add_dependency 'acts_as_list', '~>0.1.2'
17
18
 
18
19
  s.files = `git ls-files`.split("\n")
19
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-assets-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerrit Kaiser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-25 00:00:00 +00:00
18
+ date: 2011-03-20 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,22 @@ dependencies:
50
50
  version: 0.6.2
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: acts_as_list
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 31
62
+ segments:
63
+ - 0
64
+ - 1
65
+ - 2
66
+ version: 0.1.2
67
+ type: :runtime
68
+ version_requirements: *id003
53
69
  description: Makes Radiant better by adding images!
54
70
  email:
55
71
  - gerrit@gerritkaiser.de
@@ -62,14 +78,20 @@ extra_rdoc_files: []
62
78
  files:
63
79
  - .gitignore
64
80
  - Gemfile
65
- - README
81
+ - README.rdoc
66
82
  - Rakefile
67
83
  - app/controllers/admin/assets_controller.rb
84
+ - app/controllers/admin/attachments_controller.rb
85
+ - app/controllers/admin/upload_handler.rb
68
86
  - app/helpers/assets_helper.rb
69
87
  - app/models/asset.rb
70
88
  - app/models/asset_tags.rb
89
+ - app/models/attachment.rb
90
+ - app/views/admin/assets/_attachment.html.erb
91
+ - app/views/admin/assets/_attachments.html.erb
71
92
  - app/views/admin/assets/_grid.html.erb
72
93
  - app/views/admin/assets/_list.html.erb
94
+ - app/views/admin/assets/_upload.html.erb
73
95
  - app/views/admin/assets/edit.html.erb
74
96
  - app/views/admin/assets/index.html.erb
75
97
  - app/views/admin/assets/new.html.erb
@@ -82,6 +104,10 @@ files:
82
104
  - db/migrate/20110224001246_add_images_table.rb
83
105
  - db/migrate/20110225021327_add_caption.rb
84
106
  - db/migrate/20110225023017_rename_model_class.rb
107
+ - db/migrate/20110225174217_add_caching_columns_to_asset.rb
108
+ - db/migrate/20110225210821_add_attachment_to_pages.rb
109
+ - db/migrate/20110225210912_add_timestamps_and_locking_to_assets.rb
110
+ - db/migrate/20110320152044_add_position_to_attachments.rb
85
111
  - features/support/env.rb
86
112
  - features/support/paths.rb
87
113
  - lib/radiant-assets-extension.rb
@@ -101,7 +127,7 @@ has_rdoc: true
101
127
  homepage: http://ext.radiantcms.org/extensions/269-assets
102
128
  licenses: []
103
129
 
104
- post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.6'\n "
130
+ post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.7'\n "
105
131
  rdoc_options: []
106
132
 
107
133
  require_paths: