amrita2 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +5 -5
- data/Rakefile +85 -0
- data/lib/amrita2/gettext.rb +9 -4
- data/lib/amrita2/template.rb +20 -9
- data/lib/amrita2/testsupport.rb +25 -0
- data/lib/amrita2/version.rb +1 -1
- data/sample/depot/README +160 -0
- data/sample/depot/Rakefile +10 -0
- data/sample/depot/app/views/admin/_form.html.a2 +23 -0
- data/sample/depot/app/views/admin/_form.html.erb +14 -0
- data/sample/depot/app/views/admin/edit.html.a2 +22 -0
- data/sample/depot/app/views/admin/edit.html.erb +10 -0
- data/sample/depot/app/views/admin/list.html.a2 +34 -0
- data/sample/depot/app/views/admin/list.html.erb +37 -0
- data/sample/depot/app/views/admin/new.html.a2 +21 -0
- data/sample/depot/app/views/admin/new.html.erb +9 -0
- data/sample/depot/app/views/admin/show.html.a2 +12 -0
- data/sample/depot/app/views/admin/show.html.erb +13 -0
- data/sample/depot/app/views/info/who_bought.rhtml +14 -0
- data/sample/depot/app/views/info/who_bought.rxml +8 -0
- data/sample/depot/app/views/layouts/admin.a2html +32 -0
- data/sample/depot/app/views/layouts/admin.rhtml +40 -0
- data/sample/depot/app/views/layouts/store.a2html +37 -0
- data/sample/depot/app/views/layouts/store.rhtml +43 -0
- data/sample/depot/app/views/login/add_user.rhtml +33 -0
- data/sample/depot/app/views/login/index.rhtml +9 -0
- data/sample/depot/app/views/login/list_users.rhtml +20 -0
- data/sample/depot/app/views/login/login.rhtml +26 -0
- data/sample/depot/app/views/store/_cart.html.a2 +18 -0
- data/sample/depot/app/views/store/_cart.html.erb +17 -0
- data/sample/depot/app/views/store/_cart_item.html.a2 +16 -0
- data/sample/depot/app/views/store/_cart_item.html.erb +14 -0
- data/sample/depot/app/views/store/add_to_cart.rjs +11 -0
- data/sample/depot/app/views/store/checkout.html.a2 +45 -0
- data/sample/depot/app/views/store/checkout.html.a2.using_macro +32 -0
- data/sample/depot/app/views/store/checkout.html.a2.without_label +37 -0
- data/sample/depot/app/views/store/checkout.html.erb +41 -0
- data/sample/depot/app/views/store/index.html.a2 +19 -0
- data/sample/depot/app/views/store/index.html.erb +22 -0
- data/sample/depot/config/database.yml +24 -0
- data/sample/depot/db/create_database.sql +14 -0
- data/sample/depot/doc/README_FOR_APP +35 -0
- data/sample/depot/lib/tasks/db_schema_version.rake +6 -0
- data/sample/depot/log/development.log +116 -0
- data/sample/depot/log/test.log +347 -0
- data/sample/depot/public/404.html +13 -0
- data/sample/depot/public/500.html +13 -0
- data/sample/depot/public/dispatch.cgi +10 -0
- data/sample/depot/public/dispatch.fcgi +24 -0
- data/sample/depot/public/favicon.ico +0 -0
- data/sample/depot/public/images/auto.jpg +0 -0
- data/sample/depot/public/images/logo.png +0 -0
- data/sample/depot/public/images/rails.png +0 -0
- data/sample/depot/public/images/svn.jpg +0 -0
- data/sample/depot/public/images/utc.jpg +0 -0
- data/sample/depot/public/index.html +282 -0
- data/sample/depot/public/javascripts/application.js +2 -0
- data/sample/depot/public/javascripts/controls.js +832 -0
- data/sample/depot/public/javascripts/dragdrop.js +942 -0
- data/sample/depot/public/javascripts/effects.js +954 -0
- data/sample/depot/public/javascripts/prototype.js +2347 -0
- data/sample/depot/public/robots.txt +1 -0
- data/sample/depot/public/stylesheets/depot.css +227 -0
- data/sample/depot/public/stylesheets/scaffold.css +74 -0
- data/sample/depot/script/about +3 -0
- data/sample/depot/script/breakpointer +3 -0
- data/sample/depot/script/console +3 -0
- data/sample/depot/script/destroy +3 -0
- data/sample/depot/script/generate +3 -0
- data/sample/depot/script/performance/benchmarker +3 -0
- data/sample/depot/script/performance/profiler +3 -0
- data/sample/depot/script/plugin +3 -0
- data/sample/depot/script/process/inspector +3 -0
- data/sample/depot/script/process/reaper +3 -0
- data/sample/depot/script/process/spawner +3 -0
- data/sample/depot/script/runner +3 -0
- data/sample/depot/script/server +3 -0
- data/sample/depot/test/fixtures/line_items.yml +16 -0
- data/sample/depot/test/fixtures/orders.yml +4 -0
- data/sample/depot/test/fixtures/performance/products.yml +8 -0
- data/sample/depot/test/fixtures/products.yml +16 -0
- data/sample/depot/test/fixtures/users.yml +7 -0
- data/sample/depot/vendor/plugins/will_paginate/LICENSE +18 -0
- data/sample/depot/vendor/plugins/will_paginate/README +171 -0
- data/sample/depot/vendor/plugins/will_paginate/Rakefile +27 -0
- data/sample/depot/vendor/plugins/will_paginate/test/console +9 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/replies.yml +34 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
- data/sample/login_engine/README +182 -0
- data/sample/login_engine/Rakefile +27 -0
- data/sample/login_engine/app/views/layouts/user.a2html +20 -0
- data/sample/login_engine/app/views/layouts/user.rhtml +16 -0
- data/sample/login_engine/app/views/user/_edit.a2html +16 -0
- data/sample/login_engine/app/views/user/_edit.rhtml +11 -0
- data/sample/login_engine/app/views/user/_password.a2html +18 -0
- data/sample/login_engine/app/views/user/_password.rhtml +9 -0
- data/sample/login_engine/app/views/user/change_password.a2html +17 -0
- data/sample/login_engine/app/views/user/change_password.rhtml +17 -0
- data/sample/login_engine/app/views/user/edit.a2html +22 -0
- data/sample/login_engine/app/views/user/edit.rhtml +23 -0
- data/sample/login_engine/app/views/user/forgot_password.rhtml +18 -0
- data/sample/login_engine/app/views/user/home.a2html +12 -0
- data/sample/login_engine/app/views/user/home.rhtml +7 -0
- data/sample/login_engine/app/views/user/login.a2html +16 -0
- data/sample/login_engine/app/views/user/login.rhtml +17 -0
- data/sample/login_engine/app/views/user/logout.rhtml +8 -0
- data/sample/login_engine/app/views/user/signup.a2html +14 -0
- data/sample/login_engine/app/views/user/signup.rhtml +17 -0
- data/sample/login_engine/app/views/user_notify/change_password.rhtml +10 -0
- data/sample/login_engine/app/views/user_notify/delete.rhtml +5 -0
- data/sample/login_engine/app/views/user_notify/forgot_password.rhtml +11 -0
- data/sample/login_engine/app/views/user_notify/pending_delete.rhtml +9 -0
- data/sample/login_engine/app/views/user_notify/signup.rhtml +12 -0
- data/sample/login_engine/config/database.yml +18 -0
- data/sample/login_engine/db/create_database.sql +14 -0
- data/sample/login_engine/db/dev.sqlite3 +0 -0
- data/sample/login_engine/db/test.sqlite3 +0 -0
- data/sample/login_engine/doc/README_FOR_APP +2 -0
- data/sample/login_engine/locale/ja/LC_MESSAGES/login_engine.mo +0 -0
- data/sample/login_engine/log/development.log +330 -0
- data/sample/login_engine/log/test.log +19026 -0
- data/sample/login_engine/po/ja/login_engine.po +248 -0
- data/sample/login_engine/po/login_engine.pot +245 -0
- data/sample/login_engine/public/404.html +30 -0
- data/sample/login_engine/public/500.html +30 -0
- data/sample/login_engine/public/dispatch.cgi +10 -0
- data/sample/login_engine/public/dispatch.fcgi +24 -0
- data/sample/login_engine/public/favicon.ico +0 -0
- data/sample/login_engine/public/images/rails.png +0 -0
- data/sample/login_engine/public/index.html +277 -0
- data/sample/login_engine/public/javascripts/application.js +2 -0
- data/sample/login_engine/public/javascripts/controls.js +833 -0
- data/sample/login_engine/public/javascripts/dragdrop.js +942 -0
- data/sample/login_engine/public/javascripts/effects.js +1088 -0
- data/sample/login_engine/public/javascripts/prototype.js +2385 -0
- data/sample/login_engine/public/robots.txt +1 -0
- data/sample/login_engine/public/stylesheets/login_engine.css +81 -0
- data/sample/login_engine/script/about +3 -0
- data/sample/login_engine/script/breakpointer +3 -0
- data/sample/login_engine/script/console +3 -0
- data/sample/login_engine/script/destroy +3 -0
- data/sample/login_engine/script/generate +3 -0
- data/sample/login_engine/script/performance/benchmarker +3 -0
- data/sample/login_engine/script/performance/profiler +3 -0
- data/sample/login_engine/script/plugin +3 -0
- data/sample/login_engine/script/process/inspector +3 -0
- data/sample/login_engine/script/process/reaper +3 -0
- data/sample/login_engine/script/process/spawner +3 -0
- data/sample/login_engine/script/runner +3 -0
- data/sample/login_engine/script/server +3 -0
- data/sample/login_engine/test/fixtures/users.yml +41 -0
- data/specs/erb_cdata.rb +11 -0
- data/specs/filters.rb +5 -4
- data/specs/gettext/static_text.rb +30 -13
- data/specs/impl/preprocess.rb +58 -54
- metadata +375 -120
- data/sample/hello/test1.rb +0 -23
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<div class="depot-form">
|
|
7
|
+
<fieldset>
|
|
8
|
+
<legend>Please Log In</legend>
|
|
9
|
+
|
|
10
|
+
<% form_tag do %>
|
|
11
|
+
<p>
|
|
12
|
+
<label for="name">Name:</label>
|
|
13
|
+
<%= text_field_tag :name, params[:name] %>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
<label for="password">Password:</label>
|
|
18
|
+
<%= password_field_tag :password, params[:password] %>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p>
|
|
22
|
+
<%= submit_tag "Login" %>
|
|
23
|
+
</p>
|
|
24
|
+
<% end %>
|
|
25
|
+
</fieldset>
|
|
26
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<<div.cart-title<
|
|
7
|
+
Your Cart
|
|
8
|
+
|
|
9
|
+
<<table :cart | CartHelper <
|
|
10
|
+
%= render(:partial => "cart_item", :collection => $_.items)
|
|
11
|
+
<<tr class="total-line"<------------------------------
|
|
12
|
+
| colspan || 2 | |
|
|
13
|
+
| class || | total-cell |
|
|
14
|
+
| || Total | <<:total_price_currency>> |
|
|
15
|
+
----------------------------------------------------
|
|
16
|
+
|
|
17
|
+
%= button_to "Checkout", :action => :checkout
|
|
18
|
+
%= button_to "Empty cart", :action => :empty_cart
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<div class="cart-title">Your Cart</div>
|
|
7
|
+
|
|
8
|
+
<table>
|
|
9
|
+
<%= render(:partial => "cart_item", :collection => cart.items) %>
|
|
10
|
+
<tr class="total-line">
|
|
11
|
+
<td colspan="2">Total</td>
|
|
12
|
+
<td class="total-cell"><%= number_to_currency(cart.total_price) %></td>
|
|
13
|
+
</tr>
|
|
14
|
+
</table>
|
|
15
|
+
|
|
16
|
+
<%= button_to "Checkout", :action => :checkout %>
|
|
17
|
+
<%= button_to "Empty cart", :action => :empty_cart %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<< :cart_item {
|
|
7
|
+
:current => ($_ == @current_item),
|
|
8
|
+
:price => number_to_currency($_.price),
|
|
9
|
+
} <
|
|
10
|
+
<<tr id="current_item" :
|
|
11
|
+
| Attr[:id=>:current]
|
|
12
|
+
<------------------------------------------------
|
|
13
|
+
|class|| | | item-price |
|
|
14
|
+
| ||<<:quantity>> X |<<:title>>| <<:price>> |
|
|
15
|
+
-------------------------------------------------
|
|
16
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<% if cart_item == @current_item %>
|
|
7
|
+
<tr id="current_item">
|
|
8
|
+
<% else %>
|
|
9
|
+
<tr>
|
|
10
|
+
<% end %>
|
|
11
|
+
<td><%= cart_item.quantity %> X </td>
|
|
12
|
+
<td><%= h(cart_item.title) %></td>
|
|
13
|
+
<td class="item-price"><%= number_to_currency(cart_item.price) %></td>
|
|
14
|
+
</tr>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#START_HIGHLIGHT
|
|
2
|
+
page.select("div#notice").each { |div| div.hide }
|
|
3
|
+
#END_HIGHLIGHT
|
|
4
|
+
|
|
5
|
+
page.replace_html("cart", :partial => "cart", :object => @cart)
|
|
6
|
+
|
|
7
|
+
page[:cart].visual_effect :blind_down if @cart.total_items == 1
|
|
8
|
+
|
|
9
|
+
page[:current_item].visual_effect :highlight,
|
|
10
|
+
:startcolor => "#88ff88",
|
|
11
|
+
:endcolor => "#114411"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<<div.depot-form<
|
|
7
|
+
|
|
8
|
+
%= error_messages_for 'order'
|
|
9
|
+
|
|
10
|
+
<<fieldset<
|
|
11
|
+
<legend>Please Enter Your Details</legend>
|
|
12
|
+
|
|
13
|
+
<%
|
|
14
|
+
form = amrita_define_form(
|
|
15
|
+
:order,
|
|
16
|
+
:url => { :action => :save_order },
|
|
17
|
+
:amrita_format => :as_label_field_hash) do |f|
|
|
18
|
+
f.text_field :name, :size => 40
|
|
19
|
+
f.text_area :address, :rows => 3, :cols => 40
|
|
20
|
+
f.text_field :email, :size => 40
|
|
21
|
+
f.select :pay_type,
|
|
22
|
+
Order::PAYMENT_TYPES,
|
|
23
|
+
:prompt => "Select a payment method"
|
|
24
|
+
end
|
|
25
|
+
%>
|
|
26
|
+
|
|
27
|
+
<<:form | AcceptData[:hook] <
|
|
28
|
+
<<p :name<
|
|
29
|
+
<<label :label | Attr[:for] <
|
|
30
|
+
<<:text | :capitalize >>:
|
|
31
|
+
<<:field>>
|
|
32
|
+
<<p :address<
|
|
33
|
+
<<label :label | Attr[:for] <
|
|
34
|
+
<<:text | :capitalize >>:
|
|
35
|
+
<<:field>>
|
|
36
|
+
<<p :email<
|
|
37
|
+
<<label :label | Attr[:for] <
|
|
38
|
+
E-Mail:
|
|
39
|
+
<<:field>>
|
|
40
|
+
<<p :pay_type<
|
|
41
|
+
<<label :label | Attr[:for] <
|
|
42
|
+
Pay with:
|
|
43
|
+
<<:field>>
|
|
44
|
+
|
|
45
|
+
%= submit_tag "Place Order", :class => "submit"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<%(BeforeCompile)
|
|
2
|
+
use_macro(StandardForm)
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<!--
|
|
6
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
7
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
8
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
9
|
+
-->
|
|
10
|
+
<div class="depot-form">
|
|
11
|
+
|
|
12
|
+
%= error_messages_for 'order'
|
|
13
|
+
|
|
14
|
+
<< standard_form record="order" <
|
|
15
|
+
<form_title>Please Enter Your Detailsa</form_title>
|
|
16
|
+
<url action = "save_order" />
|
|
17
|
+
<<header<
|
|
18
|
+
% pay_select = select "order", :pay_type,
|
|
19
|
+
% Order::PAYMENT_TYPES, :prompt => "Select a payment method"
|
|
20
|
+
<<<--------------------------------------------------------------
|
|
21
|
+
||| Name || <text id="name" size="40" /> |
|
|
22
|
+
<<<--------------------------------------------------------------
|
|
23
|
+
||| Address || <text_area id="address" rows="3" cols="40" /> |
|
|
24
|
+
<<<--------------------------------------------------------------
|
|
25
|
+
||| E-Mail || <text id="email" size="40" /> |
|
|
26
|
+
<<<--------------------------------------------------------------
|
|
27
|
+
||| Pay with || <<field id="pay_type"< |
|
|
28
|
+
||| || <<:pay_select\|NoSanitize>> |
|
|
29
|
+
---------------------------------------------------------------
|
|
30
|
+
<<fotter<
|
|
31
|
+
%= submit_tag "Place Order", :class => "submit"
|
|
32
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<<div.depot-form<
|
|
7
|
+
|
|
8
|
+
%= error_messages_for 'order'
|
|
9
|
+
|
|
10
|
+
<<fieldset<
|
|
11
|
+
<legend>Please Enter Your Details</legend>
|
|
12
|
+
|
|
13
|
+
<%
|
|
14
|
+
form = amrita_define_form(:form_for, :order, :url => { :action => :save_order }) do |f|
|
|
15
|
+
f.text_field :name, :size => 40
|
|
16
|
+
f.text_area :address, :rows => 3, :cols => 40
|
|
17
|
+
f.text_field :email, :size => 40
|
|
18
|
+
f.select :pay_type,
|
|
19
|
+
Order::PAYMENT_TYPES,
|
|
20
|
+
:prompt => "Select a payment method"
|
|
21
|
+
end
|
|
22
|
+
%>
|
|
23
|
+
<<:form | AcceptData[:hook] <
|
|
24
|
+
<<p<
|
|
25
|
+
<label for="order_name">Name:</label>
|
|
26
|
+
<<:name>>
|
|
27
|
+
<<p<
|
|
28
|
+
<label for="order_address">Address:</label>
|
|
29
|
+
<<:address>>
|
|
30
|
+
<<p<
|
|
31
|
+
<label for="order_email">E-Mail:</label>
|
|
32
|
+
<<:email>>
|
|
33
|
+
<<p<
|
|
34
|
+
<label for="order_pay_type">Pay with:</label>
|
|
35
|
+
<<:pay_type>>
|
|
36
|
+
|
|
37
|
+
%= submit_tag "Place Order", :class => "submit"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<div class="depot-form">
|
|
7
|
+
|
|
8
|
+
<%= error_messages_for 'order' %>
|
|
9
|
+
|
|
10
|
+
<fieldset>
|
|
11
|
+
<legend>Please Enter Your Details</legend>
|
|
12
|
+
|
|
13
|
+
<% form_for :order, :url => { :action => :save_order } do |form| %>
|
|
14
|
+
<p>
|
|
15
|
+
<label for="order_name">Name:</label>
|
|
16
|
+
<%= form.text_field :name, :size => 40 %>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
<label for="order_address">Address:</label>
|
|
21
|
+
<%= form.text_area :address, :rows => 3, :cols => 40 %>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<label for="order_email">E-Mail:</label>
|
|
26
|
+
<%= form.text_field :email, :size => 40 %>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p>
|
|
30
|
+
<label for="order_pay_type">Pay with:</label>
|
|
31
|
+
<%=
|
|
32
|
+
form.select :pay_type,
|
|
33
|
+
Order::PAYMENT_TYPES,
|
|
34
|
+
:prompt => "Select a payment method"
|
|
35
|
+
%>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<%= submit_tag "Place Order", :class => "submit" %>
|
|
39
|
+
<% end %>
|
|
40
|
+
</fieldset>
|
|
41
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<h1>Your Pragmatic Catalog</h1>
|
|
7
|
+
|
|
8
|
+
<<div.entry :products <
|
|
9
|
+
%= image_tag($_.image_url)
|
|
10
|
+
<<h3 :title>>
|
|
11
|
+
<<:description>>
|
|
12
|
+
<<div.price-line<
|
|
13
|
+
<<span.price :price | ModuleExtendFilter[PriceHelper] | :to_currency >>
|
|
14
|
+
|
|
15
|
+
% form_remote_tag :url => { :action => :add_to_cart, :id => $_ } do
|
|
16
|
+
%= submit_tag "Add to Cart"
|
|
17
|
+
% end
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
|
|
3
|
+
! We make no guarantees that this code is fit for any purpose.
|
|
4
|
+
! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
|
|
5
|
+
-->
|
|
6
|
+
<h1>Your Pragmatic Catalog</h1>
|
|
7
|
+
|
|
8
|
+
<% for product in @products -%>
|
|
9
|
+
<div class="entry">
|
|
10
|
+
<%= image_tag(product.image_url) %>
|
|
11
|
+
<h3><%= h(product.title) %></h3>
|
|
12
|
+
<%= product.description %>
|
|
13
|
+
<div class="price-line">
|
|
14
|
+
<span class="price"><%= number_to_currency(product.price) %></span>
|
|
15
|
+
|
|
16
|
+
<% form_remote_tag :url => { :action => :add_to_cart, :id => product } do %>
|
|
17
|
+
<%= submit_tag "Add to Cart" %>
|
|
18
|
+
<% end %>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
development:
|
|
2
|
+
adapter: mysql
|
|
3
|
+
database: depot_dev
|
|
4
|
+
username: depot
|
|
5
|
+
password: depot
|
|
6
|
+
host: localhost
|
|
7
|
+
socket: /var/run/mysqld/mysqld.sock
|
|
8
|
+
|
|
9
|
+
test:
|
|
10
|
+
adapter: mysql
|
|
11
|
+
database: depot_test
|
|
12
|
+
username: depot
|
|
13
|
+
password: depot
|
|
14
|
+
host: localhost
|
|
15
|
+
socket: /var/run/mysqld/mysqld.sock
|
|
16
|
+
|
|
17
|
+
production:
|
|
18
|
+
adapter: mysql
|
|
19
|
+
database: depot_production
|
|
20
|
+
username: depot
|
|
21
|
+
password: depot
|
|
22
|
+
host: localhost
|
|
23
|
+
socket: /var/run/mysqld/mysqld.sock
|
|
24
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
drop database if exists depot_dev ;
|
|
3
|
+
create database depot_dev ;
|
|
4
|
+
grant all on depot_dev.* to depot@localhost identified by 'depot' ;
|
|
5
|
+
|
|
6
|
+
drop database if exists depot_test ;
|
|
7
|
+
create database depot_test ;
|
|
8
|
+
grant all on depot_test.* to depot@localhost identified by 'depot' ;
|
|
9
|
+
|
|
10
|
+
drop database if exists depot ;
|
|
11
|
+
create database depot ;
|
|
12
|
+
grant all on depot.* to depot@localhost identified by 'depot' ;
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
= The Depot Online Store
|
|
2
|
+
|
|
3
|
+
This application implements an online store, with a catalog, cart, and orders.
|
|
4
|
+
|
|
5
|
+
It is divided into three main sections:
|
|
6
|
+
|
|
7
|
+
* The buyer's side of the application manages the catalog, cart, and
|
|
8
|
+
checkout. It is implemented in StoreController and the associated
|
|
9
|
+
views.
|
|
10
|
+
|
|
11
|
+
* Only administrators can access stuff in the AdminController.
|
|
12
|
+
This is implemented by the LoginController, and is enforced by the
|
|
13
|
+
ApplicationController#authorize method.
|
|
14
|
+
|
|
15
|
+
* There's also a simple web service accessible via the InfoController.
|
|
16
|
+
|
|
17
|
+
This code was produced as an example for the book {Agile Web
|
|
18
|
+
Development with
|
|
19
|
+
Rails}[http://pragmaticprogrammer.com/titles/rails2]. It should not be
|
|
20
|
+
run as a real online store.
|
|
21
|
+
|
|
22
|
+
=== Author
|
|
23
|
+
|
|
24
|
+
Dave Thomas, The Pragmatic Programmers, LLC
|
|
25
|
+
|
|
26
|
+
=== Warranty
|
|
27
|
+
|
|
28
|
+
This code is provided for educational purposes only, and comes with
|
|
29
|
+
absolutely no warranty. It should not be used in live applications.
|
|
30
|
+
|
|
31
|
+
== Copyright
|
|
32
|
+
|
|
33
|
+
This code is Copyright (c) 2006 The Pragmatic Programmers, LLC.
|
|
34
|
+
|
|
35
|
+
It is released under the same license as Ruby.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Logfile created on Mon Mar 03 17:32:49 +0900 2008 [4;36;1mSQL (0.013002)[0m [0;1mSET SQL_AUTO_IS_NULL=0[0m
|
|
2
|
+
[4;35;1mSQL (0.060364)[0m [0mCREATE TABLE `schema_info` (version int(11))[0m
|
|
3
|
+
[4;36;1mSQL (0.042630)[0m [0;1mINSERT INTO `schema_info` (version) VALUES(0)[0m
|
|
4
|
+
[4;35;1mSQL (0.000000)[0m [0mMysql::Error: Table 'schema_info' already exists: CREATE TABLE `schema_info` (version int(11))[0m
|
|
5
|
+
[4;36;1mSQL (0.022310)[0m [0;1mSELECT version FROM schema_info[0m
|
|
6
|
+
Migrating to CreateProducts (1)
|
|
7
|
+
[4;35;1mSQL (0.251951)[0m [0mCREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255) DEFAULT NULL, `description` text DEFAULT NULL, `image_url` varchar(255) DEFAULT NULL) ENGINE=InnoDB[0m
|
|
8
|
+
[4;36;1mSQL (0.015268)[0m [0;1mUPDATE schema_info SET version = 1[0m
|
|
9
|
+
[4;35;1mSQL (0.000153)[0m [0mSELECT version FROM schema_info[0m
|
|
10
|
+
Migrating to AddPrice (2)
|
|
11
|
+
[4;36;1mSQL (0.138196)[0m [0;1mALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0[0m
|
|
12
|
+
[4;35;1mSQL (0.000350)[0m [0mUPDATE schema_info SET version = 2[0m
|
|
13
|
+
[4;36;1mSQL (0.000110)[0m [0;1mSELECT version FROM schema_info[0m
|
|
14
|
+
Migrating to AddTestData (3)
|
|
15
|
+
[4;35;1mProduct Delete all (0.000202)[0m [0mDELETE FROM `products` [0m
|
|
16
|
+
[4;36;1mProduct Columns (0.000633)[0m [0;1mSHOW FIELDS FROM `products`[0m
|
|
17
|
+
[4;35;1mSQL (0.000134)[0m [0mBEGIN[0m
|
|
18
|
+
[4;36;1mProduct Load (0.000205)[0m [0;1mSELECT * FROM `products` WHERE (products.title = 'Pragmatic Project Automation') LIMIT 1[0m
|
|
19
|
+
[4;35;1mProduct Create (0.000169)[0m [0mINSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/auto.jpg', '29.95', 'Pragmatic Project Automation', '<p>\n <em>Pragmatic Project Automation</em> shows you how to improve the \n consistency and repeatability of your project\'s procedures using \n automation to reduce risk and errors.\n </p>\n <p>\n Simply put, we\'re going to put this thing called a computer to work \n for you doing the mundane (but important) project stuff. That means \n you\'ll have more time and energy to do the really \n exciting---and difficult---stuff, like writing quality code.\n </p>')[0m
|
|
20
|
+
[4;36;1mSQL (0.000615)[0m [0;1mCOMMIT[0m
|
|
21
|
+
[4;35;1mSQL (0.000043)[0m [0mBEGIN[0m
|
|
22
|
+
[4;36;1mProduct Load (0.000179)[0m [0;1mSELECT * FROM `products` WHERE (products.title = 'Pragmatic Version Control') LIMIT 1[0m
|
|
23
|
+
[4;35;1mProduct Create (0.000126)[0m [0mINSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/svn.jpg', '28.5', 'Pragmatic Version Control', '<p>\n This book is a recipe-based approach to using Subversion that will \n get you up and \n running quickly---and correctly. All projects need version control: \n it\'s a foundational piece of any project\'s infrastructure. Yet half \n of all project teams in the U.S. don\'t use any version control at all. \n Many others don\'t use it well, and end up experiencing time-consuming problems.\n </p>')[0m
|
|
24
|
+
[4;36;1mSQL (0.007396)[0m [0;1mCOMMIT[0m
|
|
25
|
+
[4;35;1mSQL (0.000039)[0m [0mBEGIN[0m
|
|
26
|
+
[4;36;1mProduct Load (0.000150)[0m [0;1mSELECT * FROM `products` WHERE (products.title = 'Pragmatic Unit Testing (C#)') LIMIT 1[0m
|
|
27
|
+
[4;35;1mProduct Create (0.000134)[0m [0mINSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/utc.jpg', '27.75', 'Pragmatic Unit Testing (C#)', '<p>\n Pragmatic programmers use feedback to drive their development and \n personal processes. The most valuable feedback you can get while \n coding comes from unit testing.\n </p>\n <p>\n Without good tests in place, coding can become a frustrating game of \n \"whack-a-mole.\" That\'s the carnival game where the player strikes at a \n mechanical mole; it retreats and another mole pops up on the opposite side \n of the field. The moles pop up and down so fast that you end up flailing \n your mallet helplessly as the moles continue to pop up where you least \n expect them.\n </p>')[0m
|
|
28
|
+
[4;36;1mSQL (0.000149)[0m [0;1mCOMMIT[0m
|
|
29
|
+
[4;35;1mSQL (0.000274)[0m [0mUPDATE schema_info SET version = 3[0m
|
|
30
|
+
[4;36;1mSQL (0.000113)[0m [0;1mSELECT version FROM schema_info[0m
|
|
31
|
+
Migrating to AddSessions (4)
|
|
32
|
+
[4;35;1mSQL (0.000842)[0m [0mCREATE TABLE `sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `session_id` varchar(255) DEFAULT NULL, `data` text DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB[0m
|
|
33
|
+
[4;36;1mSQL (0.025951)[0m [0;1mCREATE INDEX `index_sessions_on_session_id` ON `sessions` (`session_id`)[0m
|
|
34
|
+
[4;35;1mSQL (0.000253)[0m [0mUPDATE schema_info SET version = 4[0m
|
|
35
|
+
[4;36;1mSQL (0.000139)[0m [0;1mSELECT version FROM schema_info[0m
|
|
36
|
+
Migrating to CreateOrders (5)
|
|
37
|
+
[4;35;1mSQL (0.000905)[0m [0mCREATE TABLE `orders` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `address` text DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `pay_type` varchar(10) DEFAULT NULL) ENGINE=InnoDB[0m
|
|
38
|
+
[4;36;1mSQL (0.000168)[0m [0;1mUPDATE schema_info SET version = 5[0m
|
|
39
|
+
[4;35;1mSQL (0.000114)[0m [0mSELECT version FROM schema_info[0m
|
|
40
|
+
Migrating to CreateLineItems (6)
|
|
41
|
+
[4;36;1mSQL (0.004357)[0m [0;1mCREATE TABLE `line_items` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `product_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `quantity` int(11) NOT NULL, `total_price` decimal(8,2) NOT NULL) ENGINE=InnoDB[0m
|
|
42
|
+
[4;35;1mSQL (0.002167)[0m [0malter table line_items
|
|
43
|
+
add constraint fk_line_item_products
|
|
44
|
+
foreign key (product_id) references products(id)[0m
|
|
45
|
+
[4;36;1mSQL (0.009577)[0m [0;1malter table line_items
|
|
46
|
+
add constraint fk_line_item_orders
|
|
47
|
+
foreign key (order_id) references orders(id)[0m
|
|
48
|
+
[4;35;1mSQL (0.000225)[0m [0mUPDATE schema_info SET version = 6[0m
|
|
49
|
+
[4;36;1mSQL (0.000152)[0m [0;1mSELECT version FROM schema_info[0m
|
|
50
|
+
Migrating to CreateUsers (7)
|
|
51
|
+
[4;35;1mSQL (0.000770)[0m [0mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `hashed_password` varchar(255) DEFAULT NULL, `salt` varchar(255) DEFAULT NULL) ENGINE=InnoDB[0m
|
|
52
|
+
[4;36;1mSQL (0.000164)[0m [0;1mUPDATE schema_info SET version = 7[0m
|
|
53
|
+
[4;35;1mSQL (0.000163)[0m [0mSELECT * FROM schema_info[0m
|
|
54
|
+
[4;36;1mSQL (0.000197)[0m [0;1mSHOW TABLES[0m
|
|
55
|
+
[4;35;1mSQL (0.030424)[0m [0mSHOW FIELDS FROM `line_items`[0m
|
|
56
|
+
[4;36;1mSQL (0.000380)[0m [0;1mdescribe `line_items`[0m
|
|
57
|
+
[4;35;1mSQL (0.007629)[0m [0mSHOW KEYS FROM `line_items`[0m
|
|
58
|
+
[4;36;1mSQL (0.000376)[0m [0;1mSHOW FIELDS FROM `orders`[0m
|
|
59
|
+
[4;35;1mSQL (0.000344)[0m [0mdescribe `orders`[0m
|
|
60
|
+
[4;36;1mSQL (0.000204)[0m [0;1mSHOW KEYS FROM `orders`[0m
|
|
61
|
+
[4;35;1mSQL (0.000294)[0m [0mSHOW FIELDS FROM `products`[0m
|
|
62
|
+
[4;36;1mSQL (0.000337)[0m [0;1mdescribe `products`[0m
|
|
63
|
+
[4;35;1mSQL (0.000207)[0m [0mSHOW KEYS FROM `products`[0m
|
|
64
|
+
[4;36;1mSQL (0.000313)[0m [0;1mSHOW FIELDS FROM `sessions`[0m
|
|
65
|
+
[4;35;1mSQL (0.000310)[0m [0mdescribe `sessions`[0m
|
|
66
|
+
[4;36;1mSQL (0.000216)[0m [0;1mSHOW KEYS FROM `sessions`[0m
|
|
67
|
+
[4;35;1mSQL (0.000319)[0m [0mSHOW FIELDS FROM `users`[0m
|
|
68
|
+
[4;36;1mSQL (0.000310)[0m [0;1mdescribe `users`[0m
|
|
69
|
+
[4;35;1mSQL (0.000194)[0m [0mSHOW KEYS FROM `users`[0m
|
|
70
|
+
[4;36;1mSQL (0.000114)[0m [0;1mSET SQL_AUTO_IS_NULL=0[0m
|
|
71
|
+
[4;35;1mSQL (0.000000)[0m [0mMysql::Error: Table 'schema_info' already exists: CREATE TABLE `schema_info` (version int(11))[0m
|
|
72
|
+
[4;36;1mSQL (0.000213)[0m [0;1mSELECT version FROM schema_info[0m
|
|
73
|
+
[4;35;1mSQL (0.000046)[0m [0mSELECT version FROM schema_info[0m
|
|
74
|
+
[4;36;1mSQL (0.000043)[0m [0;1mSELECT version FROM schema_info[0m
|
|
75
|
+
[4;35;1mSQL (0.000042)[0m [0mSELECT version FROM schema_info[0m
|
|
76
|
+
[4;36;1mSQL (0.000042)[0m [0;1mSELECT version FROM schema_info[0m
|
|
77
|
+
[4;35;1mSQL (0.000042)[0m [0mSELECT version FROM schema_info[0m
|
|
78
|
+
[4;36;1mSQL (0.000043)[0m [0;1mSELECT version FROM schema_info[0m
|
|
79
|
+
[4;35;1mSQL (0.000052)[0m [0mSELECT * FROM schema_info[0m
|
|
80
|
+
[4;36;1mSQL (0.000187)[0m [0;1mSHOW TABLES[0m
|
|
81
|
+
[4;35;1mSQL (0.000449)[0m [0mSHOW FIELDS FROM `line_items`[0m
|
|
82
|
+
[4;36;1mSQL (0.000340)[0m [0;1mdescribe `line_items`[0m
|
|
83
|
+
[4;35;1mSQL (0.000194)[0m [0mSHOW KEYS FROM `line_items`[0m
|
|
84
|
+
[4;36;1mSQL (0.000346)[0m [0;1mSHOW FIELDS FROM `orders`[0m
|
|
85
|
+
[4;35;1mSQL (0.000340)[0m [0mdescribe `orders`[0m
|
|
86
|
+
[4;36;1mSQL (0.000143)[0m [0;1mSHOW KEYS FROM `orders`[0m
|
|
87
|
+
[4;35;1mSQL (0.000355)[0m [0mSHOW FIELDS FROM `products`[0m
|
|
88
|
+
[4;36;1mSQL (0.000342)[0m [0;1mdescribe `products`[0m
|
|
89
|
+
[4;35;1mSQL (0.000157)[0m [0mSHOW KEYS FROM `products`[0m
|
|
90
|
+
[4;36;1mSQL (0.000322)[0m [0;1mSHOW FIELDS FROM `sessions`[0m
|
|
91
|
+
[4;35;1mSQL (0.000314)[0m [0mdescribe `sessions`[0m
|
|
92
|
+
[4;36;1mSQL (0.000159)[0m [0;1mSHOW KEYS FROM `sessions`[0m
|
|
93
|
+
[4;35;1mSQL (0.000320)[0m [0mSHOW FIELDS FROM `users`[0m
|
|
94
|
+
[4;36;1mSQL (0.000312)[0m [0;1mdescribe `users`[0m
|
|
95
|
+
[4;35;1mSQL (0.000140)[0m [0mSHOW KEYS FROM `users`[0m
|
|
96
|
+
[4;36;1mSQL (0.000063)[0m [0;1mSET SQL_AUTO_IS_NULL=0[0m
|
|
97
|
+
[4;35;1mSQL (0.003709)[0m [0mDROP DATABASE IF EXISTS `depot_test`[0m
|
|
98
|
+
[4;36;1mSQL (0.000157)[0m [0;1mCREATE DATABASE `depot_test` DEFAULT CHARACTER SET `utf8`[0m
|
|
99
|
+
[4;35;1mSQL (0.000075)[0m [0mSET SQL_AUTO_IS_NULL=0[0m
|
|
100
|
+
[4;36;1mSQL (0.000000)[0m [0;1mMysql::Error: Unknown table 'line_items': DROP TABLE `line_items`[0m
|
|
101
|
+
[4;35;1mSQL (0.002265)[0m [0mCREATE TABLE `line_items` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `product_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `quantity` int(11) NOT NULL, `total_price` decimal(8,2) NOT NULL) ENGINE=InnoDB[0m
|
|
102
|
+
[4;36;1mSQL (0.015063)[0m [0;1mCREATE INDEX `fk_line_item_products` ON `line_items` (`product_id`)[0m
|
|
103
|
+
[4;35;1mSQL (0.026515)[0m [0mCREATE INDEX `fk_line_item_orders` ON `line_items` (`order_id`)[0m
|
|
104
|
+
[4;36;1mSQL (0.000000)[0m [0;1mMysql::Error: Unknown table 'orders': DROP TABLE `orders`[0m
|
|
105
|
+
[4;35;1mSQL (0.000621)[0m [0mCREATE TABLE `orders` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `address` text DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `pay_type` varchar(10) DEFAULT NULL) ENGINE=InnoDB[0m
|
|
106
|
+
[4;36;1mSQL (0.000000)[0m [0;1mMysql::Error: Unknown table 'products': DROP TABLE `products`[0m
|
|
107
|
+
[4;35;1mSQL (0.000611)[0m [0mCREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255) DEFAULT NULL, `description` text DEFAULT NULL, `image_url` varchar(255) DEFAULT NULL, `price` decimal(8,2) DEFAULT 0.0) ENGINE=InnoDB[0m
|
|
108
|
+
[4;36;1mSQL (0.000000)[0m [0;1mMysql::Error: Unknown table 'sessions': DROP TABLE `sessions`[0m
|
|
109
|
+
[4;35;1mSQL (0.000586)[0m [0mCREATE TABLE `sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `session_id` varchar(255) DEFAULT NULL, `data` text DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB[0m
|
|
110
|
+
[4;36;1mSQL (0.010056)[0m [0;1mCREATE INDEX `index_sessions_on_session_id` ON `sessions` (`session_id`)[0m
|
|
111
|
+
[4;35;1mSQL (0.000000)[0m [0mMysql::Error: Unknown table 'users': DROP TABLE `users`[0m
|
|
112
|
+
[4;36;1mSQL (0.000614)[0m [0;1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `hashed_password` varchar(255) DEFAULT NULL, `salt` varchar(255) DEFAULT NULL) ENGINE=InnoDB[0m
|
|
113
|
+
[4;35;1mSQL (0.000401)[0m [0mCREATE TABLE `schema_info` (version int(11))[0m
|
|
114
|
+
[4;36;1mSQL (0.000149)[0m [0;1mINSERT INTO `schema_info` (version) VALUES(0)[0m
|
|
115
|
+
[4;35;1mSQL (0.000262)[0m [0mSHOW FIELDS FROM `schema_info`[0m
|
|
116
|
+
[4;36;1mSQL (0.000170)[0m [0;1mUPDATE schema_info SET version = 7[0m
|