ramaze 0.3.9.1 → 2008.06

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. data/{doc/README → README.markdown} +78 -32
  2. data/Rakefile +53 -50
  3. data/benchmark/results.txt +131 -0
  4. data/benchmark/run.rb +362 -0
  5. data/benchmark/suite/minimal.rb +13 -0
  6. data/benchmark/suite/no_informer.rb +9 -0
  7. data/benchmark/suite/no_sessions.rb +10 -0
  8. data/benchmark/suite/no_template.rb +9 -0
  9. data/benchmark/suite/simple.rb +7 -0
  10. data/benchmark/suite/template_amrita2.rb +17 -0
  11. data/benchmark/suite/template_builder.rb +12 -0
  12. data/benchmark/suite/template_erubis.rb +10 -0
  13. data/benchmark/suite/template_ezamar.rb +10 -0
  14. data/benchmark/suite/template_haml.rb +15 -0
  15. data/benchmark/suite/template_liquid.rb +13 -0
  16. data/benchmark/suite/template_markaby.rb +11 -0
  17. data/benchmark/suite/template_nagoro.rb +10 -0
  18. data/benchmark/suite/template_redcloth.rb +15 -0
  19. data/benchmark/suite/template_tenjin.rb +10 -0
  20. data/benchmark/test.rb +35 -0
  21. data/bin/ramaze +32 -122
  22. data/cache.yaml +7 -0
  23. data/doc/AUTHORS +26 -22
  24. data/doc/CHANGELOG +16720 -3907
  25. data/doc/INSTALL +77 -19
  26. data/doc/LEGAL +0 -4
  27. data/doc/meta/announcement.txt +43 -54
  28. data/doc/meta/configuration.txt +3 -2
  29. data/doc/readme_chunks/examples.txt +2 -2
  30. data/doc/readme_chunks/installing.txt +66 -20
  31. data/doc/tutorial/todolist.html +338 -520
  32. data/doc/tutorial/todolist.mkd +36 -2
  33. data/examples/{auth → app/auth}/auth.rb +0 -0
  34. data/examples/{auth → app/auth}/template/layout.haml +0 -0
  35. data/examples/{auth → app/auth}/template/login.haml +0 -0
  36. data/examples/{blog → app/blog}/README +0 -0
  37. data/examples/{blog → app/blog}/controller/main.rb +1 -1
  38. data/examples/{blog → app/blog}/model/entry.rb +1 -1
  39. data/examples/{blog → app/blog}/public/styles/blog.css +0 -0
  40. data/examples/{blog → app/blog}/spec/blog.rb +2 -2
  41. data/examples/{blog → app/blog}/start.rb +0 -0
  42. data/examples/{blog → app/blog}/view/edit.xhtml +0 -0
  43. data/examples/{blog → app/blog}/view/index.xhtml +0 -0
  44. data/examples/{blog → app/blog}/view/layout.xhtml +0 -0
  45. data/examples/{blog → app/blog}/view/new.xhtml +0 -0
  46. data/examples/app/chat/model/history.rb +36 -0
  47. data/examples/app/chat/model/message.rb +7 -0
  48. data/examples/app/chat/public/css/chat.css +13 -0
  49. data/examples/app/chat/public/js/chat.js +22 -0
  50. data/examples/app/chat/public/js/jquery.js +3436 -0
  51. data/examples/app/chat/start.rb +40 -0
  52. data/examples/app/chat/view/chat.xhtml +9 -0
  53. data/examples/app/chat/view/index.xhtml +7 -0
  54. data/examples/app/chat/view/layout.xhtml +13 -0
  55. data/examples/app/localization/start.rb +35 -0
  56. data/examples/{rammit → app/rammit}/spec/rammit.rb +2 -1
  57. data/examples/{rammit → app/rammit}/src/controller/main.rb +0 -0
  58. data/examples/{rammit → app/rammit}/src/controller/page.rb +0 -0
  59. data/examples/{rammit → app/rammit}/src/model.rb +0 -0
  60. data/examples/{rammit → app/rammit}/start.rb +0 -0
  61. data/examples/{rammit → app/rammit}/template/index.xhtml +0 -0
  62. data/examples/{rammit → app/rammit}/template/page/view.xhtml +0 -0
  63. data/examples/{rapaste → app/rapaste}/Rakefile +0 -1
  64. data/examples/{rapaste → app/rapaste}/controller/paste.rb +3 -3
  65. data/examples/{rapaste → app/rapaste}/model/paste.rb +0 -0
  66. data/examples/{rapaste → app/rapaste}/public/css/active4d.css +0 -0
  67. data/examples/{rapaste → app/rapaste}/public/css/all_hallows_eve.css +0 -0
  68. data/examples/{rapaste → app/rapaste}/public/css/amy.css +0 -0
  69. data/examples/{rapaste → app/rapaste}/public/css/blackboard.css +0 -0
  70. data/examples/{rapaste → app/rapaste}/public/css/brilliance_black.css +0 -0
  71. data/examples/{rapaste → app/rapaste}/public/css/brilliance_dull.css +0 -0
  72. data/examples/{rapaste → app/rapaste}/public/css/cobalt.css +0 -0
  73. data/examples/{rapaste → app/rapaste}/public/css/dawn.css +0 -0
  74. data/examples/{rapaste → app/rapaste}/public/css/display.css +0 -0
  75. data/examples/{rapaste → app/rapaste}/public/css/eiffel.css +0 -0
  76. data/examples/{rapaste → app/rapaste}/public/css/espresso_libre.css +0 -0
  77. data/examples/{rapaste → app/rapaste}/public/css/idle.css +0 -0
  78. data/examples/{rapaste → app/rapaste}/public/css/iplastic.css +0 -0
  79. data/examples/{rapaste → app/rapaste}/public/css/lazy.css +0 -0
  80. data/examples/{rapaste → app/rapaste}/public/css/mac_classic.css +0 -0
  81. data/examples/{rapaste → app/rapaste}/public/css/magicwb_amiga.css +0 -0
  82. data/examples/{rapaste → app/rapaste}/public/css/pastels_on_dark.css +0 -0
  83. data/examples/{rapaste → app/rapaste}/public/css/slush_poppies.css +0 -0
  84. data/examples/{rapaste → app/rapaste}/public/css/spacecadet.css +0 -0
  85. data/examples/{rapaste → app/rapaste}/public/css/sunburst.css +0 -0
  86. data/examples/{rapaste → app/rapaste}/public/css/twilight.css +0 -0
  87. data/examples/{rapaste → app/rapaste}/public/css/zenburnesque.css +0 -0
  88. data/examples/{rapaste → app/rapaste}/public/js/jquery.js +0 -0
  89. data/examples/{rapaste → app/rapaste}/spec/rapaste.rb +2 -2
  90. data/examples/{rapaste → app/rapaste}/start.rb +0 -0
  91. data/examples/{rapaste → app/rapaste}/view/copy.xhtml +0 -0
  92. data/examples/{rapaste → app/rapaste}/view/index.xhtml +0 -0
  93. data/examples/{rapaste → app/rapaste}/view/layout.xhtml +0 -0
  94. data/examples/{rapaste → app/rapaste}/view/list.xhtml +0 -0
  95. data/examples/{rapaste → app/rapaste}/view/search.xhtml +0 -0
  96. data/examples/{rapaste → app/rapaste}/view/view.xhtml +0 -0
  97. data/examples/{sourceview → app/sourceview}/public/coderay.css +0 -0
  98. data/examples/{sourceview → app/sourceview}/public/images/file.gif +0 -0
  99. data/examples/{sourceview → app/sourceview}/public/images/folder.gif +0 -0
  100. data/examples/{sourceview → app/sourceview}/public/images/tv-collapsable-last.gif +0 -0
  101. data/examples/{sourceview → app/sourceview}/public/images/tv-collapsable.gif +0 -0
  102. data/examples/{sourceview → app/sourceview}/public/images/tv-expandable-last.gif +0 -0
  103. data/examples/{sourceview → app/sourceview}/public/images/tv-expandable.gif +0 -0
  104. data/examples/{sourceview → app/sourceview}/public/images/tv-item-last.gif +0 -0
  105. data/examples/{sourceview → app/sourceview}/public/images/tv-item.gif +0 -0
  106. data/examples/{sourceview → app/sourceview}/public/jquery.js +0 -0
  107. data/examples/{sourceview → app/sourceview}/public/jquery.treeview.css +0 -0
  108. data/examples/{sourceview → app/sourceview}/public/jquery.treeview.js +0 -0
  109. data/examples/{sourceview → app/sourceview}/public/sourceview.js +0 -0
  110. data/examples/{sourceview → app/sourceview}/sourceview.rb +1 -1
  111. data/examples/{sourceview → app/sourceview}/template/index.haml +0 -0
  112. data/examples/{todolist → app/todolist}/README +0 -0
  113. data/examples/{todolist → app/todolist}/public/favicon.ico +0 -0
  114. data/examples/{todolist → app/todolist}/public/js/jquery.js +0 -0
  115. data/examples/{todolist → app/todolist}/public/ramaze.png +0 -0
  116. data/examples/{todolist → app/todolist}/spec/todolist.rb +2 -2
  117. data/examples/{todolist → app/todolist}/src/controller/main.rb +0 -0
  118. data/examples/{todolist → app/todolist}/src/element/page.rb +0 -0
  119. data/examples/{todolist → app/todolist}/src/model.rb +0 -0
  120. data/examples/{todolist → app/todolist}/start.rb +0 -0
  121. data/examples/{todolist → app/todolist}/template/index.xhtml +0 -0
  122. data/examples/{todolist → app/todolist}/template/new.xhtml +0 -0
  123. data/examples/{upload → app/upload}/start.rb +0 -0
  124. data/examples/{upload → app/upload}/view/index.xhtml +0 -0
  125. data/examples/{whywiki → app/whywiki}/spec/whywiki.rb +3 -3
  126. data/examples/{whywiki → app/whywiki}/start.rb +0 -0
  127. data/examples/{whywiki → app/whywiki}/template/edit.xhtml +0 -0
  128. data/examples/{whywiki → app/whywiki}/template/show.xhtml +0 -0
  129. data/examples/{wikore → app/wikore}/spec/wikore.rb +2 -2
  130. data/examples/{wikore → app/wikore}/src/controller.rb +0 -0
  131. data/examples/{wikore → app/wikore}/src/model.rb +0 -0
  132. data/examples/{wikore → app/wikore}/start.rb +0 -0
  133. data/examples/{wikore → app/wikore}/template/index.xhtml +0 -0
  134. data/examples/{wiktacular → app/wiktacular}/README +0 -0
  135. data/examples/{wiktacular → app/wiktacular}/mkd/link/2007-07-20_19-45-51.mkd +0 -0
  136. data/examples/{wiktacular → app/wiktacular}/mkd/link/current.mkd +0 -0
  137. data/examples/{wiktacular → app/wiktacular}/mkd/main/2007-07-20_16-31-33.mkd +0 -0
  138. data/examples/{wiktacular → app/wiktacular}/mkd/main/2007-07-20_19-21-12.mkd +0 -0
  139. data/examples/{wiktacular → app/wiktacular}/mkd/main/2007-07-20_19-23-10.mkd +0 -0
  140. data/examples/{wiktacular → app/wiktacular}/mkd/main/2007-07-20_19-45-07.mkd +0 -0
  141. data/examples/{wiktacular → app/wiktacular}/mkd/main/current.mkd +0 -0
  142. data/examples/{wiktacular → app/wiktacular}/mkd/markdown/current.mkd +0 -0
  143. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-20_16-43-46.mkd +0 -0
  144. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-20_19-43-50.mkd +0 -0
  145. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-21_18-46-01.mkd +0 -0
  146. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-21_18-46-32.mkd +0 -0
  147. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-21_18-47-08.mkd +0 -0
  148. data/examples/{wiktacular → app/wiktacular}/mkd/testing/2007-07-21_18-47-54.mkd +0 -0
  149. data/examples/{wiktacular → app/wiktacular}/mkd/testing/current.mkd +0 -0
  150. data/examples/{wiktacular → app/wiktacular}/public/favicon.ico +0 -0
  151. data/examples/{wiktacular → app/wiktacular}/public/screen.css +0 -0
  152. data/examples/{wiktacular → app/wiktacular}/spec/wiktacular.rb +4 -5
  153. data/examples/{wiktacular → app/wiktacular}/src/controller.rb +0 -0
  154. data/examples/{wiktacular → app/wiktacular}/src/model.rb +0 -0
  155. data/examples/{wiktacular → app/wiktacular}/start.rb +0 -0
  156. data/examples/{wiktacular → app/wiktacular}/template/edit.xhtml +0 -0
  157. data/examples/{wiktacular → app/wiktacular}/template/html_layout.xhtml +0 -0
  158. data/examples/{wiktacular → app/wiktacular}/template/index.xhtml +0 -0
  159. data/examples/{wiktacular → app/wiktacular}/template/new.xhtml +0 -0
  160. data/examples/{element.rb → basic/element.rb} +0 -0
  161. data/examples/basic/gestalt.rb +27 -0
  162. data/examples/{hello.rb → basic/hello.rb} +0 -0
  163. data/examples/{layout.rb → basic/layout.rb} +0 -0
  164. data/examples/{linking.rb → basic/linking.rb} +0 -0
  165. data/examples/{simple.rb → basic/simple.rb} +3 -3
  166. data/examples/{caching.rb → helpers/cache.rb} +0 -0
  167. data/examples/helpers/form_with_sequel.rb +24 -0
  168. data/examples/helpers/httpdigest.rb +50 -0
  169. data/examples/{identity.rb → helpers/identity.rb} +0 -0
  170. data/examples/{nitro_form.rb → helpers/nitro_form.rb} +0 -0
  171. data/examples/helpers/provide.rb +23 -0
  172. data/examples/helpers/rest.rb +28 -0
  173. data/examples/helpers/simple_captcha.rb +29 -0
  174. data/examples/{css.rb → misc/css.rb} +0 -0
  175. data/examples/{facebook.rb → misc/facebook.rb} +0 -0
  176. data/examples/{memleak_detector.rb → misc/memleak_detector.rb} +0 -0
  177. data/examples/misc/nagoro_element.rb +43 -0
  178. data/examples/{ramaise.rb → misc/ramaise.rb} +0 -0
  179. data/examples/misc/rapp.rb +45 -0
  180. data/examples/misc/sequel_scaffolding.rb +34 -0
  181. data/examples/{simple_auth.rb → misc/simple_auth.rb} +0 -0
  182. data/examples/templates/template_amrita2.rb +1 -1
  183. data/examples/templates/template_erubis.rb +2 -2
  184. data/examples/templates/template_ezamar.rb +1 -1
  185. data/examples/templates/template_haml.rb +2 -2
  186. data/examples/templates/template_liquid.rb +2 -2
  187. data/examples/templates/template_markaby.rb +1 -1
  188. data/examples/templates/template_nagoro.rb +1 -1
  189. data/examples/templates/template_redcloth.rb +2 -2
  190. data/examples/templates/template_remarkably.rb +1 -1
  191. data/examples/templates/template_tenjin.rb +5 -9
  192. data/examples/templates/template_xslt.rb +1 -1
  193. data/lib/proto/public/dispatch.fcgi +0 -0
  194. data/lib/proto/public/js/jquery.js +750 -577
  195. data/lib/proto/spec/main.rb +1 -1
  196. data/lib/proto/start.ru +8 -0
  197. data/lib/proto/view/page.xhtml +13 -1
  198. data/lib/ramaze.rb +32 -15
  199. data/lib/ramaze/action.rb +18 -1
  200. data/lib/ramaze/action/render.rb +45 -17
  201. data/lib/ramaze/adapter.rb +8 -7
  202. data/lib/ramaze/adapter/base.rb +79 -13
  203. data/lib/ramaze/adapter/cgi.rb +5 -10
  204. data/lib/ramaze/adapter/ebb.rb +6 -20
  205. data/lib/ramaze/adapter/fake.rb +12 -0
  206. data/lib/ramaze/adapter/fcgi.rb +5 -11
  207. data/lib/ramaze/adapter/lsws.rb +5 -9
  208. data/lib/ramaze/adapter/mongrel.rb +5 -9
  209. data/lib/ramaze/adapter/scgi.rb +4 -8
  210. data/lib/ramaze/adapter/thin.rb +6 -11
  211. data/lib/ramaze/adapter/webrick.rb +13 -22
  212. data/lib/ramaze/cache.rb +36 -10
  213. data/lib/ramaze/cache/memcached.rb +3 -2
  214. data/lib/ramaze/contrib.rb +1 -1
  215. data/lib/ramaze/contrib/email.rb +1 -1
  216. data/lib/ramaze/contrib/file_cache.rb +1 -1
  217. data/lib/ramaze/contrib/gems.rb +79 -0
  218. data/lib/ramaze/contrib/gettext/po.rb +0 -0
  219. data/lib/ramaze/contrib/profiling.rb +1 -1
  220. data/lib/ramaze/contrib/rest.rb +14 -0
  221. data/lib/ramaze/controller.rb +45 -12
  222. data/lib/ramaze/controller/error.rb +4 -4
  223. data/lib/ramaze/controller/resolve.rb +61 -42
  224. data/lib/ramaze/current.rb +2 -2
  225. data/lib/ramaze/current/request.rb +25 -2
  226. data/lib/ramaze/current/response.rb +8 -0
  227. data/lib/ramaze/current/session.rb +64 -36
  228. data/lib/ramaze/current/session/flash.rb +14 -2
  229. data/lib/ramaze/current/session/hash.rb +3 -2
  230. data/lib/ramaze/dispatcher.rb +25 -12
  231. data/lib/ramaze/dispatcher/action.rb +12 -3
  232. data/lib/ramaze/dispatcher/directory.rb +4 -1
  233. data/lib/ramaze/dispatcher/error.rb +3 -3
  234. data/lib/ramaze/dispatcher/file.rb +11 -3
  235. data/lib/ramaze/gestalt.rb +1 -1
  236. data/lib/ramaze/helper.rb +17 -21
  237. data/lib/ramaze/helper/aspect.rb +20 -14
  238. data/lib/ramaze/helper/auth.rb +1 -1
  239. data/lib/ramaze/helper/cache.rb +3 -6
  240. data/lib/ramaze/helper/cgi.rb +6 -2
  241. data/lib/ramaze/helper/flash.rb +7 -7
  242. data/lib/ramaze/helper/form.rb +281 -0
  243. data/lib/ramaze/helper/formatting.rb +76 -0
  244. data/lib/ramaze/helper/gestalt.rb +15 -0
  245. data/lib/ramaze/helper/gravatar.rb +15 -0
  246. data/lib/ramaze/helper/httpdigest.rb +48 -0
  247. data/lib/ramaze/helper/identity.rb +87 -62
  248. data/lib/ramaze/helper/partial.rb +11 -2
  249. data/lib/ramaze/helper/redirect.rb +12 -3
  250. data/lib/ramaze/helper/rest.rb +43 -0
  251. data/lib/ramaze/helper/sendfile.rb +1 -3
  252. data/lib/ramaze/helper/sequel.rb +3 -0
  253. data/lib/ramaze/helper/simple_captcha.rb +31 -0
  254. data/lib/ramaze/helper/stack.rb +14 -5
  255. data/lib/ramaze/helper/user.rb +86 -34
  256. data/lib/ramaze/helper/xhtml.rb +23 -0
  257. data/lib/ramaze/log.rb +1 -2
  258. data/lib/ramaze/log/analogger.rb +24 -19
  259. data/lib/ramaze/log/growl.rb +24 -19
  260. data/lib/ramaze/log/hub.rb +25 -22
  261. data/lib/ramaze/log/informer.rb +104 -99
  262. data/lib/ramaze/log/knotify.rb +17 -12
  263. data/lib/ramaze/log/logger.rb +14 -8
  264. data/lib/ramaze/log/logging.rb +63 -60
  265. data/lib/ramaze/log/syslog.rb +24 -19
  266. data/lib/ramaze/log/xosd.rb +77 -71
  267. data/lib/ramaze/option.rb +153 -0
  268. data/lib/ramaze/option/dsl.rb +45 -0
  269. data/lib/ramaze/option/holder.rb +153 -0
  270. data/lib/ramaze/option/merger.rb +108 -0
  271. data/lib/ramaze/route.rb +15 -2
  272. data/lib/ramaze/setup.rb +50 -0
  273. data/lib/ramaze/snippets/binding/locals.rb +1 -1
  274. data/lib/ramaze/snippets/dictionary.rb +3 -3
  275. data/lib/ramaze/snippets/divide.rb +7 -7
  276. data/lib/ramaze/snippets/kernel/__dir__.rb +1 -1
  277. data/lib/ramaze/snippets/kernel/acquire.rb +0 -5
  278. data/lib/ramaze/snippets/metaid.rb +1 -1
  279. data/lib/ramaze/snippets/numeric/filesize_format.rb +11 -5
  280. data/lib/ramaze/snippets/object/instance_variable_defined.rb +8 -0
  281. data/lib/ramaze/snippets/object/scope.rb +1 -1
  282. data/lib/ramaze/snippets/object/thread_accessor.rb +1 -1
  283. data/lib/ramaze/snippets/ordered_set.rb +5 -1
  284. data/lib/ramaze/snippets/ramaze/deprecated.rb +7 -0
  285. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +15 -1
  286. data/lib/ramaze/snippets/string/esc.rb +2 -2
  287. data/lib/ramaze/snippets/string/start_with.rb +1 -0
  288. data/lib/ramaze/snippets/string/unindent.rb +9 -1
  289. data/lib/ramaze/snippets/struct/values_at.rb +17 -1
  290. data/lib/ramaze/snippets/thread/into.rb +1 -1
  291. data/lib/ramaze/sourcereload.rb +83 -76
  292. data/lib/ramaze/spec/helper.rb +39 -26
  293. data/lib/ramaze/spec/helper/bacon.rb +5 -5
  294. data/lib/ramaze/spec/helper/mock_http.rb +1 -7
  295. data/lib/ramaze/spec/helper/pretty_output.rb +10 -2
  296. data/lib/ramaze/spec/helper/requester.rb +14 -0
  297. data/lib/ramaze/template.rb +6 -3
  298. data/lib/ramaze/template/amrita2.rb +1 -0
  299. data/lib/ramaze/template/erubis.rb +7 -1
  300. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  301. data/lib/ramaze/template/nagoro.rb +1 -0
  302. data/lib/ramaze/template/redcloth.rb +1 -0
  303. data/lib/ramaze/template/tagz.rb +8 -8
  304. data/lib/ramaze/template/tenjin.rb +42 -2
  305. data/lib/ramaze/template/xslt.rb +4 -0
  306. data/lib/ramaze/tool/daemonize.rb +37 -0
  307. data/lib/ramaze/tool/localize.rb +142 -106
  308. data/lib/ramaze/version.rb +2 -10
  309. data/rake_tasks/conf.rake +11 -13
  310. data/rake_tasks/gem.rake +59 -37
  311. data/rake_tasks/git.rake +41 -0
  312. data/rake_tasks/maintenance.rake +263 -299
  313. data/rake_tasks/release.rake +63 -0
  314. data/rake_tasks/spec.rake +1 -1
  315. data/ramaze.gemspec +731 -0
  316. data/spec/contrib/profiling.rb +5 -2
  317. data/spec/examples/caching.rb +1 -1
  318. data/spec/examples/css.rb +1 -1
  319. data/spec/examples/element.rb +1 -1
  320. data/spec/examples/hello.rb +1 -1
  321. data/spec/examples/linking.rb +1 -1
  322. data/spec/examples/simple.rb +1 -1
  323. data/spec/examples/simple_auth.rb +1 -1
  324. data/spec/ramaze/action/cache.rb +58 -14
  325. data/spec/ramaze/action/file_cache.rb +48 -0
  326. data/spec/ramaze/action/layout.rb +2 -2
  327. data/spec/ramaze/action/render.rb +1 -2
  328. data/spec/ramaze/action/{template → view}/bar.xhtml +0 -0
  329. data/spec/ramaze/action/{template → view}/instancevars/layout.xhtml +0 -0
  330. data/spec/ramaze/action/{template → view}/other_wrapper.xhtml +0 -0
  331. data/spec/ramaze/action/{template → view}/single_wrapper.xhtml +0 -0
  332. data/spec/ramaze/action/{template → view}/sub/sub_wrapper.xhtml +0 -0
  333. data/spec/ramaze/adapter.rb +29 -2
  334. data/spec/ramaze/adapter/ebb.rb +12 -0
  335. data/spec/ramaze/cache.rb +82 -15
  336. data/spec/ramaze/controller.rb +6 -3
  337. data/spec/ramaze/controller/actionless_templates.rb +2 -2
  338. data/spec/ramaze/controller/resolve.rb +1 -1
  339. data/spec/ramaze/controller/template_resolving.rb +4 -6
  340. data/spec/ramaze/controller/{template → view}/greet.xhtml +0 -0
  341. data/spec/ramaze/controller/{template → view}/list.xhtml +0 -0
  342. data/spec/ramaze/controller/{template → view}/other/greet/other.xhtml +0 -0
  343. data/spec/ramaze/controller/{template → view}/other_wrapper.xhtml +0 -0
  344. data/spec/ramaze/error.rb +1 -1
  345. data/spec/ramaze/helper/aspect.rb +4 -4
  346. data/spec/ramaze/helper/cache.rb +56 -39
  347. data/spec/ramaze/helper/flash.rb +14 -1
  348. data/spec/ramaze/helper/form.rb +118 -0
  349. data/spec/ramaze/helper/formatting.rb +21 -0
  350. data/spec/ramaze/helper/link.rb +2 -2
  351. data/spec/ramaze/helper/pager.rb +2 -2
  352. data/spec/ramaze/helper/partial.rb +13 -1
  353. data/spec/ramaze/helper/simple_captcha.rb +22 -0
  354. data/spec/ramaze/helper/user.rb +7 -10
  355. data/spec/ramaze/helper/{template → view}/locals.xhtml +0 -0
  356. data/spec/ramaze/helper/{template → view}/loop.xhtml +0 -0
  357. data/spec/ramaze/helper/{template → view}/num.xhtml +0 -0
  358. data/spec/ramaze/helper/{template → view}/partial.xhtml +0 -0
  359. data/spec/ramaze/helper/{template → view}/recursive.xhtml +0 -0
  360. data/spec/ramaze/helper/{template → view}/recursive_local_ivars.xhtml +0 -0
  361. data/spec/ramaze/helper/{template → view}/recursive_locals.xhtml +0 -0
  362. data/spec/ramaze/helper/{template → view}/test_template.xhtml +0 -0
  363. data/spec/ramaze/localize.rb +22 -0
  364. data/spec/ramaze/log/informer.rb +10 -10
  365. data/spec/ramaze/log/syslog.rb +1 -1
  366. data/spec/ramaze/request.rb +13 -1
  367. data/spec/ramaze/request/ebb.rb +9 -0
  368. data/spec/ramaze/rewrite.rb +36 -0
  369. data/spec/ramaze/rewrite/file.css +1 -0
  370. data/spec/ramaze/route.rb +1 -0
  371. data/spec/ramaze/template.rb +5 -5
  372. data/spec/ramaze/template/amrita2.rb +1 -1
  373. data/spec/ramaze/template/builder.rb +18 -22
  374. data/spec/ramaze/template/erubis.rb +1 -1
  375. data/spec/ramaze/template/ezamar.rb +1 -1
  376. data/spec/ramaze/template/haml.rb +2 -2
  377. data/spec/ramaze/template/liquid.rb +1 -1
  378. data/spec/ramaze/template/markaby.rb +1 -1
  379. data/spec/ramaze/template/nagoro.rb +1 -1
  380. data/spec/ramaze/template/redcloth.rb +1 -1
  381. data/spec/ramaze/template/remarkably.rb +1 -1
  382. data/spec/ramaze/template/sass.rb +1 -1
  383. data/spec/ramaze/template/tagz.rb +1 -1
  384. data/spec/ramaze/template/tenjin.rb +4 -6
  385. data/spec/ramaze/template/xslt.rb +1 -1
  386. data/spec/snippets/string/unindent.rb +6 -0
  387. data/spec/snippets/struct/values_at.rb +8 -0
  388. metadata +522 -487
  389. data/doc/ProjectInfo +0 -53
  390. data/doc/migrate/1110_to_1111.txt +0 -131
  391. data/lib/ramaze/contrib/route.rb +0 -22
  392. data/lib/ramaze/global.rb +0 -116
  393. data/lib/ramaze/global/dsl.rb +0 -39
  394. data/lib/ramaze/global/globalstruct.rb +0 -147
  395. data/lib/ramaze/helper/inform.rb +0 -40
  396. data/lib/ramaze/inform.rb +0 -4
  397. data/lib/ramaze/snippets/kernel/aquire.rb +0 -1
  398. data/lib/vendor/bacon.rb +0 -323
  399. data/rake_tasks/darcs.rake +0 -5
  400. data/spec/contrib/route.rb +0 -36
