ramaze 0.3.5 → 0.3.9

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.
Files changed (204) hide show
  1. data/Rakefile +5 -20
  2. data/bin/ramaze +0 -4
  3. data/doc/AUTHORS +5 -0
  4. data/doc/meta/announcement.txt +2 -1
  5. data/doc/tutorial/todolist.html +20 -21
  6. data/doc/tutorial/todolist.mkd +10 -9
  7. data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
  8. data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
  9. data/examples/blog/spec/blog.rb +3 -3
  10. data/examples/blog/start.rb +2 -3
  11. data/examples/blog/view/edit.xhtml +17 -0
  12. data/examples/blog/view/index.xhtml +17 -0
  13. data/examples/blog/view/layout.xhtml +11 -0
  14. data/examples/blog/view/new.xhtml +16 -0
  15. data/examples/facebook.rb +15 -8
  16. data/examples/identity.rb +1 -1
  17. data/examples/memleak_detector.rb +1 -1
  18. data/examples/rammit/src/model.rb +1 -1
  19. data/examples/rapaste/controller/paste.rb +7 -7
  20. data/examples/rapaste/model/paste.rb +1 -3
  21. data/examples/rapaste/public/css/display.css +2 -1
  22. data/examples/rapaste/start.rb +2 -3
  23. data/examples/sourceview/sourceview.rb +1 -1
  24. data/examples/templates/template/external.tenjin +28 -0
  25. data/examples/templates/template_amrita2.rb +0 -3
  26. data/examples/templates/template_tenjin.rb +57 -0
  27. data/examples/todolist/spec/todolist.rb +13 -2
  28. data/examples/todolist/src/controller/main.rb +1 -1
  29. data/examples/todolist/template/index.xhtml +1 -1
  30. data/examples/wiktacular/spec/wiktacular.rb +18 -0
  31. data/examples/wiktacular/src/controller.rb +2 -2
  32. data/examples/wiktacular/src/model.rb +8 -2
  33. data/lib/proto/public/css/ramaze_error.css +4 -0
  34. data/lib/proto/public/dispatch.fcgi +11 -0
  35. data/lib/proto/spec/main.rb +1 -1
  36. data/lib/proto/start.ru +8 -0
  37. data/lib/proto/view/error.xhtml +2 -0
  38. data/lib/ramaze.rb +28 -5
  39. data/lib/ramaze/action.rb +9 -2
  40. data/lib/ramaze/action/render.rb +40 -24
  41. data/lib/ramaze/adapter.rb +10 -17
  42. data/lib/ramaze/adapter/base.rb +8 -12
  43. data/lib/ramaze/adapter/cgi.rb +14 -13
  44. data/lib/ramaze/adapter/ebb.rb +34 -0
  45. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  46. data/lib/ramaze/adapter/fcgi.rb +14 -14
  47. data/lib/ramaze/adapter/lsws.rb +15 -11
  48. data/lib/ramaze/adapter/mongrel.rb +2 -1
  49. data/lib/ramaze/adapter/scgi.rb +24 -0
  50. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  51. data/lib/ramaze/adapter/thin.rb +4 -5
  52. data/lib/ramaze/adapter/webrick.rb +5 -5
  53. data/lib/ramaze/cache.rb +1 -1
  54. data/lib/ramaze/cache/memcached.rb +1 -1
  55. data/lib/ramaze/contrib.rb +70 -10
  56. data/lib/ramaze/contrib/auto_params.rb +1 -1
  57. data/lib/ramaze/contrib/email.rb +15 -15
  58. data/lib/ramaze/contrib/facebook.rb +2 -2
  59. data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
  60. data/lib/ramaze/contrib/file_cache.rb +65 -0
  61. data/lib/ramaze/contrib/gettext.rb +56 -55
  62. data/lib/ramaze/contrib/profiling.rb +36 -0
  63. data/lib/ramaze/contrib/sequel_cache.rb +92 -0
  64. data/lib/ramaze/controller.rb +80 -47
  65. data/lib/ramaze/controller/error.rb +10 -5
  66. data/lib/ramaze/controller/resolve.rb +36 -48
  67. data/lib/ramaze/current.rb +70 -0
  68. data/lib/ramaze/{trinity → current}/request.rb +62 -15
  69. data/lib/ramaze/current/response.rb +19 -0
  70. data/lib/ramaze/{trinity → current}/session.rb +32 -110
  71. data/lib/ramaze/current/session/flash.rb +67 -0
  72. data/lib/ramaze/current/session/hash.rb +65 -0
  73. data/lib/ramaze/dispatcher.rb +1 -28
  74. data/lib/ramaze/dispatcher/action.rb +6 -3
  75. data/lib/ramaze/dispatcher/directory.rb +1 -1
  76. data/lib/ramaze/dispatcher/error.rb +26 -5
  77. data/lib/ramaze/dispatcher/file.rb +13 -2
  78. data/lib/ramaze/gestalt.rb +3 -1
  79. data/lib/ramaze/global.rb +6 -3
  80. data/lib/ramaze/global/globalstruct.rb +3 -1
  81. data/lib/ramaze/helper.rb +66 -20
  82. data/lib/ramaze/helper/aspect.rb +25 -17
  83. data/lib/ramaze/helper/auth.rb +4 -3
  84. data/lib/ramaze/helper/cache.rb +5 -4
  85. data/lib/ramaze/helper/cgi.rb +11 -9
  86. data/lib/ramaze/helper/flash.rb +28 -3
  87. data/lib/ramaze/helper/formatting.rb +1 -3
  88. data/lib/ramaze/helper/identity.rb +2 -3
  89. data/lib/ramaze/helper/inform.rb +7 -6
  90. data/lib/ramaze/helper/link.rb +15 -17
  91. data/lib/ramaze/helper/markaby.rb +2 -4
  92. data/lib/ramaze/helper/maruku.rb +1 -1
  93. data/lib/ramaze/helper/nitroform.rb +4 -4
  94. data/lib/ramaze/helper/pager.rb +4 -6
  95. data/lib/ramaze/helper/partial.rb +24 -21
  96. data/lib/ramaze/helper/redirect.rb +8 -5
  97. data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
  98. data/lib/ramaze/helper/sequel.rb +1 -3
  99. data/lib/ramaze/helper/stack.rb +1 -3
  100. data/lib/ramaze/helper/tagz.rb +19 -0
  101. data/lib/ramaze/helper/user.rb +63 -0
  102. data/lib/ramaze/inform.rb +2 -24
  103. data/lib/ramaze/log.rb +28 -0
  104. data/lib/ramaze/{inform → log}/analogger.rb +3 -3
  105. data/lib/ramaze/{inform → log}/growl.rb +2 -2
  106. data/lib/ramaze/{inform → log}/hub.rb +4 -6
  107. data/lib/ramaze/{inform → log}/informer.rb +4 -4
  108. data/lib/ramaze/{inform → log}/knotify.rb +2 -2
  109. data/lib/ramaze/log/logger.rb +22 -0
  110. data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
  111. data/lib/ramaze/{inform → log}/syslog.rb +0 -0
  112. data/lib/ramaze/{inform → log}/xosd.rb +2 -2
  113. data/lib/ramaze/route.rb +64 -36
  114. data/lib/ramaze/snippets/array/put_within.rb +13 -0
  115. data/lib/ramaze/snippets/binding/locals.rb +13 -0
  116. data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
  117. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  118. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  119. data/lib/ramaze/snippets/object/pretty.rb +6 -0
  120. data/lib/ramaze/snippets/object/scope.rb +11 -0
  121. data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
  122. data/lib/ramaze/snippets/ordered_set.rb +1 -1
  123. data/lib/ramaze/snippets/proc/locals.rb +11 -0
  124. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
  125. data/lib/ramaze/snippets/string/esc.rb +29 -0
  126. data/lib/ramaze/snippets/string/start_with.rb +7 -0
  127. data/lib/ramaze/snippets/string/unindent.rb +6 -1
  128. data/lib/ramaze/snippets/struct/values_at.rb +1 -5
  129. data/lib/ramaze/sourcereload.rb +16 -14
  130. data/lib/ramaze/spec.rb +1 -0
  131. data/lib/ramaze/spec/helper.rb +11 -3
  132. data/lib/ramaze/spec/helper/browser.rb +25 -1
  133. data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
  134. data/lib/ramaze/template.rb +5 -4
  135. data/lib/ramaze/template/amrita2.rb +2 -3
  136. data/lib/ramaze/template/ezamar/element.rb +2 -3
  137. data/lib/ramaze/template/ezamar/morpher.rb +1 -2
  138. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  139. data/lib/ramaze/template/haml.rb +5 -2
  140. data/lib/ramaze/template/markaby.rb +2 -0
  141. data/lib/ramaze/template/tagz.rb +79 -0
  142. data/lib/ramaze/template/tenjin.rb +34 -0
  143. data/lib/ramaze/tool/create.rb +0 -3
  144. data/lib/ramaze/tool/localize.rb +107 -105
  145. data/lib/ramaze/tool/mime.rb +0 -2
  146. data/lib/ramaze/trinity.rb +1 -26
  147. data/lib/ramaze/version.rb +1 -1
  148. data/lib/vendor/bacon.rb +47 -41
  149. data/rake_tasks/conf.rake +18 -0
  150. data/rake_tasks/darcs.rake +5 -0
  151. data/rake_tasks/maintenance.rake +37 -24
  152. data/rake_tasks/spec.rake +1 -1
  153. data/spec/contrib/auto_params.rb +3 -1
  154. data/spec/contrib/profiling.rb +26 -0
  155. data/spec/examples/templates/template_redcloth.rb +1 -1
  156. data/spec/examples/templates/template_tenjin.rb +28 -0
  157. data/spec/helper.rb +0 -1
  158. data/spec/ramaze/action/layout.rb +28 -0
  159. data/spec/ramaze/controller/actionless_templates.rb +32 -0
  160. data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
  161. data/spec/ramaze/controller/template_resolving.rb +37 -0
  162. data/spec/ramaze/{trinity → current}/request.rb +12 -2
  163. data/spec/ramaze/current/session.rb +97 -0
  164. data/spec/ramaze/dispatcher/directory.rb +2 -1
  165. data/spec/ramaze/dispatcher/file.rb +8 -3
  166. data/spec/ramaze/dispatcher/public/file name.txt +1 -0
  167. data/spec/ramaze/gestalt.rb +11 -0
  168. data/spec/ramaze/helper/aspect.rb +28 -22
  169. data/spec/ramaze/helper/cgi.rb +2 -2
  170. data/spec/ramaze/helper/flash.rb +33 -15
  171. data/spec/ramaze/helper/formatting.rb +2 -2
  172. data/spec/ramaze/helper/link.rb +46 -18
  173. data/spec/ramaze/helper/pager.rb +8 -5
  174. data/spec/ramaze/helper/partial.rb +8 -1
  175. data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
  176. data/spec/ramaze/helper/user.rb +46 -0
  177. data/spec/ramaze/{inform → log}/informer.rb +0 -0
  178. data/spec/ramaze/{inform → log}/syslog.rb +1 -1
  179. data/spec/ramaze/request.rb +14 -10
  180. data/spec/ramaze/route.rb +23 -0
  181. data/spec/ramaze/template.rb +48 -1
  182. data/spec/ramaze/template/haml.rb +6 -16
  183. data/spec/ramaze/template/haml/locals.haml +2 -1
  184. data/spec/ramaze/template/tagz.rb +62 -0
  185. data/spec/ramaze/template/tagz/external.tagz +8 -0
  186. data/spec/ramaze/template/tagz/sum.tagz +1 -0
  187. data/spec/ramaze/template/tenjin.rb +49 -0
  188. data/spec/ramaze/template/tenjin/external.tenjin +1 -0
  189. data/spec/snippets/string/unindent.rb +15 -0
  190. metadata +509 -475
  191. data/doc/README.html +0 -729
  192. data/doc/changes.txt +0 -5757
  193. data/doc/changes.xml +0 -5759
  194. data/examples/blog/src/view.rb +0 -16
  195. data/examples/blog/template/edit.xhtml +0 -19
  196. data/examples/blog/template/index.xhtml +0 -19
  197. data/examples/blog/template/new.xhtml +0 -18
  198. data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
  199. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
  200. data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
  201. data/lib/ramaze/template/bijou.rb +0 -39
  202. data/lib/ramaze/trinity/response.rb +0 -32
  203. data/spec/ramaze/template/bijou.rb +0 -25
  204. data/spec/ramaze/trinity/session.rb +0 -29
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
- require 'rubygems'
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ end
5
+
2
6
  require 'rake'
