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 !
Make ImageScience the default image processor for assets. 

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2650 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Jan 09 00:45:06 -0800 2007
commit  8965a13a11c7fc7bf0f53ce28fd3823969125cff
tree    84c50a7a7696f9b627fe27681c89998ec285338b
parent  babaed335e543aa4ec31c958ac7b150d2310cd71
...
1
2
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,5 +1,10 @@
0
 * SVN *
0
 
0
+* Make ImageScience the default image processor for assets.
0
+ If you wish to configure this, set ASSET_IMAGE_PROCESSOR to one of 3 values in environment.rb
0
+
0
+ ASSET_IMAGE_PROCESSOR = :image_science || :rmagick || :none
0
+
0
 * paged section feeds will show the paged url for articles instead of the long permalink.
0
 
0
 * Replace a couple @article.full_permalink instances with @site.permalink_for(@article) [defunkt]
...
45
46
47
48
 
 
49
50
51
...
45
46
47
 
48
49
50
51
52
0
@@ -45,7 +45,8 @@ class Asset < ActiveRecord::Base
0
   include Mephisto::TaggableMethods
0
 
0
   belongs_to :site
0
- has_attachment :storage => :file_system, :thumbnails => { :thumb => '120>', :tiny => '50>' }, :max_size => 30.megabytes
0
+ has_attachment :storage => :file_system, :thumbnails => { :thumb => '120>', :tiny => '50>' }, :max_size => 30.megabytes,
0
+ :processor => (Object.const_defined?(:ASSET_IMAGE_PROCESSOR) ? ASSET_IMAGE_PROCESSOR : nil)
0
   before_validation_on_create :set_site_from_parent
0
   validates_presence_of :site_id
0
   validates_as_attachment
...
53
54
55
 
 
 
56
57
58
...
53
54
55
56
57
58
59
60
61
0
@@ -53,6 +53,9 @@ require 'mephisto_init'
0
 UserMailer.default_url_options[:host] = 'localhost:3000'
0
 UserMailer.mail_from = 'webmaster@localhost'
0
 
0
+# defaults to ImageScience, then RMagick, then nothing
0
+# ASSET_IMAGE_PROCESSOR = :image_science || :rmagick || :none
0
+
0
 # OPTIONAL - Redirections
0
 # Deny a route by immediately returning a 404
0
 #
...
16
17
18
19
 
20
21
22
...
26
27
28
29
 
30
31
32
...
38
39
40
41
 
42
43
44
...
49
50
51
52
 
53
54
55
...
16
17
18
 
19
20
21
22
...
26
27
28
 
29
30
31
32
...
38
39
40
 
41
42
43
44
...
49
50
51
 
52
53
54
55
0
@@ -16,7 +16,7 @@ class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_upload_asset
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     assert_difference Asset, :count, asset_count do
0
       post :upload, :asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') }
0
@@ -26,7 +26,7 @@ class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_upload_asset_and_redirect_to_article
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     assert_difference Asset, :count, asset_count do
0
       post :upload, :id => contents(:welcome).id,
0
@@ -38,7 +38,7 @@ class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_upload_asset_as_member
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     login_as :ben
0
     assert_difference Asset, :count, asset_count do
0
@@ -49,7 +49,7 @@ class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_upload_asset_and_redirect_to_article_as_member
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     login_as :ben
0
     assert_difference Asset, :count, asset_count do
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ class Admin::AssetsControllerPermissionsTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_upload_and_create_asset_records
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     assert_difference sites(:first).assets, :count do
0
       assert_difference Asset, :count, asset_count do
...
21
22
23
24
 
25
26
27
...
53
54
55
56
 
57
58
59
...
21
22
23
 
24
25
26
27
...
53
54
55
 
56
57
58
59
0
@@ -21,7 +21,7 @@ class Admin::AssetsControllerTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_upload_and_create_asset_records
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     assert_difference sites(:first).assets, :count do
0
       assert_difference Asset, :count, asset_count do
0
@@ -53,7 +53,7 @@ class Admin::AssetsControllerTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_upload_multiple_assets_and_ignore_titles
0
- asset_count = Object.const_defined?(:Magick) ? 6 : 2 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 6 : 2 # asset + 2 thumbnails
0
     assert_difference sites(:first).assets, :count, 2 do
0
       assert_difference Asset, :count, asset_count do
0
         process_upload %w(logo.png logo.png)
...
16
17
18
19
 
20
21
22
...
16
17
18
 
19
20
21
22
0
@@ -16,7 +16,7 @@ class Admin::AssetsControllerUploadTest < Test::Unit::TestCase
0
     Fixtures.delete_existing_fixtures_for(Asset.connection, :assets)
0
   end
0
 
0
-if Object.const_defined?(:Magick)
0
+if has_image_processor?
0
   def test_should_sort_assets
0
     assert_difference sites(:first).assets, :count, 21 do
0
       assert_difference Asset, :count, 63 do
...
91
92
93
 
 
 
 
 
 
 
 
94
95
96
...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
0
@@ -91,6 +91,14 @@ class Test::Unit::TestCase
0
   self.use_transactional_fixtures = true
0
   self.use_instantiated_fixtures = false
0
 
0
+ def self.has_image_processor?
0
+ @has_image_processor ||= Object.const_defined?(:ImageScience) || Object.const_defined?(:Magick)
0
+ end
0
+
0
+ def has_image_processor?
0
+ self.class.has_image_processor?
0
+ end
0
+
0
   def use_temp_file(path)
0
     temp_path = File.join(ASSET_PATH, File.basename(path))
0
     FileUtils.cp path, temp_path
...
4
5
6
7
 
8
9
10
11
12
13
 
14
15
16
...
49
50
51
52
 
53
54
55
...
179
180
181
182
 
183
184
185
...
4
5
6
 
7
8
9
10
11
12
 
13
14
15
16
...
49
50
51
 
52
53
54
55
...
179
180
181
 
182
183
184
185
0
@@ -4,13 +4,13 @@ class AssetTest < Test::Unit::TestCase
0
   fixtures :sites, :assets, :tags, :taggings
0
 
0
   def test_should_upload_and_create_asset_records
0
- asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails
0
+ asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails
0
     
0
     assert_difference sites(:first).assets, :count do
0
       assert_difference Asset, :count, asset_count do
0
         process_upload
0
         
0
- if Object.const_defined?(:Magick)
0
+ if has_image_processor?
0
           asset = Asset.find(:first, :conditions => 'id > 7', :order => 'created_at')
0
           assert_equal 2, asset.thumbnails_count
0
         end
0
@@ -49,7 +49,7 @@ class AssetTest < Test::Unit::TestCase
0
     process_upload
0
     now = Time.now.utc
0
     assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png')
0
- if Object.const_defined?(:Magick)
0
+ if has_image_processor?
0
       assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_thumb.png')
0
       assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_tiny.png')
0
     end
0
@@ -179,7 +179,7 @@ class AssetTest < Test::Unit::TestCase
0
     
0
     def assert_assets_exist(filename, created_at = Time.now.utc)
0
       assert_file_exists File.join(ASSET_PATH, created_at.year.to_s, created_at.month.to_s, created_at.day.to_s, "#{filename}.png")
0
- if Object.const_defined?(:Magick)
0
+ if has_image_processor?
0
         assert_file_exists File.join(ASSET_PATH, created_at.year.to_s, created_at.month.to_s, created_at.day.to_s, "#{filename}_thumb.png")
0
         assert_file_exists File.join(ASSET_PATH, created_at.year.to_s, created_at.month.to_s, created_at.day.to_s, "#{filename}_tiny.png")
0
       end

Comments

    No one has commented yet.