public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add asset buckets

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1903 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Aug 23 20:24:40 -0700 2006
commit  127586270851d815ea45e4498eef1cd719b3b8e2
tree    50ee74c1a7626d1526e60d0186ed2f27e94ff0ee
parent  5dcfef177c1dae51a49ac5b9af6fb1c21bd50d4c
...
1
2
 
3
4
5
...
58
59
60
 
 
 
 
 
 
 
 
 
61
62
63
...
1
 
2
3
4
5
...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
0
@@ -1,5 +1,5 @@
0
 class Admin::AssetsController < Admin::BaseController
0
- before_filter :find_asset, :except => [:index, :new, :create, :latest, :search, :upload]
0
+ before_filter :find_asset, :except => [:index, :new, :create, :latest, :search, :upload, :clear_bucket]
0
 
0
   def index
0
     search_assets 20
0
@@ -58,6 +58,15 @@ class Admin::AssetsController < Admin::BaseController
0
     flash[:notice] = "Deleted '#{@asset.filename}'"
0
   end
0
 
0
+ # rjs
0
+ def add_bucket
0
+ (session[:bucket] ||= {})[@asset.public_filename] = [@asset.public_filename(:tiny), "#{@asset.title} \n #{@asset.tags.join(', ')}"]
0
+ end
0
+
0
+ def clear_bucket
0
+ session[:bucket] = nil
0
+ end
0
+
0
   protected
0
     def find_asset
0
       @asset = site.assets.find(params[:id])
...
14
15
16
17
 
 
 
 
 
18
19
20
...
14
15
16
 
17
18
19
20
21
22
23
24
0
@@ -14,7 +14,11 @@ module ApplicationHelper
0
   end
0
 
0
   def asset_image_for(asset, thumbnail = nil, options = {})
0
- image_tag(asset.public_filename(thumbnail), { :title => "#{asset.title} \n #{asset.tags.join(', ')}" }.merge(options))
0
+ asset_image_tag asset.public_filename(thumbnail), "#{asset.title} \n #{asset.tags.join(', ')}", options
0
+ end
0
+
0
+ def asset_image_tag(filename, title, options = {})
0
+ image_tag(filename, { :title => title }.merge(options))
0
   end
0
 
0
   def todays_short_date
...
57
58
59
 
 
 
 
 
60
61
62
...
57
58
59
60
61
62
63
64
65
66
67
0
@@ -57,6 +57,11 @@ class Asset < ActiveRecord::Base
0
   end
0
   alias_method_chain :public_filename, :host
0
 
0
+ def title
0
+ t = read_attribute(:title)
0
+ t.blank? ? filename : t
0
+ end
0
+
0
   [:movie, :audio, :other].each do |content|
0
     define_method("#{content}?") { self.class.send("#{content}?", content_type) }
0
   end
...
21
22
23
24
 
25
26
27
...
41
42
43
44
45
 
 
 
 
 
 
46
47
48
...
21
22
23
 
24
25
26
27
...
41
42
43
 
 
44
45
46
47
48
49
50
51
52
0
@@ -21,7 +21,7 @@
0
   
0
   <div id="tabpanels">
0
     <div class="tabpanel" id="latest-files">
0
- <ul id="assets">
0
+ <ul id="latest-assets">
0
         <%= render :partial => "admin/assets/widget", :collection => @assets %>
0
       </ul>
0
     </div>
0
@@ -41,8 +41,12 @@
0
       <p><em>Uploading this will lose your changes to this article.</em></p>
0
     </div>
0
     <div class="tabpanel" id="bucket" style="display:none;">
0
- <ul id="assets">
0
- <%= render :partial => "admin/assets/widget", :collection => @assets %>
0
+ <ul id="bucket-assets">
0
+ <% session[:bucket].each do |filename, values| -%>
0
+ <li>
0
+ <%= link_to(asset_image_tag(values.first, values.last), filename, :target => '_blank') %>
0
+ </li>
0
+ <% end unless session[:bucket].blank? %>
0
       </ul>
0
     </div>
0
   </div>
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,6 +2,6 @@
0
            <li class="fedit"><%= link_to 'Edit', edit_asset_path(asset), :title => 'Edit this file' %></li>
0
            <li class="fdelete"><%= link_to 'Delete', asset_path(asset), :tilte => 'Delete this asset',
0
                                      :confirm => 'Are you sure you wish to delete this?', :method => :delete %></li>
0
- <li class="fbucket"><a href="#" title="Put in bucket">Add to bucket</a></li>
0
+ <li class="fbucket"><%= link_to_remote 'Add to bucket', :url => add_bucket_asset_path(asset), :html => { :title => 'Add to bucket' }%></li>
0
          </ul>
0
          <%= link_to(asset_image_for(asset, :tiny), asset.public_filename, :target => '_blank') %>
0
\ No newline at end of file
...
37
38
39
40
 
41
42
43
 
44
45
 
46
47
 
48
49
50
...
37
38
39
 
40
41
42
 
43
44
 
45
46
 
47
48
49
50
0
@@ -37,14 +37,14 @@
0
 
0
 <% content_for :sidebar do %>
0
   <div class="sgroup">