3
7
  require 'rake/clean'
4
8
  require 'rake/packagetask'
@@ -137,25 +141,6 @@ task :todo do
137
141
  end
138
142
  end
139
143
 
140
- desc "show how many patches we made so far"
141
- task :patchsize do
142
- patches = `darcs changes --reverse`.split("\n")
143
- size = patches.reject{|l| l =~ /^\s/ or l.empty?}.size
144
- puts "currently we have #{size} patches"
145
- puts "shall i now play some Death-Metal for you?" if size == 666
146
- days = (Time.now - Time.parse(patches[0])) / (3600*24)
147
- puts "#{days.round} days since init, avg #{"%4.2f" % (size/days)} patches per day"
148
- end
149
-
150
- desc "show who made how many patches"
151
- task :patchstat do
152
- total = authors.inject(0.0){|s,(n,a)| s + a[:patches]}
153
- authors.sort_by{|k,v| -v[:patches]}.each do |name, author|
154
- patches = author[:patches]
155
- puts("%s %4d [%6.2f%% ]" % [name, patches, patches/total * 100])
156
- end
157
- end
158
-
159
144
  desc "opens a simple readline that makes making requests easier"
160
145
  task 'request' do
161
146
  ARGV.clear
data/bin/ramaze CHANGED
@@ -15,10 +15,6 @@ end
15
15
 
