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 !
fix bug where assets in buckets display with broken icons

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1960 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Aug 30 23:51:41 -0700 2006
commit  d8d92731685676b8ec7bea3780c0824da56ac96a
tree    314991b69c74a7c5cb2cd4076c86157e33ef46ff
parent  ef491fd44fde92b97d7b041641abc8a1ac3f5dc1
...
61
62
63
64
 
 
65
66
67
...
61
62
63
 
64
65
66
67
68
0
@@ -61,7 +61,8 @@ class Admin::AssetsController < Admin::BaseController
0
     if (session[:bucket] ||= {}).key?(@asset.public_filename)
0
       render :nothing => true and return
0
     end
0
- session[:bucket][@asset.public_filename] = [@asset.public_filename(:tiny), "#{@asset.title} \n #{@asset.tags.join(', ')}"]
0
+ args = asset_image_args_for(@asset, :tiny, :title => "#{@asset.title} \n #{@asset.tags.join(', ')}")
0
+ session[:bucket][@asset.public_filename] = args
0
   end
0
 
0
   def clear_bucket
...
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
11
12
...
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
0
@@ -7,6 +7,25 @@ class ApplicationController < ActionController::Base
0
   attr_reader :site
0
 
0
   protected
0
+ # so not the best place for this...
0
+ def asset_image_args_for(asset, thumbnail = :tiny, options = {})
0
+ options = options.reverse_merge(:title => "#{asset.title} \n #{asset.tags.join(', ')}")
0
+ if asset.movie?
0
+ ['/images/icons/video.png', options]
0
+ elsif asset.audio?
0
+ ['/images/icons/audio.png', options]
0
+ elsif asset.pdf? and request.env['HTTP_USER_AGENT'] =~ /webkit/i
0
+ [asset.public_filename, {:class => 'pdf'}.merge(options)]
0
+ elsif asset.other?
0
+ ['/images/icons/doc.png', options]
0
+ elsif asset.thumbnails_count.zero?
0
+ [asset.public_filename, options.update(:size => Array.new(2).fill(Asset.attachment_options[:thumbnails][thumbnail].to_i).join('x'))]
0
+ else
0
+ [asset.public_filename(thumbnail), options]
0
+ end
0
+ end
0
+ helper_method :asset_image_args_for
0
+
0
     [:utc_to_local, :local_to_utc].each do |meth|
0
       define_method meth do |time|
0
         site.timezone.send(meth, time)
...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
32
33
34
...
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
21
0
@@ -15,20 +15,7 @@ module ApplicationHelper
0
   end
0
 
0
   def asset_image_for(asset, thumbnail = :tiny, options = {})
0
- options = options.reverse_merge(:title => "#{asset.title} \n #{asset.tags.join(', ')}")
0
- if asset.movie?
0
- image_tag('/images/icons/video.png', options)
0
- elsif asset.audio?
0
- image_tag('/images/icons/audio.png', options)
0
- elsif asset.pdf? and request.env['HTTP_USER_AGENT'] =~ /webkit/i
0
- image_tag(asset.public_filename, {:class => 'pdf'}.merge(options))
0
- elsif asset.other?
0
- image_tag('/images/icons/doc.png', options)
0
- elsif asset.thumbnails_count.zero?
0
- image_tag(asset.public_filename, options.update(:size => Array.new(2).fill(Asset.attachment_options[:thumbnails][thumbnail].to_i).join('x')))
0
- else
0
- image_tag(asset.public_filename(thumbnail), options)
0
- end
0
+ image_tag(*asset_image_args_for(asset, thumbnail, options))
0
   end
0
 
0
   def todays_short_date
...
45
46
47
48
 
49
50
51
...
45
46
47
 
48
49
50
51
0
@@ -45,7 +45,7 @@
0
       <ul id="bucket-assets">
0
         <% session[:bucket].each do |filename, values| -%>
0
         <li>
0
- <%= link_to(image_tag(values.first, :title => values.last), filename, :target => '_blank') %>
0
+ <%= link_to(image_tag(*values), filename, :target => '_blank') %>
0
         </li>
0
         <% end unless session[:bucket].blank? %>
0
       </ul>
...
43
44
45
46
 
47
48
49
...
43
44
45
 
46
47
48
49
0
@@ -43,7 +43,7 @@
0
     <ul id="assets">
0
       <% session[:bucket].each do |filename, values| -%>
0
       <li>
0
- <%= link_to(image_tag(values.first, :title => values.last), filename, :target => '_blank') %>
0
+ <%= link_to(image_tag(*values), filename, :target => '_blank') %>
0
       </li>
0
       <% end unless session[:bucket].blank? %>
0
     </ul>
...
1
2
3
 
 
 
 
 
 
 
 
4
5
6
...
24
25
26
27
 
28
29
30
...
37
38
39
40
41
 
 
42
43
44
45
46
47
 
 
 
 
 
 
48
49
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
32
33
34
 
35
36
37
38
...
45
46
47
 
 
48
49
50
51
 
 
 
 
52
53
54
55
56
57
58
59
0
@@ -1,6 +1,14 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 require 'application_helper'
0
 
0
+ApplicationHelperTestController = Class.new ApplicationController do
0
+ # look at how i mock the action view request
0
+ def request() self end
0
+ def env
0
+ @env ||= {}
0
+ end
0
+end
0
+
0
 class ApplicationHelperTest < Test::Unit::TestCase
0
   fixtures :assets
0
   include ActionView::Helpers::TagHelper
0
@@ -24,7 +32,7 @@ class ApplicationHelperTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_return_pdf_preview_in_safari
0
- env['HTTP_USER_AGENT'] = 'Webkit'
0
+ controller.env['HTTP_USER_AGENT'] = 'Webkit'
0
     assert_match assets(:pdf).public_filename, asset_image_for(assets(:pdf))
0
   end
0
 
0
@@ -37,13 +45,15 @@ class ApplicationHelperTest < Test::Unit::TestCase
0
   end
0
 
0
   protected
0
- def image_tag(path, options = {})
0
- tag 'img', options.merge(:src => path)
0
+ def asset_image_args_for(*args)
0
+ controller.send(:asset_image_args_for, *args)
0
     end
0
     
0
- # look at how i mock the action view request
0
- def request() self end
0
- def env
0
- @env ||= {}
0
+ def controller
0
+ @controller ||= ApplicationHelperTestController.new
0
+ end
0
+
0
+ def image_tag(path, options = {})
0
+ tag 'img', options.merge(:src => path)
0
     end
0
 end

Comments

    No one has commented yet.