0
- <h3>Your bucket <a href="#">(clear)</a></h3>
0
+ <h3>Your bucket <%= link_to_remote '(clear)', :url => clear_bucket_assets_path %></h3>
0
     <p>Add files to your bucket temporarily in order to carry them with you when creating or revising articles.</p>
0
     <ul id="assets">
0
- <% @assets.each_with_index do |asset, i| %>
0
+ <% session[:bucket].each do |filename, values| -%>
0
       <li>
0
- <%= link_to(asset_image_for(asset, :tiny), asset.public_filename, :target => '_blank') %>
0
+ <%= link_to(asset_image_tag(values.first, values.last), filename, :target => '_blank') %>
0
       </li>
0
- <% end %>
0
+ <% end unless session[:bucket].blank? %>
0
     </ul>
0
   </div>
0
   <div class="sgroup">
...
10
11
12
13
 
 
14
15
16
...
10
11
12
 
13
14
15
16
17
0
@@ -10,7 +10,8 @@ ActionController::Routing::Routes.draw do |map|
0
   
0
   map.overview 'admin/overview.xml', :controller => 'admin/overview', :action => 'feed'
0
   map.admin 'admin', :controller => 'admin/overview', :action => 'index'
0
- map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets', :collection => { :latest => :post, :search => :post, :upload => :post }
0
+ map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets', :member => { :add_bucket => :post },
0
+ :collection => { :latest => :post, :search => :post, :upload => :post, :clear_bucket => :post }
0
   
0
   map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/
0
   
...
151
152
153
154
 
155
156
157
...
151
152
153
 
154
155
156
157
0
@@ -151,7 +151,7 @@ Object.extend(Array.prototype, {
0
 var TinyTab = Class.create();
0
 TinyTab.callbacks ={
0
   'latest-files': function() {
0
- if($('assets').childNodes.length == 0)
0
+ if($('latest-assets').childNodes.length == 0)
0
       new Ajax.Request('/admin/assets;latest');
0
   },
0
   'search-files': function(q) {
...
600
601
602
603
 
604
605
606
...
1275
1276
1277
1278
 
1279
1280
1281
1282
1283
 
1284
1285
1286
1287
1288
1289
 
 
 
1290
1291
1292
1293
1294
 
 
 
1295
1296
1297
...
1299
1300
1301
1302
 
 
 
1303
1304
1305
...
600
601
602
 
603
604
605
606
...
1275
1276
1277
 
1278
1279
1280
1281
1282
 
1283
1284
1285
1286
1287
1288
 
1289
1290
1291
1292
1293
1294
1295
 
1296
1297
1298
1299
1300
1301
...
1303
1304
1305
 
1306
1307
1308
1309
1310
1311
0
@@ -600,7 +600,7 @@ a#section-home {
0
   overflow: hidden;
0
 }
0
 
0
-#revisions h4, #assets h4 {
0
+#revisions h4, #assets h4, #latest-assets h4, #bucket-assets h4 {
0
   font: bold 100% "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
0
   color: #333;
0
 }
0
@@ -1275,23 +1275,27 @@ li.event-article { background-image: url(../images/icons/articleb.gif); }
0
  *=ASSET MANAGEMENT
0
  */
0
 
0
-#assets, #files {
0
+#assets, #files, #latest-assets, #bucket-assets {
0
   list-style: none;
0
   margin-top: 5px;
0
 }
0
 
0
-#assets li, #files li {
0
+#assets li, #files li, #latest-assets li, #bucket-assets li {
0
   display: inline;
0
   margin-left: 5px;
0
   margin-bottom: 5px;
0
 }
0
 
0
-#assets li a img {
0
+#assets li a img,
0
+#latest-assets li a img,
0
+#bucket-assets li a img {
0
   padding: 4px;
0
   background: #fff;
0
 }
0
 
0
-#assets img {
0
+#assets img,
0
+#latest-assets img,
0
+#bucket-assets img {
0
   max-height: 50px;
0
   max-width: 50px;
0
   padding: 3px;
0
@@ -1299,7 +1303,9 @@ li.event-article { background-image: url(../images/icons/articleb.gif); }
0
   border: 1px solid #8BCACD;
0
 }
0
 
0
-#assets span {
0
+#assets span,
0
+#latest-assets span,
0
+#bucket-assets span {
0
   display: block;
0
   font-size: 80%;
0
 }
...
90
91
92
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
95
96
...
90
91
92
 
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
0
@@ -90,7 +90,21 @@ class Admin::AssetsControllerTest < Test::Unit::TestCase
0
     end
0
     # fixed in edge
0
     #assert_redirected_to assets_path
0
- assert_flash :notice
0
+ assert_not_nil flash[:notice]
0
+ end
0
+
0
+ def test_should_add_to_bucket
0
+ xhr :post, :add_bucket, :id => assets(:gif).id
0
+ assert_response :success
0
+ assert_equal 1, session[:bucket].size
0
+ assert_kind_of Array, session[:bucket][assets(:gif).public_filename]
0
+ end
0
+
0
+ def test_should_clear_bucket
0
+ @request.session[:bucket] = 'foo'
0
+ xhr :post, :clear_bucket
0
+ assert_response :success
0
+ assert_nil session[:bucket]
0
   end
0
 
0
   def teardown

Comments

    No one has commented yet.