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,89 @@
|
|
1
|
+
Visit http://cardboardrocket.com/pages/paginating_find for more documentation.
|
2
|
+
|
3
|
+
This plugin makes it easy to page through your model instances by enhancing the default ActiveRecord::Base#find method. In general, you can expect pagination to work with the standard #find options, including :conditions, :group, :order, :limit, and :include. To activate paging, just specify the :page option. You may also provide additional paging options that will control the behavior of the enumerator returned by the #find method. The following options are supported:
|
4
|
+
|
5
|
+
:size => Number of records in each page of results. Defaults to the total
|
6
|
+
record count or 10, whichever is smaller.
|
7
|
+
:current => The current page. Optional, defaults to the first page: 1.
|
8
|
+
:first => The first page. Optional, defaults to the current page.
|
9
|
+
:auto => Automatically load the next page during invocation of #each. Defaults to false.
|
10
|
+
:count => Number of records used to determine #page_count. Specifying this
|
11
|
+
option prevents the plugin from running a count query, which may
|
12
|
+
be helpful if the table to be queried is very large.
|
13
|
+
|
14
|
+
Note: if :page is specified, then the :offset option is not supported and an Exception to that effect will be raised.
|
15
|
+
|
16
|
+
Some handy methods you can call on the result returned by #find, when paging is enabled:
|
17
|
+
|
18
|
+
#each => Iterate over the results
|
19
|
+
#size => Number of records on all pages combined (total size)
|
20
|
+
#page_size => Number of records on each page
|
21
|
+
#page_count => Number of pages
|
22
|
+
#empty? => Are there any results?
|
23
|
+
#to_a => Create an array of the records on the current page, or all pages if :auto => true
|
24
|
+
#move!(num) => Move to a specific page number
|
25
|
+
#page_exists?(num) => Does this page number exist?
|
26
|
+
#first_page! => Move to the first page
|
27
|
+
#first_page => Page number of the first page
|
28
|
+
#last_page! => Move to the last page
|
29
|
+
#last_page => Page number of the last page
|
30
|
+
#next_page? => Is there another page available?
|
31
|
+
#next_page! => Move to the next page, if one exists
|
32
|
+
#next_page => Page number of the next page
|
33
|
+
#previous_page? => Does a previous page exist?
|
34
|
+
#previous_page! => Move to the previous page, if one exists
|
35
|
+
#previous_page => Page number of the previous pages
|
36
|
+
#first_item => The index of the first item on the page
|
37
|
+
#last_item => The index of the last item on the page
|
38
|
+
#load_page => Reload the current page
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
- Simple Example -------------------------------------------------------
|
43
|
+
|
44
|
+
# Get the first page of 'new' Cogs. Each page contains
|
45
|
+
# 10 cogs, and no more than 100 cogs will be returned.
|
46
|
+
cogs = Cog.find(:all,
|
47
|
+
:page,
|
48
|
+
:conditions => ["category = 'new'"],
|
49
|
+
:limit => 100)
|
50
|
+
|
51
|
+
# Print the name of each cog on the 1st page. Calling #each
|
52
|
+
# more than once will cause the 1st page to be printed for
|
53
|
+
# each invocation.
|
54
|
+
cogs.each { |cog| puts cog.name }
|
55
|
+
|
56
|
+
# The next_page! method must be used to move to the 2nd page.
|
57
|
+
cogs.next_page!
|
58
|
+
|
59
|
+
# Print the name of each cog on the 2nd page
|
60
|
+
cogs.each { |cog| puts cog.name }
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
- Scope Example -------------------------------------------------------
|
67
|
+
|
68
|
+
# Get the second page of 'new' Cogs, using the #with_scope method.
|
69
|
+
# Each page contains 15 cogs, and no more than 100 cogs will be returned.
|
70
|
+
Cog.with_scope(:find => {:conditions => "category = 'new'", :include => :widget}) do
|
71
|
+
cogs = Cog.find(:all,
|
72
|
+
:limit => 100,
|
73
|
+
:page => { :start => 1,
|
74
|
+
:current => 2,
|
75
|
+
:size => 15 })
|
76
|
+
end
|
77
|
+
|
78
|
+
# Print the name of each cog on the 2nd page.
|
79
|
+
cogs.each { |cog| puts cog.name }
|
80
|
+
|
81
|
+
# Move to the 3rd page of cogs. The options specified by
|
82
|
+
# with_scope apply, even though a new page is loaded outside
|
83
|
+
# the with_scope block.
|
84
|
+
cogs.next_page!
|
85
|
+
|
86
|
+
|
87
|
+
... more examples soon.
|
88
|
+
|
89
|
+
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'paging_enumerator'
|
2
|
+
require 'paging_helper'
|
3
|
+
|
4
|
+
module PaginatingFind
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
base.class_eval do
|
9
|
+
class << self
|
10
|
+
VALID_FIND_OPTIONS << :page
|
11
|
+
alias_method_chain :find, :pagination
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
DEFAULT_PAGE_SIZE = 10
|
18
|
+
VALID_COUNT_OPTIONS = [:select, :conditions, :joins, :distinct, :include, :having, :group]
|
19
|
+
|
20
|
+
# Enhancements to Base find method to support record paging. The :page option
|
21
|
+
# is used to specify additional paging options. The supported :page options are:
|
22
|
+
#
|
23
|
+
# * <tt>:size</tt>: Number of records in each page of results. Defaults to 1/10
|
24
|
+
# the total size if total size > 10, otherwise defaults to 1.
|
25
|
+
# * <tt>:current</tt>: The current page. Optional, defaults to the first page: 1.
|
26
|
+
# * <tt>:first</tt>: The first page. Optional, defaults to the first page: 1.
|
27
|
+
# * <tt>:auto</tt>: Automatically load the next page during invocation of #each. Defaults to false.
|
28
|
+
# * <tt>:count</tt>: The total record count used to determine the number of pages
|
29
|
+
# to be loaded. Optional. If not specified, the plugin will
|
30
|
+
# use the AR::Calculations#count method.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
# If :page is specified, then the enumerable returned will automatically page the
|
34
|
+
# result set for this find operation according to the additional options. Note that
|
35
|
+
# if you specify :page, you are getting back and Enumerable, not an Array.
|
36
|
+
#
|
37
|
+
# You can, however, invoke the #to_a method on the Enumerable. If you’ve got
|
38
|
+
# :auto paging turned off (default), then you’ll get back just the items on
|
39
|
+
# the current page. Otherwise, you’ll get all items on all pages.
|
40
|
+
#
|
41
|
+
# Heres a sample of how the paging options might be specified:
|
42
|
+
#
|
43
|
+
# cogs = Cog.find(:all,
|
44
|
+
# :limit => 3000,
|
45
|
+
# :page => {:size => 10,
|
46
|
+
# :first => 1,
|
47
|
+
# :current => 1,
|
48
|
+
# :auto => true})
|
49
|
+
#
|
50
|
+
def find_with_pagination(*args)
|
51
|
+
options = if args.respond_to?(:extract_options!)
|
52
|
+
args.extract_options!
|
53
|
+
else
|
54
|
+
extract_options_from_args!(args)
|
55
|
+
end
|
56
|
+
page_options = options.delete(:page) || (args.delete(:page) ? {} : nil)
|
57
|
+
if page_options
|
58
|
+
# The :page option was specified, so page the query results
|
59
|
+
raise ArgumentError, ":offset option is not supported when paging results" if options[:offset]
|
60
|
+
current = page_options[:current] && page_options[:current].to_i > 0 ? page_options[:current] : 1
|
61
|
+
first = page_options[:first] || 1
|
62
|
+
auto = page_options[:auto] || false
|
63
|
+
|
64
|
+
# Specify :count to prevent a count query.
|
65
|
+
unless (count = page_options.delete(:count))
|
66
|
+
original_table_name = self.table_name
|
67
|
+
count = count(collect_count_options(options))
|
68
|
+
count = count.length if options[:group]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Total size is either count or limit, whichever is less
|
72
|
+
limit = options.delete(:limit)
|
73
|
+
total_size = limit ? [limit, count].min : count
|
74
|
+
|
75
|
+
# If :size isn't specified, then use the lesser of the total_size
|
76
|
+
# and the default page size
|
77
|
+
page_size = page_options[:size] || [total_size, DEFAULT_PAGE_SIZE].min
|
78
|
+
|
79
|
+
# Cache the :with_scope options so that they can be reused
|
80
|
+
# during enumerator callback invocation
|
81
|
+
cached_scoped_methods = self.scoped_methods.last
|
82
|
+
|
83
|
+
PagingEnumerator.new(page_size, total_size, auto, current, first) do |page|
|
84
|
+
args.pop if args.last.is_a?(Hash)
|
85
|
+
|
86
|
+
# Set appropriate :offset and :limit options for this page
|
87
|
+
options[:offset] = (page - 1) * page_size
|
88
|
+
options[:limit] = (page_size) < total_size ? page_size : total_size
|
89
|
+
|
90
|
+
if cached_scoped_methods
|
91
|
+
# :with_scope options were specified, so
|
92
|
+
# the with_scope method must be invoked
|
93
|
+
self.with_scope(cached_scoped_methods) do
|
94
|
+
find_without_pagination(*(args << options))
|
95
|
+
end
|
96
|
+
else
|
97
|
+
find_without_pagination(*(args << options))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
else
|
101
|
+
# The :page option was not specified, so invoke the
|
102
|
+
# usual AR::Base#find method
|
103
|
+
find_without_pagination(*(args << options))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def collect_count_options(options)
|
108
|
+
rtn = {}.merge(options)
|
109
|
+
|
110
|
+
table = options[:from] || table_name
|
111
|
+
|
112
|
+
# If original :select includes the distinct keyword, then
|
113
|
+
# also include it in the count query
|
114
|
+
if rtn[:select].to_s.index(/\s*DISTINCT\s+/i) != nil
|
115
|
+
rtn[:select] = "DISTINCT #{table}.#{primary_key}"
|
116
|
+
else
|
117
|
+
rtn[:select] = "#{table}.#{primary_key}"
|
118
|
+
end
|
119
|
+
|
120
|
+
# AR::Base#find does not support :having, but some folks tack it on to the :group option,
|
121
|
+
# and it is supported by calculations, so we'll support it here.
|
122
|
+
scope = scope(:find)
|
123
|
+
group = options[:group] || (scope ? scope[:group] : nil)
|
124
|
+
if group
|
125
|
+
having = group.split(/\s+HAVING\s+/i)
|
126
|
+
if having.size == 2 # 'HAVING' was tacked on to the :group option.
|
127
|
+
rtn[:group] = having[0]
|
128
|
+
rtn[:having] = having[1]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Eliminate count options like :order, :limit, :offset.
|
133
|
+
rtn.delete_if { |k, v| !VALID_COUNT_OPTIONS.include?(k.to_sym) }
|
134
|
+
rtn
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# An enumerable that iterates through "pages" of objects.
|
2
|
+
# A page is loaded by the block callback provided to the initializer.
|
3
|
+
#
|
4
|
+
# pe = PagingEnumerable.new(25, 593) do |current_page|
|
5
|
+
# # return all results for the current_page!
|
6
|
+
# end
|
7
|
+
# pe.each { |result| puts result }
|
8
|
+
#
|
9
|
+
# Specify auto = true if you want the enumerator
|
10
|
+
# to iterate over all items rather than just those on the
|
11
|
+
# current page. If this option is enabled you may skip to the
|
12
|
+
# next page by invoking the next_page! method, or you may skip
|
13
|
+
# to any page using the move!(page) method.
|
14
|
+
#
|
15
|
+
# The callback may return an Enumerable containing the results
|
16
|
+
# for the current page, or an object if only one result is
|
17
|
+
# available for the current page.
|
18
|
+
#
|
19
|
+
# Author:: Alex Wolfe
|
20
|
+
# Copyright:: Copyright (c) 2006 Alex Wolfe
|
21
|
+
# License:: Distributes under the same terms as Ruby
|
22
|
+
# More Info:: http://cardboardrocket.com
|
23
|
+
#
|
24
|
+
class PagingEnumerator
|
25
|
+
include Enumerable
|
26
|
+
|
27
|
+
attr_accessor :results, :page, :first_page, :last_page, :stop_page, :page_size, :page_count, :size, :auto
|
28
|
+
|
29
|
+
def initialize(page_size, size, auto = false, page = 1, first_page=page, &callback)
|
30
|
+
self.page = page.to_i
|
31
|
+
self.page_size = page_size.to_i
|
32
|
+
self.size = size.to_i
|
33
|
+
self.auto = auto
|
34
|
+
self.first_page = first_page.to_i
|
35
|
+
self.last_page = page_count.to_i
|
36
|
+
self.stop_page = auto ? last_page : self.page
|
37
|
+
@callback = callback
|
38
|
+
end
|
39
|
+
|
40
|
+
def each
|
41
|
+
early_termination = false
|
42
|
+
while page <= stop_page && !early_termination
|
43
|
+
load_page
|
44
|
+
if results.respond_to?(:each)
|
45
|
+
results.each { |r| yield r }
|
46
|
+
else
|
47
|
+
yield results
|
48
|
+
end
|
49
|
+
self.page = self.page + 1
|
50
|
+
if (results.respond_to?(:size) && results.size < page_size)
|
51
|
+
early_termination = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# force usage of next_page method
|
55
|
+
self.page = self.page - 1
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def move!(page)
|
60
|
+
raise ArgumentError, "manually moving pages is only supported when auto paging is disabled" if auto
|
61
|
+
if page < self.first_page
|
62
|
+
self.page = first_page
|
63
|
+
elsif page > self.last_page
|
64
|
+
self.page = last_page
|
65
|
+
else
|
66
|
+
self.page = page
|
67
|
+
end
|
68
|
+
self.stop_page = page
|
69
|
+
end
|
70
|
+
|
71
|
+
def page_exists?(page)
|
72
|
+
page >= self.first_page && page <= self.last_page
|
73
|
+
end
|
74
|
+
|
75
|
+
def first_page!
|
76
|
+
move!(first_page)
|
77
|
+
end
|
78
|
+
|
79
|
+
def last_page!
|
80
|
+
move!(last_page)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Move to the next page if auto paging is disabled.
|
84
|
+
def next_page!
|
85
|
+
move!(next_page) if next_page?
|
86
|
+
end
|
87
|
+
|
88
|
+
def next_page?
|
89
|
+
next_page ? true : false
|
90
|
+
end
|
91
|
+
|
92
|
+
def next_page
|
93
|
+
page >= page_count ? nil : page + 1
|
94
|
+
end
|
95
|
+
|
96
|
+
# Move to the previous page if auto paging is disabled.
|
97
|
+
def previous_page!
|
98
|
+
move!(previous_page) if previous_page?
|
99
|
+
end
|
100
|
+
|
101
|
+
def previous_page?
|
102
|
+
previous_page ? true : false
|
103
|
+
end
|
104
|
+
|
105
|
+
def previous_page
|
106
|
+
page == first_page ? nil : page - 1
|
107
|
+
end
|
108
|
+
|
109
|
+
def first_item
|
110
|
+
((self.page-1) * self.page_size) + 1
|
111
|
+
end
|
112
|
+
|
113
|
+
def last_item
|
114
|
+
[self.page * self.page_size, self.size].min
|
115
|
+
end
|
116
|
+
|
117
|
+
# How many pages are available?
|
118
|
+
def page_count
|
119
|
+
@page_count ||= (empty? or page_size == 0) ? 1 : (q, r = size.divmod(page_size); r == 0 ? q : q + 1)
|
120
|
+
end
|
121
|
+
|
122
|
+
def empty?
|
123
|
+
size == 0
|
124
|
+
end
|
125
|
+
|
126
|
+
# Get the results as an array. If the enumerator is not using :auto, this array
|
127
|
+
# will contain just the current page. Otherwise, this method will iterate all pages
|
128
|
+
# and return them as an array.
|
129
|
+
def to_a
|
130
|
+
array = []
|
131
|
+
each { |e| array << e }
|
132
|
+
array
|
133
|
+
end
|
134
|
+
|
135
|
+
def to_xml(options = {})
|
136
|
+
to_a.to_xml(options)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Load the next page using the callback
|
140
|
+
def load_page
|
141
|
+
raise "Cannot load page because callback is not available. Has this enumerator been serialized?" unless @callback
|
142
|
+
self.results = @callback.call(page)
|
143
|
+
end
|
144
|
+
|
145
|
+
def _dump(depth)
|
146
|
+
load_page
|
147
|
+
Marshal.dump([results, page_size, size, false, page, first_page])
|
148
|
+
end
|
149
|
+
|
150
|
+
def PagingEnumerator._load(str)
|
151
|
+
params = Marshal.load(str)
|
152
|
+
results = params.shift
|
153
|
+
e = PagingEnumerator.new(*params)
|
154
|
+
e.results = results
|
155
|
+
e
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module PaginatingFind
|
2
|
+
module Helpers
|
3
|
+
DEFAULT_OPTIONS = { :name => :page, :window_size => 2,
|
4
|
+
:always_show_anchors => true, :link_to_current_page => false,
|
5
|
+
:params => {} }
|
6
|
+
|
7
|
+
def paginating_links(paginator, options = {}, html_options = {})
|
8
|
+
name = options[:name] || DEFAULT_OPTIONS[:name]
|
9
|
+
params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
|
10
|
+
|
11
|
+
paginating_links_each(paginator, options) do |n|
|
12
|
+
params[name] = n
|
13
|
+
link_to(n, params, html_options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def paginating_links_each(paginator, options = {})
|
18
|
+
options = DEFAULT_OPTIONS.merge(options)
|
19
|
+
|
20
|
+
window = ((paginator.page - options[:window_size] + 1)..(paginator.page + options[:window_size] - 1)).select {|w| w >= paginator.first_page && w <= paginator.last_page }
|
21
|
+
|
22
|
+
html = ''
|
23
|
+
|
24
|
+
if options[:always_show_anchors] && !window.include?(paginator.first_page)
|
25
|
+
html << yield(paginator.first_page)
|
26
|
+
html << ' ... ' unless window.first - 1 == paginator.first_page
|
27
|
+
html << ' '
|
28
|
+
end
|
29
|
+
|
30
|
+
window.each do |p|
|
31
|
+
if paginator.page == p && !options[:link_to_current_page]
|
32
|
+
html << p.to_s
|
33
|
+
else
|
34
|
+
html << yield(p)
|
35
|
+
end
|
36
|
+
html << ' '
|
37
|
+
end
|
38
|
+
|
39
|
+
if options[:always_show_anchors] && !window.include?(paginator.last_page)
|
40
|
+
html << ' ... ' unless window.last + 1 == paginator.last_page
|
41
|
+
html << yield(paginator.last_page)
|
42
|
+
end
|
43
|
+
|
44
|
+
html
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/rails'
|