spree 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/History.txt +24 -0
- data/License.txt +26 -0
- data/Manifest.txt +534 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/bin/spree +157 -0
- data/config/hoe.rb +78 -0
- data/config/requirements.rb +15 -0
- data/lib/spree/version.rb +9 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/starter-app/README +182 -0
- data/starter-app/Rakefile +10 -0
- data/starter-app/app/controllers/application.rb +14 -0
- data/starter-app/app/helpers/application_helper.rb +3 -0
- data/starter-app/app/models/role.rb +3 -0
- data/starter-app/app/models/tag.rb +37 -0
- data/starter-app/app/models/tagging.rb +16 -0
- data/starter-app/app/models/user.rb +102 -0
- data/starter-app/app/views/layouts/application.rhtml +46 -0
- data/starter-app/app/views/shared/_store_menu.rhtml +6 -0
- data/starter-app/config/boot.rb +45 -0
- data/starter-app/config/database.yml +23 -0
- data/starter-app/config/environment.rb +140 -0
- data/starter-app/config/environments/development.rb +21 -0
- data/starter-app/config/environments/production.rb +21 -0
- data/starter-app/config/environments/test.rb +19 -0
- data/starter-app/config/routes.rb +28 -0
- data/starter-app/db/migrate/001_create_users.rb +17 -0
- data/starter-app/db/migrate/002_create_roles.rb +20 -0
- data/starter-app/db/migrate/003_create_tags_and_taggings.rb +28 -0
- data/starter-app/db/migrate/004_spree_to_version_21.rb +9 -0
- data/starter-app/db/sample/addresses.yml +24 -0
- data/starter-app/db/sample/categories.yml +35 -0
- data/starter-app/db/sample/countries.yml +3 -0
- data/starter-app/db/sample/credit_cards.yml +12 -0
- data/starter-app/db/sample/images.yml +252 -0
- data/starter-app/db/sample/line_items.yml +23 -0
- data/starter-app/db/sample/option_types.yml +6 -0
- data/starter-app/db/sample/option_values.yml +35 -0
- data/starter-app/db/sample/orders.yml +15 -0
- data/starter-app/db/sample/product_option_types.yml +8 -0
- data/starter-app/db/sample/products.yml +35 -0
- data/starter-app/db/sample/roles.yml +3 -0
- data/starter-app/db/sample/skus.yml +28 -0
- data/starter-app/db/sample/states.yml +154 -0
- data/starter-app/db/sample/taggings.yml +16 -0
- data/starter-app/db/sample/tags.yml +6 -0
- data/starter-app/db/sample/txns.yml +7 -0
- data/starter-app/db/sample/users.yml +6 -0
- data/starter-app/db/sample/variations.yml +31 -0
- data/starter-app/doc/README_FOR_APP +2 -0
- data/starter-app/lib/authenticated_system.rb +116 -0
- data/starter-app/lib/authenticated_test_helper.rb +10 -0
- data/starter-app/lib/custom_fixtures.rb +7 -0
- data/starter-app/lib/hijacker.rb +78 -0
- data/starter-app/lib/role_requirement_system.rb +142 -0
- data/starter-app/lib/role_requirement_test_helper.rb +86 -0
- data/starter-app/lib/tagging_extensions.rb +104 -0
- data/starter-app/lib/tasks/sample/products/0000/0001/ror_tote.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0001/ror_tote_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0001/ror_tote_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0001/ror_tote_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0002/ror_tote_back.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0002/ror_tote_back_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0002/ror_tote_back_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0002/ror_tote_back_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0003/ror_bag.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0003/ror_bag_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0003/ror_bag_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0003/ror_bag_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0004/ror_baseball.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0004/ror_baseball_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0004/ror_baseball_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0004/ror_baseball_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0005/ror_baseball_back.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0005/ror_baseball_back_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0005/ror_baseball_back_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0005/ror_baseball_back_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0006/ror_jr_spaghetti.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0006/ror_jr_spaghetti_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0006/ror_jr_spaghetti_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0006/ror_jr_spaghetti_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0007/ror_mug.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0007/ror_mug_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0007/ror_mug_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0007/ror_mug_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0008/ror_mug_back.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0008/ror_mug_back_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0008/ror_mug_back_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0008/ror_mug_back_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0009/ror_ringer.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0009/ror_ringer_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0009/ror_ringer_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0009/ror_ringer_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0010/ror_ringer_back.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0010/ror_ringer_back_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0010/ror_ringer_back_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0010/ror_ringer_back_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0011/ror_stein.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0011/ror_stein_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0011/ror_stein_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0011/ror_stein_small.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0012/ror_stein_back.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0012/ror_stein_back_mini.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0012/ror_stein_back_product.jpeg +0 -0
- data/starter-app/lib/tasks/sample/products/0000/0012/ror_stein_back_small.jpeg +0 -0
- data/starter-app/lib/tasks/spree_sample_data.rake +38 -0
- data/starter-app/public/.htaccess +40 -0
- data/starter-app/public/404.html +30 -0
- data/starter-app/public/500.html +30 -0
- data/starter-app/public/dispatch.cgi +10 -0
- data/starter-app/public/dispatch.fcgi +24 -0
- data/starter-app/public/dispatch.rb +10 -0
- data/starter-app/public/favicon.ico +0 -0
- data/starter-app/public/images/rails.png +0 -0
- data/starter-app/public/index.html +277 -0
- data/starter-app/public/javascripts/application.js +2 -0
- data/starter-app/public/javascripts/controls.js +833 -0
- data/starter-app/public/javascripts/dragdrop.js +942 -0
- data/starter-app/public/javascripts/effects.js +1088 -0
- data/starter-app/public/javascripts/prototype.js +4184 -0
- data/starter-app/public/robots.txt +1 -0
- data/starter-app/public/stylesheets/application.css +209 -0
- data/starter-app/public/stylesheets/cart/_controller.css +4 -0
- data/starter-app/public/stylesheets/checkout/_controller.css +13 -0
- data/starter-app/script/about +3 -0
- data/starter-app/script/breakpointer +3 -0
- data/starter-app/script/console +3 -0
- data/starter-app/script/destroy +3 -0
- data/starter-app/script/generate +3 -0
- data/starter-app/script/performance/benchmarker +3 -0
- data/starter-app/script/performance/profiler +3 -0
- data/starter-app/script/plugin +3 -0
- data/starter-app/script/process/inspector +3 -0
- data/starter-app/script/process/reaper +3 -0
- data/starter-app/script/process/spawner +3 -0
- data/starter-app/script/runner +3 -0
- data/starter-app/script/server +3 -0
- data/starter-app/test/fixtures/users.yml +7 -0
- data/starter-app/test/test_helper.rb +28 -0
- data/starter-app/test/unit/user_test.rb +8 -0
- data/starter-app/vendor/plugins/acts_as_list/README +23 -0
- data/starter-app/vendor/plugins/acts_as_list/init.rb +3 -0
- data/starter-app/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/starter-app/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/starter-app/vendor/plugins/acts_as_tree/README +26 -0
- data/starter-app/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/starter-app/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/starter-app/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/starter-app/vendor/plugins/attachment_fu/CHANGELOG +24 -0
- data/starter-app/vendor/plugins/attachment_fu/README +162 -0
- data/starter-app/vendor/plugins/attachment_fu/Rakefile +22 -0
- data/starter-app/vendor/plugins/attachment_fu/amazon_s3.yml.tpl +14 -0
- data/starter-app/vendor/plugins/attachment_fu/init.rb +14 -0
- data/starter-app/vendor/plugins/attachment_fu/install.rb +5 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/geometry.rb +93 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb +410 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb +39 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb +97 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb +309 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb +61 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb +56 -0
- data/starter-app/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb +53 -0
- data/starter-app/vendor/plugins/attachment_fu/test/amazon_s3.yml +6 -0
- data/starter-app/vendor/plugins/attachment_fu/test/backends/db_file_test.rb +16 -0
- data/starter-app/vendor/plugins/attachment_fu/test/backends/file_system_test.rb +80 -0
- data/starter-app/vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb +103 -0
- data/starter-app/vendor/plugins/attachment_fu/test/base_attachment_tests.rb +57 -0
- data/starter-app/vendor/plugins/attachment_fu/test/basic_test.rb +64 -0
- data/starter-app/vendor/plugins/attachment_fu/test/database.yml +18 -0
- data/starter-app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb +57 -0
- data/starter-app/vendor/plugins/attachment_fu/test/fixtures/attachment.rb +127 -0
- data/starter-app/vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png +0 -0
- data/starter-app/vendor/plugins/attachment_fu/test/fixtures/files/foo.txt +1 -0
- data/starter-app/vendor/plugins/attachment_fu/test/fixtures/files/rails.png +0 -0
- data/starter-app/vendor/plugins/attachment_fu/test/geometry_test.rb +101 -0
- data/starter-app/vendor/plugins/attachment_fu/test/processors/image_science_test.rb +31 -0
- data/starter-app/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb +31 -0
- data/starter-app/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb +241 -0
- data/starter-app/vendor/plugins/attachment_fu/test/schema.rb +86 -0
- data/starter-app/vendor/plugins/attachment_fu/test/test_helper.rb +142 -0
- data/starter-app/vendor/plugins/attachment_fu/test/validation_test.rb +55 -0
- data/starter-app/vendor/plugins/calendar_date_select/CHANGELOG +170 -0
- data/starter-app/vendor/plugins/calendar_date_select/MIT-LICENSE +20 -0
- data/starter-app/vendor/plugins/calendar_date_select/README +10 -0
- data/starter-app/vendor/plugins/calendar_date_select/init.rb +15 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/functional/cds_test.html +324 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/prototype.js +4184 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/test.css +40 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/unit/cds_helper_methods.html +46 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/unittest.js +564 -0
- data/starter-app/vendor/plugins/calendar_date_select/lib/calendar_date_select.rb +192 -0
- data/starter-app/vendor/plugins/calendar_date_select/lib/includes_helper.rb +22 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/images/calendar_date_select/calendar.gif +0 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/calendar_date_select.js +439 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_american.js +34 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_finnish.js +24 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_hyphen_ampm.js +36 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_italian.js +24 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/locale/fi.js +10 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/blue.css +130 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/default.css +135 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/plain.css +128 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/red.css +135 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/silver.css +133 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/functional/calendar_date_select_test.rb +95 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/functional/helper_methods_test.rb +15 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/test_helper.rb +26 -0
- data/starter-app/vendor/plugins/engines/CHANGELOG +258 -0
- data/starter-app/vendor/plugins/engines/MIT-LICENSE +21 -0
- data/starter-app/vendor/plugins/engines/README +63 -0
- data/starter-app/vendor/plugins/engines/Rakefile +32 -0
- data/starter-app/vendor/plugins/engines/about.yml +7 -0
- data/starter-app/vendor/plugins/engines/boot.rb +18 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/USAGE +45 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +79 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/starter-app/vendor/plugins/engines/init.rb +2 -0
- data/starter-app/vendor/plugins/engines/lib/engines.rb +169 -0
- data/starter-app/vendor/plugins/engines/lib/engines/assets.rb +38 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin.rb +125 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb +30 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/loader.rb +18 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/locator.rb +11 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/migrator.rb +60 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb +85 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +24 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb +119 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +145 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +161 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +11 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +84 -0
- data/starter-app/vendor/plugins/engines/lib/engines/testing.rb +87 -0
- data/starter-app/vendor/plugins/engines/tasks/engines.rake +176 -0
- data/starter-app/vendor/plugins/in_place_editing/README +14 -0
- data/starter-app/vendor/plugins/in_place_editing/Rakefile +22 -0
- data/starter-app/vendor/plugins/in_place_editing/init.rb +2 -0
- data/starter-app/vendor/plugins/in_place_editing/lib/in_place_editing.rb +25 -0
- data/starter-app/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb +71 -0
- data/starter-app/vendor/plugins/in_place_editing/test/in_place_editing_test.rb +69 -0
- data/starter-app/vendor/plugins/paginating_find/CHANGELOG +120 -0
- data/starter-app/vendor/plugins/paginating_find/README +89 -0
- data/starter-app/vendor/plugins/paginating_find/init.rb +2 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paginating_find.rb +138 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paging_enumerator.rb +158 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paging_helper.rb +47 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/Rakefile +10 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/app/controllers/application.rb +2 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/boot.rb +44 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/database.yml +6 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/environment.rb +53 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/environments/test.rb +19 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/routes.rb +22 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/db/schema.rb +16 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/script/breakpointer +3 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/script/console +3 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/articles.yml +19 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/authors.yml +7 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/edits.yml +11 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/models.rb +18 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/test_helper.rb +33 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/abstract_test.rb +7 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/group_test.rb +40 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +194 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +143 -0
- data/starter-app/vendor/plugins/spree/.rakeTasks +7 -0
- data/starter-app/vendor/plugins/spree/CHANGELOG +1 -0
- data/starter-app/vendor/plugins/spree/LICENSE +26 -0
- data/starter-app/vendor/plugins/spree/README +1 -0
- data/starter-app/vendor/plugins/spree/Rakefile +10 -0
- data/starter-app/vendor/plugins/spree/VERSION +1 -0
- data/starter-app/vendor/plugins/spree/app/controllers/account_controller.rb +48 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/base_controller.rb +7 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/categories_controller.rb +107 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/images_controller.rb +15 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/option_types_controller.rb +70 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/orders_controller.rb +247 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/overview_controller.rb +14 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/products_controller.rb +207 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/reports_controller.rb +53 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/users_controller.rb +45 -0
- data/starter-app/vendor/plugins/spree/app/controllers/admin/variations_controller.rb +73 -0
- data/starter-app/vendor/plugins/spree/app/controllers/cart_controller.rb +45 -0
- data/starter-app/vendor/plugins/spree/app/controllers/checkout_controller.rb +184 -0
- data/starter-app/vendor/plugins/spree/app/controllers/rails_cart/base_controller.rb +47 -0
- data/starter-app/vendor/plugins/spree/app/controllers/store_controller.rb +27 -0
- data/starter-app/vendor/plugins/spree/app/helpers/account_helper.rb +2 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/base_helper.rb +14 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/categories_helper.rb +3 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/option_values_helper.rb +2 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/orders_helper.rb +11 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/overview_helper.rb +12 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/products_helper.rb +7 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/users_helper.rb +2 -0
- data/starter-app/vendor/plugins/spree/app/helpers/admin/variations_helper.rb +2 -0
- data/starter-app/vendor/plugins/spree/app/helpers/cart_helper.rb +6 -0
- data/starter-app/vendor/plugins/spree/app/helpers/checkout_helper.rb +17 -0
- data/starter-app/vendor/plugins/spree/app/helpers/rails_cart/base_helper.rb +101 -0
- data/starter-app/vendor/plugins/spree/app/helpers/search_helper.rb +10 -0
- data/starter-app/vendor/plugins/spree/app/helpers/store_helper.rb +3 -0
- data/starter-app/vendor/plugins/spree/app/models/address.rb +17 -0
- data/starter-app/vendor/plugins/spree/app/models/cart.rb +37 -0
- data/starter-app/vendor/plugins/spree/app/models/cart_item.rb +29 -0
- data/starter-app/vendor/plugins/spree/app/models/category.rb +66 -0
- data/starter-app/vendor/plugins/spree/app/models/country.rb +3 -0
- data/starter-app/vendor/plugins/spree/app/models/credit_card.rb +24 -0
- data/starter-app/vendor/plugins/spree/app/models/image.rb +12 -0
- data/starter-app/vendor/plugins/spree/app/models/line_item.rb +24 -0
- data/starter-app/vendor/plugins/spree/app/models/option_type.rb +4 -0
- data/starter-app/vendor/plugins/spree/app/models/option_value.rb +5 -0
- data/starter-app/vendor/plugins/spree/app/models/order.rb +87 -0
- data/starter-app/vendor/plugins/spree/app/models/order_mailer.rb +22 -0
- data/starter-app/vendor/plugins/spree/app/models/order_operation.rb +7 -0
- data/starter-app/vendor/plugins/spree/app/models/payment.rb +49 -0
- data/starter-app/vendor/plugins/spree/app/models/product.rb +42 -0
- data/starter-app/vendor/plugins/spree/app/models/product_option_type.rb +5 -0
- data/starter-app/vendor/plugins/spree/app/models/search_criteria.rb +27 -0
- data/starter-app/vendor/plugins/spree/app/models/sku.rb +7 -0
- data/starter-app/vendor/plugins/spree/app/models/state.rb +3 -0
- data/starter-app/vendor/plugins/spree/app/models/tax_treatment.rb +2 -0
- data/starter-app/vendor/plugins/spree/app/models/txn.rb +7 -0
- data/starter-app/vendor/plugins/spree/app/models/variation.rb +8 -0
- data/starter-app/vendor/plugins/spree/app/views/account/index.rhtml +3 -0
- data/starter-app/vendor/plugins/spree/app/views/account/login.rhtml +12 -0
- data/starter-app/vendor/plugins/spree/app/views/account/signup.rhtml +16 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/categories/_form.rhtml +24 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/categories/edit.rhtml +9 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/categories/list.rhtml +47 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/categories/new.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/images/new.html.erb +10 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/_form.rhtml +16 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/_new_option_value.rhtml +13 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/_option_values.rhtml +43 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/index.rhtml +23 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/new.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/select.rhtml +28 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/option_types/test.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/orders/_address.rhtml +37 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/orders/index.rhtml +99 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/orders/show.rhtml +72 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/overview/index.rhtml +0 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_form.rhtml +65 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_menu.rhtml +7 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_new_variation.rhtml +11 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_option_types.rhtml +42 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_variations.rhtml +41 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/index.rhtml +66 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/products/new.rhtml +9 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/reports/index.rhtml +29 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/reports/sales_total.rhtml +28 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/_form.rhtml +29 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/_menu.rhtml +5 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/index.rhtml +26 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/new.rhtml +6 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/users/show.rhtml +9 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/variations/_form.rhtml +33 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/variations/_option_values.rhtml +5 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/variations/list.rhtml +23 -0
- data/starter-app/vendor/plugins/spree/app/views/admin/variations/new.rhtml +14 -0
- data/starter-app/vendor/plugins/spree/app/views/cart/index.rhtml +49 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/_address.rhtml +51 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/_address_ro.rhtml +18 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/_cart_item.rhtml +5 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/_extra.rhtml +1 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/addresses.rhtml +51 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/cvv.rhtml +15 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/empty_cart.rhtml +4 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/final_confirmation.rhtml +92 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/incomplete.rhtml +7 -0
- data/starter-app/vendor/plugins/spree/app/views/checkout/thank_you.rhtml +11 -0
- data/starter-app/vendor/plugins/spree/app/views/layouts/admin.rhtml +69 -0
- data/starter-app/vendor/plugins/spree/app/views/layouts/products.rhtml +20 -0
- data/starter-app/vendor/plugins/spree/app/views/layouts/simple.rhtml +37 -0
- data/starter-app/vendor/plugins/spree/app/views/order_mailer/cancel.rhtml +15 -0
- data/starter-app/vendor/plugins/spree/app/views/order_mailer/confirm.rhtml +18 -0
- data/starter-app/vendor/plugins/spree/app/views/shared/_images.html.erb +43 -0
- data/starter-app/vendor/plugins/spree/app/views/shared/_order_details.rhtml +35 -0
- data/starter-app/vendor/plugins/spree/app/views/shared/_paginate.rhtml +34 -0
- data/starter-app/vendor/plugins/spree/app/views/shared/_report_criteria.rhtml +32 -0
- data/starter-app/vendor/plugins/spree/app/views/shared/_tax_treatments.rhtml +12 -0
- data/starter-app/vendor/plugins/spree/app/views/store/_image.html.erb +5 -0
- data/starter-app/vendor/plugins/spree/app/views/store/_products.rhtml +10 -0
- data/starter-app/vendor/plugins/spree/app/views/store/_thumbnails.html.erb +9 -0
- data/starter-app/vendor/plugins/spree/app/views/store/list.rhtml +15 -0
- data/starter-app/vendor/plugins/spree/app/views/store/show.rhtml +69 -0
- data/starter-app/vendor/plugins/spree/assets/.htaccess +40 -0
- data/starter-app/vendor/plugins/spree/assets/404.html +30 -0
- data/starter-app/vendor/plugins/spree/assets/500.html +30 -0
- data/starter-app/vendor/plugins/spree/assets/dispatch.cgi +10 -0
- data/starter-app/vendor/plugins/spree/assets/dispatch.fcgi +24 -0
- data/starter-app/vendor/plugins/spree/assets/dispatch.rb +10 -0
- data/starter-app/vendor/plugins/spree/assets/favicon.ico +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/amex_cid.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/creditcard.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/discover_cid.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/master_cid.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_bag.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_baseball_jersey.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_jr_spaghetti.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_mug.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_ringer_tshirt.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_stein.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/products/ror_tote.jpg +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/rails.png +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/spinner.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/spree/progress.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/spree/spinner.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/spree/spree_logo142x65.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/spree/spree_logo245x112.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/images/visa_cid.gif +0 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/application.js +2 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/controls.js +833 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/dragdrop.js +942 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/effects.js +1088 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/lowpro.js +307 -0
- data/starter-app/vendor/plugins/spree/assets/javascripts/prototype.js +2515 -0
- data/starter-app/vendor/plugins/spree/assets/robots.txt +1 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/cart/_controller.css +71 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/checkout/_controller.css +31 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/fullscreen.css +63 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/orders/_controller.css +3 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/products/_controller.css +38 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/spree-admin.css +348 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/spree.css +66 -0
- data/starter-app/vendor/plugins/spree/assets/stylesheets/store/_controller.css +23 -0
- data/starter-app/vendor/plugins/spree/db/migrate/001_create_addresses.rb +20 -0
- data/starter-app/vendor/plugins/spree/db/migrate/002_create_cart_items.rb +14 -0
- data/starter-app/vendor/plugins/spree/db/migrate/003_create_carts.rb +12 -0
- data/starter-app/vendor/plugins/spree/db/migrate/004_create_categories.rb +15 -0
- data/starter-app/vendor/plugins/spree/db/migrate/005_create_categories_products.rb +12 -0
- data/starter-app/vendor/plugins/spree/db/migrate/006_create_line_items.rb +17 -0
- data/starter-app/vendor/plugins/spree/db/migrate/007_create_option_values.rb +15 -0
- data/starter-app/vendor/plugins/spree/db/migrate/008_create_orders.rb +24 -0
- data/starter-app/vendor/plugins/spree/db/migrate/009_create_products.rb +20 -0
- data/starter-app/vendor/plugins/spree/db/migrate/010_create_txns.rb +18 -0
- data/starter-app/vendor/plugins/spree/db/migrate/011_create_variations.rb +11 -0
- data/starter-app/vendor/plugins/spree/db/migrate/012_create_tax_treatments.rb +23 -0
- data/starter-app/vendor/plugins/spree/db/migrate/013_create_skus.rb +13 -0
- data/starter-app/vendor/plugins/spree/db/migrate/014_create_countries.rb +11 -0
- data/starter-app/vendor/plugins/spree/db/migrate/015_create_states.rb +13 -0
- data/starter-app/vendor/plugins/spree/db/migrate/016_create_option_types.rb +13 -0
- data/starter-app/vendor/plugins/spree/db/migrate/017_create_product_option_types.rb +14 -0
- data/starter-app/vendor/plugins/spree/db/migrate/018_create_option_values_variations.rb +12 -0
- data/starter-app/vendor/plugins/spree/db/migrate/019_create_images.rb +19 -0
- data/starter-app/vendor/plugins/spree/db/migrate/020_create_credit_cards.rb +20 -0
- data/starter-app/vendor/plugins/spree/db/migrate/021_create_order_operations.rb +14 -0
- data/starter-app/vendor/plugins/spree/init.rb +11 -0
- data/starter-app/vendor/plugins/spree/install.rb +3 -0
- data/starter-app/vendor/plugins/spree/lib/constants/enumerable_constants.rb +207 -0
- data/starter-app/vendor/plugins/spree/lib/format.rb +12 -0
- data/starter-app/vendor/plugins/spree/lib/gateway/bogus_gateway.rb +63 -0
- data/starter-app/vendor/plugins/spree/lib/shipping/flat_rate.rb +10 -0
- data/starter-app/vendor/plugins/spree/lib/tasks/spree_bootstrap.rake +24 -0
- data/starter-app/vendor/plugins/spree/lib/tax/sales_tax.rb +26 -0
- data/starter-app/vendor/plugins/spree/routes.rb +3 -0
- data/starter-app/vendor/plugins/spree/script/about +3 -0
- data/starter-app/vendor/plugins/spree/script/breakpointer +3 -0
- data/starter-app/vendor/plugins/spree/script/console +3 -0
- data/starter-app/vendor/plugins/spree/script/destroy +3 -0
- data/starter-app/vendor/plugins/spree/script/generate +3 -0
- data/starter-app/vendor/plugins/spree/script/performance/benchmarker +3 -0
- data/starter-app/vendor/plugins/spree/script/performance/profiler +3 -0
- data/starter-app/vendor/plugins/spree/script/plugin +3 -0
- data/starter-app/vendor/plugins/spree/script/process/inspector +3 -0
- data/starter-app/vendor/plugins/spree/script/process/reaper +3 -0
- data/starter-app/vendor/plugins/spree/script/process/spawner +3 -0
- data/starter-app/vendor/plugins/spree/script/runner +3 -0
- data/starter-app/vendor/plugins/spree/script/server +3 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/addresses.yml +29 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/categories.yml +40 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/line_items.yml +32 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/orders.yml +17 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/products.yml +63 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/products_tags.yml +10 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/roles.yml +6 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/roles_users.yml +3 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/skus.yml +5 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/tags.yml +7 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/tax_treatments.yml +7 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/txns.yml +13 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/users.yml +40 -0
- data/starter-app/vendor/plugins/spree/test/fixtures/variations.yml +16 -0
- data/starter-app/vendor/plugins/spree/test/functional/account_controller_test.rb +129 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/base_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/option_groups_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/option_values_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/orders_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/overview_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/products_controller_test.rb +125 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/users_controller_test.rb +58 -0
- data/starter-app/vendor/plugins/spree/test/functional/admin/variations_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/spree/test/functional/application_controller_test.rb +30 -0
- data/starter-app/vendor/plugins/spree/test/functional/cart_controller_test.rb +76 -0
- data/starter-app/vendor/plugins/spree/test/functional/checkout_controller_test.rb +20 -0
- data/starter-app/vendor/plugins/spree/test/integration/authentication_test.rb +53 -0
- data/starter-app/vendor/plugins/spree/test/integration/product_admin_test.rb +135 -0
- data/starter-app/vendor/plugins/spree/test/integration/user_stories_test.rb +59 -0
- data/starter-app/vendor/plugins/spree/test/integration/variations_test.rb +24 -0
- data/starter-app/vendor/plugins/spree/test/test_helper.rb +45 -0
- data/starter-app/vendor/plugins/spree/test/unit/address_test.rb +10 -0
- data/starter-app/vendor/plugins/spree/test/unit/cart_item_test.rb +55 -0
- data/starter-app/vendor/plugins/spree/test/unit/cart_test.rb +35 -0
- data/starter-app/vendor/plugins/spree/test/unit/category_test.rb +52 -0
- data/starter-app/vendor/plugins/spree/test/unit/line_item_test.rb +61 -0
- data/starter-app/vendor/plugins/spree/test/unit/option_group_test.rb +12 -0
- data/starter-app/vendor/plugins/spree/test/unit/order_test.rb +49 -0
- data/starter-app/vendor/plugins/spree/test/unit/product_test.rb +107 -0
- data/starter-app/vendor/plugins/spree/test/unit/role_test.rb +10 -0
- data/starter-app/vendor/plugins/spree/test/unit/sales_tax_test.rb +46 -0
- data/starter-app/vendor/plugins/spree/test/unit/sku_test.rb +10 -0
- data/starter-app/vendor/plugins/spree/test/unit/tag_test.rb +9 -0
- data/starter-app/vendor/plugins/spree/test/unit/tax_treatment_test.rb +10 -0
- data/starter-app/vendor/plugins/spree/test/unit/txn_test.rb +10 -0
- data/starter-app/vendor/plugins/spree/test/unit/variation_test.rb +9 -0
- data/starter-app/vendor/plugins/spree/uninstall.rb +1 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_railscart.rb +11 -0
- metadata +628 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
Tempfile.class_eval do
|
4
|
+
# overwrite so tempfiles use the extension of the basename. important for rmagick and image science
|
5
|
+
def make_tmpname(basename, n)
|
6
|
+
ext = nil
|
7
|
+
sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'geometry'
|
12
|
+
ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
|
13
|
+
Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
|
14
|
+
FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# This Geometry class was yanked from RMagick. However, it lets ImageMagick handle the actual change_geometry.
|
2
|
+
# Use #new_dimensions_for to get new dimensons
|
3
|
+
# Used so I can use spiffy RMagick geometry strings with ImageScience
|
4
|
+
class Geometry
|
5
|
+
# ! and @ are removed until support for them is added
|
6
|
+
FLAGS = ['', '%', '<', '>']#, '!', '@']
|
7
|
+
RFLAGS = { '%' => :percent,
|
8
|
+
'!' => :aspect,
|
9
|
+
'<' => :>,
|
10
|
+
'>' => :<,
|
11
|
+
'@' => :area }
|
12
|
+
|
13
|
+
attr_accessor :width, :height, :x, :y, :flag
|
14
|
+
|
15
|
+
def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)
|
16
|
+
# Support floating-point width and height arguments so Geometry
|
17
|
+
# objects can be used to specify Image#density= arguments.
|
18
|
+
raise ArgumentError, "width must be >= 0: #{width}" if width < 0
|
19
|
+
raise ArgumentError, "height must be >= 0: #{height}" if height < 0
|
20
|
+
@width = width.to_f
|
21
|
+
@height = height.to_f
|
22
|
+
@x = x.to_i
|
23
|
+
@y = y.to_i
|
24
|
+
@flag = flag
|
25
|
+
end
|
26
|
+
|
27
|
+
# Construct an object from a geometry string
|
28
|
+
RE = /\A(\d*)(?:x(\d+))?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/
|
29
|
+
|
30
|
+
def self.from_s(str)
|
31
|
+
raise(ArgumentError, "no geometry string specified") unless str
|
32
|
+
|
33
|
+
if m = RE.match(str)
|
34
|
+
new(m[1].to_i, m[2].to_i, m[3].to_i, m[4].to_i, RFLAGS[m[5]])
|
35
|
+
else
|
36
|
+
raise ArgumentError, "invalid geometry format"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Convert object to a geometry string
|
41
|
+
def to_s
|
42
|
+
str = ''
|
43
|
+
str << "%g" % @width if @width > 0
|
44
|
+
str << 'x' if (@width > 0 || @height > 0)
|
45
|
+
str << "%g" % @height if @height > 0
|
46
|
+
str << "%+d%+d" % [@x, @y] if (@x != 0 || @y != 0)
|
47
|
+
str << FLAGS[@flag.to_i]
|
48
|
+
end
|
49
|
+
|
50
|
+
# attempts to get new dimensions for the current geometry string given these old dimensions.
|
51
|
+
# This doesn't implement the aspect flag (!) or the area flag (@). PDI
|
52
|
+
def new_dimensions_for(orig_width, orig_height)
|
53
|
+
new_width = orig_width
|
54
|
+
new_height = orig_height
|
55
|
+
|
56
|
+
case @flag
|
57
|
+
when :percent
|
58
|
+
scale_x = @width.zero? ? 100 : @width
|
59
|
+
scale_y = @height.zero? ? @width : @height
|
60
|
+
new_width = scale_x.to_f * (orig_width.to_f / 100.0)
|
61
|
+
new_height = scale_y.to_f * (orig_height.to_f / 100.0)
|
62
|
+
when :<, :>, nil
|
63
|
+
scale_factor =
|
64
|
+
if new_width.zero? || new_height.zero?
|
65
|
+
1.0
|
66
|
+
else
|
67
|
+
if @width.nonzero? && @height.nonzero?
|
68
|
+
[@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min
|
69
|
+
else
|
70
|
+
@width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
new_width = scale_factor * new_width.to_f
|
74
|
+
new_height = scale_factor * new_height.to_f
|
75
|
+
new_width = orig_width if @flag && orig_width.send(@flag, new_width)
|
76
|
+
new_height = orig_height if @flag && orig_height.send(@flag, new_height)
|
77
|
+
end
|
78
|
+
|
79
|
+
[new_width, new_height].collect! { |v| v.round }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Array
|
84
|
+
# allows you to get new dimensions for the current array of dimensions with a given geometry string
|
85
|
+
#
|
86
|
+
# [50, 64] / '40>' # => [40, 51]
|
87
|
+
def /(geometry)
|
88
|
+
raise ArgumentError, "Only works with a [width, height] pair" if size != 2
|
89
|
+
raise ArgumentError, "Must pass a valid geometry string or object" unless geometry.is_a?(String) || geometry.is_a?(Geometry)
|
90
|
+
geometry = Geometry.from_s(geometry) if geometry.is_a?(String)
|
91
|
+
geometry.new_dimensions_for first, last
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,410 @@
|
|
1
|
+
module Technoweenie # :nodoc:
|
2
|
+
module AttachmentFu # :nodoc:
|
3
|
+
@@default_processors = %w(ImageScience Rmagick MiniMagick)
|
4
|
+
@@tempfile_path = File.join(RAILS_ROOT, 'tmp', 'attachment_fu')
|
5
|
+
@@content_types = ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg']
|
6
|
+
mattr_reader :content_types, :tempfile_path, :default_processors
|
7
|
+
mattr_writer :tempfile_path
|
8
|
+
|
9
|
+
class ThumbnailError < StandardError; end
|
10
|
+
class AttachmentError < StandardError; end
|
11
|
+
|
12
|
+
module ActMethods
|
13
|
+
# Options:
|
14
|
+
# * <tt>:content_type</tt> - Allowed content types. Allows all by default. Use :image to allow all standard image types.
|
15
|
+
# * <tt>:min_size</tt> - Minimum size allowed. 1 byte is the default.
|
16
|
+
# * <tt>:max_size</tt> - Maximum size allowed. 1.megabyte is the default.
|
17
|
+
# * <tt>:size</tt> - Range of sizes allowed. (1..1.megabyte) is the default. This overrides the :min_size and :max_size options.
|
18
|
+
# * <tt>:resize_to</tt> - Used by RMagick to resize images. Pass either an array of width/height, or a geometry string.
|
19
|
+
# * <tt>:thumbnails</tt> - Specifies a set of thumbnails to generate. This accepts a hash of filename suffixes and RMagick resizing options.
|
20
|
+
# * <tt>:thumbnail_class</tt> - Set what class to use for thumbnails. This attachment class is used by default.
|
21
|
+
# * <tt>:path_prefix</tt> - path to store the uploaded files. Uses public/#{table_name} by default for the filesystem, and just #{table_name}
|
22
|
+
# for the S3 backend. Setting this sets the :storage to :file_system.
|
23
|
+
# * <tt>:storage</tt> - Use :file_system to specify the attachment data is stored with the file system. Defaults to :db_system.
|
24
|
+
#
|
25
|
+
# Examples:
|
26
|
+
# has_attachment :max_size => 1.kilobyte
|
27
|
+
# has_attachment :size => 1.megabyte..2.megabytes
|
28
|
+
# has_attachment :content_type => 'application/pdf'
|
29
|
+
# has_attachment :content_type => ['application/pdf', 'application/msword', 'text/plain']
|
30
|
+
# has_attachment :content_type => :image, :resize_to => [50,50]
|
31
|
+
# has_attachment :content_type => ['application/pdf', :image], :resize_to => 'x50'
|
32
|
+
# has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
|
33
|
+
# has_attachment :storage => :file_system, :path_prefix => 'public/files'
|
34
|
+
# has_attachment :storage => :file_system, :path_prefix => 'public/files',
|
35
|
+
# :content_type => :image, :resize_to => [50,50]
|
36
|
+
# has_attachment :storage => :file_system, :path_prefix => 'public/files',
|
37
|
+
# :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
|
38
|
+
# has_attachment :storage => :s3
|
39
|
+
def has_attachment(options = {})
|
40
|
+
# this allows you to redefine the acts' options for each subclass, however
|
41
|
+
options[:min_size] ||= 1
|
42
|
+
options[:max_size] ||= 1.megabyte
|
43
|
+
options[:size] ||= (options[:min_size]..options[:max_size])
|
44
|
+
options[:thumbnails] ||= {}
|
45
|
+
options[:thumbnail_class] ||= self
|
46
|
+
options[:s3_access] ||= :public_read
|
47
|
+
options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?
|
48
|
+
|
49
|
+
unless options[:thumbnails].is_a?(Hash)
|
50
|
+
raise ArgumentError, ":thumbnails option should be a hash: e.g. :thumbnails => { :foo => '50x50' }"
|
51
|
+
end
|
52
|
+
|
53
|
+
# doing these shenanigans so that #attachment_options is available to processors and backends
|
54
|
+
class_inheritable_accessor :attachment_options
|
55
|
+
self.attachment_options = options
|
56
|
+
|
57
|
+
# only need to define these once on a class
|
58
|
+
unless included_modules.include?(InstanceMethods)
|
59
|
+
attr_accessor :thumbnail_resize_options
|
60
|
+
|
61
|
+
attachment_options[:storage] ||= (attachment_options[:file_system_path] || attachment_options[:path_prefix]) ? :file_system : :db_file
|
62
|
+
attachment_options[:path_prefix] ||= attachment_options[:file_system_path]
|
63
|
+
if attachment_options[:path_prefix].nil?
|
64
|
+
attachment_options[:path_prefix] = attachment_options[:storage] == :s3 ? table_name : File.join("public", table_name)
|
65
|
+
end
|
66
|
+
attachment_options[:path_prefix] = attachment_options[:path_prefix][1..-1] if options[:path_prefix].first == '/'
|
67
|
+
|
68
|
+
with_options :foreign_key => 'parent_id' do |m|
|
69
|
+
m.has_many :thumbnails, :class_name => attachment_options[:thumbnail_class].to_s
|
70
|
+
m.belongs_to :parent, :class_name => base_class.to_s
|
71
|
+
end
|
72
|
+
before_destroy :destroy_thumbnails
|
73
|
+
|
74
|
+
before_validation :set_size_from_temp_path
|
75
|
+
after_save :after_process_attachment
|
76
|
+
after_destroy :destroy_file
|
77
|
+
extend ClassMethods
|
78
|
+
include InstanceMethods
|
79
|
+
include Technoweenie::AttachmentFu::Backends.const_get("#{options[:storage].to_s.classify}Backend")
|
80
|
+
case attachment_options[:processor]
|
81
|
+
when :none
|
82
|
+
when nil
|
83
|
+
processors = Technoweenie::AttachmentFu.default_processors.dup
|
84
|
+
begin
|
85
|
+
if processors.any?
|
86
|
+
attachment_options[:processor] = "#{processors.first}Processor"
|
87
|
+
include Technoweenie::AttachmentFu::Processors.const_get(attachment_options[:processor])
|
88
|
+
end
|
89
|
+
rescue LoadError, MissingSourceFile
|
90
|
+
processors.shift
|
91
|
+
retry
|
92
|
+
end
|
93
|
+
else
|
94
|
+
begin
|
95
|
+
include Technoweenie::AttachmentFu::Processors.const_get("#{options[:processor].to_s.classify}Processor")
|
96
|
+
rescue LoadError, MissingSourceFile
|
97
|
+
puts "Problems loading #{options[:processor]}Processor: #{$!}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
after_validation :process_attachment
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
module ClassMethods
|
106
|
+
delegate :content_types, :to => Technoweenie::AttachmentFu
|
107
|
+
|
108
|
+
# Performs common validations for attachment models.
|
109
|
+
def validates_as_attachment
|
110
|
+
validates_presence_of :size, :content_type, :filename
|
111
|
+
validate :attachment_attributes_valid?
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns true or false if the given content type is recognized as an image.
|
115
|
+
def image?(content_type)
|
116
|
+
content_types.include?(content_type)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Callback after an image has been resized.
|
120
|
+
#
|
121
|
+
# class Foo < ActiveRecord::Base
|
122
|
+
# acts_as_attachment
|
123
|
+
# after_resize do |record, img|
|
124
|
+
# record.aspect_ratio = img.columns.to_f / img.rows.to_f
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
def after_resize(&block)
|
128
|
+
write_inheritable_array(:after_resize, [block])
|
129
|
+
end
|
130
|
+
|
131
|
+
# Callback after an attachment has been saved either to the file system or the DB.
|
132
|
+
# Only called if the file has been changed, not necessarily if the record is updated.
|
133
|
+
#
|
134
|
+
# class Foo < ActiveRecord::Base
|
135
|
+
# acts_as_attachment
|
136
|
+
# after_attachment_saved do |record|
|
137
|
+
# ...
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
def after_attachment_saved(&block)
|
141
|
+
write_inheritable_array(:after_attachment_saved, [block])
|
142
|
+
end
|
143
|
+
|
144
|
+
# Callback before a thumbnail is saved. Use this to pass any necessary extra attributes that may be required.
|
145
|
+
#
|
146
|
+
# class Foo < ActiveRecord::Base
|
147
|
+
# acts_as_attachment
|
148
|
+
# before_thumbnail_saved do |record, thumbnail|
|
149
|
+
# ...
|
150
|
+
# end
|
151
|
+
# end
|
152
|
+
def before_thumbnail_saved(&block)
|
153
|
+
write_inheritable_array(:before_thumbnail_saved, [block])
|
154
|
+
end
|
155
|
+
|
156
|
+
# Get the thumbnail class, which is the current attachment class by default.
|
157
|
+
# Configure this with the :thumbnail_class option.
|
158
|
+
def thumbnail_class
|
159
|
+
attachment_options[:thumbnail_class] = attachment_options[:thumbnail_class].constantize unless attachment_options[:thumbnail_class].is_a?(Class)
|
160
|
+
attachment_options[:thumbnail_class]
|
161
|
+
end
|
162
|
+
|
163
|
+
# Copies the given file path to a new tempfile, returning the closed tempfile.
|
164
|
+
def copy_to_temp_file(file, temp_base_name)
|
165
|
+
returning Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path) do |tmp|
|
166
|
+
tmp.close
|
167
|
+
FileUtils.cp file, tmp.path
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Writes the given data to a new tempfile, returning the closed tempfile.
|
172
|
+
def write_to_temp_file(data, temp_base_name)
|
173
|
+
returning Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path) do |tmp|
|
174
|
+
tmp.binmode
|
175
|
+
tmp.write data
|
176
|
+
tmp.close
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
module InstanceMethods
|
182
|
+
# Checks whether the attachment's content type is an image content type
|
183
|
+
def image?
|
184
|
+
self.class.image?(content_type)
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns true/false if an attachment is thumbnailable. A thumbnailable attachment has an image content type and the parent_id attribute.
|
188
|
+
def thumbnailable?
|
189
|
+
image? && respond_to?(:parent_id) && parent_id.nil?
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns the class used to create new thumbnails for this attachment.
|
193
|
+
def thumbnail_class
|
194
|
+
self.class.thumbnail_class
|
195
|
+
end
|
196
|
+
|
197
|
+
# Gets the thumbnail name for a filename. 'foo.jpg' becomes 'foo_thumbnail.jpg'
|
198
|
+
def thumbnail_name_for(thumbnail = nil)
|
199
|
+
return filename if thumbnail.blank?
|
200
|
+
ext = nil
|
201
|
+
basename = filename.gsub /\.\w+$/ do |s|
|
202
|
+
ext = s; ''
|
203
|
+
end
|
204
|
+
# ImageScience doesn't create gif thumbnails, only pngs
|
205
|
+
ext.sub!(/gif$/, 'png') if attachment_options[:processor] == "ImageScienceProcessor"
|
206
|
+
"#{basename}_#{thumbnail}#{ext}"
|
207
|
+
end
|
208
|
+
|
209
|
+
# Creates or updates the thumbnail for the current attachment.
|
210
|
+
def create_or_update_thumbnail(temp_file, file_name_suffix, *size)
|
211
|
+
thumbnailable? || raise(ThumbnailError.new("Can't create a thumbnail if the content type is not an image or there is no parent_id column"))
|
212
|
+
returning find_or_initialize_thumbnail(file_name_suffix) do |thumb|
|
213
|
+
thumb.attributes = {
|
214
|
+
:content_type => content_type,
|
215
|
+
:filename => thumbnail_name_for(file_name_suffix),
|
216
|
+
:temp_path => temp_file,
|
217
|
+
:thumbnail_resize_options => size
|
218
|
+
}
|
219
|
+
callback_with_args :before_thumbnail_saved, thumb
|
220
|
+
thumb.save!
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# Sets the content type.
|
225
|
+
def content_type=(new_type)
|
226
|
+
write_attribute :content_type, new_type.to_s.strip
|
227
|
+
end
|
228
|
+
|
229
|
+
# Sanitizes a filename.
|
230
|
+
def filename=(new_name)
|
231
|
+
write_attribute :filename, sanitize_filename(new_name)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Returns the width/height in a suitable format for the image_tag helper: (100x100)
|
235
|
+
def image_size
|
236
|
+
[width.to_s, height.to_s] * 'x'
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns true if the attachment data will be written to the storage system on the next save
|
240
|
+
def save_attachment?
|
241
|
+
File.file?(temp_path.to_s)
|
242
|
+
end
|
243
|
+
|
244
|
+
# nil placeholder in case this field is used in a form.
|
245
|
+
def uploaded_data() nil; end
|
246
|
+
|
247
|
+
# This method handles the uploaded file object. If you set the field name to uploaded_data, you don't need
|
248
|
+
# any special code in your controller.
|
249
|
+
#
|
250
|
+
# <% form_for :attachment, :html => { :multipart => true } do |f| -%>
|
251
|
+
# <p><%= f.file_field :uploaded_data %></p>
|
252
|
+
# <p><%= submit_tag :Save %>
|
253
|
+
# <% end -%>
|
254
|
+
#
|
255
|
+
# @attachment = Attachment.create! params[:attachment]
|
256
|
+
#
|
257
|
+
# TODO: Allow it to work with Merb tempfiles too.
|
258
|
+
def uploaded_data=(file_data)
|
259
|
+
return nil if file_data.nil? || file_data.size == 0
|
260
|
+
self.content_type = file_data.content_type
|
261
|
+
self.filename = file_data.original_filename if respond_to?(:filename)
|
262
|
+
if file_data.is_a?(StringIO)
|
263
|
+
file_data.rewind
|
264
|
+
self.temp_data = file_data.read
|
265
|
+
else
|
266
|
+
self.temp_path = file_data.path
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
# Gets the latest temp path from the collection of temp paths. While working with an attachment,
|
271
|
+
# multiple Tempfile objects may be created for various processing purposes (resizing, for example).
|
272
|
+
# An array of all the tempfile objects is stored so that the Tempfile instance is held on to until
|
273
|
+
# it's not needed anymore. The collection is cleared after saving the attachment.
|
274
|
+
def temp_path
|
275
|
+
p = temp_paths.first
|
276
|
+
p.respond_to?(:path) ? p.path : p.to_s
|
277
|
+
end
|
278
|
+
|
279
|
+
# Gets an array of the currently used temp paths. Defaults to a copy of #full_filename.
|
280
|
+
def temp_paths
|
281
|
+
@temp_paths ||= (new_record? || !File.exist?(full_filename)) ? [] : [copy_to_temp_file(full_filename)]
|
282
|
+
end
|
283
|
+
|
284
|
+
# Adds a new temp_path to the array. This should take a string or a Tempfile. This class makes no
|
285
|
+
# attempt to remove the files, so Tempfiles should be used. Tempfiles remove themselves when they go out of scope.
|
286
|
+
# You can also use string paths for temporary files, such as those used for uploaded files in a web server.
|
287
|
+
def temp_path=(value)
|
288
|
+
temp_paths.unshift value
|
289
|
+
temp_path
|
290
|
+
end
|
291
|
+
|
292
|
+
# Gets the data from the latest temp file. This will read the file into memory.
|
293
|
+
def temp_data
|
294
|
+
save_attachment? ? File.read(temp_path) : nil
|
295
|
+
end
|
296
|
+
|
297
|
+
# Writes the given data to a Tempfile and adds it to the collection of temp files.
|
298
|
+
def temp_data=(data)
|
299
|
+
self.temp_path = write_to_temp_file data unless data.nil?
|
300
|
+
end
|
301
|
+
|
302
|
+
# Copies the given file to a randomly named Tempfile.
|
303
|
+
def copy_to_temp_file(file)
|
304
|
+
self.class.copy_to_temp_file file, random_tempfile_filename
|
305
|
+
end
|
306
|
+
|
307
|
+
# Writes the given file to a randomly named Tempfile.
|
308
|
+
def write_to_temp_file(data)
|
309
|
+
self.class.write_to_temp_file data, random_tempfile_filename
|
310
|
+
end
|
311
|
+
|
312
|
+
# Stub for creating a temp file from the attachment data. This should be defined in the backend module.
|
313
|
+
def create_temp_file() end
|
314
|
+
|
315
|
+
# Allows you to work with a processed representation (RMagick, ImageScience, etc) of the attachment in a block.
|
316
|
+
#
|
317
|
+
# @attachment.with_image do |img|
|
318
|
+
# self.data = img.thumbnail(100, 100).to_blob
|
319
|
+
# end
|
320
|
+
#
|
321
|
+
def with_image(&block)
|
322
|
+
self.class.with_image(temp_path, &block)
|
323
|
+
end
|
324
|
+
|
325
|
+
protected
|
326
|
+
# Generates a unique filename for a Tempfile.
|
327
|
+
def random_tempfile_filename
|
328
|
+
"#{rand Time.now.to_i}#{filename || 'attachment'}"
|
329
|
+
end
|
330
|
+
|
331
|
+
def sanitize_filename(filename)
|
332
|
+
returning filename.strip do |name|
|
333
|
+
# NOTE: File.basename doesn't work right with Windows paths on Unix
|
334
|
+
# get only the filename, not the whole path
|
335
|
+
name.gsub! /^.*(\\|\/)/, ''
|
336
|
+
|
337
|
+
# Finally, replace all non alphanumeric, underscore or periods with underscore
|
338
|
+
name.gsub! /[^\w\.\-]/, '_'
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
# before_validation callback.
|
343
|
+
def set_size_from_temp_path
|
344
|
+
self.size = File.size(temp_path) if save_attachment?
|
345
|
+
end
|
346
|
+
|
347
|
+
# validates the size and content_type attributes according to the current model's options
|
348
|
+
def attachment_attributes_valid?
|
349
|
+
[:size, :content_type].each do |attr_name|
|
350
|
+
enum = attachment_options[attr_name]
|
351
|
+
errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
# Initializes a new thumbnail with the given suffix.
|
356
|
+
def find_or_initialize_thumbnail(file_name_suffix)
|
357
|
+
respond_to?(:parent_id) ?
|
358
|
+
thumbnail_class.find_or_initialize_by_thumbnail_and_parent_id(file_name_suffix.to_s, id) :
|
359
|
+
thumbnail_class.find_or_initialize_by_thumbnail(file_name_suffix.to_s)
|
360
|
+
end
|
361
|
+
|
362
|
+
# Stub for a #process_attachment method in a processor
|
363
|
+
def process_attachment
|
364
|
+
@saved_attachment = save_attachment?
|
365
|
+
end
|
366
|
+
|
367
|
+
# Cleans up after processing. Thumbnails are created, the attachment is stored to the backend, and the temp_paths are cleared.
|
368
|
+
def after_process_attachment
|
369
|
+
if @saved_attachment
|
370
|
+
if respond_to?(:process_attachment_with_processing) && thumbnailable? && !attachment_options[:thumbnails].blank? && parent_id.nil?
|
371
|
+
temp_file = temp_path || create_temp_file
|
372
|
+
attachment_options[:thumbnails].each { |suffix, size| create_or_update_thumbnail(temp_file, suffix, *size) }
|
373
|
+
end
|
374
|
+
save_to_storage
|
375
|
+
@temp_paths.clear
|
376
|
+
@saved_attachment = nil
|
377
|
+
callback :after_attachment_saved
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
# Resizes the given processed img object with either the attachment resize options or the thumbnail resize options.
|
382
|
+
def resize_image_or_thumbnail!(img)
|
383
|
+
if (!respond_to?(:parent_id) || parent_id.nil?) && attachment_options[:resize_to] # parent image
|
384
|
+
resize_image(img, attachment_options[:resize_to])
|
385
|
+
elsif thumbnail_resize_options # thumbnail
|
386
|
+
resize_image(img, thumbnail_resize_options)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
# Yanked from ActiveRecord::Callbacks, modified so I can pass args to the callbacks besides self.
|
391
|
+
# Only accept blocks, however
|
392
|
+
def callback_with_args(method, arg = self)
|
393
|
+
notify(method)
|
394
|
+
|
395
|
+
result = nil
|
396
|
+
callbacks_for(method).each do |callback|
|
397
|
+
result = callback.call(self, arg)
|
398
|
+
return false if result == false
|
399
|
+
end
|
400
|
+
|
401
|
+
return result
|
402
|
+
end
|
403
|
+
|
404
|
+
# Removes the thumbnails for the attachment, if it has any
|
405
|
+
def destroy_thumbnails
|
406
|
+
self.thumbnails.each { |thumbnail| thumbnail.destroy } if thumbnailable?
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|