16
16
  RAMAZE_VERSION = "Ramaze Version #{Ramaze::VERSION}"
17
17
 
18
- require 'optparse'
19
- require 'ostruct'
20
- require 'abbrev'
21
-
22
18
  options = {:origin => :console, :create => false, :force => true}
23
19
  cli_options = Ramaze::CLI_OPTIONS
24
20
  cli_abbrevs = cli_options.map{|o| o.name.to_s}.abbrev
@@ -1,19 +1,24 @@
1
1
  Following persons (in alphabetical order) have contributed to Ramaze:
2
2
 
3
3
  Aman Gupta - aman@ramaze.net
4
+ Ara T. Howard - ahoward
4
5
  Carlo Zottmann - carlo@zottmann.org
5
6
  Chris Duncan - celldee@gmail.com
6
7
  Christian Neukirchen - chneukirchen@gmail.com
7
8
  Clive Crous - clive@crous.co.za
8
9
  Fabian Buch - fabian.buch@fabian-buch.de
9
10
  Gabriele Renzi - rff.rff@gmail.com
11
+ Jeremy Evans - code@jeremyevans.net
12
+ Joe Holt - joe07734@gmail.com
10
13
  Jonathan Buch - john@oxyliquit.de
11
14
  Keita Yamaguchi - keita.yamaguchi@gmail.com
