trollied 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +294 -0
  4. data/README.rdoc +96 -0
  5. data/Rakefile +55 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/line_items_controller.rb +168 -0
  8. data/app/controllers/notes_controller.rb +121 -0
  9. data/app/controllers/orders_controller.rb +210 -0
  10. data/app/controllers/trolleys_controller.rb +26 -0
  11. data/app/helpers/gets_trollied_helper.rb +31 -0
  12. data/app/helpers/line_items_helper.rb +5 -0
  13. data/app/helpers/orders_helper.rb +184 -0
  14. data/app/models/line_item.rb +14 -0
  15. data/app/models/note.rb +15 -0
  16. data/app/models/order.rb +29 -0
  17. data/app/models/trolley.rb +51 -0
  18. data/app/views/line_items/_form.html.erb +8 -0
  19. data/app/views/line_items/_line_item.html.erb +12 -0
  20. data/app/views/line_items/new.html.erb +11 -0
  21. data/app/views/notes/_form.html.erb +7 -0
  22. data/app/views/notes/_new.html.erb +14 -0
  23. data/app/views/notes/_note.html.erb +4 -0
  24. data/app/views/notes/index.html.erb +13 -0
  25. data/app/views/notes/new.html.erb +5 -0
  26. data/app/views/orders/_date_pickers.html.erb +15 -0
  27. data/app/views/orders/_order.html.erb +53 -0
  28. data/app/views/orders/index.html.erb +22 -0
  29. data/app/views/orders/show.html.erb +14 -0
  30. data/app/views/trolleys/_orders.html.erb +13 -0
  31. data/app/views/trolleys/show.html.erb +16 -0
  32. data/config/locales/en.yml +115 -0
  33. data/config/routes.rb +8 -0
  34. data/generators/trollied_migrations/USAGE +2 -0
  35. data/generators/trollied_migrations/templates/line_items_migration.rb +16 -0
  36. data/generators/trollied_migrations/templates/notes_migration.rb +15 -0
  37. data/generators/trollied_migrations/templates/orders_migration.rb +15 -0
  38. data/generators/trollied_migrations/templates/trolleys_migration.rb +14 -0
  39. data/generators/trollied_migrations/trollied_migrations_generator.rb +13 -0
  40. data/lib/gets_trollied.rb +38 -0
  41. data/lib/gets_trollied_controller_helpers.rb +29 -0
  42. data/lib/has_trolley.rb +42 -0
  43. data/lib/has_trolley_controller_helpers.rb +43 -0
  44. data/lib/order_status.rb +121 -0
  45. data/lib/trollied.rb +5 -0
  46. data/rails/init.rb +10 -0
  47. data/test/full_2_3_5_app_with_tests/.gitignore +27 -0
  48. data/test/full_2_3_5_app_with_tests/README +1 -0
  49. data/test/full_2_3_5_app_with_tests/Rakefile +10 -0
  50. data/test/full_2_3_5_app_with_tests/app/controllers/application_controller.rb +14 -0
  51. data/test/full_2_3_5_app_with_tests/app/controllers/items_controller.rb +85 -0
  52. data/test/full_2_3_5_app_with_tests/app/controllers/user_controller.rb +2 -0
  53. data/test/full_2_3_5_app_with_tests/app/helpers/application_helper.rb +3 -0
  54. data/test/full_2_3_5_app_with_tests/app/helpers/items_helper.rb +2 -0
  55. data/test/full_2_3_5_app_with_tests/app/helpers/user_helper.rb +2 -0
  56. data/test/full_2_3_5_app_with_tests/app/models/item.rb +4 -0
  57. data/test/full_2_3_5_app_with_tests/app/models/user.rb +3 -0
  58. data/test/full_2_3_5_app_with_tests/app/views/items/edit.html.erb +20 -0
  59. data/test/full_2_3_5_app_with_tests/app/views/items/index.html.erb +22 -0
  60. data/test/full_2_3_5_app_with_tests/app/views/items/new.html.erb +19 -0
  61. data/test/full_2_3_5_app_with_tests/app/views/items/show.html.erb +13 -0
  62. data/test/full_2_3_5_app_with_tests/app/views/layouts/application.html.erb +19 -0
  63. data/test/full_2_3_5_app_with_tests/app/views/layouts/items.html.erb +19 -0
  64. data/test/full_2_3_5_app_with_tests/config/boot.rb +110 -0
  65. data/test/full_2_3_5_app_with_tests/config/database.yml +22 -0
  66. data/test/full_2_3_5_app_with_tests/config/environment.rb +57 -0
  67. data/test/full_2_3_5_app_with_tests/config/environments/development.rb +17 -0
  68. data/test/full_2_3_5_app_with_tests/config/environments/production.rb +28 -0
  69. data/test/full_2_3_5_app_with_tests/config/environments/test.rb +28 -0
  70. data/test/full_2_3_5_app_with_tests/config/initializers/backtrace_silencers.rb +7 -0
  71. data/test/full_2_3_5_app_with_tests/config/initializers/inflections.rb +10 -0
  72. data/test/full_2_3_5_app_with_tests/config/initializers/mime_types.rb +5 -0
  73. data/test/full_2_3_5_app_with_tests/config/initializers/new_rails_defaults.rb +21 -0
  74. data/test/full_2_3_5_app_with_tests/config/initializers/session_store.rb +15 -0
  75. data/test/full_2_3_5_app_with_tests/config/locales/en.yml +4 -0
  76. data/test/full_2_3_5_app_with_tests/config/locales/fr.yml +4 -0
  77. data/test/full_2_3_5_app_with_tests/config/locales/zh.yml +4 -0
  78. data/test/full_2_3_5_app_with_tests/config/locales.yml +5 -0
  79. data/test/full_2_3_5_app_with_tests/config/routes.rb +8 -0
  80. data/test/full_2_3_5_app_with_tests/config.ru +6 -0
  81. data/test/full_2_3_5_app_with_tests/db/migrate/20100407010602_create_items.rb +13 -0
  82. data/test/full_2_3_5_app_with_tests/db/migrate/20110426030509_create_users.rb +13 -0
  83. data/test/full_2_3_5_app_with_tests/db/migrate/20110426033906_create_trolleys.rb +14 -0
  84. data/test/full_2_3_5_app_with_tests/db/migrate/20110426033907_create_orders.rb +15 -0
  85. data/test/full_2_3_5_app_with_tests/db/migrate/20110426033908_create_line_items.rb +16 -0
  86. data/test/full_2_3_5_app_with_tests/db/migrate/20110615234040_create_notes.rb +15 -0
  87. data/test/full_2_3_5_app_with_tests/db/schema.rb +56 -0
  88. data/test/full_2_3_5_app_with_tests/db/seeds.rb +7 -0
  89. data/test/full_2_3_5_app_with_tests/doc/README_FOR_APP +2 -0
  90. data/test/full_2_3_5_app_with_tests/public/404.html +30 -0
  91. data/test/full_2_3_5_app_with_tests/public/422.html +30 -0
  92. data/test/full_2_3_5_app_with_tests/public/500.html +30 -0
  93. data/test/full_2_3_5_app_with_tests/public/favicon.ico +0 -0
  94. data/test/full_2_3_5_app_with_tests/public/images/rails.png +0 -0
  95. data/test/full_2_3_5_app_with_tests/public/index.html +275 -0
  96. data/test/full_2_3_5_app_with_tests/public/javascripts/application.js +2 -0
  97. data/test/full_2_3_5_app_with_tests/public/javascripts/controls.js +963 -0
  98. data/test/full_2_3_5_app_with_tests/public/javascripts/dragdrop.js +973 -0
  99. data/test/full_2_3_5_app_with_tests/public/javascripts/effects.js +1128 -0
  100. data/test/full_2_3_5_app_with_tests/public/javascripts/prototype.js +4320 -0
  101. data/test/full_2_3_5_app_with_tests/public/robots.txt +5 -0
  102. data/test/full_2_3_5_app_with_tests/public/stylesheets/scaffold.css +54 -0
  103. data/test/full_2_3_5_app_with_tests/script/about +4 -0
  104. data/test/full_2_3_5_app_with_tests/script/console +3 -0
  105. data/test/full_2_3_5_app_with_tests/script/dbconsole +3 -0
  106. data/test/full_2_3_5_app_with_tests/script/destroy +3 -0
  107. data/test/full_2_3_5_app_with_tests/script/generate +3 -0
  108. data/test/full_2_3_5_app_with_tests/script/performance/benchmarker +3 -0
  109. data/test/full_2_3_5_app_with_tests/script/performance/profiler +3 -0
  110. data/test/full_2_3_5_app_with_tests/script/plugin +3 -0
  111. data/test/full_2_3_5_app_with_tests/script/runner +3 -0
  112. data/test/full_2_3_5_app_with_tests/script/server +3 -0
  113. data/test/full_2_3_5_app_with_tests/test/factories.rb +22 -0
  114. data/test/full_2_3_5_app_with_tests/test/functional/line_items_controller_test.rb +69 -0
  115. data/test/full_2_3_5_app_with_tests/test/functional/orders_controller_test.rb +75 -0
  116. data/test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb +38 -0
  117. data/test/full_2_3_5_app_with_tests/test/integration/order_test.rb +79 -0
  118. data/test/full_2_3_5_app_with_tests/test/integration/trolley_test.rb +71 -0
  119. data/test/full_2_3_5_app_with_tests/test/performance/browsing_test.rb +9 -0
  120. data/test/full_2_3_5_app_with_tests/test/selenium.rb +83 -0
  121. data/test/full_2_3_5_app_with_tests/test/test_helper.rb +54 -0
  122. data/test/full_2_3_5_app_with_tests/test/unit/gets_trollied_test.rb +29 -0
  123. data/test/full_2_3_5_app_with_tests/test/unit/helpers/gets_trollied_helper_test.rb +75 -0
  124. data/test/full_2_3_5_app_with_tests/test/unit/helpers/orders_helper_test.rb +34 -0
  125. data/test/full_2_3_5_app_with_tests/test/unit/line_item_test.rb +28 -0
  126. data/test/full_2_3_5_app_with_tests/test/unit/note_test.rb +14 -0
  127. data/test/full_2_3_5_app_with_tests/test/unit/order_test.rb +65 -0
  128. data/test/full_2_3_5_app_with_tests/test/unit/trolley_test.rb +80 -0
  129. data/test/full_2_3_5_app_with_tests/tmp/restart.txt +0 -0
  130. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/init.rb +1 -0
  131. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/base.rb +31 -0
  132. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/force_extension.rb +57 -0
  133. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/locale.rb +70 -0
  134. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/pagination.rb +33 -0
  135. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/uuid_token.rb +78 -0
  136. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter.rb +94 -0
  137. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/force_extension_spec.rb +65 -0
  138. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/generation_spec.rb +367 -0
  139. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/pagination_extension_spec.rb +19 -0
  140. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/recognition_spec.rb +76 -0
  141. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/routing_filter_spec.rb +114 -0
  142. data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/spec_helper.rb +108 -0
  143. data/test/helper.rb +10 -0
  144. metadata +345 -0
