beef-has_assets 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/admin/assets_controller.rb +14 -13
- data/app/helpers/admin/assets_helper.rb +13 -14
- data/app/views/admin/assets/_list.html.erb +4 -4
- data/app/views/admin/assets/attach.js.rjs +4 -0
- data/beef-has_assets.gemspec +3 -2
- data/config/routes.rb +1 -1
- data/generators/assets_admin_files/templates/public/javascripts/admin/assets.js +5 -81
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Admin::AssetsController < Admin::BaseController
|
2
2
|
unloadable
|
3
|
-
|
3
|
+
|
4
4
|
protect_from_forgery :except => [:destroy, :rename_category]
|
5
5
|
|
6
6
|
# GET /assets
|
@@ -15,9 +15,9 @@ class Admin::AssetsController < Admin::BaseController
|
|
15
15
|
format.js { render :action => 'index'}
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
alias :by_category :index
|
20
|
-
|
20
|
+
|
21
21
|
def by_content_type
|
22
22
|
@asset_types = Asset.grouped_by_content_type
|
23
23
|
@grouping = 'by_content_type'
|
@@ -28,7 +28,7 @@ class Admin::AssetsController < Admin::BaseController
|
|
28
28
|
format.js { render :action => 'index'}
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def by_description
|
33
33
|
@asset_types = Asset.grouped_by_description
|
34
34
|
@grouping = 'by_description'
|
@@ -59,18 +59,18 @@ class Admin::AssetsController < Admin::BaseController
|
|
59
59
|
format.js { render :layout => false, :action => 'category'}
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def descriptions
|
64
64
|
@descriptions = Asset.not_thumbnails.find(:all, :select => 'description', :group => 'description', :order => 'description', :conditions => 'description IS NOT NULL')
|
65
|
-
|
65
|
+
|
66
66
|
respond_to do |format|
|
67
67
|
format.json { render :json => @descriptions.collect{ |a| a.description }}
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def categories
|
72
72
|
@categories = Asset.not_thumbnails.find(:all, :select => 'category', :group => 'category', :order => 'category', :conditions => 'category IS NOT NULL')
|
73
|
-
|
73
|
+
|
74
74
|
respond_to do |format|
|
75
75
|
format.json { render :json => @categories.collect{ |a| a.category }}
|
76
76
|
end
|
@@ -87,6 +87,7 @@ class Admin::AssetsController < Admin::BaseController
|
|
87
87
|
format.xml { render :xml => @asset }
|
88
88
|
end
|
89
89
|
end
|
90
|
+
alias :attach :show
|
90
91
|
|
91
92
|
# POST /assets
|
92
93
|
# POST /assets.xml
|
@@ -127,7 +128,7 @@ class Admin::AssetsController < Admin::BaseController
|
|
127
128
|
end
|
128
129
|
end
|
129
130
|
end
|
130
|
-
|
131
|
+
|
131
132
|
def select_thumbnail
|
132
133
|
@asset = Asset.find(params[:id])
|
133
134
|
respond_to do |wants|
|
@@ -135,7 +136,7 @@ class Admin::AssetsController < Admin::BaseController
|
|
135
136
|
wants.js
|
136
137
|
end
|
137
138
|
end
|
138
|
-
|
139
|
+
|
139
140
|
def replace_thumbnail
|
140
141
|
@asset = Asset.find(params[:id])
|
141
142
|
@asset.create_or_update_thumbnail(params[:asset][:uploaded_data],:square,Asset.attachment_options[:thumbnails][:square])
|
@@ -146,15 +147,15 @@ class Admin::AssetsController < Admin::BaseController
|
|
146
147
|
end
|
147
148
|
format.js { render :json => @asset, :status => 200 }
|
148
149
|
end
|
149
|
-
|
150
|
+
|
150
151
|
rescue Technoweenie::AttachmentFu::ThumbnailError => m
|
151
|
-
|
152
|
+
|
152
153
|
respond_to do |format|
|
153
154
|
format.html { flash[:error] = m }
|
154
155
|
format.js { render :json => [m] }
|
155
156
|
end
|
156
157
|
end
|
157
|
-
|
158
|
+
|
158
159
|
def rename_category
|
159
160
|
respond_to do |format|
|
160
161
|
format.js do
|
@@ -1,33 +1,32 @@
|
|
1
1
|
module Admin::AssetsHelper
|
2
|
-
|
2
|
+
|
3
3
|
def asset_list(content_node)
|
4
|
-
|
5
|
-
|
6
|
-
end
|
4
|
+
list = render( :partial => '/admin/assets/list', :locals => { :content_node => content_node, :assets => content_node.assets.images, :title => 'Gallery' } )
|
5
|
+
list << render( :partial => '/admin/assets/list', :locals => { :content_node => content_node, :assets => content_node.assets.documents, :title => 'Downloads' } )
|
7
6
|
content_tag :div, list, :id => 'attach-asset-list'
|
8
7
|
end
|
9
|
-
|
8
|
+
|
10
9
|
def asset_browser(for_content = false)
|
11
|
-
render :partial => '/admin/assets/browser',
|
10
|
+
render :partial => '/admin/assets/browser',
|
12
11
|
:locals => { :asset_types => Asset.grouped_by_category,
|
13
12
|
:for_content => for_content,
|
14
13
|
:ajaxify => true }
|
15
14
|
end
|
16
|
-
|
15
|
+
|
17
16
|
def asset_upload_form
|
18
17
|
render :partial => '/admin/assets/form'
|
19
18
|
end
|
20
|
-
|
19
|
+
|
21
20
|
def toggle_grouping_links
|
22
21
|
render :partial => 'admin/assets/toggle'
|
23
22
|
end
|
24
|
-
|
23
|
+
|
25
24
|
def admin_assets_path_with_session_information
|
26
25
|
session_key = ActionController::Base.session_options[:key]
|
27
26
|
params = {request_forgery_protection_token => form_authenticity_token, :cookies => cookies}
|
28
27
|
admin_assets_path(params)
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
def replace_thumbnail_admin_asset_path_with_session_information(asset)
|
32
31
|
session_key = ActionController::Base.session_options[:key]
|
33
32
|
replace_thumbnail_admin_asset_path(asset, session_key => cookies[session_key], request_forgery_protection_token => form_authenticity_token)
|
@@ -45,14 +44,14 @@ module Admin::AssetsHelper
|
|
45
44
|
logger.warn "Flickr error: #{e}"
|
46
45
|
return
|
47
46
|
end
|
48
|
-
|
49
|
-
|
47
|
+
|
48
|
+
|
50
49
|
def flickr_select
|
51
50
|
return unless defined?(Flickr) and File.exists?("#{RAILS_ROOT}/config/flickr.yml") and !Settings.flickr_user_id.blank?
|
52
51
|
render :partial => 'admin/flickrs/selector'
|
53
52
|
end
|
54
|
-
|
53
|
+
|
55
54
|
def flickr_default_size
|
56
|
-
defined?(Beef::Has::Assets::FLICKR_DEFAULT_SIZE) ? Beef::Has::Assets::FLICKR_DEFAULT_SIZE : :medium
|
55
|
+
defined?(Beef::Has::Assets::FLICKR_DEFAULT_SIZE) ? Beef::Has::Assets::FLICKR_DEFAULT_SIZE : :medium
|
57
56
|
end
|
58
57
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h2><%= content_node.class.name.titleize %>
|
2
|
-
<ul class="asset-list" id="
|
3
|
-
<% for asset in
|
1
|
+
<h2><%= content_node.class.name.titleize %> <%= title %></h2>
|
2
|
+
<ul class="asset-list" id="<%= title.parameterize %>-list">
|
3
|
+
<% for asset in assets -%>
|
4
4
|
<li id="asset-<%= asset.id %>" class="<%= asset.content_type.gsub('/','-') %>">
|
5
5
|
<% if asset.content_type =~ /image/ -%>
|
6
6
|
<%= render :partial => "admin/assets/image", :locals => { :asset => asset, :for_content => false } %>
|
@@ -8,5 +8,5 @@
|
|
8
8
|
<%= render :partial => "admin/assets/document", :locals => { :asset => asset, :for_content => false } %>
|
9
9
|
<% end -%>
|
10
10
|
</li>
|
11
|
-
<% end -%>
|
11
|
+
<% end -%>
|
12
12
|
</ul>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
list_id = "#{@asset.is_image? ? 'gallery' : 'downloads' }-list"
|
2
|
+
page.insert_html :bottom, list_id, content_tag( :li, render( :partial => "admin/assets/#{@asset.is_image? ? 'image' : 'document' }", :locals => { :asset => @asset, :for_content => false } ), :id => "asset-#{@asset.id}", :class => @asset.content_type.gsub('/','-') )
|
3
|
+
page.show(list_id)
|
4
|
+
page << "AssetBrowser.setUpAssetList();"
|
data/beef-has_assets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{beef-has_assets}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve England"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.email = %q{steve@wearebeef.co.uk}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"app/views/admin/assets/_image.html.erb",
|
37
37
|
"app/views/admin/assets/_list.html.erb",
|
38
38
|
"app/views/admin/assets/_toggle.html.erb",
|
39
|
+
"app/views/admin/assets/attach.js.rjs",
|
39
40
|
"app/views/admin/assets/category.html.erb",
|
40
41
|
"app/views/admin/assets/index.html.erb",
|
41
42
|
"app/views/admin/assets/index.js.rjs",
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
2
|
map.namespace(:admin) do |admin|
|
3
3
|
admin.resources :flickrs
|
4
|
-
admin.resources :assets, :collection => { :by_content_type => :get, :descriptions => :get, :by_category => :get, :categories => :get, :category => :get, :content_type => :get }, :member => { :
|
4
|
+
admin.resources :assets, :collection => { :by_content_type => :get, :descriptions => :get, :by_category => :get, :categories => :get, :category => :get, :content_type => :get }, :member => { :attach => :post, :rename_category => :post }
|
5
5
|
end
|
6
6
|
end
|
@@ -150,7 +150,7 @@ Object.extend(AssetBrowser, {
|
|
150
150
|
this.setUpAssetList();
|
151
151
|
this.contentNodeForm.addAssetIDs = function() {
|
152
152
|
$$('input.asset_id').invoke('remove');
|
153
|
-
assets = $$('#asset-list li');
|
153
|
+
assets = $$('#attach-asset-list li');
|
154
154
|
|
155
155
|
if (assets.size() == 0) {
|
156
156
|
$(this).insert('<input type="hidden" name="' + this.model_name + '[asset_ids]" class="asset_id" value="" />');
|
@@ -174,89 +174,13 @@ Object.extend(AssetBrowser, {
|
|
174
174
|
},
|
175
175
|
|
176
176
|
setUpAssetList: function() {
|
177
|
-
|
178
|
-
|
179
|
-
Sortable.create(this.assetList);
|
180
|
-
}
|
181
|
-
this.contentNodeForm.assetList = this.assetList;
|
177
|
+
Sortable.create('gallery-list');
|
178
|
+
Sortable.create('downloads-list');
|
182
179
|
},
|
183
180
|
|
184
181
|
addAssetToContentNode: function(asset) {
|
185
|
-
if (!this.assetList) {
|
186
|
-
$('attach-asset-list').insert({top:'<h2 class="drop-down open">' + this.contentNodeForm.model_name.charAt(0).toUpperCase() + this.contentNodeForm.model_name.slice(1).toLowerCase() + ' Files</h2><ul class="asset-list" id="asset-list"></ul>'});
|
187
|
-
this.setUpAssetList();
|
188
|
-
}
|
189
|
-
|
190
|
-
this.assetList.show();
|
191
182
|
if (!$('asset-' + asset.id)) {
|
192
|
-
|
193
|
-
if(/image/.test(asset.content_type)){
|
194
|
-
li = new Element('li', { 'class': asset.content_type.replace('/','-'), id: 'asset-' + asset.id }).update('<img alt=\"' + asset.filename + '\" src=\"' + asset.sizes.find(function(size){ return size[0] == 'square'; })[1] + '\" />');
|
195
|
-
} else {
|
196
|
-
li = new Element('li', { 'class': asset.content_type.replace('/','-'), id: 'asset-' + asset.id }).update(asset.filename + ' ' + asset.description);
|
197
|
-
}
|
198
|
-
|
199
|
-
filename = new Element('h4').update(asset.filename);
|
200
|
-
div = new Element('div');
|
201
|
-
h4 = new Element('h4').update("Insert Image");
|
202
|
-
view_info = new Element('a').update('View Info');
|
203
|
-
|
204
|
-
view_info.onclick = function() {
|
205
|
-
AssetBrowser.openInfo(asset.id, this);
|
206
|
-
return false;
|
207
|
-
};
|
208
|
-
|
209
|
-
insert_image_large = new Element('a').update('Large | ');
|
210
|
-
insert_image_medium = new Element('a').update('Medium | ');
|
211
|
-
insert_image_small = new Element('a').update('Small');
|
212
|
-
|
213
|
-
insert_image_large.onclick = function() {
|
214
|
-
addAsset(asset.id, 'large' );
|
215
|
-
return false;
|
216
|
-
};
|
217
|
-
insert_image_medium.onclick = function() {
|
218
|
-
addAsset(asset.id, 'medium' );
|
219
|
-
return false;
|
220
|
-
};
|
221
|
-
insert_image_small.onclick = function() {
|
222
|
-
addAsset(asset.id, 'thumb' );
|
223
|
-
return false;
|
224
|
-
};
|
225
|
-
insert_document = new Element('a').update(' | Insert');
|
226
|
-
|
227
|
-
var theForm = this.contentNodeForm;
|
228
|
-
|
229
|
-
deleter = new Element('a').update('Detach');
|
230
|
-
deleter.onclick = function() {
|
231
|
-
AssetBrowser.removeAssetFromContentNode(asset.id);
|
232
|
-
return false;
|
233
|
-
};
|
234
|
-
|
235
|
-
div.insert(filename);
|
236
|
-
div.insert(view_info);
|
237
|
-
div.insert('<br/>');
|
238
|
-
div.insert(deleter);
|
239
|
-
|
240
|
-
li.insert(div);
|
241
|
-
|
242
|
-
if (/image/.test(asset.content_type)) {
|
243
|
-
//setup for images
|
244
|
-
div.insert(h4);
|
245
|
-
div.insert(insert_image_large);
|
246
|
-
div.insert(insert_image_medium);
|
247
|
-
div.insert(insert_image_small);
|
248
|
-
|
249
|
-
} else {
|
250
|
-
//setup for documents
|
251
|
-
insert_document.onclick = function() {
|
252
|
-
addAsset(asset.id);
|
253
|
-
return false;
|
254
|
-
};
|
255
|
-
div.insert(insert_document);
|
256
|
-
}
|
257
|
-
|
258
|
-
this.assetList.insert(li);
|
259
|
-
this.setUpAssetList();
|
183
|
+
new Ajax.Request('/admin/assets/'+asset.id+'/attach');
|
260
184
|
}
|
261
185
|
},
|
262
186
|
|
@@ -307,7 +231,7 @@ Event.observe(window, 'load', function() {
|
|
307
231
|
flash_url : '/flash/swfupload.swf',
|
308
232
|
file_post_name: 'asset[uploaded_data]',
|
309
233
|
|
310
|
-
file_size_limit : '
|
234
|
+
file_size_limit : '7 MB',
|
311
235
|
file_upload_limit : 0,
|
312
236
|
|
313
237
|
file_queue_error_handler : UploadHandler.fileQueueError,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beef-has_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve England
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-26 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- app/views/admin/assets/_image.html.erb
|
44
44
|
- app/views/admin/assets/_list.html.erb
|
45
45
|
- app/views/admin/assets/_toggle.html.erb
|
46
|
+
- app/views/admin/assets/attach.js.rjs
|
46
47
|
- app/views/admin/assets/category.html.erb
|
47
48
|
- app/views/admin/assets/index.html.erb
|
48
49
|
- app/views/admin/assets/index.js.rjs
|