12
15
  Lars Olsson - lasso@lassoweb.se
16
+ Leo Borisenko - leo.borisenko@gmail.com
13
17
  Martin Hilbig - blueonyx@dev-area.net
14
18
  Michael Fellinger - m.fellinger@gmail.com
15
19
  Pistos - jesuswasramazing.10.pistos@geoshell.com
16
20
  Richard Outten - outtenr@gmail.com
21
+ Ryan Grove - ryan@wonko.com
17
22
  Stephan Maka - stephan@spaceboyz.net
18
23
  skaar - skaar@waste.org
19
24
  zenix - comp.lang.zenix+ramaze@gmail.com
@@ -48,7 +48,8 @@ Special (alphabetic) thanks go to:
48
48
  Selected summary of the 62 patches from 0.3.0 to 0.3.5:
49
49
 
50
50
  Core
51
- - Ramaze::Contrib::Route made available by default as Ramaze::Route (backwards compatibility retained)
51
+ - Ramaze::Contrib::Route made available by default as Ramaze::Route
52
+ (backwards compatibility retained)
52
53
  - Support added for ETag and If-Modified-Since in Dispatcher::File
53
54
  - Adapter for LiteSpeed webserver added
54
55
  - Added ability to set default session cookie options using Session::COOKIE
@@ -70,7 +70,7 @@ RubyForge.</p>
70
70
  <p>Additionally, we now have added tests for the resulting application that you
71
71
  can find in spec/examples/todolist.rb</p>
72
72
 
73
- <p>Date of last update: Thu Jun 14 13:25:45 JST 2007</p>
73
+ <p>Date of last update: Thu Jan 31 04:37:16 JST 2008</p>
74
74
 
75
75
  <p>Thanks in advance.
76
76
  The author of the tutorial, Michael 'manveru' Fellinger</p>
@@ -95,17 +95,16 @@ to-do list.</p>
95
95
  So we are going to base this on the tools available, you can just do the same
96
96
  with your ORM or database-library of choice.</p>
97
97
 