@@ -0,0 +1,121 @@
1
+ # off the top of my head possible states:
2
+ # current (i.e. user building order)
3
+ # ordered (i.e. user checkout)
4
+ # queued (first phase of user checkout)
5
+ # payment_pending (system) - to be defined in module
6
+ # payment_received (system) - to be defined in module
7
+ # orderd (system)
8
+ # in_process (being prepared by staff)
9
+ # altered (staff altered, awaiting user approval)
10
+ # alteration_approved (user approves staff alteration)
11
+ # cancelled (user or staff)
12
+ # fulfilled (staff)
13
+ # ready_to_be_shipped
14
+ # shipped (staff) - to be defined in module
15
+ # received (user) - to be defined in module
16
+ # completed (system or staff)
17
+ module OrderStatus
18
+ def self.included(klass)
19
+ klass.extend ClassMethods
20
+
21
+ klass.class_eval do
22
+ include Workflow
23
+
24
+ workflow do
25
+ state :current do
26
+ # event :checkout, :transitions_to => :ordered
27
+ event :checkout, :transitions_to => :in_process
28
+ end
29
+
30
+ # anticipating an interim step between checkout
31
+ # and the system queueing the order for fulfillment
32
+ # in the future, other events, such as "pay", "shipping_info_added"
33
+ # might be added here
34
+ # state :ordered do
35
+ # event :queue, :transitions_to => :in_process
36
+ # end
37
+
38
+ state :in_process do
39
+ event :cancel, :transition_to => :cancelled
40
+ event :alter, :transitions_to => :user_review
41
+ event :accept, :transitions_to => :accepted
42
+ event :fulfilled_without_acceptance, :transitions_to => :ready
43
+ end
44
+
45
+ state :user_review do
46
+ event :alteration_approve, :transitions_to => :in_process
47
+ end
48
+
49
+ state :accepted do
50
+ event :fulfilled, :transitions_to => :ready
51
+ event :complete, :transitions_to => :completed
52
+ end
53
+
54
+ state :ready do
55
+ event :finish, :transitions_to => :completed
56
+ end
57
+
58
+ state :cancelled
59
+ state :completed
60
+ end
61
+
62
+ # create a named_scope for each of our declared states
63
+ workflow_spec.state_names.each do |name|
64
+ scope_name = "with_state_#{name}".to_sym
65
+ named_scope scope_name, :conditions => { :workflow_state => name.to_s }
66
+ end
67
+
68
+ # in(state_name)
69
+ named_scope :in, lambda { |*args|
70
+ options = args.last.is_a?(Hash) ? args.pop : Hash.new
71
+ state = args.is_a?(Array) ? args.first : args
72
+
73
+ if state == 'all'
74
+ options
75
+ else
76
+ { :conditions => { :workflow_state => state.to_s }.merge(options) }
77
+ end
78
+ }
79
+
80
+ def state_ok_to_delete_line_item?
81
+ return false if %w(user_review cancelled completed ready).include?(workflow_state)
82
+ true
83
+ end
84
+
85
+ # write methods named the same as your states
86
+ # to handle things like notifications in your apps
87
+ # when your order moves to that particular state
88
+
89
+
90
+ def new_note(note)
91
+ # trigger transition to user_review state if note is added to ready or in_process order
92
+ alter! if !user_review? && note.user != user
93
+ end
94
+ end
95
+ end
96
+
97
+ module ClassMethods
98
+ # returns a Hash where keys are event name and values are event object
99
+ def workflow_events
100
+ events = workflow_spec.states.values.collect &:events
101
+
102
+ # skip blank values
103
+ events = events.select { |e| e.present? }
104
+
105
+ # flatten
106
+ events_hash = Hash.new
107
+ events.each do |v|
108
+ v.each do |key,value|
109
+ events_hash[key] = value
110
+ end
111
+ end
112
+
113
+ events_hash
114
+ end
115
+
116
+ def workflow_event_names
117
+ workflow_events.keys
118
+ end
119
+ end
120
+ end
121
+
data/lib/trollied.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'gets_trollied'
2
+ require 'gets_trollied_controller_helpers'
3
+ require 'has_trolley'
4
+ require 'has_trolley_controller_helpers'
5
+ require 'order_status'
data/rails/init.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'workflow'
2
+
3
+ ActionController::Base.send(:include, GetsTrolliedControllerHelpers)
4
+ ActionController::Base.send(:include, HasTrolleyControllerHelpers)
5
+ ActionController::Base.send(:helper, GetsTrolliedHelper)
6
+ ActionController::Base.send(:helper, OrdersHelper)
7
+ ActionController::Base.send(:helper, LineItemsHelper)
8
+
9
+ # load our locales
10
+ I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'config', 'locales', '*.{rb,yml}') ]
@@ -0,0 +1,27 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ webrat*
23
+ test.sqlite3
24
+ test/debug.log
25
+ db/development.sqlite3
26
+ db/test.sqlite3
27
+ log/*.log
@@ -0,0 +1 @@
1
+ This is a full Rails app used to test the gem's functionality.
@@ -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'
@@ -0,0 +1,14 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # for now, for testing purposes, just returns a user
9
+ def current_user
10
+ User.first || User.create!(:name => "Franz Ficklestein")
11
+ end
12
+
13
+ helper_method :current_user
14
+ end
@@ -0,0 +1,85 @@
1
+ class ItemsController < ApplicationController
2
+ # GET /items
3
+ # GET /items.xml
4
+ def index
5
+ @items = Item.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @items }
10
+ end
11
+ end
12
+
13
+ # GET /items/1
14
+ # GET /items/1.xml
15
+ def show
16
+ @item = Item.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @item }
21
+ end
22
+ end
23
+
24
+ # GET /items/new
25
+ # GET /items/new.xml
26
+ def new
27
+ @item = Item.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @item }
32
+ end
33
+ end
34
+
35
+ # GET /items/1/edit
36
+ def edit
37
+ @item = Item.find(params[:id])
38
+ end
39
+
40
+ # POST /items
41
+ # POST /items.xml
42
+ def create
43
+ @item = Item.new(params[:item])
44
+
45
+ respond_to do |format|
46
+ if @item.save
47
+ flash[:notice] = 'Item was successfully created.'
48
+ format.html { redirect_to(@item) }
49
+ format.xml { render :xml => @item, :status => :created, :location => @item }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @item.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /items/1
58
+ # PUT /items/1.xml
59
+ def update
60
+ @item = Item.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @item.update_attributes(params[:item])
64
+ flash[:notice] = 'Item was successfully updated.'
65
+ format.html { redirect_to(@item) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @item.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /items/1
75
+ # DELETE /items/1.xml
76
+ def destroy
77
+ @item = Item.find(params[:id])
78
+ @item.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(items_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,2 @@
1
+ class UserController < ApplicationController
2
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module ItemsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UserHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class Item < ActiveRecord::Base
2
+ include GetsTrollied
3
+ set_up_to_get_trollied :described_as => :label
4
+ end
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ include HasTrolley
3
+ end
@@ -0,0 +1,20 @@
1
+ <h1>Editing item</h1>
2
+
3
+ <% form_for(@item) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :label %><br />
8
+ <%= f.text_field :label %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :value %><br />
12
+ <%= f.text_field :value %>
13
+ </p>
14
+ <p>
15
+ <%= f.submit 'Update' %>
16
+ </p>
17
+ <% end %>
18
+
19
+ <%= link_to 'Show', @item %> |
20
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,22 @@
1
+ <h1>Listing items</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Label</th>
6
+ <th>Value</th>
7
+ </tr>
8
+
9
+ <% @items.each do |item| %>
10
+ <tr>
11
+ <td><%=h item.label %></td>
12
+ <td><%=h item.value %></td>
13
+ <td><%= link_to 'Show', item %></td>
14
+ <td><%= link_to 'Edit', edit_item_path(item) %></td>
15
+ <td><%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
19
+
20
+ <br />
21
+
22
+ <%= link_to 'New item', new_item_path %>
@@ -0,0 +1,19 @@
1
+ <h1>New item</h1>
2
+
3
+ <% form_for(@item) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :label %><br />
8
+ <%= f.text_field :label %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :value %><br />
12
+ <%= f.text_field :value %>
13
+ </p>
14
+ <p>
15
+ <%= f.submit 'Create' %>
16
+ </p>
17
+ <% end %>
18
+
19
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,13 @@
1
+ <p>
2
+ <b>Label:</b>
3
+ <%=h @item.label %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Value:</b>
8
+ <%=h @item.value %>
9
+ </p>
10
+
11
+ <%= link_to 'Edit', edit_item_path(@item) %> |
12
+ <%= link_to 'Back', items_path %> |
13
+ <%= in_trolley_status_or_button_to_place_in_trolley(@item) -%>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title><%= @title -%></title>
8
+ <%= yield :add_on_scripts_and_links %>
9
+ <%= stylesheet_link_tag 'scaffold' %>
10
+ <%= javascript_include_tag :defaults %>
11
+ </head>
12
+ <body>
13
+
14
+ <p style="color: green"><%= flash[:notice] %></p>
15
+
16
+ <%= yield %>
17
+
18
+ </body>
19
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Items: <%= controller.action_name %></title>
8
+ <%= yield :add_on_scripts_and_links %>
9
+ <%= stylesheet_link_tag 'scaffold' %>
10
+ <%= javascript_include_tag :defaults %>
11
+ </head>
12
+ <body>
13
+
14
+ <p style="color: green"><%= flash[:notice] %></p>
15
+
16
+ <%= yield %>
17
+
18
+ </body>
19
+ </html>
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ min_version = '1.3.2'
86
+ require 'rubygems'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,57 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ # thanks to http://www.justinball.com/2009/06/16/testing-rails-engine-gems/
10
+ class TestGemLocator < Rails::Plugin::Locator
11
+ def plugins
12
+ Rails::Plugin.new(File.join(File.dirname(__FILE__), *%w(.. .. ..)))
13
+ end
14
+ end
15
+
16
+ Rails::Initializer.run do |config|
17
+ # Settings in config/environments/* take precedence over those specified here.
18
+ # Application configuration should go into files in config/initializers
19
+ # -- all .rb files in that directory are automatically loaded.
20
+
21
+ # Add additional load paths for your own custom dirs
22
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
23
+
24
+ # Specify gems that this application depends on and have them installed with rake gems:install
25
+ # config.gem "bj"
26
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
27
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
28
+ # config.gem "aws-s3", :lib => "aws/s3"
29
+ # this allows us to place locale in URL
30
+ # without messing with the rest of the rails routing mechanism
31
+ # config.gem "routing_filter" # using plugin for the moment
32
+ # config.gem "mongo_translatable"
33
+ config.plugin_locators << TestGemLocator
34
+
35
+ # config.gem "trollied"
36
+ config.gem "will_paginate"
37
+
38
+ # Only load the plugins named here, in the order given (default is alphabetical).
39
+ # :all can be used as a placeholder for all plugins not explicitly named
40
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
41
+
42
+ # Skip frameworks you're not going to use. To use Rails without a database,
43
+ # you must remove the Active Record framework.
44
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
45
+
46
+ # Activate observers that should always be running
47
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
48
+
49
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
50
+ # Run "rake -D time" for a list of tasks for finding time zone names.
51
+ config.time_zone = 'UTC'
52
+
53
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
54
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
55
+ # config.i18n.default_locale = :de
56
+ end
57
+
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.action_controller.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Enable serving of images, stylesheets, and javascripts from an asset server
22
+ # config.action_controller.asset_host = "http://assets.example.com"
23
+
24
+ # Disable delivery errors, bad email addresses will be ignored
25
+ # config.action_mailer.raise_delivery_errors = false
26
+
27
+ # Enable threaded mode
28
+ # config.threadsafe!