robinboening-fleximage 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGELOG.rdoc +14 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +257 -0
  4. data/Rakefile +49 -0
  5. data/VERSION +1 -0
  6. data/autotest.rb +5 -0
  7. data/fleximage.gemspec +179 -0
  8. data/init.rb +1 -0
  9. data/lib/dsl_accessor.rb +52 -0
  10. data/lib/fleximage.rb +56 -0
  11. data/lib/fleximage/aviary_controller.rb +75 -0
  12. data/lib/fleximage/blank.rb +70 -0
  13. data/lib/fleximage/helper.rb +41 -0
  14. data/lib/fleximage/image_proxy.rb +69 -0
  15. data/lib/fleximage/legacy_view.rb +63 -0
  16. data/lib/fleximage/model.rb +711 -0
  17. data/lib/fleximage/operator/background.rb +62 -0
  18. data/lib/fleximage/operator/base.rb +189 -0
  19. data/lib/fleximage/operator/border.rb +50 -0
  20. data/lib/fleximage/operator/crop.rb +58 -0
  21. data/lib/fleximage/operator/image_overlay.rb +85 -0
  22. data/lib/fleximage/operator/resize.rb +92 -0
  23. data/lib/fleximage/operator/shadow.rb +87 -0
  24. data/lib/fleximage/operator/text.rb +104 -0
  25. data/lib/fleximage/operator/trim.rb +14 -0
  26. data/lib/fleximage/operator/unsharp_mask.rb +36 -0
  27. data/lib/fleximage/rmagick_image_patch.rb +5 -0
  28. data/lib/fleximage/view.rb +57 -0
  29. data/tasks/fleximage_tasks.rake +154 -0
  30. data/test/fixtures/100x1.jpg +0 -0
  31. data/test/fixtures/100x100.jpg +0 -0
  32. data/test/fixtures/1x1.jpg +0 -0
  33. data/test/fixtures/1x100.jpg +0 -0
  34. data/test/fixtures/cmyk.jpg +0 -0
  35. data/test/fixtures/not_a_photo.xml +1 -0
  36. data/test/fixtures/photo.jpg +0 -0
  37. data/test/mock_file.rb +21 -0
  38. data/test/rails_root/app/controllers/application.rb +10 -0
  39. data/test/rails_root/app/controllers/avatars_controller.rb +85 -0
  40. data/test/rails_root/app/controllers/photo_bares_controller.rb +85 -0
  41. data/test/rails_root/app/controllers/photo_dbs_controller.rb +85 -0
  42. data/test/rails_root/app/controllers/photo_files_controller.rb +85 -0
  43. data/test/rails_root/app/helpers/application_helper.rb +3 -0
  44. data/test/rails_root/app/helpers/avatars_helper.rb +2 -0
  45. data/test/rails_root/app/helpers/photo_bares_helper.rb +2 -0
  46. data/test/rails_root/app/helpers/photo_dbs_helper.rb +2 -0
  47. data/test/rails_root/app/helpers/photo_files_helper.rb +2 -0
  48. data/test/rails_root/app/locales/de.yml +7 -0
  49. data/test/rails_root/app/locales/en.yml +8 -0
  50. data/test/rails_root/app/models/abstract.rb +8 -0
  51. data/test/rails_root/app/models/avatar.rb +4 -0
  52. data/test/rails_root/app/models/photo_bare.rb +7 -0
  53. data/test/rails_root/app/models/photo_custom_error.rb +10 -0
  54. data/test/rails_root/app/models/photo_db.rb +3 -0
  55. data/test/rails_root/app/models/photo_file.rb +3 -0
  56. data/test/rails_root/app/models/photo_s3.rb +5 -0
  57. data/test/rails_root/app/views/avatars/edit.html.erb +17 -0
  58. data/test/rails_root/app/views/avatars/index.html.erb +20 -0
  59. data/test/rails_root/app/views/avatars/new.html.erb +16 -0
  60. data/test/rails_root/app/views/avatars/show.html.erb +8 -0
  61. data/test/rails_root/app/views/layouts/avatars.html.erb +17 -0
  62. data/test/rails_root/app/views/layouts/photo_bares.html.erb +17 -0
  63. data/test/rails_root/app/views/layouts/photo_dbs.html.erb +17 -0
  64. data/test/rails_root/app/views/layouts/photo_files.html.erb +17 -0
  65. data/test/rails_root/app/views/photo_bares/edit.html.erb +12 -0
  66. data/test/rails_root/app/views/photo_bares/index.html.erb +18 -0
  67. data/test/rails_root/app/views/photo_bares/new.html.erb +11 -0
  68. data/test/rails_root/app/views/photo_bares/show.html.erb +3 -0
  69. data/test/rails_root/app/views/photo_dbs/edit.html.erb +32 -0
  70. data/test/rails_root/app/views/photo_dbs/index.html.erb +26 -0
  71. data/test/rails_root/app/views/photo_dbs/new.html.erb +31 -0
  72. data/test/rails_root/app/views/photo_dbs/show.html.erb +23 -0
  73. data/test/rails_root/app/views/photo_files/edit.html.erb +27 -0
  74. data/test/rails_root/app/views/photo_files/index.html.erb +24 -0
  75. data/test/rails_root/app/views/photo_files/new.html.erb +26 -0
  76. data/test/rails_root/app/views/photo_files/show.html.erb +18 -0
  77. data/test/rails_root/config/boot.rb +109 -0
  78. data/test/rails_root/config/database.yml +7 -0
  79. data/test/rails_root/config/environment.rb +66 -0
  80. data/test/rails_root/config/environments/development.rb +18 -0
  81. data/test/rails_root/config/environments/production.rb +19 -0
  82. data/test/rails_root/config/environments/sqlite3.rb +0 -0
  83. data/test/rails_root/config/environments/test.rb +22 -0
  84. data/test/rails_root/config/initializers/inflections.rb +10 -0
  85. data/test/rails_root/config/initializers/load_translations.rb +4 -0
  86. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  87. data/test/rails_root/config/routes.rb +43 -0
  88. data/test/rails_root/db/migrate/001_create_photo_files.rb +16 -0
  89. data/test/rails_root/db/migrate/002_create_photo_dbs.rb +16 -0
  90. data/test/rails_root/db/migrate/003_create_photo_bares.rb +12 -0
  91. data/test/rails_root/db/migrate/004_create_avatars.rb +13 -0
  92. data/test/rails_root/db/migrate/005_create_photo_s3s.rb +12 -0
  93. data/test/rails_root/public/.htaccess +40 -0
  94. data/test/rails_root/public/404.html +30 -0
  95. data/test/rails_root/public/422.html +30 -0
  96. data/test/rails_root/public/500.html +30 -0
  97. data/test/rails_root/public/dispatch.cgi +10 -0
  98. data/test/rails_root/public/dispatch.fcgi +24 -0
  99. data/test/rails_root/public/dispatch.rb +10 -0
  100. data/test/rails_root/public/favicon.ico +0 -0
  101. data/test/rails_root/public/images/rails.png +0 -0
  102. data/test/rails_root/public/index.html +277 -0
  103. data/test/rails_root/public/javascripts/application.js +2 -0
  104. data/test/rails_root/public/javascripts/controls.js +963 -0
  105. data/test/rails_root/public/javascripts/dragdrop.js +972 -0
  106. data/test/rails_root/public/javascripts/effects.js +1120 -0
  107. data/test/rails_root/public/javascripts/prototype.js +4225 -0
  108. data/test/rails_root/public/robots.txt +5 -0
  109. data/test/rails_root/public/stylesheets/scaffold.css +74 -0
  110. data/test/rails_root/vendor/plugins/fleximage/init.rb +2 -0
  111. data/test/s3_stubs.rb +7 -0
  112. data/test/test_helper.rb +82 -0
  113. data/test/unit/abstract_test.rb +20 -0
  114. data/test/unit/basic_model_test.rb +40 -0
  115. data/test/unit/blank_test.rb +23 -0
  116. data/test/unit/default_image_path_option_test.rb +16 -0
  117. data/test/unit/dsl_accessor_test.rb +120 -0
  118. data/test/unit/file_upload_from_local_test.rb +31 -0
  119. data/test/unit/file_upload_from_strings_test.rb +23 -0
  120. data/test/unit/file_upload_from_url_test.rb +35 -0
  121. data/test/unit/file_upload_to_db_test.rb +41 -0
  122. data/test/unit/has_store_test.rb +4 -0
  123. data/test/unit/i18n_messages_test.rb +49 -0
  124. data/test/unit/image_directory_option_test.rb +20 -0
  125. data/test/unit/image_proxy_test.rb +17 -0
  126. data/test/unit/image_storage_format_option_test.rb +31 -0
  127. data/test/unit/magic_columns_test.rb +34 -0
  128. data/test/unit/minimum_image_size_test.rb +56 -0
  129. data/test/unit/operator_base_test.rb +124 -0
  130. data/test/unit/operator_resize_test.rb +18 -0
  131. data/test/unit/preprocess_image_option_test.rb +21 -0
  132. data/test/unit/require_image_option_test.rb +30 -0
  133. data/test/unit/temp_image_test.rb +23 -0
  134. data/test/unit/use_creation_date_based_directories_option_test.rb +16 -0
  135. metadata +258 -0
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ This is not a photo
Binary file
data/test/mock_file.rb ADDED
@@ -0,0 +1,21 @@
1
+ # This is a testable class that emulates an uploaded file
2
+ class MockFile
3
+ attr_reader :path
4
+ def initialize(path)
5
+ @path = path
6
+ end
7
+
8
+ def size
9
+ 1
10
+ end
11
+
12
+ def original_filename
13
+ @path.split('/').last
14
+ end
15
+
16
+ def read
17
+ File.open(@path) { |f| f.read }
18
+ end
19
+
20
+ def rewind; end
21
+ end
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+
7
+ # See ActionController::RequestForgeryProtection for details
8
+ # Uncomment the :secret if you're not using the cookie session store
9
+ protect_from_forgery # :secret => 'da69588ceb6298fcc3dd908cd8ca94f7'
10
+ end
@@ -0,0 +1,85 @@
1
+ class AvatarsController < ApplicationController
2
+ # GET /avatars
3
+ # GET /avatars.xml
4
+ def index
5
+ @avatars = Avatar.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @avatars }
10
+ end
11
+ end
12
+
13
+ # GET /avatars/1
14
+ # GET /avatars/1.xml
15
+ def show
16
+ @avatar = Avatar.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @avatar }
21
+ end
22
+ end
23
+
24
+ # GET /avatars/new
25
+ # GET /avatars/new.xml
26
+ def new
27
+ @avatar = Avatar.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @avatar }
32
+ end
33
+ end
34
+
35
+ # GET /avatars/1/edit
36
+ def edit
37
+ @avatar = Avatar.find(params[:id])
38
+ end
39
+
40
+ # POST /avatars
41
+ # POST /avatars.xml
42
+ def create
43
+ @avatar = Avatar.new(params[:avatar])
44
+
45
+ respond_to do |format|
46
+ if @avatar.save
47
+ flash[:notice] = 'Avatar was successfully created.'
48
+ format.html { redirect_to(@avatar) }
49
+ format.xml { render :xml => @avatar, :status => :created, :location => @avatar }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @avatar.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /avatars/1
58
+ # PUT /avatars/1.xml
59
+ def update
60
+ @avatar = Avatar.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @avatar.update_attributes(params[:avatar])
64
+ flash[:notice] = 'Avatar was successfully updated.'
65
+ format.html { redirect_to(@avatar) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @avatar.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /avatars/1
75
+ # DELETE /avatars/1.xml
76
+ def destroy
77
+ @avatar = Avatar.find(params[:id])
78
+ @avatar.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(avatars_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,85 @@
1
+ class PhotoBaresController < ApplicationController
2
+ # GET /photo_bares
3
+ # GET /photo_bares.xml
4
+ def index
5
+ @photo_bares = PhotoBare.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @photo_bares }
10
+ end
11
+ end
12
+
13
+ # GET /photo_bares/1
14
+ # GET /photo_bares/1.xml
15
+ def show
16
+ @photo_bare = PhotoBare.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @photo_bare }
21
+ end
22
+ end
23
+
24
+ # GET /photo_bares/new
25
+ # GET /photo_bares/new.xml
26
+ def new
27
+ @photo_bare = PhotoBare.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @photo_bare }
32
+ end
33
+ end
34
+
35
+ # GET /photo_bares/1/edit
36
+ def edit
37
+ @photo_bare = PhotoBare.find(params[:id])
38
+ end
39
+
40
+ # POST /photo_bares
41
+ # POST /photo_bares.xml
42
+ def create
43
+ @photo_bare = PhotoBare.new(params[:photo_bare])
44
+
45
+ respond_to do |format|
46
+ if @photo_bare.save
47
+ flash[:notice] = 'PhotoBare was successfully created.'
48
+ format.html { redirect_to(@photo_bare) }
49
+ format.xml { render :xml => @photo_bare, :status => :created, :location => @photo_bare }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @photo_bare.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /photo_bares/1
58
+ # PUT /photo_bares/1.xml
59
+ def update
60
+ @photo_bare = PhotoBare.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @photo_bare.update_attributes(params[:photo_bare])
64
+ flash[:notice] = 'PhotoBare was successfully updated.'
65
+ format.html { redirect_to(@photo_bare) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @photo_bare.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /photo_bares/1
75
+ # DELETE /photo_bares/1.xml
76
+ def destroy
77
+ @photo_bare = PhotoBare.find(params[:id])
78
+ @photo_bare.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(photo_bares_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,85 @@
1
+ class PhotoDbsController < ApplicationController
2
+ # GET /photo_dbs
3
+ # GET /photo_dbs.xml
4
+ def index
5
+ @photo_dbs = PhotoDb.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @photo_dbs }
10
+ end
11
+ end
12
+
13
+ # GET /photo_dbs/1
14
+ # GET /photo_dbs/1.xml
15
+ def show
16
+ @photo_db = PhotoDb.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @photo_db }
21
+ end
22
+ end
23
+
24
+ # GET /photo_dbs/new
25
+ # GET /photo_dbs/new.xml
26
+ def new
27
+ @photo_db = PhotoDb.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @photo_db }
32
+ end
33
+ end
34
+
35
+ # GET /photo_dbs/1/edit
36
+ def edit
37
+ @photo_db = PhotoDb.find(params[:id])
38
+ end
39
+
40
+ # POST /photo_dbs
41
+ # POST /photo_dbs.xml
42
+ def create
43
+ @photo_db = PhotoDb.new(params[:photo_db])
44
+
45
+ respond_to do |format|
46
+ if @photo_db.save
47
+ flash[:notice] = 'PhotoDb was successfully created.'
48
+ format.html { redirect_to(@photo_db) }
49
+ format.xml { render :xml => @photo_db, :status => :created, :location => @photo_db }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @photo_db.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /photo_dbs/1
58
+ # PUT /photo_dbs/1.xml
59
+ def update
60
+ @photo_db = PhotoDb.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @photo_db.update_attributes(params[:photo_db])
64
+ flash[:notice] = 'PhotoDb was successfully updated.'
65
+ format.html { redirect_to(@photo_db) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @photo_db.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /photo_dbs/1
75
+ # DELETE /photo_dbs/1.xml
76
+ def destroy
77
+ @photo_db = PhotoDb.find(params[:id])
78
+ @photo_db.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(photo_dbs_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,85 @@
1
+ class PhotoFilesController < ApplicationController
2
+ # GET /photo_files
3
+ # GET /photo_files.xml
4
+ def index
5
+ @photo_files = PhotoFile.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @photo_files }
10
+ end
11
+ end
12
+
13
+ # GET /photo_files/1
14
+ # GET /photo_files/1.xml
15
+ def show
16
+ @photo_file = PhotoFile.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @photo_file }
21
+ end
22
+ end
23
+
24
+ # GET /photo_files/new
25
+ # GET /photo_files/new.xml
26
+ def new
27
+ @photo_file = PhotoFile.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @photo_file }
32
+ end
33
+ end
34
+
35
+ # GET /photo_files/1/edit
36
+ def edit
37
+ @photo_file = PhotoFile.find(params[:id])
38
+ end
39
+
40
+ # POST /photo_files
41
+ # POST /photo_files.xml
42
+ def create
43
+ @photo_file = PhotoFile.new(params[:photo_file])
44
+
45
+ respond_to do |format|
46
+ if @photo_file.save
47
+ flash[:notice] = 'PhotoFile was successfully created.'
48
+ format.html { redirect_to(@photo_file) }
49
+ format.xml { render :xml => @photo_file, :status => :created, :location => @photo_file }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @photo_file.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /photo_files/1
58
+ # PUT /photo_files/1.xml
59
+ def update
60
+ @photo_file = PhotoFile.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @photo_file.update_attributes(params[:photo_file])
64
+ flash[:notice] = 'PhotoFile was successfully updated.'
65
+ format.html { redirect_to(@photo_file) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @photo_file.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /photo_files/1
75
+ # DELETE /photo_files/1.xml
76
+ def destroy
77
+ @photo_file = PhotoFile.find(params[:id])
78
+ @photo_file.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(photo_files_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module AvatarsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PhotoBaresHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PhotoDbsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PhotoFilesHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ de:
2
+ activerecord:
3
+ errors:
4
+ messages:
5
+ missing_image: ist erforderlich
6
+ invalid_image: war nicht lesbar
7
+ image_too_small: "ist zu klein (Minimalgröße: {{minimum}})"
@@ -0,0 +1,8 @@
1
+ en:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ photo_custom_error:
6
+ missing_image: needs to be attached
7
+ invalid_image: seems to be broken
8
+ image_too_small: "must be bigger (min. size: {{minimum}})"
@@ -0,0 +1,8 @@
1
+ class Abstract < ActiveRecord::Base
2
+ set_table_name :photo_dbs
3
+
4
+ acts_as_fleximage do
5
+ require_image false
6
+ default_image :size => '320x240', :color => 'red'
7
+ end
8
+ end