98
- <p>So first, edit the <code>src/model.rb</code> to fit better into our application:</p>
98
+ <p>So first, create a <code>model/todolist.rb</code> for our application:</p>
99
99
 
100
- <pre><code>TodoList = Store::Default.new('todolist.yaml')
100
+ <pre><code>require 'ramaze/store/default'
101
+ TodoList = Ramaze::Store::Default.new('todolist.yaml')
101
102
  </code></pre>
102
103
 
103
104
  <p>Let's add some items as well to have a base to start from.</p>
104
105
 
105
- <pre><code>{
106
- 'Laundry' =&gt; {:done =&gt; false},
106
+ <pre><code>{ 'Laundry' =&gt; {:done =&gt; false},
107
107
  'Wash dishes' =&gt; {:done =&gt; false},
108
-
109
108
  }.each do |title, value|
110
109
  TodoList[title] = value
111
110
  end
@@ -115,7 +114,7 @@ end
115
114
 
116
115
  <p>Now let's get our hands dirty and just edit the templates for our to-do list.</p>
117
116
 
118
- <p>Start with editing <code>template/index.xhtml</code>, it is using the default templating
117
+ <p>Start with editing <code>view/index.xhtml</code>, it is using the default templating
119
118
  of Ramaze, called Ezamar.</p>
120
119
 
121
120
  <p>The index.xhtml currently contains a default welcome page, remove the contents.</p>
@@ -134,7 +133,7 @@ simple.</p>
134
133
  TodoList.each do |title, value|
135
134
  status = value[:done] ? 'done' : 'not done'
136
135
  ?&gt;
137
- &lt;li&gt;#{title}: #{status}&lt;/li&gt;
136
+ &lt;li&gt;#{c title}: #{status}&lt;/li&gt;
138
137
  &lt;?r end ?&gt;
139
138
  &lt;/ul&gt;
140
139
  &lt;/body&gt;
@@ -189,7 +188,7 @@ application and secondly provides excellent ways of changing the complete
189
188
  Structure of the Model or View independent from each other.</p>
190
189
 
191
190
  <p>OK, enough of the theory, you will see the benefits in an instant. Go on and
192
- edit the file <code>src/controller/main.rb</code>.</p>
191
+ edit the file <code>controller/main.rb</code>.</p>
193
192
 
194
193
  <p>The contents of it are like following:</p>
195
194
 
@@ -234,7 +233,7 @@ changed to do following:</p>
234
233
  &lt;?r else ?&gt;
235
234
  &lt;ul&gt;
236
235
  &lt;?r @tasks.each do |title, status| ?&gt;
237
- &lt;li&gt;#{title}: #{status}&lt;/li&gt;
236
+ &lt;li&gt;#{c title}: #{status}&lt;/li&gt;
238
237
  &lt;?r end ?&gt;
239
238
  &lt;/ul&gt;
240
239
  &lt;?r end ?&gt;
@@ -260,13 +259,13 @@ Tasks it will say so.</p>
260
259
  <p>We set out to build the ultimate to-do list, but there are still some things
261
260
  missing. First off, we want to add new tasks, so let's get that done.</p>
262
261
 
263
- <p>Add a link on the <code>template/index.xhtml</code> like this:</p>
262
+ <p>Add a link on the <code>view/index.xhtml</code> like this:</p>
264
263
 
265
264
  <pre><code>&lt;h1&gt;TodoList&lt;/h1&gt;
266
265
  &lt;a href="/new"&gt;New Task&lt;/a&gt;
267
266
  </code></pre>
268
267
 
269
- <p>Open a new file <code>template/new.xhtml</code> with a form to add a new task.</p>
268
+ <p>Open a new file <code>view/new.xhtml</code> with a form to add a new task.</p>
270
269
 
271
270
  <pre><code>&lt;html&gt;
272
271
  &lt;head&gt;
@@ -321,11 +320,11 @@ and redirect back to the mapping of the current Controller ('/' in this case).</
321
320
  <p>Since the nature of tasks is to be done eventually
322
321
  we will need some way to mark it as done or open tasks again.</p>
323
322
 
324
- <p>Jump into <code>template/index.xhtml</code> and do the following:</p>
323
+ <p>Jump into <code>view/index.xhtml</code> and do the following:</p>
325
324
 
326
325
  <pre><code>&lt;?r @tasks.each do |title, status, toggle| ?&gt;
327
326
  &lt;li&gt;
328
- #{title}: #{status} - [ #{toggle} ]
327
+ #{c title}: #{status} - [ #{toggle} ]
329
328
  &lt;/li&gt;
330
329
  &lt;?r end ?&gt;
331
330
  </code></pre>
@@ -429,11 +428,11 @@ Controller:</p>
429
428
  end
430
429
  </code></pre>
431
430
 
432
- <p>Now jumping to <code>template/index.xhtml</code> again, change it so it shows the link:</p>
431
+ <p>Now jumping to <code>view/index.xhtml</code> again, change it so it shows the link:</p>
433
432
 
434
433
  <pre><code>&lt;?r @tasks.each do |title, status, toggle, delete| ?&gt;
435
434
  &lt;li&gt;
436
- #{title}: #{status} [ #{toggle} | #{delete} ]
435
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
437
436
  &lt;/li&gt;
438
437
  &lt;?r end ?&gt;
439
438
  </code></pre>
@@ -524,7 +523,7 @@ end
524
523
 
525
524
  <p>And let's change our templates as well.</p>
526
525
 
527
- <p>First the <code>template/index.xhtml</code></p>
526
+ <p>First the <code>view/index.xhtml</code></p>
528
527
 
529
528
  <pre><code>&lt;Page title="TodoList"&gt;
530
529
  &lt;a href="/new"&gt;New Task&lt;/a&gt;
@@ -534,7 +533,7 @@ end
534
533
  &lt;ul&gt;
535
534
  &lt;?r @tasks.each do |title, status, toggle, delete| ?&gt;
536
535
  &lt;li&gt;
537
- #{title}: #{status} [ #{toggle} | #{delete} ]
536
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
538
537
  &lt;/li&gt;
539
538
  &lt;?r end ?&gt;
540
539
  &lt;/ul&gt;
@@ -542,7 +541,7 @@ end
542
541
  &lt;/Page&gt;
543
542
  </code></pre>
544
543
 
545
- <p>and the <code>template/new.xhtml</code></p>
544
+ <p>and the <code>view/new.xhtml</code></p>
546
545
 
547
546
  <pre><code>&lt;Page title="New Task"&gt;
548
547
  &lt;a href="/"&gt;Back to TodoList&lt;/a&gt;
@@ -566,7 +565,7 @@ to get it line up properly and look actually structured.</p>
566
565
  <pre><code>&lt;ul&gt;
567
566
  &lt;?r @tasks.each do |title, status, toggle, delete| ?&gt;
568
567
  &lt;li&gt;
569
- #{title}: #{status} [ #{toggle} | #{delete} ]
568
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
570
569
  &lt;/li&gt;
571
570
  &lt;?r end ?&gt;
572
571
  &lt;/ul&gt;
@@ -577,7 +576,7 @@ to get it line up properly and look actually structured.</p>
577
576
  <pre><code>&lt;table&gt;
578
577
  &lt;?r @tasks.each do |title, status, toggle, delete| ?&gt;
579
578
  &lt;tr&gt;
580
- &lt;td class="title"&gt; #{title} &lt;/td&gt;
579
+ &lt;td class="title"&gt; #{c title} &lt;/td&gt;
581
580
  &lt;td class="status"&gt; #{status} &lt;/td&gt;
582
581
  &lt;td class="toggle"&gt; #{toggle} &lt;/td&gt;
583
582
  &lt;td class="delete"&gt; #{delete} &lt;/td&gt;
@@ -25,7 +25,7 @@ RubyForge.
25
25
  Additionally, we now have added tests for the resulting application that you
26
26
  can find in spec/examples/todolist.rb
27
27
 
28
- Date of last update: Thu Jun 14 13:25:45 JST 2007
28
+ Date of last update: Thu Jan 31 04:37:16 JST 2008
29
29
 
30
30
  Thanks in advance.
31
31
  The author of the tutorial, Michael 'manveru' Fellinger
@@ -52,7 +52,8 @@ with your ORM or database-library of choice.
52
52
 
53
53
  So first, create a `model/todolist.rb` for our application:
54
54
 
55
- TodoList = Store::Default.new('todolist.yaml')
55
+ require 'ramaze/store/default'
56
+ TodoList = Ramaze::Store::Default.new('todolist.yaml')
56
57
 
57
58
  Let's add some items as well to have a base to start from.
58
59
 
@@ -86,7 +87,7 @@ simple.
86
87
  TodoList.each do |title, value|
87
88
  status = value[:done] ? 'done' : 'not done'
88
89
  ?>
89
- <li>#{title}: #{status}</li>
90
+ <li>#{c title}: #{status}</li>
90
91
  <?r end ?>
91
92
  </ul>
92
93
  </body>
@@ -183,7 +184,7 @@ changed to do following:
183
184
  <?r else ?>
184
185
  <ul>
185
186
  <?r @tasks.each do |title, status| ?>
186
- <li>#{title}: #{status}</li>
187
+ <li>#{c title}: #{status}</li>
187
188
  <?r end ?>
188
189
  </ul>
189
190
  <?r end ?>
@@ -270,7 +271,7 @@ Jump into `view/index.xhtml` and do the following:
270
271
 
271
272
  <?r @tasks.each do |title, status, toggle| ?>
272
273
  <li>
273
- #{title}: #{status} - [ #{toggle} ]
274
+ #{c title}: #{status} - [ #{toggle} ]
274
275
  </li>
275
276
  <?r end ?>
276
277
 
@@ -371,7 +372,7 @@ Now jumping to `view/index.xhtml` again, change it so it shows the link:
371
372
 
372
373
  <?r @tasks.each do |title, status, toggle, delete| ?>
373
374
  <li>
374
- #{title}: #{status} [ #{toggle} | #{delete} ]
375
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
375
376
  </li>
376
377
  <?r end ?>
377
378
 
@@ -467,7 +468,7 @@ First the `view/index.xhtml`
467
468
  <ul>
468
469
  <?r @tasks.each do |title, status, toggle, delete| ?>
469
470
  <li>
470
- #{title}: #{status} [ #{toggle} | #{delete} ]
471
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
471
472
  </li>
472
473
  <?r end ?>
473
474
  </ul>
@@ -498,7 +499,7 @@ So, from what we have right now:
498
499
  <ul>
499
500
  <?r @tasks.each do |title, status, toggle, delete| ?>
500
501
  <li>
501
- #{title}: #{status} [ #{toggle} | #{delete} ]
502
+ #{c title}: #{status} [ #{toggle} | #{delete} ]
502
503
  </li>
503
504
  <?r end ?>
504
505
  </ul>
@@ -508,7 +509,7 @@ To something like this:
508
509
  <table>
509
510
  <?r @tasks.each do |title, status, toggle, delete| ?>
510
511
  <tr>
511
- <td class="title"> #{title} </td>
512
+ <td class="title"> #{c title} </td>
512
513
  <td class="status"> #{status} </td>
513
514
  <td class="toggle"> #{toggle} </td>
514
515
  <td class="delete"> #{delete} </td>
@@ -1,4 +1,6 @@
1
1
  class MainController < Ramaze::Controller
2
+ layout '/layout'
3
+
2
4
  def index
3
5
  @entries = Entry.order(:created.DESC).all
4
6
  end
@@ -9,7 +9,7 @@ require 'start'
9
9
  describe 'Blog' do
10
10
  behaves_like 'http'
11
11
  ramaze :public_root => base/:public,
12
- :template_root => base/:template
12
+ :template_root => base/:view
13
13
 
14
14
  after do
15
15
  Entry.each{|e| e.delete unless e.id == 1 }
@@ -21,8 +21,8 @@ describe 'Blog' do
21
21
  page.body.should.not == nil
22
22
 
23
23
  doc = Hpricot(page.body)
24
- doc.at('title').inner_html.should == 'bl_Og'
25
- doc.at('h1').inner_html.should == 'bl_Og'
24
+ doc.at('title').inner_html.should == 'Blog'
25
+ doc.at('h1').inner_html.should == 'Blog'
26
26
 
27
27
  doc.search('div#entries').size.should == 1
28
28
 
@@ -1,8 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'ramaze'
3
3
 
4
- require 'src/model'
5
- require 'src/view'
6
- require 'src/controller'
4
+ require 'model/entry'
5
+ require 'controller/main'
7
6
 
8
7
  Ramaze.start
@@ -0,0 +1,17 @@
1
+ <h2>Editing entry</h2>
2
+ <div id="entries">
3
+ <div class="entry">
4
+ <form method="post" action="#{R self,:save}">
5
+ <input name="id" type="hidden" value="#{@entry.id}"/>
6
+ <div class="header">
7
+ <div class="title">
8
+ <input name="title" type="text" value="#{@entry.title}"/>
9
+ </div>
10
+ </div>
11
+ <div class="content">
12
+ <textarea name="content">#{@entry.content}</textarea>
13
+ </div>
14
+ <input type="submit" value="Update Entry"/>
15
+ </form>
16
+ </div>
17
+ </div>
@@ -0,0 +1,17 @@
1
+ <div id="actions">#{A 'new entry', :href => Rs(:new)}</div>
2
+ <div id="entries">
3
+ <?r @entries.each do |entry| ?>
4
+ <div class="entry">
5
+ <div class="header">
6
+ <div class="title">#{entry.title}</div>
7
+ <div class="created">Created: #{entry.created}</div>
8
+ <ul>
9
+ <li>#{A 'edit', :href => Rs(:edit, entry.id)}</li>
10
+ <li>#{A 'delete', :href => Rs(:delete, entry.id)}</li>
11
+ </ul>
12
+ </div>
13
+ <div class="content">#{entry.content}</div>
14
+ <div class="updated">Last updated: #{entry.updated}</div>
15
+ </div>
16
+ <?r end ?>
17
+ </div>
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <title>Blog</title>
4
+ <link rel="stylesheet" href="/styles/blog.css" type="text/css"/>
5
+ </head>
6
+ <body>
7
+ <h1>Blog</h1>
8
+ #@content
9
+ </body>
10
+ </html>
11
+
@@ -0,0 +1,16 @@
1
+ <h2>New entry</h2>
2
+ <div id="entries">
3
+ <div class="entry">
4
+ <form method="post" action="#{R self,:create}">
5
+ <div class="header">
6
+ <div class="title">
7
+ <input name="title" type="text" value=""/>
8
+ </div>
9
+ </div>
10
+ <div class="content">
11
+ <textarea name="content"></textarea>
12
+ </div>
13
+ <input type="submit" value="Add Entry"/>
14
+ </form>
15
+ </div>
16
+ </div>
@@ -76,30 +76,37 @@ end unless defined? Facebook::ID
76
76
  # facebook.addurl '/url' # add url for app that redirects to /url after successful install
77
77
 
78
78
  class MainController < Ramaze::Controller
79
- helper :formatting # for time_diff
79
+ helper :formatting
80
80
  helper :facebook
81
81
 
82
- before_all {
82
+ before {
83
83
  # show some information about current user in logs
84
84
  # INFO Facebook {:user=>15601088, :in_canvas=>true, :added=>true}
85
- inform :info, "Facebook " + fb.params.reject{|k,v| k.to_s !~ /^(in|is|user|added)/}.inspect if fb[:user]
85
+ if fb[:user]
86
+ # use facebook session_key as session cookie
87
+ session.session_id = fb[:session_key] if fb[:session_key]
88
+
89
+ Ramaze::Log.info "Facebook " + fb.params.reject{|k,v| k.to_s !~ /^(in|is|user|added|locale|request)/}.inspect
90
+ else
91
+ # require_add: redirect to add url
92
+ # fb.redirect fb.addurl
93
+ end
86
94
 
87
95
  # suggest setting SESSION key if one is not set, and current user is an admin
88
96
  # INFO Set a default session key: SESSION = 'b3638446fa02466210c49f42-15601088'
89
97
  if Facebook::SESSION.empty? and Facebook::ADMINS.include? fb[:user]
90
- inform :info, "Set a default session key: SESSION = '#{fb[:session_key]}'"
98
+ Ramaze::Log.info "Set a default session key: SESSION = '#{fb[:session_key]}'"
91
99
  end
92
- nil
93
100
  }
94
101
 
95
102
  def install
96
- inform :info, "#{fb[:user]} installed app" if request['installed'] == '1'
103
+ Ramaze::Log.info "#{fb[:user]} installed app" if request['installed'] == '1'
97
104
  facebook.profile.setFBML :uid => fb[:user], :markup => "Isn't this a great surprise!?"
98
105
  facebook.redirect request['next'] || '/'
99
106
  end
100
107
 
101
108
  def uninstall
102
- inform :info, "#{fb[:user]} uninstalled app"
109
+ Ramaze::Log.info "#{fb[:user]} uninstalled app"
103
110
  end
104
111
 
105
112
  def main
@@ -149,4 +156,4 @@ class MainController < Ramaze::Controller
149
156
  layout :layout
150
157
  end
151
158
 
152
- Ramaze.start :adapter => :mongrel
159
+ Ramaze.start :adapter => :mongrel