opensteam 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +78 -0
- data/LICENSE +345 -0
- data/{README.txt → README.rdoc} +20 -17
- data/Rakefile +40 -0
- data/generators/opensteam/opensteam_generator.rb +95 -194
- data/generators/opensteam/templates/{controllers/administration → app/controllers/admin}/inventories_controller.rb +4 -4
- data/generators/opensteam/templates/app/controllers/admin/invoices_controller.rb +106 -0
- data/generators/opensteam/templates/app/controllers/admin/orders_controller.rb +113 -0
- data/generators/opensteam/templates/app/controllers/admin/search_controller.rb +17 -0
- data/generators/opensteam/templates/app/controllers/admin/shipments_controller.rb +106 -0
- data/generators/opensteam/templates/app/controllers/admin/users_controller.rb +99 -0
- data/generators/opensteam/templates/app/controllers/admin_controller.rb +40 -0
- data/generators/opensteam/templates/app/controllers/cart_controller.rb +94 -0
- data/generators/opensteam/templates/app/controllers/checkout_controller.rb +139 -0
- data/generators/opensteam/templates/app/controllers/profile/infos_controller.rb +52 -0
- data/generators/opensteam/templates/app/controllers/profile/orders_controller.rb +105 -0
- data/generators/opensteam/templates/app/controllers/profile_controller.rb +37 -0
- data/generators/opensteam/templates/app/controllers/searches_controller.rb +23 -0
- data/generators/opensteam/templates/app/controllers/user_sessions_controller.rb +38 -0
- data/generators/opensteam/templates/app/controllers/users_controller.rb +40 -0
- data/generators/opensteam/templates/{controllers → app/controllers}/webshop_controller.rb +35 -13
- data/generators/opensteam/templates/app/helpers/admin_helper.rb +40 -0
- data/generators/opensteam/templates/app/helpers/users_helper.rb +53 -0
- data/generators/opensteam/templates/app/helpers/webshop_helper.rb +91 -0
- data/generators/opensteam/templates/app/models/search.rb +36 -0
- data/generators/opensteam/templates/{views/administration → app/views/admin}/_address.html.erb +0 -0
- data/generators/opensteam/templates/app/views/admin/_nav.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/catalog.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/index.html.erb +21 -0
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/edit.html.erb +10 -9
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/index.html.erb +3 -3
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/new.html.erb +3 -3
- data/generators/opensteam/templates/app/views/admin/inventories/show.html.erb +46 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoices.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/invoices/index.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/invoices/new.html.erb +54 -0
- data/generators/opensteam/templates/app/views/admin/invoices/show.html.erb +55 -0
- data/generators/opensteam/templates/app/views/admin/orders/_event.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order_item.html.erb +10 -0
- data/generators/opensteam/templates/app/views/admin/orders/_orders.html.erb +19 -0
- data/generators/opensteam/templates/app/views/admin/orders/index.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/orders/livesearch.rjs +6 -0
- data/generators/opensteam/templates/app/views/admin/orders/show.html.erb +58 -0
- data/generators/opensteam/templates/app/views/admin/products.html.erb +8 -0
- data/generators/opensteam/templates/app/views/admin/properties.html.erb +7 -0
- data/generators/opensteam/templates/app/views/admin/sales.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/shipments/_shipment.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/shipments/_shipments.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/shipments/index.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/shipments/new.html.erb +51 -0
- data/generators/opensteam/templates/app/views/admin/shipments/show.html.erb +55 -0
- data/generators/opensteam/templates/app/views/admin/users/_admins.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/users/_admins_header.html.erb +10 -0
- data/generators/opensteam/templates/app/views/admin/users/_customer.html.erb +32 -0
- data/generators/opensteam/templates/app/views/admin/users/_customers.html.erb +29 -0
- data/generators/opensteam/templates/app/views/admin/users/_customers_header.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/users/_user_fields.html.erb +9 -0
- data/generators/opensteam/templates/app/views/admin/users/_users.html.erb +29 -0
- data/generators/opensteam/templates/app/views/admin/users/_users_header.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/users/edit.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/users/index.html.erb +7 -0
- data/generators/opensteam/templates/app/views/admin/users/new.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/users/show.html.erb +34 -0
- data/generators/opensteam/templates/app/views/admin/users.html.erb +4 -0
- data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_admin.erb +0 -0
- data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_customer.erb +0 -0
- data/generators/opensteam/templates/app/views/cart/_cart.html.erb +8 -0
- data/generators/opensteam/templates/{views/webshop → app/views/cart}/_cart_content.html.erb +7 -10
- data/generators/opensteam/templates/app/views/cart/index.html.erb +5 -0
- data/generators/opensteam/templates/app/views/cart/update.rjs +1 -0
- data/generators/opensteam/templates/app/views/checkout/intro.html.erb +18 -0
- data/generators/opensteam/templates/{views → app/views}/checkout/outro.html.erb +0 -1
- data/generators/opensteam/templates/{views → app/views}/checkout/payment.html.erb +0 -0
- data/generators/opensteam/templates/app/views/checkout/shipping.html.erb +45 -0
- data/generators/opensteam/templates/app/views/checkout/show_cart.html.erb +13 -0
- data/generators/opensteam/templates/{views → app/views}/checkout/update_cart_content.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/common/_cart.html.erb +2 -2
- data/generators/opensteam/templates/{views → app/views}/common/_cart_content.html.erb +1 -1
- data/generators/opensteam/templates/app/views/common/_footer.html.erb +1 -0
- data/generators/opensteam/templates/app/views/common/_header.html.erb +4 -0
- data/generators/opensteam/templates/app/views/common/_header_flash.html.erb +3 -0
- data/generators/opensteam/templates/app/views/common/_signup_fields.html.erb +16 -0
- data/generators/opensteam/templates/app/views/common/_top_links.html.erb +10 -0
- data/generators/opensteam/templates/app/views/layouts/admin.html.erb +45 -0
- data/generators/opensteam/templates/app/views/layouts/profile.html.erb +45 -0
- data/generators/opensteam/templates/app/views/layouts/webshop.html.erb +51 -0
- data/generators/opensteam/templates/app/views/profile/_customer_sidebar.html.erb +12 -0
- data/generators/opensteam/templates/app/views/profile/index.html.erb +11 -0
- data/generators/opensteam/templates/app/views/profile/infos/_customer.html.erb +5 -0
- data/generators/opensteam/templates/app/views/profile/infos/edit.html.erb +25 -0
- data/generators/opensteam/templates/app/views/profile/infos/edit_password.html.erb +26 -0
- data/generators/opensteam/templates/app/views/profile/orders/_order.html.erb +11 -0
- data/generators/opensteam/templates/app/views/profile/orders/_order_item.html.erb +10 -0
- data/generators/opensteam/templates/app/views/profile/orders/_orders.html.erb +19 -0
- data/generators/opensteam/templates/app/views/profile/orders/index.html.erb +14 -0
- data/generators/opensteam/templates/app/views/profile/orders/show.html.erb +48 -0
- data/generators/opensteam/templates/app/views/searches/_search_bar.html.erb +5 -0
- data/generators/opensteam/templates/app/views/searches/new.html.erb +23 -0
- data/generators/opensteam/templates/app/views/searches/show.html.erb +1 -0
- data/generators/opensteam/templates/app/views/user_sessions/new.html.erb +14 -0
- data/generators/opensteam/templates/app/views/users/_user_bar.html.erb +5 -0
- data/generators/opensteam/templates/app/views/users/index.html.erb +27 -0
- data/generators/opensteam/templates/app/views/users/new.html.erb +7 -0
- data/generators/opensteam/templates/app/views/users/show.html.erb +5 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/_inventory_content.html.erb +0 -0
- data/generators/opensteam/templates/app/views/webshop/_nav.html.erb +6 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/add_inventory_to_cart.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/add_to_cart_with_parameters.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/del_item.rjs +0 -0
- data/generators/opensteam/templates/app/views/webshop/index.html.erb +11 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/inventory.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/show.html.erb +15 -15
- data/generators/opensteam/templates/config/initializers/init_states.rb +68 -0
- data/generators/opensteam/templates/{init → config/initializers}/opensteam.rb +6 -0
- data/generators/opensteam/templates/config/initializers/opensteam_model_tables.rb +57 -0
- data/generators/opensteam/templates/db/migrate/20080609095714_create_profiles.rb +14 -0
- data/generators/opensteam/templates/{migrations/create_sessions.rb → db/migrate/20080609095720_create_sessions.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080609095721_create_users.rb +29 -0
- data/generators/opensteam/templates/{migrations/create_addresses.rb → db/migrate/20080609095723_create_addresses.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_customers.rb → db/migrate/20080609095724_create_customers.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080609095725_create_dummy_users.rb +21 -0
- data/generators/opensteam/templates/{migrations/create_inventories.rb → db/migrate/20080609095726_create_inventories.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_inventories_properties.rb → db/migrate/20080609095727_create_inventories_properties.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_order_items.rb → db/migrate/20080609095728_create_order_items.rb} +5 -0
- data/generators/opensteam/templates/db/migrate/20080609095729_create_orders.rb +32 -0
- data/generators/opensteam/templates/{migrations/create_payment_types.rb → db/migrate/20080609095730_create_payment_types.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_properties.rb → db/migrate/20080609095731_create_properties.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080623075613_create_states.rb +13 -0
- data/generators/opensteam/templates/db/migrate/20080624132807_create_searches.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080630114155_create_state_histories.rb +14 -0
- data/generators/opensteam/templates/db/migrate/20080714131513_create_invoices.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080714131650_create_shipments.rb +19 -0
- data/generators/opensteam/templates/lib/authenticated_system.rb +201 -0
- data/generators/opensteam/templates/lib/authentication/by_cookie_token.rb +90 -0
- data/generators/opensteam/templates/lib/authentication/by_password.rb +68 -0
- data/generators/opensteam/templates/lib/authentication.rb +46 -0
- data/generators/opensteam/templates/lib/states/invoice/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/invoice/payment_received.rb +8 -0
- data/generators/opensteam/templates/lib/states/invoice/pending.rb +6 -0
- data/generators/opensteam/templates/lib/states/invoice/waiting_for_payment.rb +5 -0
- data/generators/opensteam/templates/lib/states/order/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/order/pending.rb +19 -0
- data/generators/opensteam/templates/lib/states/order/processing.rb +11 -0
- data/generators/opensteam/templates/lib/states/shipment/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/shipment/pending.rb +5 -0
- data/generators/opensteam/templates/lib/tasks/opensteam.rake +114 -0
- data/generators/opensteam/templates/public/images/athmo_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/bg.jpg +0 -0
- data/generators/opensteam/templates/public/images/cart_big.gif +0 -0
- data/generators/opensteam/templates/public/images/cross.png +0 -0
- data/generators/opensteam/templates/public/images/enter.gif +0 -0
- data/generators/opensteam/templates/public/images/menu_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_logo1.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_petstore_logo1.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_store_logo.jpg +0 -0
- data/generators/opensteam/templates/public/images/os_logo.gif +0 -0
- data/generators/opensteam/templates/public/images/slogan.png +0 -0
- data/generators/opensteam/templates/public/images/tick.png +0 -0
- data/generators/opensteam/templates/public/images/zoom.png +0 -0
- data/generators/opensteam/templates/public/index.html +19 -36
- data/generators/opensteam/templates/public/javascripts/opensteam.js +30 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_newdesign.css +188 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_white.css +168 -0
- data/generators/opensteam/templates/public/stylesheets/webshop.css +0 -1
- data/generators/opensteam/templates/tasks/opensteam.rake +1 -1
- data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories_properties.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/product_animals.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/product_dog_foods.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/properties.yml +0 -0
- data/generators/opensteam_product/opensteam_product_generator.rb +25 -9
- data/generators/opensteam_product/templates/controllers/product_controller.rb +5 -4
- data/generators/opensteam_product/templates/migration.rb +2 -1
- data/generators/opensteam_product/templates/models/product.rb +1 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/_attributes.html.erb +1 -1
- data/generators/opensteam_product/templates/views/{administration → admin}/_get_products.html.erb +0 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/_inventories.html.erb +2 -2
- data/generators/opensteam_product/templates/views/admin/edit.html.erb +13 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/index.html.erb +5 -5
- data/generators/opensteam_product/templates/views/admin/new.html.erb +16 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/show.html.erb +2 -2
- data/generators/opensteam_property/opensteam_property_generator.rb +8 -8
- data/generators/opensteam_property/templates/controllers/property_controller.rb +6 -4
- data/generators/opensteam_property/templates/migration.rb +2 -1
- data/generators/opensteam_property/templates/models/property.rb +1 -0
- data/generators/opensteam_property/templates/views/{administration → admin}/edit.html.erb +3 -3
- data/generators/opensteam_property/templates/views/admin/index.html.erb +24 -0
- data/generators/opensteam_property/templates/views/{administration → admin}/new.html.erb +2 -2
- data/generators/opensteam_property/templates/views/admin/show.html.erb +10 -0
- data/lib/opensteam/base.rb +16 -0
- data/lib/opensteam/cart_base.rb +227 -0
- data/lib/opensteam/checkout.rb +30 -3
- data/lib/opensteam/config.rb +37 -0
- data/lib/opensteam/extension_base.rb +76 -0
- data/lib/opensteam/finder.rb +36 -5
- data/lib/opensteam/helper/configurable_table.rb +228 -0
- data/lib/opensteam/history.rb +56 -0
- data/lib/opensteam/initializer.rb +127 -0
- data/lib/opensteam/inventory_base.rb +24 -1
- data/lib/opensteam/invoice_base.rb +61 -0
- data/lib/opensteam/order_base.rb +105 -14
- data/lib/opensteam/product_base.rb +31 -3
- data/lib/opensteam/property_base.rb +16 -0
- data/lib/opensteam/shipment_base.rb +60 -0
- data/lib/opensteam/shopping_cart.rb +32 -14
- data/lib/opensteam/state_logic.rb +218 -0
- data/lib/opensteam/state_machine.rb +216 -0
- data/lib/opensteam/user_base.rb +115 -131
- data/lib/opensteam/version.rb +17 -1
- data/lib/opensteam.rb +30 -35
- metadata +245 -146
- data/History.txt +0 -0
- data/License.txt +0 -4
- data/Manifest.txt +0 -131
- data/Manifest.txt.bak +0 -132
- data/generators/opensteam/templates/controllers/administration/customers_controller.rb +0 -23
- data/generators/opensteam/templates/controllers/administration/orders_controller.rb +0 -61
- data/generators/opensteam/templates/controllers/administration_controller.rb +0 -80
- data/generators/opensteam/templates/controllers/checkout_controller.rb +0 -142
- data/generators/opensteam/templates/helpers/webshop_helper.rb +0 -29
- data/generators/opensteam/templates/migrations/create_dummy_users.rb +0 -16
- data/generators/opensteam/templates/migrations/create_orders.rb +0 -18
- data/generators/opensteam/templates/migrations/create_users.rb +0 -19
- data/generators/opensteam/templates/models/administration_mailer.rb +0 -18
- data/generators/opensteam/templates/models/inventories_property.rb +0 -10
- data/generators/opensteam/templates/models/inventory.rb +0 -57
- data/generators/opensteam/templates/public/images/rails.png +0 -0
- data/generators/opensteam/templates/views/administration/_nav.html.erb +0 -11
- data/generators/opensteam/templates/views/administration/_update_tree.html.erb +0 -18
- data/generators/opensteam/templates/views/administration/admin_info.html.erb +0 -12
- data/generators/opensteam/templates/views/administration/customers/index.html.erb +0 -27
- data/generators/opensteam/templates/views/administration/customers/show.html.erb +0 -27
- data/generators/opensteam/templates/views/administration/customers.html.erb +0 -44
- data/generators/opensteam/templates/views/administration/index.html.erb +0 -9
- data/generators/opensteam/templates/views/administration/inventories/show.html.erb +0 -45
- data/generators/opensteam/templates/views/administration/login.html.erb +0 -16
- data/generators/opensteam/templates/views/administration/order.html.erb +0 -22
- data/generators/opensteam/templates/views/administration/orders/_order_item.html.erb +0 -22
- data/generators/opensteam/templates/views/administration/orders/index.html.erb +0 -32
- data/generators/opensteam/templates/views/administration/orders/show.html.erb +0 -25
- data/generators/opensteam/templates/views/administration/orders.html.erb +0 -32
- data/generators/opensteam/templates/views/administration/products.html.erb +0 -7
- data/generators/opensteam/templates/views/administration/properties.html.erb +0 -7
- data/generators/opensteam/templates/views/administration/show_order_item.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/signup.html.erb +0 -65
- data/generators/opensteam/templates/views/administration/tree.html.erb +0 -15
- data/generators/opensteam/templates/views/administration/update_products.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/update_properties.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/update_tree.rjs +0 -3
- data/generators/opensteam/templates/views/checkout/intro.html.erb +0 -5
- data/generators/opensteam/templates/views/checkout/shipping.html.erb +0 -39
- data/generators/opensteam/templates/views/checkout/show_cart.html.erb +0 -13
- data/generators/opensteam/templates/views/common/_header.html.erb +0 -15
- data/generators/opensteam/templates/views/layouts/administration.html.erb +0 -29
- data/generators/opensteam/templates/views/layouts/webshop.html.erb +0 -36
- data/generators/opensteam/templates/views/webshop/_cart.html.erb +0 -11
- data/generators/opensteam/templates/views/webshop/_header.html.erb +0 -15
- data/generators/opensteam/templates/views/webshop/index.html.erb +0 -12
- data/generators/opensteam_product/templates/views/administration/edit.html.erb +0 -13
- data/generators/opensteam_product/templates/views/administration/new.html.erb +0 -16
- data/generators/opensteam_property/templates/views/administration/index.html.erb +0 -24
- data/generators/opensteam_property/templates/views/administration/show.html.erb +0 -10
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- coding: mule-utf-8 -*-
|
2
|
+
|
3
|
+
# borrowed from the Restful Authentication Generator
|
4
|
+
# git://github.com/technoweenie/restful-authentication.git
|
5
|
+
|
6
|
+
module Authentication
|
7
|
+
module ByCookieToken
|
8
|
+
# Stuff directives into including module
|
9
|
+
def self.included( recipient )
|
10
|
+
recipient.extend( ModelClassMethods )
|
11
|
+
recipient.class_eval do
|
12
|
+
include ModelInstanceMethods
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Class Methods
|
18
|
+
#
|
19
|
+
module ModelClassMethods
|
20
|
+
end # class methods
|
21
|
+
|
22
|
+
#
|
23
|
+
# Instance Methods
|
24
|
+
#
|
25
|
+
module ModelInstanceMethods
|
26
|
+
def remember_token?
|
27
|
+
(!remember_token.blank?) &&
|
28
|
+
remember_token_expires_at && (Time.now.utc < remember_token_expires_at.utc)
|
29
|
+
end
|
30
|
+
|
31
|
+
# These create and unset the fields required for remembering users between browser closes
|
32
|
+
def remember_me
|
33
|
+
# remember_me_for 2.weeks
|
34
|
+
remember_me_for 1.minutes
|
35
|
+
end
|
36
|
+
|
37
|
+
def remember_me_for(time)
|
38
|
+
remember_me_until time.from_now.utc
|
39
|
+
end
|
40
|
+
|
41
|
+
def remember_me_until(time)
|
42
|
+
self.remember_token_expires_at = time
|
43
|
+
self.remember_token = self.class.make_token
|
44
|
+
save(false)
|
45
|
+
end
|
46
|
+
|
47
|
+
# refresh token (keeping same expires_at) if it exists
|
48
|
+
def refresh_token
|
49
|
+
if remember_token?
|
50
|
+
self.remember_token = self.class.make_token
|
51
|
+
save(false)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Deletes the server-side record of the authentication token. The
|
57
|
+
# client-side (browser cookie) and server-side (this remember_token) must
|
58
|
+
# always be deleted together.
|
59
|
+
#
|
60
|
+
def forget_me
|
61
|
+
self.remember_token_expires_at = nil
|
62
|
+
self.remember_token = nil
|
63
|
+
save(false)
|
64
|
+
end
|
65
|
+
end # instance methods
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
#
|
70
|
+
#
|
71
|
+
module ByCookieTokenController
|
72
|
+
# Stuff directives into including module
|
73
|
+
def self.included( recipient )
|
74
|
+
recipient.extend( ControllerClassMethods )
|
75
|
+
recipient.class_eval do
|
76
|
+
include ControllerInstanceMethods
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Class Methods
|
82
|
+
#
|
83
|
+
module ControllerClassMethods
|
84
|
+
end # class methods
|
85
|
+
|
86
|
+
module ControllerInstanceMethods
|
87
|
+
end # instance methods
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# borrowed from the Restful Authentication Generator
|
2
|
+
# git://github.com/technoweenie/restful-authentication.git
|
3
|
+
|
4
|
+
module Authentication
|
5
|
+
module ByPassword
|
6
|
+
|
7
|
+
# Stuff directives into including module
|
8
|
+
def self.included( recipient )
|
9
|
+
recipient.extend( ModelClassMethods )
|
10
|
+
recipient.class_eval do
|
11
|
+
include ModelInstanceMethods
|
12
|
+
|
13
|
+
# Virtual attribute for the unencrypted password
|
14
|
+
attr_accessor :password
|
15
|
+
validates_presence_of :password, :if => :password_required?
|
16
|
+
validates_presence_of :password_confirmation, :if => :password_required?
|
17
|
+
validates_confirmation_of :password, :if => :password_required?
|
18
|
+
validates_length_of :password, :within => 6..40, :if => :password_required?
|
19
|
+
before_save :encrypt_password
|
20
|
+
end
|
21
|
+
end # #included directives
|
22
|
+
|
23
|
+
#
|
24
|
+
# Class Methods
|
25
|
+
#
|
26
|
+
module ModelClassMethods
|
27
|
+
# This provides a modest increased defense against a dictionary attack if
|
28
|
+
# your db were ever compromised, but will invalidate existing passwords.
|
29
|
+
# See the README and the file config/initializers/site_keys.rb
|
30
|
+
#
|
31
|
+
# It may not be obvious, but if you set REST_AUTH_SITE_KEY to nil and
|
32
|
+
# REST_AUTH_DIGEST_STRETCHES to 1 you'll have backwards compatibility with
|
33
|
+
# older versions of restful-authentication.
|
34
|
+
def password_digest(password, salt)
|
35
|
+
digest = REST_AUTH_SITE_KEY
|
36
|
+
REST_AUTH_DIGEST_STRETCHES.times do
|
37
|
+
digest = secure_digest(digest, salt, password, REST_AUTH_SITE_KEY)
|
38
|
+
end
|
39
|
+
digest
|
40
|
+
end
|
41
|
+
end # class methods
|
42
|
+
|
43
|
+
#
|
44
|
+
# Instance Methods
|
45
|
+
#
|
46
|
+
module ModelInstanceMethods
|
47
|
+
|
48
|
+
# Encrypts the password with the user salt
|
49
|
+
def encrypt(password)
|
50
|
+
self.class.password_digest(password, salt)
|
51
|
+
end
|
52
|
+
|
53
|
+
def authenticated?(password)
|
54
|
+
crypted_password == encrypt(password)
|
55
|
+
end
|
56
|
+
|
57
|
+
# before filter
|
58
|
+
def encrypt_password
|
59
|
+
return if password.blank?
|
60
|
+
self.salt = self.class.make_token if new_record?
|
61
|
+
self.crypted_password = encrypt(password)
|
62
|
+
end
|
63
|
+
def password_required?
|
64
|
+
crypted_password.blank? || !password.blank?
|
65
|
+
end
|
66
|
+
end # instance methods
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# borrowed from the Restful Authentication Generator
|
2
|
+
# git://github.com/technoweenie/restful-authentication.git
|
3
|
+
|
4
|
+
module Authentication
|
5
|
+
unless defined? CONSTANTS_DEFINED
|
6
|
+
# Uncomment to suit
|
7
|
+
RE_LOGIN_OK = /\A\w[\w\.\-_@]+\z/ # ASCII, strict
|
8
|
+
# RE_LOGIN_OK = /\A[[:alnum:]][[:alnum:]\.\-_@]+\z/ # Unicode, strict
|
9
|
+
# RE_LOGIN_OK = /\A[^[:cntrl:]\\<>\/&]*\z/ # Unicode, permissive
|
10
|
+
MSG_LOGIN_BAD = "use only letters, numbers, and .-_@ please."
|
11
|
+
|
12
|
+
RE_NAME_OK = /\A[^[:cntrl:]\\<>\/&]*\z/ # Unicode, permissive
|
13
|
+
MSG_NAME_BAD = "avoid non-printing characters and \\><&/ please."
|
14
|
+
|
15
|
+
# This is purposefully imperfect -- it's just a check for bogus input. See
|
16
|
+
# http://www.regular-expressions.info/email.html
|
17
|
+
RE_EMAIL_NAME = '[\w\.%\+\-]+' # what you actually see in practice
|
18
|
+
#RE_EMAIL_NAME = '0-9A-Z!#\$%\&\'\*\+_/=\?^\-`\{|\}~\.' # technically allowed by RFC-2822
|
19
|
+
RE_DOMAIN_HEAD = '(?:[A-Z0-9\-]+\.)+'
|
20
|
+
RE_DOMAIN_TLD = '(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)'
|
21
|
+
RE_EMAIL_OK = /\A#{RE_EMAIL_NAME}@#{RE_DOMAIN_HEAD}#{RE_DOMAIN_TLD}\z/i
|
22
|
+
MSG_EMAIL_BAD = "should look like an email address."
|
23
|
+
|
24
|
+
CONSTANTS_DEFINED = 'yup' # sorry for the C idiom
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.included( recipient )
|
28
|
+
recipient.extend( ModelClassMethods )
|
29
|
+
recipient.class_eval do
|
30
|
+
include ModelInstanceMethods
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module ModelClassMethods
|
35
|
+
def secure_digest(*args)
|
36
|
+
Digest::SHA1.hexdigest(args.flatten.join('--'))
|
37
|
+
end
|
38
|
+
def make_token
|
39
|
+
secure_digest(Time.now, (1..10).map{ rand.to_s })
|
40
|
+
end
|
41
|
+
end # class methods
|
42
|
+
|
43
|
+
module ModelInstanceMethods
|
44
|
+
end # instance methods
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Opensteam::OrderBase::States::Pending
|
2
|
+
include Opensteam::StateLogic::Mod
|
3
|
+
|
4
|
+
|
5
|
+
include ActionController::UrlWriter
|
6
|
+
include ActionView::Helpers::UrlHelper
|
7
|
+
include ActionController::UrlWriter
|
8
|
+
|
9
|
+
|
10
|
+
def view_link_to_create_shipment
|
11
|
+
{ :controller => "admin/shipments", :action => 'new', :order_id => self.id }
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def view_link_to_create_invoice
|
16
|
+
{ :controller => "admin/invoices", :action => 'new', :order_id => self.id }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
RUBY_PATH = "c:\\ruby\\bin"
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
namespace :opensteam do
|
18
|
+
|
19
|
+
namespace :petstore do
|
20
|
+
|
21
|
+
|
22
|
+
task :create do
|
23
|
+
|
24
|
+
|
25
|
+
# begin
|
26
|
+
# require 'has_many_polymorphs'
|
27
|
+
# rescue LoadError
|
28
|
+
# puts '-' * 80
|
29
|
+
# puts
|
30
|
+
# puts "\tYour are missing the \'has_many_polymorphs' gem.\n\t1Please install it before proceeding"
|
31
|
+
# puts
|
32
|
+
# puts '-' * 80
|
33
|
+
# raise
|
34
|
+
# end
|
35
|
+
|
36
|
+
|
37
|
+
logger "welcome to the OpenSteam 'Petstore' sample application"
|
38
|
+
|
39
|
+
logger "creating opensteam petstore products"
|
40
|
+
|
41
|
+
system "ruby script/generate opensteam_product Animal name:string art:string type:string description:text picture:string"
|
42
|
+
system "ruby script/generate opensteam_product DogFood name:string description:text"
|
43
|
+
|
44
|
+
logger "creating opensteam petstore properties"
|
45
|
+
system "ruby script/generate opensteam_property Weight name:string"
|
46
|
+
system "ruby script/generate opensteam_property DogKind name:string"
|
47
|
+
|
48
|
+
|
49
|
+
%w(dog fish reptile).each do |f|
|
50
|
+
ff = File.open("app/models/#{f}.rb", 'w')
|
51
|
+
ff.puts "require 'animal.rb'\nclass #{f.capitalize} < Animal\nend\n"
|
52
|
+
ff.close
|
53
|
+
end
|
54
|
+
FileUtils.rm 'app/models/animal.rb', :force => true
|
55
|
+
ff = File.open('app/models/animal.rb', 'w' )
|
56
|
+
ff.puts "class Animal < ActiveRecord::Base\n opensteam :product\n\n def self.table_name() \"product_animals\" ; end\nend\n"
|
57
|
+
ff.close
|
58
|
+
|
59
|
+
|
60
|
+
logger "migrating"
|
61
|
+
|
62
|
+
Rake::Task["db:migrate"].invoke
|
63
|
+
|
64
|
+
logger "loading fixtures"
|
65
|
+
|
66
|
+
require 'active_record'
|
67
|
+
require 'active_record/fixtures'
|
68
|
+
ActiveRecord::Base.establish_connection( YAML.load_file("config/database.yml")["#{RAILS_ENV}"] )
|
69
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
70
|
+
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
# incl = "require 'has_many_polymorphs'"
|
76
|
+
# sentinel = "Rails::Initializer.run do |config|"
|
77
|
+
# gsub_file "config/environment.rb", /(#{Regexp.escape(sentinel)})/mi do |match|
|
78
|
+
# "#{incl}\n\n#{match}"
|
79
|
+
# end
|
80
|
+
|
81
|
+
|
82
|
+
incl = <<ANIMAL_CONTR
|
83
|
+
if params[:animal][:type] && ( params[:animal][:type].constantize.superclass == Animal)
|
84
|
+
@animal = params[:animal][:type].classify.constantize.new( params[:animal] )
|
85
|
+
else
|
86
|
+
@animal = Animal.new(params[:animal])
|
87
|
+
end
|
88
|
+
ANIMAL_CONTR
|
89
|
+
|
90
|
+
sentinel = "@animal = Animal.new(params[:animal])"
|
91
|
+
gsub_file "app/controllers/admin/animals_controller.rb", /(#{Regexp.escape(sentinel)})/mi do |match|
|
92
|
+
"#{incl}\n\n"
|
93
|
+
end
|
94
|
+
|
95
|
+
logger "finished ... have fun !!"
|
96
|
+
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
def gsub_file(path, regexp, *args, &block)
|
107
|
+
content = File.read(path).gsub(regexp, *args, &block)
|
108
|
+
File.open(path, 'wb') { |file| file.write(content) }
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def logger(str)
|
113
|
+
puts "\n\t*** #{str} ****\n"
|
114
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<html>
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
6
|
+
<title>openSteam</title>
|
7
7
|
<style type="text/css" media="screen">
|
8
8
|
body {
|
9
9
|
margin: 0;
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
#page {
|
32
32
|
background-color: #f0f0f0;
|
33
|
-
width:
|
33
|
+
width: 750px;
|
34
34
|
margin: 0;
|
35
35
|
margin-left: auto;
|
36
36
|
margin-right: auto;
|
@@ -42,7 +42,7 @@
|
|
42
42
|
border: 3px solid #aaa;
|
43
43
|
border-top: none;
|
44
44
|
padding: 25px;
|
45
|
-
width:
|
45
|
+
width: 500px;
|
46
46
|
}
|
47
47
|
|
48
48
|
#sidebar {
|
@@ -58,18 +58,10 @@
|
|
58
58
|
#header, #about, #getting-started {
|
59
59
|
padding-left: 75px;
|
60
60
|
padding-right: 30px;
|
61
|
-
}
|
62
|
-
|
63
|
-
#header2 {
|
64
|
-
padding-left: 150px;
|
65
|
-
padding-right: 10px;
|
66
61
|
}
|
67
62
|
|
68
63
|
|
69
64
|
#header {
|
70
|
-
background-image: url("images/opensteam_logo_web.jpg");
|
71
|
-
background-repeat: no-repeat;
|
72
|
-
background-position: top left;
|
73
65
|
height: 64px;
|
74
66
|
}
|
75
67
|
#header h1, #header h2 {margin: 0}
|
@@ -219,10 +211,11 @@
|
|
219
211
|
</form>
|
220
212
|
</li>
|
221
213
|
<li>
|
222
|
-
<h3>
|
214
|
+
<h3>openSteam</h3>
|
223
215
|
<ul class="links">
|
224
|
-
|
225
|
-
<li><a href="http://
|
216
|
+
<li><a href="http://www.opensteam.net/">openSteam Homepage</a></li>
|
217
|
+
<li><a href="http://blog.opensteam.net/">openSteam weblog</a></li>
|
218
|
+
<li><a href="http://www.rubyforge.org/projects/opensteam/">@rubyforge</a></li>
|
226
219
|
</ul>
|
227
220
|
</li>
|
228
221
|
|
@@ -231,10 +224,7 @@
|
|
231
224
|
<ul class="links">
|
232
225
|
<li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
|
233
226
|
<li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
|
234
|
-
<li><a href="http://lists.rubyonrails.org/">Mailing lists</a></li>
|
235
|
-
<li><a href="http://wiki.rubyonrails.org/rails/pages/IRC">IRC channel</a></li>
|
236
227
|
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
|
237
|
-
<li><a href="http://dev.rubyonrails.org/">Bug tracker</a></li>
|
238
228
|
</ul>
|
239
229
|
</li>
|
240
230
|
|
@@ -250,15 +240,10 @@
|
|
250
240
|
</div>
|
251
241
|
|
252
242
|
<div id="content">
|
253
|
-
<div id="header">
|
254
|
-
<div id="header2">
|
255
|
-
<h1>Welcome aboard</h1>
|
256
|
-
<h2>You’re riding Ruby on Rails with OpenSteam!</h2>
|
257
|
-
</div>
|
258
|
-
</div>
|
259
|
-
|
260
243
|
<div id="about">
|
261
|
-
|
244
|
+
<a href="/store"><img src="images/opensteam_logo1.jpg" border="0" /></a>
|
245
|
+
<img border="0" src="images/slogan.png" /><br /><br />
|
246
|
+
<a href="rails/info/properties" onclick="about(); return false">About your application’s environment</a>
|
262
247
|
<div id="about-content" style="display: none"></div>
|
263
248
|
</div>
|
264
249
|
|
@@ -266,27 +251,25 @@
|
|
266
251
|
<h1>Getting started</h1>
|
267
252
|
<h2>Here’s how to get rolling:</h2>
|
268
253
|
|
269
|
-
<ol>
|
254
|
+
<ol>
|
270
255
|
<li>
|
271
|
-
<h2>
|
272
|
-
<p>Rails needs to know your login and password.</p>
|
273
|
-
</li>
|
274
|
-
|
275
|
-
<li>
|
276
|
-
<h2>Use <tt>script/generate opensteam_product <Product></tt> to create products</h2>
|
256
|
+
<h2>Use <tt>script/generate opensteam_product</tt> to create your products</h2>
|
277
257
|
<p>To see all available options, run it without parameters.</p>
|
278
258
|
</li>
|
279
|
-
|
280
259
|
<li>
|
281
|
-
<h2>Use <tt>script/generate opensteam_property
|
260
|
+
<h2>Use <tt>script/generate opensteam_property</tt> to create your properties</h2>
|
282
261
|
<p>To see all available options, run it without parameters.</p>
|
283
262
|
</li>
|
284
263
|
|
285
264
|
<li>
|
286
|
-
<h2>
|
287
|
-
<p>
|
265
|
+
<h2>Set up a default route and remove or rename this file</h2>
|
266
|
+
<p>Routes are set up in config/routes.rb.</p>
|
288
267
|
</li>
|
289
268
|
|
269
|
+
<li>
|
270
|
+
<h2>Create your database</h2>
|
271
|
+
<p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
|
272
|
+
</li>
|
290
273
|
</ol>
|
291
274
|
</div>
|
292
275
|
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
function toggle_admin_display(name) {
|
2
|
+
var els = getElementsByClassName("sub_content_box") ;
|
3
|
+
|
4
|
+
for(var i=0;i< els.length ; i++)
|
5
|
+
{
|
6
|
+
els[i].style.display = "none" ;
|
7
|
+
}
|
8
|
+
|
9
|
+
var el = document.getElementById(name) ;
|
10
|
+
if( el.style.display == "none" )
|
11
|
+
{
|
12
|
+
el.style.display = "" ;
|
13
|
+
}
|
14
|
+
else
|
15
|
+
{
|
16
|
+
el.style.display = "none" ;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
function getElementsByClassName(classname, node) {
|
22
|
+
if(!node) node = document.getElementsByTagName("body")[0];
|
23
|
+
var a = [];
|
24
|
+
var re = new RegExp('\\b' + classname + '\\b');
|
25
|
+
var els = node.getElementsByTagName("*");
|
26
|
+
for(var i=0,j=els.length; i<j; i++)
|
27
|
+
if(re.test(els[i].className))a.push(els[i]);
|
28
|
+
return a;
|
29
|
+
}
|
30
|
+
|