tvdeyen-fleximage 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/CHANGELOG.rdoc +14 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +36 -0
  4. data/Rakefile +49 -0
  5. data/VERSION +1 -0
  6. data/autotest.rb +5 -0
  7. data/init.rb +1 -0
  8. data/lib/dsl_accessor.rb +52 -0
  9. data/lib/fleximage.rb +59 -0
  10. data/lib/fleximage/aviary_controller.rb +75 -0
  11. data/lib/fleximage/blank.rb +70 -0
  12. data/lib/fleximage/helper.rb +41 -0
  13. data/lib/fleximage/image_proxy.rb +69 -0
  14. data/lib/fleximage/legacy_view.rb +63 -0
  15. data/lib/fleximage/model.rb +713 -0
  16. data/lib/fleximage/operator/background.rb +62 -0
  17. data/lib/fleximage/operator/base.rb +189 -0
  18. data/lib/fleximage/operator/border.rb +50 -0
  19. data/lib/fleximage/operator/crop.rb +58 -0
  20. data/lib/fleximage/operator/image_overlay.rb +85 -0
  21. data/lib/fleximage/operator/resize.rb +92 -0
  22. data/lib/fleximage/operator/shadow.rb +87 -0
  23. data/lib/fleximage/operator/text.rb +104 -0
  24. data/lib/fleximage/operator/trim.rb +14 -0
  25. data/lib/fleximage/operator/unsharp_mask.rb +36 -0
  26. data/lib/fleximage/rails3_view.rb +31 -0
  27. data/lib/fleximage/rmagick_image_patch.rb +7 -0
  28. data/lib/fleximage/view.rb +57 -0
  29. data/lib/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. data/tvdeyen-fleximage.gemspec +180 -0
  136. metadata +244 -0