@@ -1,34 +1,92 @@
1
- = Installating Ramaze
2
-
3
1
  * via RubyGems
4
2
 
5
- The simplest way of installing Ramaze is via
3
+ The simplest way of installing Ramaze is via the gem.
4
+
5
+ [Rubygems](http://rubygems.org) is the package manager for ruby apps and
6
+ libraries and provides you with the last tagged version of Ramaze.
6
7
 
7
- $ gem install ramaze
8
+ $ gem install ramaze
8
9
 
9
- in case you have RubyGems installed.
10
- (this will work as soon as I have registered on RubyForge ;)
10
+ Versions are made as we see fit and get an announcment out (usually that's
11
+ the major obstacle as there is a lot to announce).
11
12
 
12
- * via install.rb
13
+ If you want to install the nightly gem of Ramaze you can do this with:
13
14
 
14
- Ramaze provides a basic install.rb that should take care of the installation
15
- you can use it like
15
+ $ gem install ramaze --source=http://gem.ramaze.net/
16
16
 
17
- $ ruby install.rb
17
+ We also use the gem building process on github, which locates gems at
18
+ http://gems.github.com - so you can get a version from there as well:
18
19
 
19
- you may need root-privileges to do
20
- that, depending on what options you provide.
21
- (please note that I haven't tested the install.rb extensively yet, so if you
22
- find some quirks, please send me patches or a simple note)
20
+ $ gem install manveru-ramaze --source=http://gems.github.com/
23
21
 
24
- * via darcs
22
+ * via git
25
23
 
26
24
  To get the latest and sweetest, you can just pull from the repository and run
27
25
  Ramaze that way.
28
26
 
29
- $ darcs get --partial http://manveru.mine.nu/ramaze
27
+ $ git clone git://github.com/manveru/ramaze.git
30
28
 
31
- Please read the man page or `darcs help` for more information about updating
29
+ Please read the `man git` or `git help` for more information about updating
32
30
  and creating your own patches.
33
- This is at the moment the premier way to use Ramaze, since it is the way I use
34
- it.
31
+ This is at the moment the premier way to use Ramaze, since it is the way I
32
+ use it.
33
+
34
+ Some hints for the usage of Git.
35
+
36
+ * use `require 'ramaze'` from everywhere
37
+
38
+ Simply add the path to your repository to the RUBYLIB environment variable.
39
+ If you are using bash you can simply put following line into your .bashrc:
40
+
41
+ $ export RUBYLIB="$HOME/path/to/repo/lib/"
42
+
43
+ Of course you should put the real path instead, you can also add multiple
44
+ paths, or create your personal `site_ruby`:
45
+
46
+ $ export RUBYLIB="$HOME/ruby/ramaze/lib:$HOME/.site_ruby:$HOME/ruby/bacon/lib"
47
+
48
+ * use `require 'ramaze'` systemwide from everywhere
49
+
50
+ add a file to your `site_ruby` directory named 'ramaze.rb'
51
+ the content should be: `require '/path/to/git/repo/ramaze/lib/ramaze'`
52
+
53
+ * Pull the latest version
54
+
55
+ $ git pull
56
+
57
+ * Reset the repo to original state (if you screw up something)
58
+
59
+ $ git reset --hard # resets the whole repo
60
+
61
+ * Revert changes to (for example) lib/ramaze.rb only
62
+
63
+ $ git checkout master lib/ramaze.rb
64
+
65
+ * Add and commit all changes.
66
+
67
+ $ git commit -a
68
+
69
+ * Adding only specific changes.
70
+
71
+ # Add hunks you want to commit to the staging area (index)
72
+ $ git add -p
73
+
74
+ * Commit the changes into the history of your repository
75
+
76
+ # Create a commit from the hunks added
77
+ $ git commit
78
+
79
+ * output your patches into a bundle ready to be mailed (compress it before
80
+ sending to make sure it arrives in the way you sent it)
81
+
82
+ At the end of this process you will have a tar.bz2 for all your changes
83
+ that you can mail to ramaze@googlegroups.com
84
+
85
+ # make sure you are on latest revision to avoid conflicts
86
+ $ git pull
87
+
88
+ # create 00xx-blah.patch files against the remote repo
89
+ $ git format-patch origin/HEAD
90
+
91
+ # From here on you can use either git-send-email or go the manual route
92
+ $ tar -cjf ramaze_bundle.tar.bz2 *.patch
data/doc/LEGAL CHANGED
@@ -20,7 +20,3 @@ lib/ramaze/spec/helper/simple_http.rb
20
20
  lib/ramaze/template/xslt.rb
21
21
  License: Ruby
22
22
  Author: Stephan Maka
23
-
24
- lib/vendor/bacon.rb
25
- License: MIT
26
- Author: Christian Neukirchen
@@ -1,4 +1,4 @@
1
- This time we are proud to announce Version 0.3.5 of Ramaze, the light and
1
+ This time we are proud to announce Version 2008.06 of Ramaze, the light and
2
2
  modular open source web framework.
3
3
 
4
4
  This release features a lot of work directly from our community and we are
@@ -10,11 +10,15 @@ implementation and usage. Ramaze is under development by a growing community
10
10
  and in production use at companies.
11
11
 
12
12
 
13
- Home page: http://ramaze.net
14
- Screencasts: http://ramaze.net/screencasts
13
+ Home page: http://ramaze.net
14
+ Screencasts: http://ramaze.net/screencasts
15
15
 
16
- View source: http://source.ramaze.net
17
- Darcsweb: http://darcs.ramaze.net
16
+ View source: http://source.ramaze.net
17
+ Github: http://github.com/manveru/ramaze
18
+
19
+ Nightly gems: http://gems.ramaze.net
20
+ Git clone: git://github.com/manveru/ramaze
21
+ Current tarball: http://github.com/manveru/ramaze/tarball/master
18
22
 
19
23
  IRC: #ramaze on irc.freenode.net
20
24
 
@@ -32,59 +36,44 @@ Simple example:
32
36
  Ramaze.start
33
37
 
34
38
 
35
- Special (alphabetic) thanks go to:
39
+ This is a special release, and the first of the upcoming new series of monthly releases.
40
+ As you may have noticed, Ramaze has changed to a date base versioning system,
41
+ although this means that people who have waited for a 1.0 for the past years
42
+ may be disappointed it provides much larger flexibility in detecting new
43
+ versions and comparing them with nightly builds.
44
+
45
+ Another change is the switch from darcs to git and moving our primary
46
+ repository to github. There have been serious performance issues regarding
47
+ darcs as Ramaze gathered a longer history, using git allows us to move on at a
48
+ faster pace again.
36
49
 
37
- Aman 'tmm1' Gupta - patches and support
38
- Carlo Zottmann - first patch!
39
- Chris 'celldee' Duncan - first patch!
40
- Gabriele 'riffraff' Renzi - patches for file dispatcher
41
- jeedee - new Ramaze logo
42
- Jonathan 'Kashia' Buch - patches and support
43
- Keita Yamaguchi - first patch!
44
- Pistos - lots of friendly support
45
- skaar - first patch!
46
-
47
-
48
- Selected summary of the 62 patches from 0.3.0 to 0.3.5:
49
-
50
- Core
51
- - Ramaze::Contrib::Route made available by default as Ramaze::Route
52
- (backwards compatibility retained)
53
- - Support added for ETag and If-Modified-Since in Dispatcher::File
54
- - Adapter for LiteSpeed webserver added
55
- - Added ability to set default session cookie options using Session::COOKIE
56
- - Support added for Content-Language based localization and gettext
57
-
58
- Templates
59
- - Support added for passing in locals to render_template
60
- - Added support for symbol argument to template_root
61
- - render_template no longer requires template extensions
62
- - Dots allowed in template extensions (template.html.erb)
63
-
64
- Templating Engines
65
- - Builder templating engine added to produce XML
66
- - RedCloth templating engine added
67
- - Amrita2 templating engine updated to latest release
68
-
69
- Helpers
70
- - Simple EmailHelper added
71
- - IdentityHelper updated for latest ruby-openid
72
- - MarukuHelper added
73
- - AuthHelper cleaned up
74
- - LinkHelper improved: A(), R(), Rs() and breadcrumbs
75
-
76
- Examples
77
- - All examples were standardized to include rubygems
78
- - Simple file upload example added
79
- - Search and diff functionality added to Rapaste
80
-
81
- Misc
82
- - Read and read/write issues fixed in Ramaze::Store
83
- - Fix applied for running Ramaze apps within IDEs on Windows
50
+ Please regard this release as a major step from the previous one, over 450
51
+ patches have been applied and there were changes in the internal API.
52
+
53
+ We are unable to nicely summarize these changes, so this release will not have
54
+ a list of the most important ones, if you are concerned about a specific area
55
+ feel free to ask on the Mailing list or stop by on IRC.
56
+
57
+ Special (alphabetic) thanks go to:
84
58
 
59
+ Aman 'tmm1' Gupta - Tons of patches, support
60
+ andy - Cleanup
61
+ Ara T. Howard - Tagz templating engine
62
+ Clive Crous - Patches, cleanup
63
+ evaryont - Patches for identity helper
64
+ James Tucker - OSX compatibility, cleanup and fixes
65
+ Jonathan 'Kashia' Buch - Patches, support and the first ramaze paper
66
+ Keita Yamaguchi - Much work on the benchmark suite
67
+ Leo Borisenko - Fix for SourceReload on windows
68
+ Pistos - Mathetes, patches and lots of friendly support
69
+ Riku Räisäenen - Patches for scaffolding example
70
+ Ryan Grove - Various fixes and patches
71
+ Sam Carr - Patches and action matching speedup
72
+ Thomas Leitner - Patches for identity helper
73
+ Wang Jinjing - patches, 1.9/1.8.7 compatibility
85
74
 
86
75
  A complete Changelog is available at
87
- http://darcs.ramaze.net/ramaze/doc/CHANGELOG
76
+ http://github.com/manveru/ramaze/tree/master/doc/CHANGELOG?raw=true
88
77
 
89
78
 
90
79
  Known issues:
@@ -18,9 +18,10 @@ Global with Ramaze so it is written Ramaze::Global.
18
18
 
19
19
  #### Basic assignment:
20
20
 
21
- Global.spawn = 10
21
+ Global.port = 10
22
22
 
23
- if you do that before calling Ramaze::start Ramaze will spawn the given number of servers.
23
+ if you do that before calling Ramaze::start Ramaze will choose the given number
24
+ as port.
24
25
 
25
26
 
26
27
  #### Multiple assignment:
@@ -29,10 +29,10 @@ Examples include:
29
29
  Not yet fully functional, but coming along.
30
30
 
31
31
  * examples/whywiki
32
- A basic examples of a minimalistic application, based on the Wiki of _why in
32
+ A basic examples of a minimalistic application, based on the Wiki of \_why in
33
33
  his camping-framework.
34
34
 
35
35
  * examples/templates
36
36
  examples of real usage of the templating-engines. Tries to implement the same
37
- functionality in each template_*.rb file using a different engine.
37
+ functionality in each `template_*.rb` file using a different engine.
38
38
 
@@ -1,46 +1,92 @@
1
1
  * via RubyGems
2
2
 
3
- The simplest way of installing Ramaze is via
3
+ The simplest way of installing Ramaze is via the gem.
4
4
 
5
- $ gem install ramaze
5
+ [Rubygems](http://rubygems.org) is the package manager for ruby apps and
6
+ libraries and provides you with the last tagged version of Ramaze.
6
7
 
7
- in case you have RubyGems installed.
8
+ $ gem install ramaze
8
9
 
10
+ Versions are made as we see fit and get an announcment out (usually that's
11
+ the major obstacle as there is a lot to announce).
9
12
 
10
- * via darcs
13
+ If you want to install the nightly gem of Ramaze you can do this with:
14
+
15
+ $ gem install ramaze --source=http://gem.ramaze.net/
16
+
17
+ We also use the gem building process on github, which locates gems at
18
+ http://gems.github.com - so you can get a version from there as well:
19
+
20
+ $ gem install manveru-ramaze --source=http://gems.github.com/
21
+
22
+ * via git
11
23
 
12
24
  To get the latest and sweetest, you can just pull from the repository and run
13
25
  Ramaze that way.
14
26
 
15
- $ darcs get --partial http://darcs.ramaze.net/ramaze
27
+ $ git clone git://github.com/manveru/ramaze.git
16
28
 
17
- Please read the man page or `darcs help` for more information about updating
29
+ Please read the `man git` or `git help` for more information about updating
18
30
  and creating your own patches.
19
- This is at the moment the premier way to use Ramaze, since it is the way I use
20
- it.
31
+ This is at the moment the premier way to use Ramaze, since it is the way I
32
+ use it.
33
+
34
+ Some hints for the usage of Git.
35
+
36
+ * use `require 'ramaze'` from everywhere
37
+
38
+ Simply add the path to your repository to the RUBYLIB environment variable.
39
+ If you are using bash you can simply put following line into your .bashrc:
40
+
41
+ $ export RUBYLIB="$HOME/path/to/repo/lib/"
42
+
43
+ Of course you should put the real path instead, you can also add multiple
44
+ paths, or create your personal `site_ruby`:
45
+
46
+ $ export RUBYLIB="$HOME/ruby/ramaze/lib:$HOME/.site_ruby:$HOME/ruby/bacon/lib"
47
+
48
+ * use `require 'ramaze'` systemwide from everywhere
49
+
50
+ add a file to your `site_ruby` directory named 'ramaze.rb'
51
+ the content should be: `require '/path/to/git/repo/ramaze/lib/ramaze'`
52
+
53
+ * Pull the latest version
54
+
55
+ $ git pull
56
+
57
+ * Reset the repo to original state (if you screw up something)
58
+
59
+ $ git reset --hard # resets the whole repo
60
+
61
+ * Revert changes to (for example) lib/ramaze.rb only
21
62
 
22
- Some hints for the usage of Darcs.
63
+ $ git checkout master lib/ramaze.rb
23
64
 
24
- * use require 'ramaze' from everywhere
65
+ * Add and commit all changes.
25
66
 
26
- add a file to your site_ruby named 'ramaze.rb'
27
- the content should be: "require '/path/to/darcs/repo/ramaze/lib/ramaze'"
67
+ $ git commit -a
28
68
 
29
- * get the latest version (from inside the ramaze-directory)
69
+ * Adding only specific changes.
30
70
 
31
- $ darcs pull
71
+ # Add hunks you want to commit to the staging area (index)
72
+ $ git add -p
32
73
 
33
- * record a patch
74
+ * Commit the changes into the history of your repository
34
75
 
35
- $ darcs record
76
+ # Create a commit from the hunks added
77
+ $ git commit
36
78
 
37
79
  * output your patches into a bundle ready to be mailed (compress it before
38
80
  sending to make sure it arrives in the way you sent it)
39
81
 
40
- $ darcs send -o ramaze_bundle
41
- $ gzip -c ramaze_bundle > ramaze_bundle.gz
82
+ At the end of this process you will have a tar.bz2 for all your changes
83
+ that you can mail to ramaze@googlegroups.com
42
84
 
85
+ # make sure you are on latest revision to avoid conflicts
86
+ $ git pull
43
87
 
44
- * via install.rb
88
+ # create 00xx-blah.patch files against the remote repo
89
+ $ git format-patch origin/HEAD
45
90
 
46
- Support for install.rb has been canceled and the file removed.
91
+ # From here on you can use either git-send-email or go the manual route
92
+ $ tar -cjf ramaze_bundle.tar.bz2 *.patch
@@ -1,128 +1,86 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html>
4
- <head>
5
- <title>Ramaze Tutorial: Todolist</title>
6
- <style>
7
- body {
8
- background: #eee;
9
- }
10
- code {
11
- background: #ddd;
12
- }
13
- pre code {
14
- background: #ddd;
15
- width: 70%;
16
- display: block;
17
- margin: 1em;
18
- padding: 0.7em;
19
- overflow: auto;
20
- }
21
- </style>
22
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
23
- </head>
24
- <body>
25
-
26
- <h1>To-do List Tutorial</h1>
27
-
28
- <div class="menu">
29
- <h3>Table of Contents</h3>
30
- <li>
31
- <ol><a href="#Step_Zero,_Introduction">Step Zero, Introduction</a></ol>
32
- <ol><a href="#First_Step,_Create">First Step, Create</a></ol>
33
- <ol><a href="#Second_Step,_M,_like_Model">Second Step, M, like Model</a></ol>
34
- <ol><a href="#Third_Step,_V,_like_View">Third Step, V, like View</a></ol>
35
- <ol><a href="#Fourth_Step,_C,_like_Controller">Fourth Step, C, like Controller</a></ol>
36
- <ol><a href="#Fifth_Step,_getting_dynamic">Fifth Step, getting dynamic</a></ol>
37
- <ol><a href="#Sixth_Step,_open_and_close_tasks">Sixth Step, open and close tasks</a></ol>
38
- <ol><a href="#Seventh_Step,_delete_tasks">Seventh Step, delete tasks</a></ol>
39
- <ol><a href="#Eighth_Step,_Elements">Eighth Step, Elements</a></ol>
40
- <ol><a href="#Ninth_Step,_Prettify">Ninth Step, Prettify</a></ol>
41
- <ol><a href="#Tenth_Step,_Configuration">Tenth Step, Configuration</a></ol>
42
- <ol><a href="#Eleventh_Step,_Refactor_with_AspectHelper">Eleventh Step, Refactor with AspectHelper</a></ol>
43
- <ol><a href="#Twelfth_Step,_Validation_and_Errors">Twelfth Step, Validation and Errors</a></ol>
44
- </li>
45
- </div>
46
-
47
-
48
- <a name="Step_Zero,_Introduction"><h2>Step Zero, Introduction</h2></a>
49
-
50
- <p>Welcome to our official tutorial, the mandatory to-do list.
51
- I'm writing this while doing the steps to assure it will work for you.</p>
52
-
53
- <p>The tutorial assumes that you have Ramaze installed already. The easiest way to
54
- do that is <code>gem install ramaze</code>, for other ways of installation please see the
55
- documentation at http://ramaze.rubyforge.org</p>
56
-
57
- <p>Should you encounter any problems while doing this tutorial, this might either
58
- be because Ramaze changed (which happens very often while it is still young)
59
- or I actually made some mistake while writing it.</p>
60
-
61
- <p>In either case it would make me (and all other poor fellows who happen to try
62
- this tutorial) very happy if you could spare some time and report the issue
63
- either on the Bug tracker at http://rubyforge.org/projects/ramaze or just
64
- drop by on IRC ( irc.freenode.org channel: #ramaze ).</p>
65
-
66
- <p>There is also a Mailing list available where you can keep yourself updated on
67
- what is going on with little effort, it is also located on the project-page at
68
- RubyForge.</p>
69
-
70
- <p>Additionally, we now have added tests for the resulting application that you
71
- can find in spec/examples/todolist.rb</p>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
3
+ <html xml:lang="en" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/1999/xhtml">
4
+ <head><meta content="application/xhtml+xml;charset=utf-8" http-equiv="Content-type" /><title>The official Ramaze todolist tutorial</title><style type="text/css">
5
+ .ruby .normal {}
6
+ .ruby .comment { color: #005; font-style: italic; }
7
+ .ruby .keyword { color: #A00; font-weight: bold; }
8
+ .ruby .method { color: #077; }
9
+ .ruby .class { color: #074; }
10
+ .ruby .module { color: #050; }
11
+ .ruby .punct { color: #447; font-weight: bold; }
12
+ .ruby .symbol { color: #099; }
13
+ .ruby .string { color: #944; background: #FFE; }
14
+ .ruby .char { color: #F07; }
15
+ .ruby .ident { color: #004; }
16
+ .ruby .constant { color: #07F; }
17
+ .ruby .regex { color: #B66; background: #FEF; }
18
+ .ruby .number { color: #F99; }
19
+ .ruby .attribute { color: #7BB; }
20
+ .ruby .global { color: #7FB; }
21
+ .ruby .expr { color: #227; }
22
+ .ruby .escape { color: #277; }
23
+
24
+ </style></head>
25
+ <body>
26
+ <h1 id="todo_list_tutorial">To-do List Tutorial</h1>
27
+ <div class="maruku_toc"><ul style="list-style: none;"><li><a href="#step_zero_introduction">Step Zero, Introduction</a></li><li><a href="#first_step_create">First Step, Create</a></li><li><a href="#second_step_m_like_model">Second Step, M, like Model</a></li><li><a href="#third_step_v_like_view">Third Step, V, like View</a></li><li><a href="#fourth_step_c_like_controller">Fourth Step, C, like Controller</a></li><li><a href="#fifth_step_getting_dynamic">Fifth Step, getting dynamic</a></li><li><a href="#sixth_step_open_and_close_tasks">Sixth Step, open and close tasks</a></li><li><a href="#seventh_step_delete_tasks">Seventh Step, delete tasks</a></li><li><a href="#eighth_step_elements">Eighth Step, Elements</a></li><li><a href="#ninth_step_prettify">Ninth Step, Prettify</a></li><li><a href="#tenth_step_configuration">Tenth Step, Configuration</a></li><li><a href="#eleventh_step_refactor_with_aspecthelper">Eleventh Step, Refactor with AspectHelper</a></li><li><a href="#twelfth_step_validation_and_errors">Twelfth Step, Validation and Errors</a></li></ul></div>
28
+ <h2 id="step_zero_introduction">Step Zero, Introduction</h2>
29
+
30
+ <p>Welcome to our official tutorial, the mandatory to-do list. I&#8217;m writing this while doing the steps to assure it will work for you.</p>
31
+
32
+ <p>The tutorial assumes that you have Ramaze installed already. The easiest way to do that is <code>gem install ramaze</code>, for other ways of installation please see the documentation at http://ramaze.rubyforge.org</p>
33
+
34
+ <p>Should you encounter any problems while doing this tutorial, this might either be because Ramaze changed (which happens very often while it is still young) or I actually made some mistake while writing it.</p>
35
+
36
+ <p>In either case it would make me (and all other poor fellows who happen to try this tutorial) very happy if you could spare some time and report the issue either on the Bug tracker at http://rubyforge.org/projects/ramaze or just drop by on IRC ( irc.freenode.org channel: #ramaze ).</p>
37
+
38
+ <p>There is also a Mailing list available where you can keep yourself updated on what is going on with little effort, it is also located on the project-page at RubyForge.</p>
39
+
40
+ <p>Additionally, we now have added tests for the resulting application that you can find in spec/examples/todolist.rb</p>
72
41
 
73
42
  <p>Date of last update: Thu Jan 31 04:37:16 JST 2008</p>
74
43
 
75
- <p>Thanks in advance.
76
- The author of the tutorial, Michael 'manveru' Fellinger</p>
44
+ <p>Thanks in advance. The author of the tutorial, Michael &#8216;manveru&#8217; Fellinger</p>
77
45
 
78
- <a name="First_Step,_Create"><h2>First Step, Create</h2></a>
46
+ <h2 id="first_step_create">First Step, Create</h2>
79
47
 
80
- <p>We are using <code>ramaze --create todolist</code> to create a new application.
81
- Ramaze will then create the directory and fill it with a skeleton of a quite
82
- sophisticated hello-world example out of which we will create the actual
83
- to-do list.</p>
48
+ <p>We are using <code>ramaze --create todolist</code> to create a new application. Ramaze will then create the directory and fill it with a skeleton of a quite sophisticated hello-world example out of which we will create the actual to-do list.</p>
84
49
 
85
50
  <p>So run:</p>
86
51
 
87
- <pre><code>$ ramaze --create todolist
88
- </code></pre>
52
+ <pre><code>$ ramaze --create todolist</code></pre>
89
53
 
90
54
  <p>done.</p>
91
55
 
92
- <a name="Second_Step,_M,_like_Model"><h2>Second Step, M, like Model</h2></a>
56
+ <h2 id="second_step_m_like_model">Second Step, M, like Model</h2>
93
57
 
94
- <p>Ramaze comes at the moment only with a simple wrapper of the YAML::Store.
95
- So we are going to base this on the tools available, you can just do the same
96
- with your ORM or database-library of choice.</p>
58
+ <p>Ramaze comes at the moment only with a simple wrapper of the YAML::Store. So we are going to base this on the tools available, you can just do the same with your ORM or database-library of choice.</p>
97
59
 
98
60
  <p>So first, create a <code>model/todolist.rb</code> for our application:</p>
99
61
 
100
- <pre><code>require 'ramaze/store/default'
101
- TodoList = Ramaze::Store::Default.new('todolist.yaml')
102
- </code></pre>
62
+ <pre><code class="ruby" lang="ruby"><span class="ident">require</span> <span class="punct">&#39;</span><span class="string">ramaze/store/default</span><span class="punct">&#39;</span>
63
+ <span class="constant">TodoList</span> <span class="punct">=</span> <span class="constant">Ramaze</span><span class="punct">::</span><span class="constant">Store</span><span class="punct">::</span><span class="constant">Default</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(&#39;</span><span class="string">todolist.yaml</span><span class="punct">&#39;)</span></code></pre>
103
64
 
104
- <p>Let's add some items as well to have a base to start from.</p>
65
+ <p>Let&#8217;s add some items as well to have a base to start from.</p>
105
66
 
106
- <pre><code>{ 'Laundry' =&gt; {:done =&gt; false},
107
- 'Wash dishes' =&gt; {:done =&gt; false},
108
- }.each do |title, value|
109
- TodoList[title] = value
110
- end
111
- </code></pre>
67
+ <pre><code class="ruby" lang="ruby"><span class="punct">{</span> <span class="punct">&#39;</span><span class="string">Laundry</span><span class="punct">&#39;</span> <span class="punct">=&gt;</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">},</span>
68
+ <span class="punct">&#39;</span><span class="string">Wash dishes</span><span class="punct">&#39;</span> <span class="punct">=&gt;</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">},</span>
69
+ <span class="punct">}.</span><span class="ident">each</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">value</span><span class="punct">|</span>
70
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">value</span>
71
+ <span class="keyword">end</span></code></pre>
112
72
 
113
- <a name="Third_Step,_V,_like_View"><h2>Third Step, V, like View</h2></a>
73
+ <h2 id="third_step_v_like_view">Third Step, V, like View</h2>
114
74
 
115
- <p>Now let's get our hands dirty and just edit the templates for our to-do list.</p>
75
+ <p>Now let&#8217;s get our hands dirty and just edit the templates for our to-do list.</p>
116
76
 
117
- <p>Start with editing <code>view/index.xhtml</code>, it is using the default templating
118
- of Ramaze, called Ezamar.</p>
77
+ <p>Start with editing <code>view/index.xhtml</code>, it is using the default templating of Ramaze, called Ezamar.</p>
119
78
 
120
79
  <p>The index.xhtml currently contains a default welcome page, remove the contents.</p>
121
80
 
122
- <p>Let's put some things in there, I'll explain the syntax as we go, it's quite
123
- simple.</p>
81
+ <p>Let&#8217;s put some things in there, I&#8217;ll explain the syntax as we go, it&#8217;s quite simple.</p>
124
82
 
125
- <pre><code>&lt;html&gt;
83
+ <pre><code class="nagoro" lang="nagoro">&lt;html&gt;
126
84
  &lt;head&gt;
127
85
  &lt;title&gt;TodoList&lt;/title&gt;
128
86
  &lt;/head&gt;
@@ -131,139 +89,111 @@ simple.</p>
131
89
  &lt;ul&gt;
132
90
  &lt;?r
133
91
  TodoList.each do |title, value|
134
- status = value[:done] ? 'done' : 'not done'
92
+ status = value[:done] ? &#39;done&#39; : &#39;not done&#39;
135
93
  ?&gt;
136
94
  &lt;li&gt;#{c title}: #{status}&lt;/li&gt;
137
95
  &lt;?r end ?&gt;
138
96
  &lt;/ul&gt;
139
97
  &lt;/body&gt;
140
- &lt;/html&gt;
141
- </code></pre>
98
+ &lt;/html&gt;</code></pre>
142
99
 
143
- <p>I will assume that you are familiar with basic Ruby already, so we will
144
- concentrate on the things new here.</p>
100
+ <p>I will assume that you are familiar with basic Ruby already, so we will concentrate on the things new here.</p>
145
101
 
146
- <p><code>&lt;?r ?&gt;</code> defines an area of ruby-code. Later, when the template is transformed
147
- into pure Ruby it will be evaluated. We iterate over the TodoList model and
148
- pass the title and value into a block. In that block we can just get the values
149
- of title and status (which we define based on the value) displayed on the
150
- page.</p>
102
+ <p><code>&lt;?r ?&gt;</code> defines an area of ruby-code. Later, when the template is transformed into pure Ruby it will be evaluated. We iterate over the TodoList model and pass the title and value into a block. In that block we can just get the values of title and status (which we define based on the value) displayed on the page.</p>
151
103
 
152
- <p>The whole Template would expand to something like this (only showing the
153
- interesting part)</p>
104
+ <p>The whole Template would expand to something like this (only showing the interesting part)</p>
154
105
 
155
- <pre><code>&lt;ul&gt;
106
+ <pre><code class="nagoro" lang="nagoro">&lt;ul&gt;
156
107
  &lt;li&gt;Laundry: not done&lt;/li&gt;
157
108
  &lt;li&gt;Wash dishes: not done&lt;/li&gt;
158
- &lt;/ul&gt;
159
- </code></pre>
109
+ &lt;/ul&gt;</code></pre>
160
110
 
161
- <p>That wasn't too bad, huh?</p>
111
+ <p>That wasn&#8217;t too bad, huh?</p>
162
112
 
163
- <p>Now, so we can get our instant pleasure of seeing the result of our (hard) work,
164
- let's see how to start ramaze.</p>
113
+ <p>Now, so we can get our instant pleasure of seeing the result of our (hard) work, let&#8217;s see how to start ramaze.</p>
165
114
 
166
115
  <p>In the <code>todolist</code> directory run <code>ramaze</code>.</p>
167
116
 
168
- <p>This will start an instance of Ramaze and run your application on it. You can
169
- now access it by browsing to http://localhost:7000/</p>
117
+ <p>This will start an instance of Ramaze and run your application on it. You can now access it by browsing to http://localhost:7000/</p>
170
118
 
171
- <p>7000 is the default-port Ramaze will run on, to change it you can just run
172
- <code>ramaze -p 7070</code> or similar. Also be sure to look at the output of
173
- <code>ramaze --help</code> to see some other options.</p>
119
+ <p>7000 is the default-port Ramaze will run on, to change it you can just run <code>ramaze -p 7070</code> or similar. Also be sure to look at the output of <code>ramaze --help</code> to see some other options.</p>
174
120
 
175
- <a name="Fourth_Step,_C,_like_Controller"><h2>Fourth Step, C, like Controller</h2></a>
121
+ <h2 id="fourth_step_c_like_controller">Fourth Step, C, like Controller</h2>
176
122
 
177
123
  <p>The last part of the MVC-paradigm is the Controller.</p>
178
124
 
179
- <p>Wouldn't it be nice to have a way to add and remove items on our to-do list?
180
- Editing the model every time would be quite tiresome and limited.</p>
125
+ <p>Wouldn&#8217;t it be nice to have a way to add and remove items on our to-do list? Editing the model every time would be quite tiresome and limited.</p>
181
126
 
182
- <p>Well, come along, I'll introduce you to Controller.</p>
127
+ <p>Well, come along, I&#8217;ll introduce you to Controller.</p>
183
128
 
184
- <p>In the way MVC is structured, the Controller provides the data in a nice way
185
- for the View, removing all of the data-preparation and most of the logic from
186
- the templates. This makes it firstly simple to change the front end of your
187
- application and secondly provides excellent ways of changing the complete
188
- Structure of the Model or View independent from each other.</p>
129
+ <p>In the way MVC is structured, the Controller provides the data in a nice way for the View, removing all of the data-preparation and most of the logic from the templates. This makes it firstly simple to change the front end of your application and secondly provides excellent ways of changing the complete Structure of the Model or View independent from each other.</p>
189
130
 
190
- <p>OK, enough of the theory, you will see the benefits in an instant. Go on and
191
- edit the file <code>controller/main.rb</code>.</p>
131
+ <p>OK, enough of the theory, you will see the benefits in an instant. Go on and edit the file <code>controller/main.rb</code>.</p>
192
132
 
193
133
  <p>The contents of it are like following:</p>
194
134
 
195
- <pre><code>class MainController &lt; Controller
196
- def index
197
- @welcome = "Welcome to Ramaze!"
198
- end
135
+ <pre><code class="ruby" lang="ruby"><span class="keyword">class </span><span class="class">MainController</span> <span class="punct">&lt;</span> <span class="constant">Controller</span>
136
+ <span class="keyword">def </span><span class="method">index</span>
137
+ <span class="attribute">@welcome</span> <span class="punct">=</span> <span class="punct">&quot;</span><span class="string">Welcome to Ramaze!</span><span class="punct">&quot;</span>
138
+ <span class="keyword">end</span>
199
139
 
200
- def notemplate
201
- "there is no template associated with this action"
202
- end
203
- end
204
- </code></pre>
140
+ <span class="keyword">def </span><span class="method">notemplate</span>
141
+ <span class="punct">&quot;</span><span class="string">there is no template associated with this action</span><span class="punct">&quot;</span>
142
+ <span class="keyword">end</span>
143
+ <span class="keyword">end</span></code></pre>
205
144
 
206
- <p>The only methods right now are <code>#index</code> and <code>#notemplate</code>.
207
- The relationship between the methods on the controller and the templates is
208
- 1:1, so the method <code>#index</code> is combined with the template <code>index.xhtml</code>. This
209
- combination is called an <code>action</code>.</p>
145
+ <p>The only methods right now are <code>#index</code> and <code>#notemplate</code>. The relationship between the methods on the controller and the templates is 1:1, so the method <code>#index</code> is combined with the template <code>index.xhtml</code>. This combination is called an <code>action</code>.</p>
210
146
 
211
- <p>Let's get back to editing and change the method <code>#index</code> to this:</p>
147
+ <p>Let&#8217;s get back to editing and change the method <code>#index</code> to this:</p>
212
148
 
213
- <pre><code>def index
214
- @tasks = TodoList.original
215
- @tasks.each do |title, value|
216
- status = value[:done] ? 'done' : 'not done'
217
- @tasks[title] = status
218
- end
219
- end
220
- </code></pre>
149
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">index</span>
150
+ <span class="attribute">@tasks</span> <span class="punct">=</span> <span class="constant">TodoList</span><span class="punct">.</span><span class="ident">original</span>
151
+ <span class="attribute">@tasks</span><span class="punct">.</span><span class="ident">each</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">value</span><span class="punct">|</span>
152
+ <span class="ident">status</span> <span class="punct">=</span> <span class="ident">value</span><span class="punct">[</span><span class="symbol">:done</span><span class="punct">]</span> <span class="punct">?</span> <span class="punct">&#39;</span><span class="string">done</span><span class="punct">&#39;</span> <span class="punct">:</span> <span class="punct">&#39;</span><span class="string">not done</span><span class="punct">&#39;</span>
153
+ <span class="attribute">@tasks</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">status</span>
154
+ <span class="keyword">end</span>
155
+ <span class="keyword">end</span></code></pre>
221
156
 
222
- <p>This will take care of the logic inside the template, which now should be
223
- changed to do following:</p>
157
+ <p>This will take care of the logic inside the template, which now should be changed to do following:</p>
224
158
 
225
- <pre><code>&lt;html&gt;
226
- &lt;head&gt;
227
- &lt;title&gt;TodoList&lt;/title&gt;
228
- &lt;/head&gt;
229
- &lt;body&gt;
230
- &lt;h1&gt;TodoList&lt;/h1&gt;
159
+ <pre><code class="ruby" lang="ruby"><span class="punct">&lt;</span><span class="ident">html</span><span class="punct">&gt;</span>
160
+ <span class="punct">&lt;</span><span class="ident">head</span><span class="punct">&gt;</span>
161
+ <span class="punct">&lt;</span><span class="ident">title</span><span class="punct">&gt;</span><span class="constant">TodoList</span><span class="punct">&lt;/</span><span class="regex">title&gt;
162
+ &lt;</span><span class="punct">/</span><span class="ident">head</span><span class="punct">&gt;</span>
163
+ <span class="punct">&lt;</span><span class="ident">body</span><span class="punct">&gt;</span>
164
+ <span class="punct">&lt;</span><span class="ident">h1</span><span class="punct">&gt;</span><span class="constant">TodoList</span><span class="punct">&lt;/</span><span class="regex">h1&gt;
231
165
  &lt;?r if @tasks.empty? ?&gt;
232
166
  No Tasks
233
167
  &lt;?r else ?&gt;
234
168
  &lt;ul&gt;
235
169
  &lt;?r @tasks.each do |title, status| ?&gt;
236
- &lt;li&gt;#{c title}: #{status}&lt;/li&gt;
237
- &lt;?r end ?&gt;
238
- &lt;/ul&gt;
170
+ &lt;li&gt;<span class="expr">#{c title}</span>: <span class="expr">#{status}</span>&lt;</span><span class="punct">/</span><span class="ident">li</span><span class="punct">&gt;</span>
171
+ <span class="punct">&lt;</span><span class="char">?r</span> <span class="keyword">end</span> <span class="char">?&gt;</span>
172
+ <span class="punct">&lt;/</span><span class="regex">ul&gt;
239
173
  &lt;?r end ?&gt;
240
- &lt;/body&gt;
241
- &lt;/html&gt;
242
- </code></pre>
174
+ &lt;</span><span class="punct">/</span><span class="ident">body</span><span class="punct">&gt;</span>
175
+ <span class="punct">&lt;/</span><span class="regex">html&gt;</span></code></pre>
243
176
 
244
177
  <p>The rest of the template can stay the same.</p>
245
178
 
246
- <p>Now, if you browse to http://localhost:7000/ again you will not notice any
247
- change, which is how it should be. The only change is that if there are no
248
- Tasks it will say so.</p>
179
+ <p>Now, if you browse to http://localhost:7000/ again you will not notice any change, which is how it should be. The only change is that if there are no Tasks it will say so.</p>
249
180
 
250
181
  <p>Some things you should know:</p>
251
182
 
252
183
  <ul>
253
184
  <li>Instance-variables defined in the Controller are available in the View.</li>
185
+
254
186
  <li>The return-value of the Controller does not matter if a template is present.</li>
255
187
  </ul>
256
188
 
257
- <a name="Fifth_Step,_getting_dynamic"><h2>Fifth Step, getting dynamic</h2></a>
189
+ <h2 id="fifth_step_getting_dynamic">Fifth Step, getting dynamic</h2>
258
190
 
259
- <p>We set out to build the ultimate to-do list, but there are still some things
260
- missing. First off, we want to add new tasks, so let's get that done.</p>
191
+ <p>We set out to build the ultimate to-do list, but there are still some things missing. First off, we want to add new tasks, so let&#8217;s get that done.</p>
261
192
 
262
193
  <p>Add a link on the <code>view/index.xhtml</code> like this:</p>
263
194
 
264
195
  <pre><code>&lt;h1&gt;TodoList&lt;/h1&gt;
265
- &lt;a href="/new"&gt;New Task&lt;/a&gt;
266
- </code></pre>
196
+ &lt;a href=&quot;/new&quot;&gt;New Task&lt;/a&gt;</code></pre>
267
197
 
268
198
  <p>Open a new file <code>view/new.xhtml</code> with a form to add a new task.</p>
269
199
 
@@ -273,160 +203,124 @@ missing. First off, we want to add new tasks, so let's get that done.</p>
273
203
  &lt;/head&gt;
274
204
  &lt;body&gt;
275
205
  &lt;h1&gt;New Task&lt;/h1&gt;
276
- &lt;a href="/"&gt;Back to TodoList&lt;/a&gt;
277
- &lt;form method="POST" action="create"&gt;
278
- Task: &lt;input type="text" name="title" /&gt;&lt;br /&gt;
279
- &lt;input type="submit" /&gt;
206
+ &lt;a href=&quot;/&quot;&gt;Back to TodoList&lt;/a&gt;
207
+ &lt;form method=&quot;POST&quot; action=&quot;create&quot;&gt;
208
+ Task: &lt;input type=&quot;text&quot; name=&quot;title&quot; /&gt;&lt;br /&gt;
209
+ &lt;input type=&quot;submit&quot; /&gt;
280
210
  &lt;/form&gt;
281
211
  &lt;/body&gt;
282
- &lt;/html&gt;
283
- </code></pre>
212
+ &lt;/html&gt;</code></pre>
284
213
 
285
- <p>We will not need a method for this on our controller, in fact, actions can
286
- consist of either method and template or only one of them. The Controller
287
- can act as a View and the View can work like you may know it from PHP.</p>
214
+ <p>We will not need a method for this on our controller, in fact, actions can consist of either method and template or only one of them. The Controller can act as a View and the View can work like you may know it from PHP.</p>
288
215
 
289
- <p>If you try to use this form you will notice that we have not yet defined a way
290
- to actually create the task.</p>
216
+ <p>If you try to use this form you will notice that we have not yet defined a way to actually create the task.</p>
291
217
 
292
- <p>You will get the default Ramaze error-page instead. Please take your time to
293
- explore it and see how Ramaze reacted on the error.</p>
218
+ <p>You will get the default Ramaze error-page instead. Please take your time to explore it and see how Ramaze reacted on the error.</p>
294
219
 
295
- <p>It will show you the back trace and what state the application is in at the
296
- moment, the request and response and the contents of the session. This is very
297
- useful for debugging and development, you can provide your own set of
298
- error-pages before going into production (or deactivate them fully) though.</p>
220
+ <p>It will show you the back trace and what state the application is in at the moment, the request and response and the contents of the session. This is very useful for debugging and development, you can provide your own set of error-pages before going into production (or deactivate them fully) though.</p>
299
221
 
300
- <p>OK, let's implement the action for <code>#create</code>, all we want to do is take the
301
- requests parameters and create a new task for it, this looks like following on
302
- your MainController.</p>
222
+ <p>OK, let&#8217;s implement the action for <code>#create</code>, all we want to do is take the requests parameters and create a new task for it, this looks like following on your MainController.</p>
303
223
 
304
- <pre><code>def create
305
- title = request['title']
306
- TodoList[title] = {:done =&gt; false}
307
- redirect Rs()
308
- end
309
- </code></pre>
224
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">create</span>
225
+ <span class="ident">title</span> <span class="punct">=</span> <span class="ident">request</span><span class="punct">[&#39;</span><span class="string">title</span><span class="punct">&#39;]</span>
226
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">}</span>
227
+ <span class="ident">redirect</span> <span class="constant">Rs</span><span class="punct">()</span>
228
+ <span class="keyword">end</span></code></pre>
310
229
 
311
- <p>That's all folks!</p>
230
+ <p>That&#8217;s all folks!</p>
312
231
 
313
- <p>We get the title from the request-object, put it into our TodoList as undone
314
- and redirect back to the mapping of the current Controller ('/' in this case).</p>
232
+ <p>We get the title from the request-object, put it into our TodoList as undone and redirect back to the mapping of the current Controller (&#8217;/&#8217; in this case).</p>
315
233
 
316
- <p>Now you can create as many tasks as you want, please don't get overworked ;)</p>
234
+ <p>Now you can create as many tasks as you want, please don&#8217;t get overworked ;)</p>
317
235
 
318
- <a name="Sixth_Step,_open_and_close_tasks"><h2>Sixth Step, open and close tasks</h2></a>
236
+ <h2 id="sixth_step_open_and_close_tasks">Sixth Step, open and close tasks</h2>
319
237
 
320
- <p>Since the nature of tasks is to be done eventually
321
- we will need some way to mark it as done or open tasks again.</p>
238
+ <p>Since the nature of tasks is to be done eventually we will need some way to mark it as done or open tasks again.</p>
322
239
 
323
240
  <p>Jump into <code>view/index.xhtml</code> and do the following:</p>
324
241
 
325
- <pre><code>&lt;?r @tasks.each do |title, status, toggle| ?&gt;
326
- &lt;li&gt;
327
- #{c title}: #{status} - [ #{toggle} ]
328
- &lt;/li&gt;
329
- &lt;?r end ?&gt;
330
- </code></pre>
331
-
332
- <p>We added a new element here, <code>toggle</code>, the Controller should give us
333
- a link to change the status corresponding to the status of the task, so off
334
- we go and change the index method on the controller once again:</p>
335
-
336
- <pre><code>def index
337
- @tasks = []
338
- TodoList.original.each do |title, value|
339
- if value[:done]
340
- status = 'done'
341
- toggle = A('Open Task', :href =&gt; Rs(:open, title))
342
- else
343
- status = 'not done'
344
- toggle = A('Close Task', :href =&gt; Rs(:close, title))
345
- end
346
- @tasks &lt;&lt; [title, status, toggle]
347
- end
348
- @tasks.sort!
349
- end
350
- </code></pre>
242
+ <pre><code class="ruby" lang="ruby"><span class="punct">&lt;</span><span class="char">?r</span> <span class="attribute">@tasks</span><span class="punct">.</span><span class="ident">each</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span><span class="punct">,</span> <span class="ident">toggle</span><span class="punct">|</span> <span class="char">?&gt;</span>
243
+ <span class="punct">&lt;</span><span class="ident">li</span><span class="punct">&gt;</span>
244
+ <span class="comment">#{c title}: #{status} - [ #{toggle} ]</span>
245
+ <span class="punct">&lt;/</span><span class="regex">li&gt;
246
+ &lt;?r end</span></code></pre>
247
+
248
+ <p>We added a new element here, <code>toggle</code>, the Controller should give us a link to change the status corresponding to the status of the task, so off we go and change the index method on the controller once again:</p>
249
+
250
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">index</span>
251
+ <span class="attribute">@tasks</span> <span class="punct">=</span> <span class="punct">[]</span>
252
+ <span class="constant">TodoList</span><span class="punct">.</span><span class="ident">original</span><span class="punct">.</span><span class="ident">each</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">value</span><span class="punct">|</span>
253
+ <span class="keyword">if</span> <span class="ident">value</span><span class="punct">[</span><span class="symbol">:done</span><span class="punct">]</span>
254
+ <span class="ident">status</span> <span class="punct">=</span> <span class="punct">&#39;</span><span class="string">done</span><span class="punct">&#39;</span>
255
+ <span class="ident">toggle</span> <span class="punct">=</span> <span class="constant">A</span><span class="punct">(&#39;</span><span class="string">Open Task</span><span class="punct">&#39;,</span> <span class="symbol">:href</span> <span class="punct">=&gt;</span> <span class="constant">Rs</span><span class="punct">(</span><span class="symbol">:open</span><span class="punct">,</span> <span class="ident">title</span><span class="punct">))</span>
256
+ <span class="keyword">else</span>
257
+ <span class="ident">status</span> <span class="punct">=</span> <span class="punct">&#39;</span><span class="string">not done</span><span class="punct">&#39;</span>
258
+ <span class="ident">toggle</span> <span class="punct">=</span> <span class="constant">A</span><span class="punct">(&#39;</span><span class="string">Close Task</span><span class="punct">&#39;,</span> <span class="symbol">:href</span> <span class="punct">=&gt;</span> <span class="constant">Rs</span><span class="punct">(</span><span class="symbol">:close</span><span class="punct">,</span> <span class="ident">title</span><span class="punct">))</span>
259
+ <span class="keyword">end</span>
260
+ <span class="attribute">@tasks</span> <span class="punct">&lt;&lt;</span> <span class="punct">[</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span><span class="punct">,</span> <span class="ident">toggle</span><span class="punct">]</span>
261
+ <span class="keyword">end</span>
262
+ <span class="attribute">@tasks</span><span class="punct">.</span><span class="ident">sort!</span>
263
+ <span class="keyword">end</span></code></pre>
351
264
 
352
265
  <p>Wow, quite some new stuff here. Let me explain that in detail.</p>
353
266
 
354
- <p>We first decide whether a task is done or not, then go on and provide a link to
355
- toggle the status, A and Rs are both methods that help you do that.
356
- The result will be something like:</p>
267
+ <p>We first decide whether a task is done or not, then go on and provide a link to toggle the status, A and Rs are both methods that help you do that. The result will be something like:</p>
357
268
 
358
- <pre><code>&lt;a href="/open/Wash+dishes"&gt;Close Task&lt;/a&gt;
359
- </code></pre>
269
+ <pre><code>&lt;a href=&quot;/open/Wash+dishes&quot;&gt;Close Task&lt;/a&gt;</code></pre>
360
270
 
361
- <p>Rs actually is responsible to build the links href, for more information please
362
- take a look at the RDoc for LinkHelper.</p>
271
+ <p>Rs actually is responsible to build the links href, for more information please take a look at the RDoc for LinkHelper.</p>
363
272
 
364
- <p>Also, you might have noticed that the tasks were changing order on every reload,
365
- which is because we were using an Hash, which are per definition unsorted, so
366
- now we use an array to hold our tasks and sort it.</p>
273
+ <p>Also, you might have noticed that the tasks were changing order on every reload, which is because we were using an Hash, which are per definition unsorted, so now we use an array to hold our tasks and sort it.</p>
367
274
 
368
- <p>As usual since the links for open and close don't lead anywhere, add the
369
- corresponding methods to the Controller:</p>
275
+ <p>As usual since the links for open and close don&#8217;t lead anywhere, add the corresponding methods to the Controller:</p>
370
276
 
371
- <pre><code>def open title
372
- task_status title, false
373
- redirect Rs()
374
- end
277
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">open</span> <span class="ident">title</span>
278
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">false</span>
279
+ <span class="ident">redirect</span> <span class="constant">Rs</span><span class="punct">()</span>
280
+ <span class="keyword">end</span>
375
281
 
376
- def close title
377
- task_status title, true
378
- redirect Rs()
379
- end
282
+ <span class="keyword">def </span><span class="method">close</span> <span class="ident">title</span>
283
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">true</span>
284
+ <span class="ident">redirect</span> <span class="constant">Rs</span><span class="punct">()</span>
285
+ <span class="keyword">end</span>
380
286
 
381
- private
287
+ <span class="ident">private</span>
382
288
 
383
- def task_status title, status
384
- task = TodoList[title]
385
- task[:done] = status
386
- TodoList[title] = task
387
- end
388
- </code></pre>
289
+ <span class="keyword">def </span><span class="method">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span>
290
+ <span class="ident">task</span> <span class="punct">=</span> <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span>
291
+ <span class="ident">task</span><span class="punct">[</span><span class="symbol">:done</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">status</span>
292
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">task</span>
293
+ <span class="keyword">end</span></code></pre>
389
294
 
390
- <p>Oh, now what have we got here?
391
- <code>private</code> declares that methods from here on are only to be used within the
392
- Controller itself, we define an <code>#task_status</code> method that takes the title and
393
- status to be set so we don't have to repeat that code in <code>#open</code> and <code>#close</code>
394
- and follow the DRY (Don't repeat yourself) paradigm.</p>
295
+ <p>Oh, now what have we got here? <code>private</code> declares that methods from here on are only to be used within the Controller itself, we define an <code>#task_status</code> method that takes the title and status to be set so we don&#8217;t have to repeat that code in <code>#open</code> and <code>#close</code> and follow the DRY (Don&#8217;t repeat yourself) paradigm.</p>
395
296
 
396
- <p>Another thing we have not encountered so far is that you can define your public
397
- methods to take parameters on their own, they will be calculated from requests.</p>
297
+ <p>Another thing we have not encountered so far is that you can define your public methods to take parameters on their own, they will be calculated from requests.</p>
398
298
 
399
- <pre><code>'/open/Wash+dishes'
400
- </code></pre>
299
+ <pre><code class="ruby" lang="ruby"><span class="punct">&#39;</span><span class="string">/open/Wash+dishes</span><span class="punct">&#39;</span></code></pre>
401
300
 
402
301
  <p>will translate into:</p>
403
302
 
404
- <pre><code>open('Wash dishes')
405
- </code></pre>
303
+ <pre><code class="ruby" lang="ruby"><span class="ident">open</span><span class="punct">(&#39;</span><span class="string">Wash dishes</span><span class="punct">&#39;)</span></code></pre>
406
304
 
407
- <p>Which in turn will call <code>task_status('Wash dishes', false)</code></p>
305
+ <p>Which in turn will call <code>task_status(&#39;Wash dishes&#39;, false)</code></p>
408
306
 
409
- <p>That's it, go on and try it :)</p>
307
+ <p>That&#8217;s it, go on and try it :)</p>
410
308
 
411
- <a name="Seventh_Step,_delete_tasks"><h2>Seventh Step, delete tasks</h2></a>
309
+ <h2 id="seventh_step_delete_tasks">Seventh Step, delete tasks</h2>
412
310
 
413
- <p>Well, creating, opening and closing work now, one of the things you will
414
- consider is to delete a task permanently.</p>
311
+ <p>Well, creating, opening and closing work now, one of the things you will consider is to delete a task permanently.</p>
415
312
 
416
- <p>This is just two little changes away, so let's add the link for deletion in our
417
- Controller:</p>
313
+ <p>This is just two little changes away, so let&#8217;s add the link for deletion in our Controller:</p>
418
314
 
419
- <pre><code>delete = A('Delete', :href =&gt; Rs(:delete, title))
420
- @tasks &lt;&lt; [title, status, toggle, delete]
421
- </code></pre>
315
+ <pre><code class="ruby" lang="ruby"><span class="ident">delete</span> <span class="punct">=</span> <span class="constant">A</span><span class="punct">(&#39;</span><span class="string">Delete</span><span class="punct">&#39;,</span> <span class="symbol">:href</span> <span class="punct">=&gt;</span> <span class="constant">Rs</span><span class="punct">(</span><span class="symbol">:delete</span><span class="punct">,</span> <span class="ident">title</span><span class="punct">))</span>
316
+ <span class="attribute">@tasks</span> <span class="punct">&lt;&lt;</span> <span class="punct">[</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span><span class="punct">,</span> <span class="ident">toggle</span><span class="punct">,</span> <span class="ident">delete</span><span class="punct">]</span></code></pre>
422
317
 
423
- <p>and an corresponding method while we're at it:</p>
318
+ <p>and an corresponding method while we&#8217;re at it:</p>
424
319
 
425
- <pre><code>def delete title
426
- TodoList.delete title
427
- redirect Rs()
428
- end
429
- </code></pre>
320
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">delete</span> <span class="ident">title</span>
321
+ <span class="constant">TodoList</span><span class="punct">.</span><span class="ident">delete</span> <span class="ident">title</span>
322
+ <span class="ident">redirect</span> <span class="constant">Rs</span><span class="punct">()</span>
323
+ <span class="keyword">end</span></code></pre>
430
324
 
431
325
  <p>Now jumping to <code>view/index.xhtml</code> again, change it so it shows the link:</p>
432
326
 
@@ -434,22 +328,17 @@ end
434
328
  &lt;li&gt;
435
329
  #{c title}: #{status} [ #{toggle} | #{delete} ]
436
330
  &lt;/li&gt;
437
- &lt;?r end ?&gt;
438
- </code></pre>
331
+ &lt;?r end ?&gt;</code></pre>
439
332
 
440
333
  <p>Voilà, you now have acquired the Certificate of Ramazeness.</p>
441
334
 
442
- <p>Just kidding, but that really are the basics, in the next few steps I will
443
- explain some more advanced concepts of Ramaze and Ezamar.</p>
335
+ <p>Just kidding, but that really are the basics, in the next few steps I will explain some more advanced concepts of Ramaze and Ezamar.</p>
444
336
 
445
- <a name="Eighth_Step,_Elements"><h2>Eighth Step, Elements</h2></a>
337
+ <h2 id="eighth_step_elements">Eighth Step, Elements</h2>
446
338
 
447
- <pre><code>&lt;Page&gt;&lt;/Page&gt;
448
- </code></pre>
339
+ <pre><code>&lt;Page&gt;&lt;/Page&gt;</code></pre>
449
340
 
450
- <p>This is called an Element, Ramaze will go and search for a class that matches
451
- the name Page and responds to <code>#render</code>. Then it will go and hand the content in
452
- between to that Element.</p>
341
+ <p>This is called an Element, Ramaze will go and search for a class that matches the name Page and responds to <code>#render</code>. Then it will go and hand the content in between to that Element.</p>
453
342
 
454
343
  <p>Sounds weird?</p>
455
344
 
@@ -462,71 +351,63 @@ between to that Element.</p>
462
351
  &lt;body&gt;
463
352
  &lt;h1&gt;some title&lt;/h1&gt;
464
353
  &lt;/body&gt;
465
- &lt;/html&gt;
466
- </code></pre>
354
+ &lt;/html&gt;</code></pre>
467
355
 
468
356
  <p>How about replacing that with something short and reusable:</p>
469
357
 
470
- <pre><code>&lt;Page title="TodoList"&gt;
358
+ <pre><code>&lt;Page title=&quot;TodoList&quot;&gt;
471
359
  your other content
472
- &lt;/Page&gt;
473
- </code></pre>
360
+ &lt;/Page&gt;</code></pre>
474
361
 
475
- <p>Would be nice of course, and when you start having more templates it makes an
476
- awful lot of sense being able to change the enclosing stuff in one place.</p>
362
+ <p>Would be nice of course, and when you start having more templates it makes an awful lot of sense being able to change the enclosing stuff in one place.</p>
477
363
 
478
- <p>So let's apply DRY here as well.</p>
364
+ <p>So let&#8217;s apply DRY here as well.</p>
479
365
 
480
366
  <p>Take a look at the <code>src/element/page.rb</code></p>
481
367
 
482
- <pre><code>class Page &lt; Ezamar::Element
483
- def render
484
- %{
368
+ <pre><code class="ruby" lang="ruby"><span class="keyword">class </span><span class="class">Page</span> <span class="punct">&lt;</span> <span class="constant">Ezamar</span><span class="punct">::</span><span class="constant">Element</span>
369
+ <span class="keyword">def </span><span class="method">render</span>
370
+ <span class="punct">%{</span><span class="string">
485
371
  &lt;html&gt;
486
372
  &lt;head&gt;
487
373
  &lt;title&gt;Welcome to Ramaze&lt;/title&gt;
488
374
  &lt;/head&gt;
489
375
  &lt;body&gt;
490
- #{content}
376
+ <span class="expr">#{content}</span>
491
377
  &lt;/body&gt;
492
378
  &lt;/html&gt;
493
- }
494
- end
495
- end
496
- </code></pre>
379
+ </span><span class="punct">}</span>
380
+ <span class="keyword">end</span>
381
+ <span class="keyword">end</span></code></pre>
497
382
 
498
- <p>Alright, most things we need are in place already, the most important thing
499
- is the <code>#content</code> method that we call with <code>#{content}</code> inside the string in
500
- <code>#render</code>.</p>
383
+ <p>Alright, most things we need are in place already, the most important thing is the <code>#content</code> method that we call with <code>#{content}</code> inside the string in <code>#render</code>.</p>
501
384
 
502
- <p>Just adopt it to your liking, I'll just use the things we had in our templates
503
- so far:</p>
385
+ <p>Just adopt it to your liking, I&#8217;ll just use the things we had in our templates so far:</p>
504
386
 
505
- <pre><code>class Page &lt; Ezamar::Element
506
- def render
507
- %{
387
+ <pre><code class="ruby" lang="ruby"><span class="keyword">class </span><span class="class">Page</span> <span class="punct">&lt;</span> <span class="constant">Ezamar</span><span class="punct">::</span><span class="constant">Element</span>
388
+ <span class="keyword">def </span><span class="method">render</span>
389
+ <span class="punct">%{</span><span class="string">
508
390
  &lt;html&gt;
509
391
  &lt;head&gt;
510
392
  &lt;title&gt;TodoList&lt;/title&gt;
511
393
  &lt;/head&gt;
512
394
  &lt;body&gt;
513
- &lt;h1&gt;#{@title}&lt;/h1&gt;
514
- #{content}
395
+ &lt;h1&gt;<span class="expr">#{@title}</span>&lt;/h1&gt;
396
+ <span class="expr">#{content}</span>
515
397
  &lt;/body&gt;
516
398
  &lt;/html&gt;
517
- }
518
- end
519
- end
520
- </code></pre>
399
+ </span><span class="punct">}</span>
400
+ <span class="keyword">end</span>
401
+ <span class="keyword">end</span></code></pre>
521
402
 
522
403
  <p>Please note that instance variables reflecting the parameters are set.</p>
523
404
 
524
- <p>And let's change our templates as well.</p>
405
+ <p>And let&#8217;s change our templates as well.</p>
525
406
 
526
407
  <p>First the <code>view/index.xhtml</code></p>
527
408
 
528
- <pre><code>&lt;Page title="TodoList"&gt;
529
- &lt;a href="/new"&gt;New Task&lt;/a&gt;
409
+ <pre><code>&lt;Page title=&quot;TodoList&quot;&gt;
410
+ &lt;a href=&quot;/new&quot;&gt;New Task&lt;/a&gt;
530
411
  &lt;?r if @tasks.empty? ?&gt;
531
412
  No Tasks
532
413
  &lt;?r else ?&gt;
@@ -538,27 +419,23 @@ end
538
419
  &lt;?r end ?&gt;
539
420
  &lt;/ul&gt;
540
421
  &lt;?r end ?&gt;
541
- &lt;/Page&gt;
542
- </code></pre>
422
+ &lt;/Page&gt;</code></pre>
543
423
 
544
424
  <p>and the <code>view/new.xhtml</code></p>
545
425
 
546
- <pre><code>&lt;Page title="New Task"&gt;
547
- &lt;a href="/"&gt;Back to TodoList&lt;/a&gt;
548
- &lt;form method="POST" action="create"&gt;
549
- Task: &lt;input type="text" name="title" /&gt;&lt;br /&gt;
550
- &lt;input type="submit" /&gt;
426
+ <pre><code>&lt;Page title=&quot;New Task&quot;&gt;
427
+ &lt;a href=&quot;/&quot;&gt;Back to TodoList&lt;/a&gt;
428
+ &lt;form method=&quot;POST&quot; action=&quot;create&quot;&gt;
429
+ Task: &lt;input type=&quot;text&quot; name=&quot;title&quot; /&gt;&lt;br /&gt;
430
+ &lt;input type=&quot;submit&quot; /&gt;
551
431
  &lt;/form&gt;
552
- &lt;/Page&gt;
553
- </code></pre>
432
+ &lt;/Page&gt;</code></pre>
554
433
 
555
- <p>Alright, now just go and look at the result in the browser, try changing
556
- the things inside the Element and look at how it behaves.</p>
434
+ <p>Alright, now just go and look at the result in the browser, try changing the things inside the Element and look at how it behaves.</p>
557
435
 
558
- <a name="Ninth_Step,_Prettify"><h2>Ninth Step, Prettify</h2></a>
436
+ <h2 id="ninth_step_prettify">Ninth Step, Prettify</h2>
559
437
 
560
- <p>We structure the data inside the list a little bit, in this case into a table,
561
- to get it line up properly and look actually structured.</p>
438
+ <p>We structure the data inside the list a little bit, in this case into a table, to get it line up properly and look actually structured.</p>
562
439
 
563
440
  <p>So, from what we have right now:</p>
564
441
 
@@ -568,25 +445,22 @@ to get it line up properly and look actually structured.</p>
568
445
  #{c title}: #{status} [ #{toggle} | #{delete} ]
569
446
  &lt;/li&gt;
570
447
  &lt;?r end ?&gt;
571
- &lt;/ul&gt;
572
- </code></pre>
448
+ &lt;/ul&gt;</code></pre>
573
449
 
574
450
  <p>To something like this:</p>
575
451
 
576
452
  <pre><code>&lt;table&gt;
577
453
  &lt;?r @tasks.each do |title, status, toggle, delete| ?&gt;
578
454
  &lt;tr&gt;
579
- &lt;td class="title"&gt; #{c title} &lt;/td&gt;
580
- &lt;td class="status"&gt; #{status} &lt;/td&gt;
581
- &lt;td class="toggle"&gt; #{toggle} &lt;/td&gt;
582
- &lt;td class="delete"&gt; #{delete} &lt;/td&gt;
455
+ &lt;td class=&quot;title&quot;&gt; #{c title} &lt;/td&gt;
456
+ &lt;td class=&quot;status&quot;&gt; #{status} &lt;/td&gt;
457
+ &lt;td class=&quot;toggle&quot;&gt; #{toggle} &lt;/td&gt;
458
+ &lt;td class=&quot;delete&quot;&gt; #{delete} &lt;/td&gt;
583
459
  &lt;/tr&gt;
584
460
  &lt;?r end ?&gt;
585
- &lt;/table&gt;
586
- </code></pre>
461
+ &lt;/table&gt;</code></pre>
587
462
 
588
- <p>And, since we have proper classes to address some style sheets, jump into the
589
- Page element and add some style sheet:</p>
463
+ <p>And, since we have proper classes to address some style sheets, jump into the Page element and add some style sheet:</p>
590
464
 
591
465
  <pre><code>&lt;head&gt;
592
466
  &lt;title&gt;TodoList&lt;/title&gt;
@@ -598,219 +472,163 @@ Page element and add some style sheet:</p>
598
472
  td.status { margin: 1em; }
599
473
  a { color: #3a3; }
600
474
  &lt;/style&gt;
601
- &lt;/head&gt;
602
- </code></pre>
475
+ &lt;/head&gt;</code></pre>
603
476
 
604
- <p>That looks quite a bit nicer, right? And yes, if you don't like tables (though
605
- this is an entirely legit use in my opinion) you can just do it like you want,
606
- using nested lists or divs/spans, replacing the open/close and delete links with
607
- nice images and changing the style according to the status.</p>
477
+ <p>That looks quite a bit nicer, right? And yes, if you don&#8217;t like tables (though this is an entirely legit use in my opinion) you can just do it like you want, using nested lists or divs/spans, replacing the open/close and delete links with nice images and changing the style according to the status.</p>
608
478
 
609
479
  <p>I will leave this as an exercise to the reader.</p>
610
480
 
611
- <a name="Tenth_Step,_Configuration"><h2>Tenth Step, Configuration</h2></a>
481
+ <h2 id="tenth_step_configuration">Tenth Step, Configuration</h2>
612
482
 
613
- <p>To round up this tutorial a bit, let's introduce you to configuration in Ramaze.
614
- This will not go into full depth of possibilities or a total coverage of the
615
- options, since they are bound to change over time.</p>
483
+ <p>To round up this tutorial a bit, let&#8217;s introduce you to configuration in Ramaze. This will not go into full depth of possibilities or a total coverage of the options, since they are bound to change over time.</p>
616
484
 
617
- <p>First of all, the default port Ramaze runs on is 7000, but to make it a usual
618
- webserver it has to run on port 80. So, let's add following line in your
619
- start.rb right after the lines of require you added before:</p>
485
+ <p>First of all, the default port Ramaze runs on is 7000, but to make it a usual webserver it has to run on port 80. So, let&#8217;s add following line in your start.rb right after the lines of require you added before:</p>
620
486
 
621
- <pre><code>Ramaze::Global.port = 80
622
- </code></pre>
487
+ <pre><code class="ruby" lang="ruby"><span class="constant">Ramaze</span><span class="punct">::</span><span class="constant">Global</span><span class="punct">.</span><span class="ident">port</span> <span class="punct">=</span> <span class="number">80</span></code></pre>
623
488
 
624
- <p>Alright, that wasn't that hard.
625
- Let's say now you also want to run Mongrel instead of WEBrick, to get nice a bit
626
- of performance:</p>
489
+ <p>Alright, that wasn&#8217;t that hard. Let&#8217;s say now you also want to run Mongrel instead of WEBrick, to get nice a bit of performance:</p>
627
490
 
628
- <pre><code>Ramaze::Global.adapter = :mongrel
629
- </code></pre>
491
+ <pre><code class="ruby" lang="ruby"><span class="constant">Ramaze</span><span class="punct">::</span><span class="constant">Global</span><span class="punct">.</span><span class="ident">adapter</span> <span class="punct">=</span> <span class="symbol">:mongrel</span></code></pre>
630
492
 
631
493
  <p>To do this in a DRY way you could also do following:</p>
632
494
 
633
- <pre><code>Ramaze::Global.setup do |g|
634
- g.port = 80
635
- g.adapter = :mongrel
636
- end
637
- </code></pre>
495
+ <pre><code class="ruby" lang="ruby"><span class="constant">Ramaze</span><span class="punct">::</span><span class="constant">Global</span><span class="punct">.</span><span class="ident">setup</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">g</span><span class="punct">|</span>
496
+ <span class="ident">g</span><span class="punct">.</span><span class="ident">port</span> <span class="punct">=</span> <span class="number">80</span>
497
+ <span class="ident">g</span><span class="punct">.</span><span class="ident">adapter</span> <span class="punct">=</span> <span class="symbol">:mongrel</span>
498
+ <span class="keyword">end</span></code></pre>
638
499
 
639
- <p>It seems to be quite common to put this configuration into separate files so you
640
- can just require it on demand. There are other, slightly stronger way to set
641
- options, which is either using flags on the ramaze executable, or like this:</p>
500
+ <p>It seems to be quite common to put this configuration into separate files so you can just require it on demand. There are other, slightly stronger way to set options, which is either using flags on the ramaze executable, or like this:</p>
642
501
 
643
- <pre><code>Ramaze.start :port =&gt; 80, :adapter =&gt; :mongrel
644
- </code></pre>
502
+ <pre><code class="ruby" lang="ruby"><span class="constant">Ramaze</span><span class="punct">.</span><span class="ident">start</span> <span class="symbol">:port</span> <span class="punct">=&gt;</span> <span class="number">80</span><span class="punct">,</span> <span class="symbol">:adapter</span> <span class="punct">=&gt;</span> <span class="symbol">:mongrel</span></code></pre>
645
503
 
646
- <p>We haven't started Ramaze directly as of yet, but this allows you to ignore the
647
- ramaze executable and just run your application by <code>ruby start.rb</code>.</p>
504
+ <p>We haven&#8217;t started Ramaze directly as of yet, but this allows you to ignore the ramaze executable and just run your application by <code>ruby start.rb</code>.</p>
648
505
 
649
- <a name="Eleventh_Step,_Refactor_with_AspectHelper"><h2>Eleventh Step, Refactor with AspectHelper</h2></a>
506
+ <h2 id="eleventh_step_refactor_with_aspecthelper">Eleventh Step, Refactor with AspectHelper</h2>
650
507
 
651
508
  <p>Now, if you take a closer look at the Controller you will see:</p>
652
509
 
653
- <pre><code>def create
654
- title = request['title']
655
- TodoList[title] = {:done =&gt; false}
656
- redirect R(self)
657
- end
510
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">create</span>
511
+ <span class="ident">title</span> <span class="punct">=</span> <span class="ident">request</span><span class="punct">[&#39;</span><span class="string">title</span><span class="punct">&#39;]</span>
512
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">}</span>
513
+ <span class="ident">redirect</span> <span class="constant">R</span><span class="punct">(</span><span class="constant">self</span><span class="punct">)</span>
514
+ <span class="keyword">end</span>
658
515
 
659
- def open title
660
- task_status title, false
661
- redirect R(self)
662
- end
516
+ <span class="keyword">def </span><span class="method">open</span> <span class="ident">title</span>
517
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">false</span>
518
+ <span class="ident">redirect</span> <span class="constant">R</span><span class="punct">(</span><span class="constant">self</span><span class="punct">)</span>
519
+ <span class="keyword">end</span>
663
520
 
664
- def close title
665
- task_status title, true
666
- redirect R(self)
667
- end
521
+ <span class="keyword">def </span><span class="method">close</span> <span class="ident">title</span>
522
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">true</span>
523
+ <span class="ident">redirect</span> <span class="constant">R</span><span class="punct">(</span><span class="constant">self</span><span class="punct">)</span>
524
+ <span class="keyword">end</span>
668
525
 
669
- def delete title
670
- TodoList.delete title
671
- redirect R(self)
672
- end
673
- </code></pre>
526
+ <span class="keyword">def </span><span class="method">delete</span> <span class="ident">title</span>
527
+ <span class="constant">TodoList</span><span class="punct">.</span><span class="ident">delete</span> <span class="ident">title</span>
528
+ <span class="ident">redirect</span> <span class="constant">R</span><span class="punct">(</span><span class="constant">self</span><span class="punct">)</span>
529
+ <span class="keyword">end</span></code></pre>
674
530
 
675
- <p>We did some refactoring before, by introducing <code>#task_status</code>, but here we have
676
- repetition again: <code>redirect Rs()</code> <em>after</em> each method did its job.</p>
531
+ <p>We did some refactoring before, by introducing <code>#task_status</code>, but here we have repetition again: <code>redirect Rs()</code> <em>after</em> each method did its job.</p>
677
532
 
678
- <p>However, we can take advantage of one of the helpers Ramaze offers, the
679
- AspectHelper.
680
- It allows you to easily wrap actions in your controller with other methods</p>
533
+ <p>However, we can take advantage of one of the helpers Ramaze offers, the AspectHelper. It allows you to easily wrap actions in your controller with other methods</p>
681
534
 
682
535
  <p>In your Controller, replace the previous chunk with following:</p>
683
536
 
684
- <pre><code>def create
685
- title = request['title']
686
- TodoList[title] = {:done =&gt; false}
687
- end
537
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">create</span>
538
+ <span class="ident">title</span> <span class="punct">=</span> <span class="ident">request</span><span class="punct">[&#39;</span><span class="string">title</span><span class="punct">&#39;]</span>
539
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">}</span>
540
+ <span class="keyword">end</span>
688
541
 
689
- def open title
690
- task_status title, false
691
- end
542
+ <span class="keyword">def </span><span class="method">open</span> <span class="ident">title</span>
543
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">false</span>
544
+ <span class="keyword">end</span>
692
545
 
693
- def close title
694
- task_status title, true
695
- end
546
+ <span class="keyword">def </span><span class="method">close</span> <span class="ident">title</span>
547
+ <span class="ident">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="constant">true</span>
548
+ <span class="keyword">end</span>
696
549
 
697
- def delete title
698
- TodoList.delete title
699
- end
550
+ <span class="keyword">def </span><span class="method">delete</span> <span class="ident">title</span>
551
+ <span class="constant">TodoList</span><span class="punct">.</span><span class="ident">delete</span> <span class="ident">title</span>
552
+ <span class="keyword">end</span>
700
553
 
701
- helper :aspect
702
- after(:create, :open, :close, :delete){ redirect(Rs()) }
703
- </code></pre>
554
+ <span class="ident">helper</span> <span class="symbol">:aspect</span>
555
+ <span class="ident">after</span><span class="punct">(</span><span class="symbol">:create</span><span class="punct">,</span> <span class="symbol">:open</span><span class="punct">,</span> <span class="symbol">:close</span><span class="punct">,</span> <span class="symbol">:delete</span><span class="punct">){</span> <span class="ident">redirect</span><span class="punct">(</span><span class="constant">Rs</span><span class="punct">())</span> <span class="punct">}</span></code></pre>
704
556
 
705
557
  <p>Alright, that looks a lot nicer already and is definitely easier to maintain.</p>
706
558
 
707
- <p>There is a symmetrical <code>before</code> aspect that you could take advantage of as
708
- well, and in case you want to add required authentication for all actions of a
709
- Controller you could use <code>before_all</code> and <code>after_all</code> instead of a list of
710
- action-names.</p>
559
+ <p>There is a symmetrical <code>before</code> aspect that you could take advantage of as well, and in case you want to add required authentication for all actions of a Controller you could use <code>before_all</code> and <code>after_all</code> instead of a list of action-names.</p>
711
560
 
712
- <a name="Twelfth_Step,_Validation_and_Errors"><h2>Twelfth Step, Validation and Errors</h2></a>
561
+ <h2 id="twelfth_step_validation_and_errors">Twelfth Step, Validation and Errors</h2>
713
562
 
714
- <p>Right now, all kinds of things could still go wrong when you do things like
715
- creating tasks with no title at all or try to open/close a task that does not
716
- exist. So in this step we will add some little checks for these cases.</p>
563
+ <p>Right now, all kinds of things could still go wrong when you do things like creating tasks with no title at all or try to open/close a task that does not exist. So in this step we will add some little checks for these cases.</p>
717
564
 
718
565
  <p>First we head over to the Controller again and take a look at <code>#create</code>:</p>
719
566
 
720
- <pre><code>def create
721
- title = request['title']
722
- TodoList[title] = {:done =&gt; false}
723
- end
724
- </code></pre>
725
-
726
- <p>Here we just create a new task, no matter what we get. Every seasoned
727
- web-developer would advise you to be suspicious about all the input you receive
728
- from your users, so let's apply this advice.</p>
729
-
730
- <pre><code>def create
731
- if title = request['title']
732
- title.strip!
733
- if title.empty?
734
- failed("Please enter a title")
735
- redirect '/new'
736
- end
737
- TodoList[title] = {:done =&gt; false}
738
- end
739
- end
740
- </code></pre>
741
-
742
- <p>First of all we check if we got a request with a value for 'title', if we get
743
- none we just let the aspect kick in that will redirect the browser to the index.
744
- Next we strip the title of all spaces around it so we can check if it is empty.
745
- We will talk about the specifics of our error-handling now.</p>
746
-
747
- <p>Ramaze has a helper called FlashHelper, that will keep a hash associated with
748
- the session for one request, afterwards the hash is thrown away. This is
749
- specifically useful for giving the user feedback while keeping a stateless
750
- approach.</p>
751
-
752
- <p>Let me show you our <code>#failed</code> method (it goes in the private section to
753
- <code>#task_status</code>):</p>
754
-
755
- <pre><code>def failed(message)
756
- flash[:error] = message
757
- end
758
- </code></pre>
759
-
760
- <p>Duh, you may say, wouldn't that fit in the one line instead of the call to
761
- <code>#failed</code>?
762
- Indeed, it would, but let me remind you, we have no checks for changing the
763
- status of a task yet. We will need error-handling there as well, so we just keep
764
- our code DRY and maintainable by collecting shared behaviour in small pieces.</p>
567
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">create</span>
568
+ <span class="ident">title</span> <span class="punct">=</span> <span class="ident">request</span><span class="punct">[&#39;</span><span class="string">title</span><span class="punct">&#39;]</span>
569
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">}</span>
570
+ <span class="keyword">end</span></code></pre>
571
+
572
+ <p>Here we just create a new task, no matter what we get. Every seasoned web-developer would advise you to be suspicious about all the input you receive from your users, so let&#8217;s apply this advice.</p>
573
+
574
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">create</span>
575
+ <span class="keyword">if</span> <span class="ident">title</span> <span class="punct">=</span> <span class="ident">request</span><span class="punct">[&#39;</span><span class="string">title</span><span class="punct">&#39;]</span>
576
+ <span class="ident">title</span><span class="punct">.</span><span class="ident">strip!</span>
577
+ <span class="keyword">if</span> <span class="ident">title</span><span class="punct">.</span><span class="ident">empty?</span>
578
+ <span class="ident">failed</span><span class="punct">(&quot;</span><span class="string">Please enter a title</span><span class="punct">&quot;)</span>
579
+ <span class="ident">redirect</span> <span class="punct">&#39;</span><span class="string">/new</span><span class="punct">&#39;</span>
580
+ <span class="keyword">end</span>
581
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="punct">{</span><span class="symbol">:done</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">}</span>
582
+ <span class="keyword">end</span>
583
+ <span class="keyword">end</span></code></pre>
584
+
585
+ <p>First of all we check if we got a request with a value for &#8216;title&#8217;, if we get none we just let the aspect kick in that will redirect the browser to the index. Next we strip the title of all spaces around it so we can check if it is empty. We will talk about the specifics of our error-handling now.</p>
586
+
587
+ <p>Ramaze has a helper called FlashHelper, that will keep a hash associated with the session for one request, afterwards the hash is thrown away. This is specifically useful for giving the user feedback while keeping a stateless approach.</p>
588
+
589
+ <p>Let me show you our <code>#failed</code> method (it goes in the private section to <code>#task_status</code>):</p>
590
+
591
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">failed</span><span class="punct">(</span><span class="ident">message</span><span class="punct">)</span>
592
+ <span class="ident">flash</span><span class="punct">[</span><span class="symbol">:error</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">message</span>
593
+ <span class="keyword">end</span></code></pre>
594
+
595
+ <p>Duh, you may say, wouldn&#8217;t that fit in the one line instead of the call to <code>#failed</code>? Indeed, it would, but let me remind you, we have no checks for changing the status of a task yet. We will need error-handling there as well, so we just keep our code DRY and maintainable by collecting shared behaviour in small pieces.</p>
765
596
 
766
597
  <p>Now on to the <code>#task_status</code>:</p>
767
598
 
768
- <pre><code>def task_status title, status
769
- unless task = TodoList[title]
770
- failed "No such Task: `#{title}'"
771
- redirect_referer
772
- end
599
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span>
600
+ <span class="keyword">unless</span> <span class="ident">task</span> <span class="punct">=</span> <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span>
601
+ <span class="ident">failed</span> <span class="punct">&quot;</span><span class="string">No such Task: `<span class="expr">#{title}</span>&#39;</span><span class="punct">&quot;</span>
602
+ <span class="ident">redirect_referer</span>
603
+ <span class="keyword">end</span>
773
604
 
774
- task[:done] = status
775
- TodoList[title] = task
776
- end
777
- </code></pre>
605
+ <span class="ident">task</span><span class="punct">[</span><span class="symbol">:done</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">status</span>
606
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">task</span>
607
+ <span class="keyword">end</span></code></pre>
778
608
 
779
609
  <p>That used to look like this:</p>
780
610
 
781
- <pre><code>def task_status title, status
782
- task = TodoList[title]
783
- task[:done] = status
784
- TodoList[title] = task
785
- end
786
- </code></pre>
611
+ <pre><code class="ruby" lang="ruby"><span class="keyword">def </span><span class="method">task_status</span> <span class="ident">title</span><span class="punct">,</span> <span class="ident">status</span>
612
+ <span class="ident">task</span> <span class="punct">=</span> <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span>
613
+ <span class="ident">task</span><span class="punct">[</span><span class="symbol">:done</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">status</span>
614
+ <span class="constant">TodoList</span><span class="punct">[</span><span class="ident">title</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">task</span>
615
+ <span class="keyword">end</span></code></pre>
787
616
 
788
- <p>So in fact all we added is a check whether a task already exists, set an
789
- error-message in case it doesn't and redirect to wherever the browser came from.</p>
617
+ <p>So in fact all we added is a check whether a task already exists, set an error-message in case it doesn&#8217;t and redirect to wherever the browser came from.</p>
790
618
 
791
- <p>But what about actually showing the error-messages we so carefully set? Well,
792
- where do we change the view? Right, in the templates. But both templates we have
793
- so far (index and new) share this behaviour, so we head over to the Element
794
- and add in the right place:</p>
619
+ <p>But what about actually showing the error-messages we so carefully set? Well, where do we change the view? Right, in the templates. But both templates we have so far (index and new) share this behaviour, so we head over to the Element and add in the right place:</p>
795
620
 
796
621
  <pre><code>&lt;body&gt;
797
622
  &lt;h1&gt;#{@title}&lt;/h1&gt;
798
623
  &lt;?r if flash[:error] ?&gt;
799
- &lt;div class="error"&gt;
800
- \#{flash[:error]}
624
+ &lt;div class=&quot;error&quot;&gt;
625
+ \\#{flash[:error]}
801
626
  &lt;/div&gt;
802
627
  &lt;?r end ?&gt;
803
628
  #{content}
804
- &lt;/body&gt;
805
- </code></pre>
806
-
807
- <p>The only thing special about it is the <code>\#{flash[:error]}</code>, we have to escape
808
- the <code>#</code> so it won't evaluate this immediately but wait until it is really
809
- rendered.
810
- As a note, If you read this as pure markaby, the double backslash is to output
811
- properly to HTML, just use one instead.
812
- Again, you can add some nifty style for that.</p>
813
-
814
- <p>To be continued...</p>
815
- </body>
816
- </html>
629
+ &lt;/body&gt;</code></pre>
630
+
631
+ <p>The only thing special about it is the <code>\\#{flash[:error]}</code>, we have to escape the <code>#</code> so it won&#8217;t evaluate this immediately but wait until it is really rendered. As a note, If you read this as pure markaby, the double backslash is to output properly to HTML, just use one instead. Again, you can add some nifty style for that.</p>
632
+
633
+ <p>To be continued&#8230;</p>
634
+ </body></html>