@@ -0,0 +1,7 @@
1
+ class PhotoBare < ActiveRecord::Base
2
+ acts_as_fleximage do
3
+ image_directory 'public/uploads'
4
+ validates_image_size '2x2'
5
+ require_image true
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class PhotoCustomError < ActiveRecord::Base
2
+ set_table_name :photo_dbs
3
+ acts_as_fleximage do
4
+ image_directory 'public/uploads'
5
+ validates_image_size '2x2'
6
+ missing_image_message "needs to be attached"
7
+ invalid_image_message "seems to be broken"
8
+ image_too_small_message "must be bigger (min. size: {{minimum}})"
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ class PhotoDb < ActiveRecord::Base
2
+ acts_as_fleximage
3
+ end
@@ -0,0 +1,3 @@
1
+ class PhotoFile < ActiveRecord::Base
2
+ acts_as_fleximage :image_directory => 'public/uploads'
3
+ end
@@ -0,0 +1,5 @@
1
+ class PhotoS3 < ActiveRecord::Base
2
+ acts_as_fleximage do
3
+ s3_bucket 'test-bucket'
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ <h1>Editing avatar</h1>
2
+
3
+ <%= error_messages_for :avatar %>
4
+
5
+ <% form_for(@avatar) do |f| %>
6
+ <p>
7
+ <b>Username</b><br />
8
+ <%= f.text_field :username %>
9
+ </p>
10
+
11
+ <p>
12
+ <%= f.submit "Update" %>
13
+ </p>
14
+ <% end %>
15
+
16
+ <%= link_to 'Show', @avatar %> |
17
+ <%= link_to 'Back', avatars_path %>
@@ -0,0 +1,20 @@
1
+ <h1>Listing avatars</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Username</th>
6
+ </tr>
7
+
8
+ <% for avatar in @avatars %>
9
+ <tr>
10
+ <td><%=h avatar.username %></td>
11
+ <td><%= link_to 'Show', avatar %></td>
12
+ <td><%= link_to 'Edit', edit_avatar_path(avatar) %></td>
13
+ <td><%= link_to 'Destroy', avatar, :confirm => 'Are you sure?', :method => :delete %></td>
14
+ </tr>
15
+ <% end %>
16
+ </table>
17
+
18
+ <br />
19
+
20
+ <%= link_to 'New avatar', new_avatar_path %>
@@ -0,0 +1,16 @@
1
+ <h1>New avatar</h1>
2
+
3
+ <%= error_messages_for :avatar %>
4
+
5
+ <% form_for(@avatar) do |f| %>
6
+ <p>
7
+ <b>Username</b><br />
8
+ <%= f.text_field :username %>
9
+ </p>
10
+
11
+ <p>
12
+ <%= f.submit "Create" %>
13
+ </p>
14
+ <% end %>
15
+
16
+ <%= link_to 'Back', avatars_path %>
@@ -0,0 +1,8 @@
1
+ <p>
2
+ <b>Username:</b>
3
+ <%=h @avatar.username %>
4
+ </p>
5
+
6
+
7
+ <%= link_to 'Edit', edit_avatar_path(@avatar) %> |
8
+ <%= link_to 'Back', avatars_path %>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Avatars: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>PhotoBares: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>PhotoDbs: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>PhotoFiles: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,12 @@
1
+ <h1>Editing photo_bare</h1>
2
+
3
+ <%= error_messages_for :photo_bare %>
4
+
5
+ <% form_for(@photo_bare) do |f| %>
6
+ <p>
7
+ <%= f.submit "Update" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Show', @photo_bare %> |
12
+ <%= link_to 'Back', photo_bares_path %>
@@ -0,0 +1,18 @@
1
+ <h1>Listing photo_bares</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ </tr>
6
+
7
+ <% for photo_bare in @photo_bares %>
8
+ <tr>
9
+ <td><%= link_to 'Show', photo_bare %></td>
10
+ <td><%= link_to 'Edit', edit_photo_bare_path(photo_bare) %></td>
11
+ <td><%= link_to 'Destroy', photo_bare, :confirm => 'Are you sure?', :method => :delete %></td>
12
+ </tr>
13
+ <% end %>
14
+ </table>
15
+
16
+ <br />
17
+
18
+ <%= link_to 'New photo_bare', new_photo_bare_path %>
@@ -0,0 +1,11 @@
1
+ <h1>New photo_bare</h1>
2
+
3
+ <%= error_messages_for :photo_bare %>
4
+
5
+ <% form_for(@photo_bare) do |f| %>
6
+ <p>
7
+ <%= f.submit "Create" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Back', photo_bares_path %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= link_to 'Edit', edit_photo_bare_path(@photo_bare) %> |
3
+ <%= link_to 'Back', photo_bares_path %>
@@ -0,0 +1,32 @@
1
+ <h1>Editing photo_db</h1>
2
+
3
+ <%= error_messages_for :photo_db %>
4
+
5
+ <% form_for(@photo_db) do |f| %>
6
+ <p>
7
+ <b>Image filename</b><br />
8
+ <%= f.text_field :image_filename %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image width</b><br />
13
+ <%= f.text_field :image_width %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Image height</b><br />
18
+ <%= f.text_field :image_height %>
19
+ </p>
20
+
21
+ <p>
22
+ <b>Image file data</b><br />
23
+ <%= f.text_field :image_file_data %>
24
+ </p>
25
+
26
+ <p>
27
+ <%= f.submit "Update" %>
28
+ </p>
29
+ <% end %>
30
+
31
+ <%= link_to 'Show', @photo_db %> |
32
+ <%= link_to 'Back', photo_dbs_path %>
@@ -0,0 +1,26 @@
1
+ <h1>Listing photo_dbs</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Image filename</th>
6
+ <th>Image width</th>
7
+ <th>Image height</th>
8
+ <th>Image file data</th>
9
+ </tr>
10
+
11
+ <% for photo_db in @photo_dbs %>
12
+ <tr>
13
+ <td><%=h photo_db.image_filename %></td>
14
+ <td><%=h photo_db.image_width %></td>
15
+ <td><%=h photo_db.image_height %></td>
16
+ <td><%=h photo_db.image_file_data %></td>
17
+ <td><%= link_to 'Show', photo_db %></td>
18
+ <td><%= link_to 'Edit', edit_photo_db_path(photo_db) %></td>
19
+ <td><%= link_to 'Destroy', photo_db, :confirm => 'Are you sure?', :method => :delete %></td>
20
+ </tr>
21
+ <% end %>
22
+ </table>
23
+
24
+ <br />
25
+
26
+ <%= link_to 'New photo_db', new_photo_db_path %>
@@ -0,0 +1,31 @@
1
+ <h1>New photo_db</h1>
2
+
3
+ <%= error_messages_for :photo_db %>
4
+
5
+ <% form_for(@photo_db) do |f| %>
6
+ <p>
7
+ <b>Image filename</b><br />
8
+ <%= f.text_field :image_filename %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image width</b><br />
13
+ <%= f.text_field :image_width %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Image height</b><br />
18
+ <%= f.text_field :image_height %>
19
+ </p>
20
+
21
+ <p>
22
+ <b>Image file data</b><br />
23
+ <%= f.text_field :image_file_data %>
24
+ </p>
25
+
26
+ <p>
27
+ <%= f.submit "Create" %>
28
+ </p>
29
+ <% end %>
30
+
31
+ <%= link_to 'Back', photo_dbs_path %>
@@ -0,0 +1,23 @@
1
+ <p>
2
+ <b>Image filename:</b>
3
+ <%=h @photo_db.image_filename %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Image width:</b>
8
+ <%=h @photo_db.image_width %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image height:</b>
13
+ <%=h @photo_db.image_height %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Image file data:</b>
18
+ <%=h @photo_db.image_file_data %>
19
+ </p>
20
+
21
+
22
+ <%= link_to 'Edit', edit_photo_db_path(@photo_db) %> |
23
+ <%= link_to 'Back', photo_dbs_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Editing photo_file</h1>
2
+
3
+ <%= error_messages_for :photo_file %>
4
+
5
+ <% form_for(@photo_file) do |f| %>
6
+ <p>
7
+ <b>Image filename</b><br />
8
+ <%= f.text_field :image_filename %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image width</b><br />
13
+ <%= f.text_field :image_width %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Image height</b><br />
18
+ <%= f.text_field :image_height %>
19
+ </p>
20
+
21
+ <p>
22
+ <%= f.submit "Update" %>
23
+ </p>
24
+ <% end %>
25
+
26
+ <%= link_to 'Show', @photo_file %> |
27
+ <%= link_to 'Back', photo_files_path %>
@@ -0,0 +1,24 @@
1
+ <h1>Listing photo_files</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Image filename</th>
6
+ <th>Image width</th>
7
+ <th>Image height</th>
8
+ </tr>
9
+
10
+ <% for photo_file in @photo_files %>
11
+ <tr>
12
+ <td><%=h photo_file.image_filename %></td>
13
+ <td><%=h photo_file.image_width %></td>
14
+ <td><%=h photo_file.image_height %></td>
15
+ <td><%= link_to 'Show', photo_file %></td>
16
+ <td><%= link_to 'Edit', edit_photo_file_path(photo_file) %></td>
17
+ <td><%= link_to 'Destroy', photo_file, :confirm => 'Are you sure?', :method => :delete %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+
22
+ <br />
23
+
24
+ <%= link_to 'New photo_file', new_photo_file_path %>
@@ -0,0 +1,26 @@
1
+ <h1>New photo_file</h1>
2
+
3
+ <%= error_messages_for :photo_file %>
4
+
5
+ <% form_for(@photo_file) do |f| %>
6
+ <p>
7
+ <b>Image filename</b><br />
8
+ <%= f.text_field :image_filename %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image width</b><br />
13
+ <%= f.text_field :image_width %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Image height</b><br />
18
+ <%= f.text_field :image_height %>
19
+ </p>
20
+
21
+ <p>
22
+ <%= f.submit "Create" %>
23
+ </p>
24
+ <% end %>
25
+
26
+ <%= link_to 'Back', photo_files_path %>
@@ -0,0 +1,18 @@
1
+ <p>
2
+ <b>Image filename:</b>
3
+ <%=h @photo_file.image_filename %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Image width:</b>
8
+ <%=h @photo_file.image_width %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Image height:</b>
13
+ <%=h @photo_file.image_height %>
14
+ </p>
15
+
16
+
17
+ <%= link_to 'Edit', edit_photo_file_path(@photo_file) %> |
18
+ <%= link_to 'Back', photo_files_path %>