ramaze 2009.03 → 2009.04
Sign up to get free protection for your applications and to get access to all the features.
- data/.mailmap +25 -0
- data/CHANGELOG +16750 -0
- data/MANIFEST +485 -0
- data/{README.md → README.markdown} +0 -5
- data/Rakefile +79 -242
- data/bin/ramaze +275 -52
- data/doc/AUTHORS +36 -28
- data/doc/FAQ +1 -1
- data/doc/tutorial/todolist.html +1415 -742
- data/doc/tutorial/todolist.txt +939 -0
- data/examples/app/auth/layout/auth.xhtml +25 -0
- data/examples/app/auth/start.rb +23 -0
- data/examples/app/auth/view/index.xhtml +4 -0
- data/examples/app/auth/view/login.xhtml +20 -0
- data/examples/app/auth/view/secret.xhtml +1 -0
- data/examples/app/blog/app.rb +69 -0
- data/{lib/proto/start.ru → examples/app/blog/config.ru} +8 -7
- data/examples/app/blog/controller/comment.rb +45 -0
- data/examples/app/blog/controller/entry.rb +85 -0
- data/examples/app/blog/controller/init.rb +86 -0
- data/examples/app/blog/controller/main.rb +16 -25
- data/examples/app/blog/controller/tag.rb +9 -0
- data/examples/app/blog/layout/default.nag +31 -0
- data/examples/app/blog/model/comment.rb +58 -0
- data/examples/app/blog/model/entry.rb +81 -22
- data/examples/app/blog/model/init.rb +15 -0
- data/examples/app/blog/model/tag.rb +36 -0
- data/examples/app/blog/public/css/screen.css +273 -0
- data/examples/app/blog/start.rb +3 -5
- data/examples/app/blog/view/comment/form.nag +10 -0
- data/examples/app/blog/view/comment/show.nag +16 -0
- data/examples/app/blog/view/entry/edit.nag +14 -0
- data/examples/app/blog/view/entry/feed.atom.nag +8 -0
- data/examples/app/blog/view/entry/feed.rss.nag +7 -0
- data/examples/app/blog/view/entry/index.nag +7 -0
- data/examples/app/blog/view/entry/new.nag +13 -0
- data/examples/app/blog/view/entry/show.nag +36 -0
- data/examples/app/blog/view/feed.atom.nag +18 -0
- data/examples/app/blog/view/feed.rss.nag +25 -0
- data/examples/app/blog/view/index.nag +6 -0
- data/examples/app/blog/view/tag/index.nag +5 -0
- data/examples/app/chat/{view/layout.xhtml → layout/default.nag} +1 -1
- data/examples/app/chat/model/history.rb +13 -11
- data/examples/app/chat/public/css/chat.css +9 -13
- data/examples/app/chat/public/js/chat.js +6 -0
- data/examples/app/chat/start.rb +16 -17
- data/examples/app/chat/view/{chat.xhtml → chat.nag} +0 -0
- data/examples/app/chat/view/{index.xhtml → index.nag} +0 -0
- data/examples/app/sourceview/{sourceview.rb → start.rb} +36 -34
- data/examples/app/sourceview/{template → view}/index.haml +0 -0
- data/examples/app/todolist/controller/init.rb +10 -0
- data/examples/app/todolist/controller/task.rb +39 -0
- data/examples/app/todolist/layout/default.xhtml +14 -0
- data/examples/app/todolist/model/init.rb +14 -0
- data/examples/app/todolist/model/task.rb +39 -0
- data/examples/app/todolist/public/css/screen.css +63 -0
- data/examples/app/todolist/start.rb +6 -6
- data/examples/app/todolist/view/index.xhtml +29 -0
- data/examples/app/wikore/spec/wikore.rb +4 -6
- data/examples/app/wikore/src/controller.rb +9 -11
- data/examples/app/wikore/src/model.rb +7 -10
- data/examples/app/wikore/start.rb +1 -1
- data/examples/app/wikore/{template → view}/index.xhtml +0 -0
- data/examples/basic/element.rb +5 -3
- data/examples/basic/gestalt.rb +1 -2
- data/examples/basic/hello.rb +3 -4
- data/examples/basic/layout.rb +2 -2
- data/examples/basic/linking.rb +7 -7
- data/examples/basic/partial.rb +3 -5
- data/examples/basic/simple.rb +1 -5
- data/examples/helpers/cache.rb +5 -5
- data/examples/helpers/httpdigest.rb +31 -32
- data/examples/misc/memleak_detector.rb +17 -12
- data/examples/misc/rapp.rb +28 -17
- data/examples/misc/serve_directory.rb +6 -0
- data/examples/templates/template_erubis.rb +9 -10
- data/examples/templates/template_ezamar.rb +8 -7
- data/examples/templates/template_haml.rb +6 -7
- data/examples/templates/template_liquid.rb +20 -19
- data/examples/templates/template_markaby.rb +2 -3
- data/examples/templates/template_nagoro.rb +6 -7
- data/examples/templates/template_redcloth.rb +8 -9
- data/examples/templates/template_remarkably.rb +7 -8
- data/examples/templates/template_tenjin.rb +6 -7
- data/examples/templates/{template → view}/external.haml +4 -4
- data/examples/templates/{template → view}/external.liquid +0 -0
- data/examples/templates/{template → view}/external.mab +0 -0
- data/examples/templates/{template → view}/external.nag +4 -4
- data/examples/templates/{template → view}/external.redcloth +4 -4
- data/examples/templates/{template → view}/external.rem +4 -4
- data/examples/templates/{template → view}/external.rhtml +6 -6
- data/examples/templates/{template → view}/external.tenjin +4 -4
- data/examples/templates/{template → view}/external.zmr +6 -6
- data/lib/proto/app.rb +15 -0
- data/lib/proto/config.ru +16 -0
- data/lib/proto/controller/init.rb +2 -2
- data/lib/proto/{view/page.xhtml → layout/default.xhtml} +1 -4
- data/lib/proto/public/.htaccess +24 -0
- data/lib/proto/public/css/screen.css +30 -0
- data/lib/proto/public/js/jquery.js +2121 -1294
- data/lib/proto/spec/main.rb +11 -15
- data/lib/proto/start.rb +6 -10
- data/lib/proto/view/index.xhtml +34 -27
- data/lib/ramaze.rb +78 -129
- data/lib/ramaze/app.rb +124 -0
- data/lib/ramaze/cache.rb +9 -104
- data/lib/ramaze/cache/localmemcache.rb +56 -0
- data/lib/ramaze/cache/memcache.rb +99 -0
- data/lib/ramaze/cache/sequel.rb +67 -0
- data/lib/ramaze/contrib/app_graph.rb +64 -0
- data/lib/ramaze/contrib/email.rb +2 -0
- data/lib/ramaze/contrib/gettext/po.rb +23 -23
- data/lib/ramaze/contrib/gzip_filter.rb +1 -69
- data/lib/ramaze/contrib/rest.rb +20 -15
- data/lib/ramaze/contrib/sequel/create_join.rb +1 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
- data/lib/ramaze/contrib/sequel/image.rb +9 -11
- data/lib/ramaze/contrib/sequel/relation.rb +21 -5
- data/lib/ramaze/controller.rb +63 -257
- data/lib/ramaze/controller/default.rb +12 -0
- data/lib/ramaze/current.rb +3 -47
- data/lib/ramaze/files.rb +24 -0
- data/lib/ramaze/gestalt.rb +6 -1
- data/lib/ramaze/helper.rb +6 -81
- data/lib/ramaze/helper/auth.rb +68 -104
- data/lib/ramaze/helper/bench.rb +0 -2
- data/lib/ramaze/helper/cache.rb +71 -120
- data/lib/ramaze/helper/disqus.rb +26 -0
- data/lib/ramaze/helper/flash.rb +32 -44
- data/lib/ramaze/helper/form.rb +83 -252
- data/lib/ramaze/helper/formatting.rb +32 -5
- data/lib/ramaze/helper/gestalt.rb +1 -1
- data/lib/ramaze/helper/gravatar.rb +66 -19
- data/lib/ramaze/helper/httpdigest.rb +66 -62
- data/lib/ramaze/helper/link.rb +62 -109
- data/lib/ramaze/helper/localize.rb +138 -0
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/maruku.rb +10 -3
- data/lib/ramaze/helper/pager.rb +2 -1
- data/lib/ramaze/helper/paginate.rb +17 -9
- data/lib/ramaze/helper/partial.rb +86 -91
- data/lib/ramaze/helper/remarkably.rb +14 -0
- data/lib/ramaze/helper/request_accessor.rb +16 -0
- data/lib/ramaze/helper/sequel_form.rb +284 -0
- data/lib/ramaze/helper/simple_captcha.rb +46 -16
- data/lib/ramaze/helper/stack.rb +64 -66
- data/lib/ramaze/helper/user.rb +141 -22
- data/lib/ramaze/helper/xhtml.rb +27 -16
- data/lib/ramaze/log.rb +19 -7
- data/lib/ramaze/log/analogger.rb +1 -2
- data/lib/ramaze/log/informer.rb +1 -0
- data/lib/ramaze/log/logging.rb +2 -8
- data/lib/ramaze/log/syslog.rb +36 -36
- data/lib/ramaze/middleware_compiler.rb +13 -0
- data/lib/ramaze/plugin.rb +69 -0
- data/lib/ramaze/reloader.rb +8 -6
- data/lib/ramaze/request.rb +118 -0
- data/lib/ramaze/{current/response.rb → response.rb} +9 -10
- data/lib/ramaze/setup.rb +93 -33
- data/lib/ramaze/snippets/ramaze/deprecated.rb +3 -1
- data/lib/ramaze/snippets/{dictionary.rb → ramaze/dictionary.rb} +0 -104
- data/lib/ramaze/snippets/ramaze/fiber.rb +5 -5
- data/lib/ramaze/spec.rb +34 -1
- data/lib/ramaze/spec/helper/bacon.rb +4 -3
- data/lib/ramaze/spec/helper/snippets.rb +3 -1
- data/lib/ramaze/spec/helper/template_examples.rb +29 -0
- data/lib/ramaze/tool/create.rb +1 -1
- data/lib/ramaze/version.rb +1 -4
- data/lib/ramaze/view.rb +48 -0
- data/lib/ramaze/view/erubis.rb +23 -0
- data/lib/ramaze/view/ezamar.rb +23 -0
- data/lib/ramaze/view/haml.rb +16 -0
- data/lib/ramaze/view/liquid.rb +100 -0
- data/lib/ramaze/view/maruku.rb +14 -0
- data/lib/ramaze/view/nagoro.rb +44 -0
- data/lib/ramaze/view/nagoro/render_partial.rb +32 -0
- data/lib/ramaze/view/redcloth.rb +21 -0
- data/lib/ramaze/view/remarkably.rb +21 -0
- data/lib/ramaze/view/sass.rb +21 -0
- data/lib/ramaze/view/tagz.rb +63 -0
- data/lib/ramaze/view/tenjin.rb +29 -0
- data/lib/vendor/etag.rb +20 -0
- data/lib/vendor/route_exceptions.rb +48 -0
- data/ramaze.gemspec +44 -0
- data/spec/contrib/rest.rb +28 -0
- data/spec/examples/caching.rb +1 -2
- data/spec/examples/css.rb +1 -2
- data/spec/examples/element.rb +1 -2
- data/spec/examples/hello.rb +2 -3
- data/spec/examples/helpers/httpdigest.rb +64 -0
- data/spec/examples/linking.rb +1 -2
- data/spec/examples/simple.rb +1 -6
- data/spec/examples/templates/template_erubis.rb +3 -17
- data/spec/examples/templates/template_ezamar.rb +3 -18
- data/spec/examples/templates/template_haml.rb +3 -17
- data/spec/examples/templates/template_liquid.rb +3 -23
- data/spec/examples/templates/template_markaby.rb +6 -19
- data/spec/examples/templates/template_nagoro.rb +9 -0
- data/spec/examples/templates/template_redcloth.rb +3 -22
- data/spec/examples/templates/template_remarkably.rb +3 -17
- data/spec/examples/templates/template_tenjin.rb +3 -22
- data/spec/helper.rb +10 -3
- data/spec/ramaze/action/render.rb +5 -15
- data/spec/ramaze/action/view/other_wrapper.erb +1 -0
- data/spec/ramaze/action/view/sub/sub_wrapper.erb +1 -0
- data/spec/ramaze/app.rb +47 -0
- data/spec/ramaze/cache/localmemcache.rb +49 -0
- data/spec/ramaze/cache/memcache.rb +54 -0
- data/spec/ramaze/cache/sequel.rb +51 -0
- data/spec/ramaze/controller/actionless_templates.rb +14 -10
- data/spec/ramaze/controller/mapping.rb +57 -0
- data/spec/ramaze/controller/provide_inheritance.rb +47 -0
- data/spec/ramaze/controller/resolve.rb +7 -9
- data/spec/ramaze/controller/subclass.rb +13 -13
- data/spec/ramaze/controller/template_resolving.rb +21 -57
- data/spec/ramaze/dispatcher/directory.rb +38 -24
- data/spec/ramaze/dispatcher/file.rb +55 -44
- data/spec/ramaze/error.rb +56 -62
- data/spec/ramaze/files.rb +29 -0
- data/spec/ramaze/files/public_1/plain.txt +1 -0
- data/spec/ramaze/files/public_2/rich.txt +1 -0
- data/spec/ramaze/gestalt.rb +2 -4
- data/spec/ramaze/helper/auth.rb +41 -24
- data/spec/ramaze/helper/bench.rb +17 -0
- data/spec/ramaze/helper/cache.rb +65 -101
- data/spec/ramaze/helper/flash.rb +20 -112
- data/spec/ramaze/helper/form.rb +336 -98
- data/spec/ramaze/helper/formatting.rb +66 -9
- data/spec/ramaze/helper/gestalt.rb +15 -0
- data/spec/ramaze/helper/gravatar.rb +40 -0
- data/spec/ramaze/helper/httpdigest.rb +144 -0
- data/spec/ramaze/helper/link.rb +25 -100
- data/spec/ramaze/helper/localize.rb +60 -0
- data/spec/ramaze/helper/maruku.rb +19 -0
- data/spec/ramaze/helper/pager.rb +13 -16
- data/spec/ramaze/helper/paginate.rb +68 -0
- data/spec/ramaze/helper/request_accessor.rb +19 -0
- data/spec/ramaze/helper/sequel_form.rb +89 -0
- data/spec/ramaze/helper/simple_captcha.rb +35 -12
- data/spec/ramaze/helper/stack.rb +52 -39
- data/spec/ramaze/helper/user.rb +39 -10
- data/spec/ramaze/helper/xhtml.rb +32 -0
- data/spec/ramaze/log/informer.rb +20 -19
- data/spec/ramaze/log/logging.rb +63 -0
- data/spec/ramaze/log/syslog.rb +59 -62
- data/spec/ramaze/params.rb +8 -11
- data/spec/ramaze/request.rb +57 -181
- data/spec/ramaze/view.rb +36 -0
- data/spec/ramaze/view/erubis.rb +73 -0
- data/spec/ramaze/view/erubis/external.rhtml +8 -0
- data/spec/ramaze/view/erubis/sum.rhtml +1 -0
- data/spec/ramaze/view/ezamar.rb +73 -0
- data/spec/ramaze/view/ezamar/external.zmr +8 -0
- data/spec/ramaze/view/ezamar/sum.zmr +1 -0
- data/spec/ramaze/view/haml.rb +86 -0
- data/spec/ramaze/view/haml/external.haml +5 -0
- data/spec/ramaze/view/haml/sum.haml +2 -0
- data/spec/ramaze/view/liquid.rb +73 -0
- data/spec/ramaze/view/liquid/external.liquid +8 -0
- data/spec/ramaze/view/liquid/sum.liquid +1 -0
- data/spec/ramaze/view/nagoro.rb +73 -0
- data/spec/ramaze/view/nagoro/external.nag +8 -0
- data/spec/ramaze/view/nagoro/sum.nag +1 -0
- data/spec/ramaze/view/redcloth.rb +66 -0
- data/spec/ramaze/view/redcloth/external.redcloth +8 -0
- data/spec/ramaze/view/remarkably.rb +49 -0
- data/spec/ramaze/{template → view}/remarkably/external.rem +0 -0
- data/spec/ramaze/{template → view}/remarkably/sum.rem +0 -0
- data/spec/ramaze/view/sass.rb +73 -0
- data/spec/ramaze/{template → view}/sass/file.css.sass +0 -0
- data/spec/ramaze/{template → view}/tagz.rb +18 -29
- data/spec/ramaze/{template → view}/tagz/external.tagz +0 -0
- data/spec/ramaze/{template → view}/tagz/sum.tagz +0 -0
- data/spec/ramaze/view/tenjin.rb +57 -0
- data/spec/ramaze/view/tenjin/external.rbhtml +8 -0
- data/spec/ramaze/view/tenjin/sum.rbhtml +1 -0
- data/spec/snippets/ramaze/dictionary.rb +110 -0
- data/spec/snippets/ramaze/struct.rb +12 -0
- data/spec/snippets/thread/into.rb +3 -14
- data/tasks/authors.rake +30 -0
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/copyright.rake +21 -0
- data/tasks/gem.rake +22 -0
- data/tasks/gem_installer.rake +76 -0
- data/{rake_tasks → tasks}/git.rake +10 -5
- data/tasks/grancher.rake +12 -0
- data/tasks/install_dependencies.rake +6 -0
- data/tasks/jquery.rake +15 -0
- data/tasks/manifest.rake +4 -0
- data/{rake_tasks/metric.rake → tasks/metric_changes.rake} +7 -7
- data/tasks/rcov.rake +23 -0
- data/tasks/release.rake +51 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +24 -0
- data/tasks/todo.rake +29 -0
- data/tasks/traits.rake +21 -0
- data/tasks/yard.rake +4 -0
- metadata +191 -452
- data/benchmark/suite/template_amrita2.rb +0 -17
- data/doc/readme_chunks/appendix.txt +0 -10
- data/doc/readme_chunks/examples.txt +0 -38
- data/doc/readme_chunks/features.txt +0 -148
- data/doc/readme_chunks/getting_help.txt +0 -5
- data/doc/readme_chunks/getting_started.txt +0 -18
- data/doc/readme_chunks/installing.txt +0 -92
- data/doc/readme_chunks/introduction.txt +0 -18
- data/doc/readme_chunks/principles.txt +0 -56
- data/doc/readme_chunks/thanks.txt +0 -59
- data/examples/app/auth/auth.rb +0 -54
- data/examples/app/auth/template/layout.haml +0 -20
- data/examples/app/auth/template/login.haml +0 -16
- data/examples/app/blog/public/styles/blog.css +0 -132
- data/examples/app/blog/view/edit.xhtml +0 -17
- data/examples/app/blog/view/index.xhtml +0 -17
- data/examples/app/blog/view/layout.xhtml +0 -11
- data/examples/app/blog/view/new.xhtml +0 -16
- data/examples/app/rapaste/Rakefile +0 -34
- data/examples/app/rapaste/controller/paste.rb +0 -101
- data/examples/app/rapaste/model/paste.rb +0 -58
- data/examples/app/rapaste/public/css/active4d.css +0 -114
- data/examples/app/rapaste/public/css/all_hallows_eve.css +0 -72
- data/examples/app/rapaste/public/css/amy.css +0 -147
- data/examples/app/rapaste/public/css/blackboard.css +0 -88
- data/examples/app/rapaste/public/css/brilliance_black.css +0 -605
- data/examples/app/rapaste/public/css/brilliance_dull.css +0 -599
- data/examples/app/rapaste/public/css/cobalt.css +0 -149
- data/examples/app/rapaste/public/css/dawn.css +0 -121
- data/examples/app/rapaste/public/css/display.css +0 -197
- data/examples/app/rapaste/public/css/eiffel.css +0 -121
- data/examples/app/rapaste/public/css/espresso_libre.css +0 -109
- data/examples/app/rapaste/public/css/idle.css +0 -62
- data/examples/app/rapaste/public/css/iplastic.css +0 -80
- data/examples/app/rapaste/public/css/lazy.css +0 -73
- data/examples/app/rapaste/public/css/mac_classic.css +0 -123
- data/examples/app/rapaste/public/css/magicwb_amiga.css +0 -104
- data/examples/app/rapaste/public/css/pastels_on_dark.css +0 -188
- data/examples/app/rapaste/public/css/slush_poppies.css +0 -85
- data/examples/app/rapaste/public/css/spacecadet.css +0 -51
- data/examples/app/rapaste/public/css/sunburst.css +0 -180
- data/examples/app/rapaste/public/css/twilight.css +0 -137
- data/examples/app/rapaste/public/css/zenburnesque.css +0 -91
- data/examples/app/rapaste/public/js/jquery.js +0 -11
- data/examples/app/rapaste/spec/rapaste.rb +0 -51
- data/examples/app/rapaste/start.rb +0 -25
- data/examples/app/rapaste/view/copy.xhtml +0 -10
- data/examples/app/rapaste/view/index.xhtml +0 -9
- data/examples/app/rapaste/view/layout.xhtml +0 -25
- data/examples/app/rapaste/view/list.xhtml +0 -29
- data/examples/app/rapaste/view/search.xhtml +0 -41
- data/examples/app/rapaste/view/view.xhtml +0 -40
- data/examples/app/todolist/README +0 -1
- data/examples/app/todolist/public/js/jquery.js +0 -1923
- data/examples/app/todolist/public/ramaze.png +0 -0
- data/examples/app/todolist/spec/todolist.rb +0 -132
- data/examples/app/todolist/src/controller/main.rb +0 -70
- data/examples/app/todolist/src/element/page.rb +0 -31
- data/examples/app/todolist/src/model.rb +0 -14
- data/examples/app/todolist/template/index.xhtml +0 -17
- data/examples/app/todolist/template/new.xhtml +0 -7
- data/examples/helpers/provide.rb +0 -23
- data/examples/misc/simple_auth.rb +0 -35
- data/examples/templates/template/external.amrita +0 -19
- data/examples/templates/template/external.xsl +0 -57
- data/examples/templates/template_amrita2.rb +0 -74
- data/examples/templates/template_xslt.rb +0 -49
- data/lib/proto/public/css/ramaze_error.css +0 -90
- data/lib/proto/view/error.xhtml +0 -64
- data/lib/ramaze/action.rb +0 -159
- data/lib/ramaze/action/render.rb +0 -192
- data/lib/ramaze/adapter.rb +0 -97
- data/lib/ramaze/adapter/base.rb +0 -128
- data/lib/ramaze/adapter/cgi.rb +0 -20
- data/lib/ramaze/adapter/ebb.rb +0 -18
- data/lib/ramaze/adapter/evented_mongrel.rb +0 -7
- data/lib/ramaze/adapter/fake.rb +0 -12
- data/lib/ramaze/adapter/fcgi.rb +0 -18
- data/lib/ramaze/adapter/lsws.rb +0 -19
- data/lib/ramaze/adapter/mongrel.rb +0 -21
- data/lib/ramaze/adapter/scgi.rb +0 -18
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +0 -7
- data/lib/ramaze/adapter/thin.rb +0 -17
- data/lib/ramaze/adapter/webrick.rb +0 -43
- data/lib/ramaze/cache/file.rb +0 -71
- data/lib/ramaze/cache/memcached.rb +0 -69
- data/lib/ramaze/cache/memory.rb +0 -6
- data/lib/ramaze/cache/yaml_store.rb +0 -68
- data/lib/ramaze/contrib.rb +0 -82
- data/lib/ramaze/contrib/file_cache.rb +0 -3
- data/lib/ramaze/contrib/gems.rb +0 -82
- data/lib/ramaze/contrib/sequel/fill.rb +0 -12
- data/lib/ramaze/contrib/sequel_cache.rb +0 -92
- data/lib/ramaze/controller/error.rb +0 -46
- data/lib/ramaze/controller/main.rb +0 -2
- data/lib/ramaze/controller/resolve.rb +0 -278
- data/lib/ramaze/current/request.rb +0 -231
- data/lib/ramaze/current/session.rb +0 -179
- data/lib/ramaze/current/session/flash.rb +0 -88
- data/lib/ramaze/current/session/hash.rb +0 -62
- data/lib/ramaze/dispatcher.rb +0 -145
- data/lib/ramaze/dispatcher/action.rb +0 -50
- data/lib/ramaze/dispatcher/directory.rb +0 -119
- data/lib/ramaze/dispatcher/error.rb +0 -108
- data/lib/ramaze/dispatcher/file.rb +0 -100
- data/lib/ramaze/error.rb +0 -24
- data/lib/ramaze/helper/aspect.rb +0 -106
- data/lib/ramaze/helper/cgi.rb +0 -39
- data/lib/ramaze/helper/redirect.rb +0 -100
- data/lib/ramaze/helper/rest.rb +0 -43
- data/lib/ramaze/helper/sendfile.rb +0 -16
- data/lib/ramaze/option.rb +0 -156
- data/lib/ramaze/option/dsl.rb +0 -45
- data/lib/ramaze/option/holder.rb +0 -131
- data/lib/ramaze/option/merger.rb +0 -108
- data/lib/ramaze/route.rb +0 -97
- data/lib/ramaze/snippets/object/traits.rb +0 -76
- data/lib/ramaze/snippets/ramaze/caller_info.rb +0 -30
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +0 -51
- data/lib/ramaze/snippets/ramaze/state.rb +0 -86
- data/lib/ramaze/snippets/string/each.rb +0 -19
- data/lib/ramaze/spec/helper.rb +0 -135
- data/lib/ramaze/spec/helper/browser.rb +0 -88
- data/lib/ramaze/spec/helper/mock_http.rb +0 -64
- data/lib/ramaze/spec/helper/requester.rb +0 -63
- data/lib/ramaze/spec/helper/simple_http.rb +0 -434
- data/lib/ramaze/store/default.rb +0 -109
- data/lib/ramaze/template.rb +0 -87
- data/lib/ramaze/template/amrita2.rb +0 -49
- data/lib/ramaze/template/builder.rb +0 -28
- data/lib/ramaze/template/erubis.rb +0 -41
- data/lib/ramaze/template/ezamar.rb +0 -42
- data/lib/ramaze/template/ezamar/element.rb +0 -169
- data/lib/ramaze/template/ezamar/engine.rb +0 -76
- data/lib/ramaze/template/ezamar/morpher.rb +0 -135
- data/lib/ramaze/template/ezamar/render_partial.rb +0 -39
- data/lib/ramaze/template/ezamar/textpow.syntax +0 -34
- data/lib/ramaze/template/haml.rb +0 -37
- data/lib/ramaze/template/liquid.rb +0 -36
- data/lib/ramaze/template/markaby.rb +0 -52
- data/lib/ramaze/template/maruku.rb +0 -34
- data/lib/ramaze/template/nagoro.rb +0 -52
- data/lib/ramaze/template/none.rb +0 -14
- data/lib/ramaze/template/redcloth.rb +0 -25
- data/lib/ramaze/template/remarkably.rb +0 -38
- data/lib/ramaze/template/sass.rb +0 -38
- data/lib/ramaze/template/tagz.rb +0 -79
- data/lib/ramaze/template/tenjin.rb +0 -74
- data/lib/ramaze/template/xslt.rb +0 -100
- data/lib/ramaze/tool.rb +0 -9
- data/lib/ramaze/tool/daemonize.rb +0 -37
- data/lib/ramaze/tool/localize.rb +0 -202
- data/lib/ramaze/tool/mime.rb +0 -35
- data/lib/ramaze/tool/mime_types.yaml +0 -615
- data/lib/ramaze/tool/record.rb +0 -6
- data/lib/ramaze/trinity.rb +0 -16
- data/lib/vendor/bacon.rb +0 -323
- data/rake_tasks/conf.rake +0 -71
- data/rake_tasks/coverage.rake +0 -45
- data/rake_tasks/gem.rake +0 -74
- data/rake_tasks/maintenance.rake +0 -386
- data/rake_tasks/release.rake +0 -76
- data/rake_tasks/spec.rake +0 -61
- data/spec/contrib/profiling.rb +0 -29
- data/spec/contrib/sequel/fill.rb +0 -47
- data/spec/examples/simple_auth.rb +0 -32
- data/spec/examples/templates/template_amrita2.rb +0 -16
- data/spec/ramaze/action/basics.rb +0 -36
- data/spec/ramaze/action/cache.rb +0 -87
- data/spec/ramaze/action/file_cache.rb +0 -70
- data/spec/ramaze/action/layout.rb +0 -190
- data/spec/ramaze/adapter.rb +0 -49
- data/spec/ramaze/adapter/ebb.rb +0 -12
- data/spec/ramaze/adapter/mongrel.rb +0 -12
- data/spec/ramaze/adapter/record.rb +0 -31
- data/spec/ramaze/adapter/webrick.rb +0 -12
- data/spec/ramaze/cache.rb +0 -140
- data/spec/ramaze/controller.rb +0 -180
- data/spec/ramaze/current/request.rb +0 -30
- data/spec/ramaze/current/session.rb +0 -97
- data/spec/ramaze/dispatcher.rb +0 -31
- data/spec/ramaze/element.rb +0 -107
- data/spec/ramaze/helper/aspect.rb +0 -101
- data/spec/ramaze/helper/cgi.rb +0 -43
- data/spec/ramaze/helper/file.rb +0 -18
- data/spec/ramaze/helper/partial.rb +0 -88
- data/spec/ramaze/helper/redirect.rb +0 -112
- data/spec/ramaze/localize.rb +0 -89
- data/spec/ramaze/morpher.rb +0 -111
- data/spec/ramaze/public/error404.xhtml +0 -1
- data/spec/ramaze/request/ebb.rb +0 -9
- data/spec/ramaze/request/mongrel.rb +0 -9
- data/spec/ramaze/request/thin.rb +0 -9
- data/spec/ramaze/request/webrick.rb +0 -5
- data/spec/ramaze/rewrite.rb +0 -36
- data/spec/ramaze/route.rb +0 -131
- data/spec/ramaze/session.rb +0 -94
- data/spec/ramaze/store/default.rb +0 -71
- data/spec/ramaze/template.rb +0 -128
- data/spec/ramaze/template/amrita2.rb +0 -50
- data/spec/ramaze/template/amrita2/external.amrita +0 -6
- data/spec/ramaze/template/amrita2/sum.amrita +0 -1
- data/spec/ramaze/template/builder.rb +0 -51
- data/spec/ramaze/template/builder/external.rxml +0 -3
- data/spec/ramaze/template/erubis.rb +0 -41
- data/spec/ramaze/template/erubis/sum.rhtml +0 -1
- data/spec/ramaze/template/ezamar.rb +0 -63
- data/spec/ramaze/template/ezamar/another/long/action.zmr +0 -1
- data/spec/ramaze/template/ezamar/combined.zmr +0 -1
- data/spec/ramaze/template/ezamar/file_only.zmr +0 -1
- data/spec/ramaze/template/ezamar/index.zmr +0 -1
- data/spec/ramaze/template/ezamar/nested.zmr +0 -1
- data/spec/ramaze/template/ezamar/other__index.xhtml +0 -1
- data/spec/ramaze/template/ezamar/some__long__action.zmr +0 -1
- data/spec/ramaze/template/ezamar/sum.zmr +0 -1
- data/spec/ramaze/template/haml.rb +0 -66
- data/spec/ramaze/template/haml/index.haml +0 -5
- data/spec/ramaze/template/haml/locals.haml +0 -2
- data/spec/ramaze/template/haml/with_vars.haml +0 -4
- data/spec/ramaze/template/liquid.rb +0 -99
- data/spec/ramaze/template/liquid/index.liquid +0 -1
- data/spec/ramaze/template/liquid/products.liquid +0 -45
- data/spec/ramaze/template/markaby.rb +0 -61
- data/spec/ramaze/template/markaby/external.mab +0 -8
- data/spec/ramaze/template/markaby/sum.mab +0 -1
- data/spec/ramaze/template/nagoro.rb +0 -64
- data/spec/ramaze/template/nagoro/another/long/action.nag +0 -1
- data/spec/ramaze/template/nagoro/combined.nag +0 -1
- data/spec/ramaze/template/nagoro/file_only.nag +0 -1
- data/spec/ramaze/template/nagoro/index.nag +0 -1
- data/spec/ramaze/template/nagoro/nested.nag +0 -1
- data/spec/ramaze/template/nagoro/some__long__action.nag +0 -1
- data/spec/ramaze/template/nagoro/sum.nag +0 -1
- data/spec/ramaze/template/redcloth.rb +0 -38
- data/spec/ramaze/template/redcloth/external.redcloth +0 -1
- data/spec/ramaze/template/remarkably.rb +0 -58
- data/spec/ramaze/template/sass.rb +0 -70
- data/spec/ramaze/template/tenjin.rb +0 -47
- data/spec/ramaze/template/tenjin/external.tenjin +0 -1
- data/spec/ramaze/template/xslt.rb +0 -90
- data/spec/ramaze/template/xslt/concat_words.xsl +0 -16
- data/spec/ramaze/template/xslt/index.xsl +0 -14
- data/spec/ramaze/template/xslt/products.xsl +0 -32
- data/spec/ramaze/template/xslt/ruby_version.xsl +0 -14
- data/spec/snippets/ramaze/caller_info.rb +0 -39
- data/spec/snippets/ramaze/caller_lines.rb +0 -30
@@ -0,0 +1,939 @@
|
|
1
|
+
The official Ramaze Todo-list tutorial
|
2
|
+
=====================================
|
3
|
+
Michael 'manveru' Fellinger <m.fellinger@gmail.com>
|
4
|
+
revision 2.0, March 2009
|
5
|
+
|
6
|
+
== Abstract
|
7
|
+
|
8
|
+
Welcome to the official tutorial for http://ramaze.net[Ramaze], the mandatory
|
9
|
+
Todo-list.
|
10
|
+
|
11
|
+
I also assume that you have some experience with HTML and some other basics in
|
12
|
+
web-development already (you want to learn a web-framework after all).
|
13
|
+
|
14
|
+
The tutorial assumes a working installation of http://ruby-lang.org[Ruby] and
|
15
|
+
http://rubygems.org/[Rubygems].
|
16
|
+
|
17
|
+
For more information on how to install these please read the introductory
|
18
|
+
documentation of Ramaze, this is not in the scope of this tutorial.
|
19
|
+
|
20
|
+
To install Ramaze you can `gem install ramaze`, other ways of installation are
|
21
|
+
covered by the http://wiki.ramaze.net/[Ramaze Wiki].
|
22
|
+
|
23
|
+
Should you encounter any problems while doing this tutorial, this might either
|
24
|
+
be because Ramaze changed (which happens very often while it is still young)
|
25
|
+
or I actually made some mistake while writing it.
|
26
|
+
|
27
|
+
In either case it would make me (and all other poor fellows who happen to try
|
28
|
+
this tutorial) very happy if you could spare some time and report the issue
|
29
|
+
either on the http://ramazetrac.purepistos.org/[Bug tracker], or just
|
30
|
+
drop by on IRC on `irc.freenode.org` in the channel `#ramaze`.
|
31
|
+
|
32
|
+
If you have trouble with some of the terms used in this tutorial you can
|
33
|
+
consult the <<glossary, Glossary>> at the end of this document.
|
34
|
+
|
35
|
+
We are also working on a book that describes Ramaze in more depth, called
|
36
|
+
'Journey to Ramaze', it is still very much work in progress, but some of the
|
37
|
+
contents might interest you.
|
38
|
+
|
39
|
+
The repository for the book is at http://github.com/manveru/ramaze-book.
|
40
|
+
Every once in a while, updates for the book will be available in HTML and PDF
|
41
|
+
form at http://book.ramaze.net.
|
42
|
+
|
43
|
+
|
44
|
+
== First Step, Create
|
45
|
+
|
46
|
+
The last version of this tutorial assumed a generator to produce a skeleton in
|
47
|
+
which we do the work. This time around we will do everything from scratch to
|
48
|
+
give you a better experience of how exactly the pieces fit together.
|
49
|
+
|
50
|
+
You can also skip all the boring learning-by-doing part and play around with
|
51
|
+
the source of the todo-list example shipping with Ramaze.
|
52
|
+
|
53
|
+
NOTE: The example and this tutorial differ in some points, it is recommended to
|
54
|
+
actually work through the tutorial first and read the example afterwards, it
|
55
|
+
takes the basics taught here one step further by utilizing the Model.
|
56
|
+
|
57
|
+
You can find the example it in the `examples/app/todolist/` directory of your
|
58
|
+
Ramaze distribution.
|
59
|
+
To find out where that is located (as this differs widely between systems), you
|
60
|
+
can follow these steps in `irb`:
|
61
|
+
|
62
|
+
[source,ruby]
|
63
|
+
--------------------------------------------------------------------------------
|
64
|
+
require 'rubygems'
|
65
|
+
# => true
|
66
|
+
require 'ramaze'
|
67
|
+
# => true
|
68
|
+
File.expand_path(Ramaze::BASEDIR + '/../examples/app/todolist')
|
69
|
+
# => "/home/manveru/c/ramaze/examples/app/todolist"
|
70
|
+
--------------------------------------------------------------------------------
|
71
|
+
|
72
|
+
To start things off, we will create a basic directory structure looking like this:
|
73
|
+
|
74
|
+
--------------------------------------------------------------------------------
|
75
|
+
.
|
76
|
+
|-- controller
|
77
|
+
|-- layout
|
78
|
+
|-- model
|
79
|
+
|-- public
|
80
|
+
| |-- css
|
81
|
+
`-- view
|
82
|
+
--------------------------------------------------------------------------------
|
83
|
+
|
84
|
+
Doing that is quite simple: `mkdir -p controller layout model public/css view`
|
85
|
+
|
86
|
+
Alright, done? Let's go to the next step.
|
87
|
+
|
88
|
+
== Second Step. Hello, World!
|
89
|
+
|
90
|
+
To make sure Ramaze is installed, and working correctly we will follow an old
|
91
|
+
tradition, we create a file at the root of your application directory called
|
92
|
+
'start.rb' with following content:
|
93
|
+
|
94
|
+
[source,ruby]
|
95
|
+
--------------------------------------------------------------------------------
|
96
|
+
require 'rubygems'
|
97
|
+
require 'ramaze'
|
98
|
+
|
99
|
+
class MainController < Ramaze::Controller
|
100
|
+
def index
|
101
|
+
"Hello, World!"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
Ramaze.start
|
106
|
+
--------------------------------------------------------------------------------
|
107
|
+
|
108
|
+
Now we run it:
|
109
|
+
|
110
|
+
--------------------------------------------------------------------------------
|
111
|
+
delta ~/tmp/tutorial % ruby start.rb
|
112
|
+
D [2009-03-30 14:15:01 $2124] DEBUG | : Using webrick
|
113
|
+
I [2009-03-30 14:15:01 $2124] INFO | : WEBrick 1.3.1
|
114
|
+
I [2009-03-30 14:15:01 $2124] INFO | : ruby 1.9.2 (2009-03-02) [i686-linux]
|
115
|
+
D [2009-03-30 14:15:01 $2124] DEBUG | : TCPServer.new(0.0.0.0, 7000)
|
116
|
+
D [2009-03-30 14:15:01 $2124] DEBUG | : Rack::Handler::WEBrick is mounted on /.
|
117
|
+
I [2009-03-30 14:15:01 $2124] INFO | : WEBrick::HTTPServer#start: pid=2124 port=7000
|
118
|
+
--------------------------------------------------------------------------------
|
119
|
+
|
120
|
+
The logging output tells us that a server was started, listening to all
|
121
|
+
connections at port 7000. If you open your browser and go to
|
122
|
+
http://localhost:7000/ you should be able to see 'Hello, World!'.
|
123
|
+
|
124
|
+
|
125
|
+
== Third Step. M, like Model
|
126
|
+
|
127
|
+
Model is a term from the MVC paradigm, meaning the representation of data
|
128
|
+
within your application.
|
129
|
+
Ramaze doesn't promote a particular way for this part of your application, and
|
130
|
+
how you are supposed to integrate it. Since there are quite a number of ways to
|
131
|
+
represent data and none is clearly superior to another, this would be both
|
132
|
+
futile and short-sighted.
|
133
|
+
|
134
|
+
For the purpose of this tutorial we will use a lightweight database access
|
135
|
+
toolkit for Ruby called http://sequel.rubyforge.org/[Sequel].
|
136
|
+
|
137
|
+
Sequel is designed to take the hassle away from connecting to databases and
|
138
|
+
manipulating them. Sequel deals with all the boring stuff like maintaining
|
139
|
+
connections, formatting SQL correctly and fetching records so you can
|
140
|
+
concentrate on your application.
|
141
|
+
|
142
|
+
Being familiar with it is not a requirement for this tutorial, but will help
|
143
|
+
you tremendously when it comes to writing your own applications.
|
144
|
+
|
145
|
+
Installing Sequel is as simple as installing Ramaze: `gem install sequel`.
|
146
|
+
|
147
|
+
In this tutorial we are going to use the light-weight
|
148
|
+
http://www.sqlite.org/[sqlite] database.
|
149
|
+
This requires the http://rubyforge.org/projects/sqlite-ruby[sqlite-ruby]
|
150
|
+
bindings.
|
151
|
+
|
152
|
+
You can try to `gem install sqlite`, which will complain if your system doesn't
|
153
|
+
provide bindings, in which case I have to refer you to http://sqlite.org.
|
154
|
+
|
155
|
+
In order to use Sequel we also need a database connection.
|
156
|
+
|
157
|
+
So we create a new file at 'model/init.rb' with following content:
|
158
|
+
|
159
|
+
[source,ruby]
|
160
|
+
--------------------------------------------------------------------------------
|
161
|
+
require 'sequel'
|
162
|
+
|
163
|
+
Sequel::Model.plugin(:schema)
|
164
|
+
|
165
|
+
DB = Sequel.sqlite('todolist.db')
|
166
|
+
--------------------------------------------------------------------------------
|
167
|
+
|
168
|
+
The `:schema` plugin is required since Sequel 3.0, if you run a version prior
|
169
|
+
to 2.12 you may remove this line if it gives you any problems.
|
170
|
+
|
171
|
+
Next we edit 'start.rb', remove the `Hello` class, and add a require for the
|
172
|
+
file, 'start.rb' should look like this now:
|
173
|
+
|
174
|
+
[source,ruby]
|
175
|
+
--------------------------------------------------------------------------------
|
176
|
+
require 'rubygems'
|
177
|
+
require 'ramaze'
|
178
|
+
|
179
|
+
require 'model/init'
|
180
|
+
|
181
|
+
Ramaze.start
|
182
|
+
--------------------------------------------------------------------------------
|
183
|
+
|
184
|
+
This should hook us up with a database, but anyone familiar with SQL will now
|
185
|
+
ask how we are going to create our schema.
|
186
|
+
|
187
|
+
So our next step is to create the actual model for our data, for this we create another file at 'model/task.rb':
|
188
|
+
|
189
|
+
[source,ruby]
|
190
|
+
--------------------------------------------------------------------------------
|
191
|
+
class Task < Sequel::Model
|
192
|
+
set_schema do
|
193
|
+
primary_key :id
|
194
|
+
|
195
|
+
varchar :title, :unique => true, :empty => false
|
196
|
+
boolean :done, :default => false
|
197
|
+
end
|
198
|
+
|
199
|
+
create_table unless table_exists?
|
200
|
+
|
201
|
+
if empty?
|
202
|
+
create :title => 'Laundry'
|
203
|
+
create :title => 'Wash dishes'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
--------------------------------------------------------------------------------
|
207
|
+
|
208
|
+
For this tutorial we will not bother with migrations, although Sequel does have
|
209
|
+
very good support for them as well, but seriously, this is a really simple
|
210
|
+
schema that probably won't change much over the next few years.
|
211
|
+
|
212
|
+
Finally, add a line to your 'model/init.rb' that requires 'model/task.rb':
|
213
|
+
|
214
|
+
[source,ruby]
|
215
|
+
--------------------------------------------------------------------------------
|
216
|
+
require 'sequel'
|
217
|
+
|
218
|
+
Sequel::Model.plugin(:schema)
|
219
|
+
|
220
|
+
DB = Sequel.sqlite('todolist.db')
|
221
|
+
|
222
|
+
require 'model/task'
|
223
|
+
--------------------------------------------------------------------------------
|
224
|
+
|
225
|
+
|
226
|
+
== Fourth Step, V, like View
|
227
|
+
|
228
|
+
To see anything of the data in your Model we will have to add the second
|
229
|
+
element in MVC, the View.
|
230
|
+
|
231
|
+
We are going to use the templating engine shipping with Ramaze, called Etanni.
|
232
|
+
It has a very simple syntax compatible with SGML and XML documents.
|
233
|
+
|
234
|
+
When handling a request to '/', Ramaze will automatically try to find an Action
|
235
|
+
called 'index'. Don't bother too much about what Action means just yet, we will
|
236
|
+
explain that in more detail later when we come to layouts.
|
237
|
+
|
238
|
+
To start we put some contents into 'view/index.xhtml' (xhtml is the default
|
239
|
+
filename-extension for Etanni templates)
|
240
|
+
|
241
|
+
[source,html]
|
242
|
+
--------------------------------------------------------------------------------
|
243
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
244
|
+
<html>
|
245
|
+
<head>
|
246
|
+
<title>TodoList</title>
|
247
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
248
|
+
</head>
|
249
|
+
<body>
|
250
|
+
<h1>TodoList</h1>
|
251
|
+
<ul>
|
252
|
+
<?r Task.each do |task| ?>
|
253
|
+
<li>#{ h(task.title) }: #{ task.done }</li>
|
254
|
+
<?r end ?>
|
255
|
+
</ul>
|
256
|
+
</body>
|
257
|
+
</html>
|
258
|
+
--------------------------------------------------------------------------------
|
259
|
+
|
260
|
+
The '<?r ?>' and '\#{ }' elements enclose ruby code that will be executed when
|
261
|
+
the template is being rendered (on every request to 'index').
|
262
|
+
Code within '<?r ?>' is only executed and will not show up in the resulting
|
263
|
+
document, while code within '#{ }' will be interpolated.
|
264
|
+
|
265
|
+
In this template we iterate over all the data stored in the Task model,
|
266
|
+
yielding a list of task titles and the respective status of the task.
|
267
|
+
|
268
|
+
That wasn't too hard, right?
|
269
|
+
|
270
|
+
Now, so we can get our instant pleasure of seeing the result of our (hard)
|
271
|
+
work, let's see how this looks like in a browser, start your application like above with `ruby start.rb` and open http://localhost:7000/.
|
272
|
+
|
273
|
+
The template expanded to something like (only showing the interesting part):
|
274
|
+
|
275
|
+
[source,html]
|
276
|
+
--------------------------------------------------------------------------------
|
277
|
+
<ul>
|
278
|
+
<li>Laundry: false</li>
|
279
|
+
<li>Wash dishes: false</li>
|
280
|
+
</ul>
|
281
|
+
--------------------------------------------------------------------------------
|
282
|
+
|
283
|
+
That wasn't too bad, huh?
|
284
|
+
|
285
|
+
|
286
|
+
== Fifth Step, C, like Controller
|
287
|
+
|
288
|
+
The last part of the MVC paradigm is the Controller. As the name indicates it
|
289
|
+
gives you control over the interaction between Model and View.
|
290
|
+
|
291
|
+
Wouldn't it be nice to have a way to add and remove items on our to-do list?
|
292
|
+
Editing the model every time would be quite tiresome and problematic to do
|
293
|
+
remotely.
|
294
|
+
|
295
|
+
Well, come along, I'll give you a short intro to the concept of controllers.
|
296
|
+
|
297
|
+
In the way MVC is structured, the Controller provides the data in a nice way
|
298
|
+
for the View, removing all of the data-preparation and most of the logic from
|
299
|
+
the templates. This makes it firstly simple to change the front end of your
|
300
|
+
application and secondly provides excellent ways of changing the complete
|
301
|
+
Structure of the Model or View independent from each other.
|
302
|
+
|
303
|
+
OK, enough of the theory, you will see the benefits in an instant, first of all
|
304
|
+
we will implement marking a task as done.
|
305
|
+
|
306
|
+
Go on and create the file 'controller/task.rb' with following contents:
|
307
|
+
|
308
|
+
[source,ruby]
|
309
|
+
--------------------------------------------------------------------------------
|
310
|
+
class Tasks < Ramaze::Controller
|
311
|
+
map '/'
|
312
|
+
|
313
|
+
def close(title)
|
314
|
+
task = Task[:title => title]
|
315
|
+
task.done = true
|
316
|
+
task.save
|
317
|
+
|
318
|
+
redirect_referrer
|
319
|
+
end
|
320
|
+
end
|
321
|
+
--------------------------------------------------------------------------------
|
322
|
+
|
323
|
+
That does following:
|
324
|
+
|
325
|
+
* Define a `Tasks` class as a subclass of `Ramaze::Controller`.
|
326
|
+
* Tell Ramaze that a request to '/' goes to this Controller.
|
327
|
+
* Define a `#close` method that requires a `title` argument.
|
328
|
+
* Query for a task that has the given title.
|
329
|
+
* Set the status of the task to done and store the change to the database.
|
330
|
+
* Redirect the client to where it came from.
|
331
|
+
|
332
|
+
And we add a require to 'controller/task.rb' to our 'start.rb':
|
333
|
+
|
334
|
+
[source,ruby]
|
335
|
+
--------------------------------------------------------------------------------
|
336
|
+
require 'rubygems'
|
337
|
+
require 'ramaze'
|
338
|
+
|
339
|
+
require 'model/init'
|
340
|
+
require 'controller/task'
|
341
|
+
|
342
|
+
Ramaze.start
|
343
|
+
--------------------------------------------------------------------------------
|
344
|
+
|
345
|
+
Next we will have to modify the 'view/index.xhtml' to contain a link that will
|
346
|
+
change the status of a task:
|
347
|
+
|
348
|
+
[source,html]
|
349
|
+
--------------------------------------------------------------------------------
|
350
|
+
<ul>
|
351
|
+
<?r Task.each do |task| ?>
|
352
|
+
<li>
|
353
|
+
#{ h(task.title) }: #{ task.done },
|
354
|
+
(#{ anchor('close', route('close', url_encode(task.title))) })
|
355
|
+
</li>
|
356
|
+
<?r end ?>
|
357
|
+
</ul>
|
358
|
+
--------------------------------------------------------------------------------
|
359
|
+
|
360
|
+
Now we have an additional link next to each task that allows us to set it to
|
361
|
+
done.
|
362
|
+
|
363
|
+
The line we added requires some closer examination, it consists of following
|
364
|
+
parts (from inside out and with intermediate variables and annotation):
|
365
|
+
|
366
|
+
[source,ruby]
|
367
|
+
----
|
368
|
+
title = task.title <1>
|
369
|
+
url_title = url_encode(title) <2>
|
370
|
+
action = route('close', url_title) <3>
|
371
|
+
link = anchor('close', action) <4>
|
372
|
+
----
|
373
|
+
|
374
|
+
<1> Obtain the title of the task from the Model object.
|
375
|
+
<2> Encode the title for use in an URL.
|
376
|
+
<3> Ask the Controller about it's mapping for the 'close' action and build a
|
377
|
+
link from that, this means that if you ever change the mapping of the
|
378
|
+
`Tasks` Controller, you will not have to change any links.
|
379
|
+
<4> Finally create the anchor tag that will look like:
|
380
|
+
`<a href="/close/Wash+dishes">close</a>`
|
381
|
+
|
382
|
+
An even shorter way of writing that line using default aliases, that you will
|
383
|
+
encounter in other applications is:
|
384
|
+
|
385
|
+
[source,ruby]
|
386
|
+
--------------------------------------------------------------------------------
|
387
|
+
a('close', r('close', u(task.title)))
|
388
|
+
--------------------------------------------------------------------------------
|
389
|
+
|
390
|
+
But for the purpose of this tutorial we'll try to be as explicit as possible.
|
391
|
+
|
392
|
+
Now that's a lot of things at once, but I'm sure you will be able to keep up,
|
393
|
+
the hardest part is behind us.
|
394
|
+
|
395
|
+
Don't forget to try the new functionality in your browser, wash your dishes and
|
396
|
+
do your laundry and come back for the next episode.
|
397
|
+
|
398
|
+
== Sixth Step, Clean, Rinse, Repeat
|
399
|
+
|
400
|
+
Now that you have closed (and hopefully done) all of your chores, it's time to
|
401
|
+
open them again, so you won't be without work tomorrow.
|
402
|
+
|
403
|
+
Let's add a method to our Controller that will let us open a closed task:
|
404
|
+
|
405
|
+
[source,ruby]
|
406
|
+
--------------------------------------------------------------------------------
|
407
|
+
class Tasks < Ramaze::Controller
|
408
|
+
map '/'
|
409
|
+
|
410
|
+
def close(title)
|
411
|
+
task = Task[:title => title]
|
412
|
+
task.done = true
|
413
|
+
task.save
|
414
|
+
|
415
|
+
redirect_referrer
|
416
|
+
end
|
417
|
+
|
418
|
+
def open(title)
|
419
|
+
task = Task[:title => title]
|
420
|
+
task.done = false
|
421
|
+
task.save
|
422
|
+
|
423
|
+
redirect_referrer
|
424
|
+
end
|
425
|
+
end
|
426
|
+
--------------------------------------------------------------------------------
|
427
|
+
|
428
|
+
And add a link to that action:
|
429
|
+
|
430
|
+
[source,html]
|
431
|
+
--------------------------------------------------------------------------------
|
432
|
+
<ul>
|
433
|
+
<?r Task.each do |task| ?>
|
434
|
+
<li>
|
435
|
+
#{ h(task.title) }: #{ task.done },
|
436
|
+
(#{ anchor('close', route('close', url_encode(task.title))) })
|
437
|
+
(#{ anchor('open', route('open', url_encode(task.title))) })
|
438
|
+
</li>
|
439
|
+
<?r end ?>
|
440
|
+
</ul>
|
441
|
+
--------------------------------------------------------------------------------
|
442
|
+
|
443
|
+
OK, nothing new here, move along.
|
444
|
+
|
445
|
+
Oh, wait!
|
446
|
+
|
447
|
+
Rumor has it that some mad Japanese scientist got screwed by his company (they
|
448
|
+
produce dishwashers), so he filed a patent for the ultimate dish washing robot
|
449
|
+
that will take care of that for you.
|
450
|
+
|
451
|
+
Time to get rid of that task once and for all. No more dish washing yay!
|
452
|
+
|
453
|
+
A little modification to Controller, using destructive force.
|
454
|
+
|
455
|
+
[source,ruby]
|
456
|
+
--------------------------------------------------------------------------------
|
457
|
+
class Tasks < Ramaze::Controller
|
458
|
+
map '/'
|
459
|
+
|
460
|
+
def close(title)
|
461
|
+
task = Task[:title => title]
|
462
|
+
task.done = true
|
463
|
+
task.save
|
464
|
+
|
465
|
+
redirect_referrer
|
466
|
+
end
|
467
|
+
|
468
|
+
def open(title)
|
469
|
+
task = Task[:title => title]
|
470
|
+
task.done = false
|
471
|
+
task.save
|
472
|
+
|
473
|
+
redirect_referrer
|
474
|
+
end
|
475
|
+
|
476
|
+
def delete(title)
|
477
|
+
task = Task[:title => title]
|
478
|
+
task.destroy
|
479
|
+
|
480
|
+
redirect_referrer
|
481
|
+
end
|
482
|
+
end
|
483
|
+
--------------------------------------------------------------------------------
|
484
|
+
|
485
|
+
And a link to the `delete` action.
|
486
|
+
|
487
|
+
[source,html]
|
488
|
+
--------------------------------------------------------------------------------
|
489
|
+
<ul>
|
490
|
+
<?r Task.each do |task| ?>
|
491
|
+
<li>
|
492
|
+
#{ h(task.title) }: #{ task.done },
|
493
|
+
(#{ anchor('close', route('close', url_encode(task.title))) })
|
494
|
+
(#{ anchor('open', route('open', url_encode(task.title))) })
|
495
|
+
(#{ anchor('delete', route('delete', url_encode(task.title))) })
|
496
|
+
</li>
|
497
|
+
<?r end ?>
|
498
|
+
</ul>
|
499
|
+
--------------------------------------------------------------------------------
|
500
|
+
|
501
|
+
And dish-washing begone!
|
502
|
+
|
503
|
+
|
504
|
+
== Seventh Step, More Tasks
|
505
|
+
|
506
|
+
Sure, it would be nice if life was so simple and you only have to do your
|
507
|
+
laundry, but that would mean a premature end for this tutorial and an obstacle
|
508
|
+
for GTD evangelists (not that they couldn't overcome it).
|
509
|
+
|
510
|
+
So now you got a smart new robot that washes your dishes, but unfortunately it
|
511
|
+
wasn't programmed to recharge once in a while and buy soap, no biggie, we can
|
512
|
+
do that with little effort, but since reddit takes up all your time you keep
|
513
|
+
forgetting about it.
|
514
|
+
|
515
|
+
No problem, I say, adding following code to our 'view/index.xhtml' will give us
|
516
|
+
a nice little form that we can fill out in the few seconds between proving
|
517
|
+
people on the internet wrong.
|
518
|
+
|
519
|
+
[source,html]
|
520
|
+
--------------------------------------------------------------------------------
|
521
|
+
<form method="post" action="#{ route('create') }">
|
522
|
+
<fieldset>
|
523
|
+
<legend>Add a task by entering a title.</legend>
|
524
|
+
<label for="form-title">Task title:</label>
|
525
|
+
<input id="form-title" name="title" type="text" />
|
526
|
+
<input type="submit" value="Create" />
|
527
|
+
</fieldset>
|
528
|
+
</form>
|
529
|
+
--------------------------------------------------------------------------------
|
530
|
+
|
531
|
+
Unfortunately, you see, this references the `create` action, and we have none
|
532
|
+
yet. Trying to create a task will result in an error.
|
533
|
+
|
534
|
+
So what we have to do is adding one more method to our Controller that will
|
535
|
+
take care of actually creating the Task.
|
536
|
+
|
537
|
+
[source,ruby]
|
538
|
+
--------------------------------------------------------------------------------
|
539
|
+
def create
|
540
|
+
if request.post? and title = request[:title]
|
541
|
+
title.strip!
|
542
|
+
|
543
|
+
unless title.empty?
|
544
|
+
Task.create :title => title
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
redirect route('/')
|
549
|
+
end
|
550
|
+
--------------------------------------------------------------------------------
|
551
|
+
|
552
|
+
What is going on here?
|
553
|
+
|
554
|
+
* Check whether the request was using the HTTP POST method and actually sent a
|
555
|
+
title with it.
|
556
|
+
* Strip all whitespace from beginning and end of the title.
|
557
|
+
* If the title still has something in it we go on and create a task with that
|
558
|
+
title.
|
559
|
+
* Redirect back to the `index`
|
560
|
+
|
561
|
+
== Eighth Step, Eep, Exceptions!
|
562
|
+
|
563
|
+
So far, so good, but remember, when we defined the schema for `Task` we said we
|
564
|
+
really want to have unique titles.
|
565
|
+
|
566
|
+
So once you created the task 'recharge DishBot9000' and try to create another
|
567
|
+
one with the same title, you will get a nice error:
|
568
|
+
|
569
|
+
Sequel::DatabaseError: SQLite3::SQLException column title is not unique
|
570
|
+
|
571
|
+
OK, programmers ignore warnings and hide errors, let's rescue the exception and
|
572
|
+
just act as if nothing has happened.
|
573
|
+
|
574
|
+
[source,ruby]
|
575
|
+
--------------------------------------------------------------------------------
|
576
|
+
class Tasks < Ramaze::Controller
|
577
|
+
map '/'
|
578
|
+
|
579
|
+
def create
|
580
|
+
if request.post? and title = request[:title]
|
581
|
+
title.strip!
|
582
|
+
|
583
|
+
unless title.empty?
|
584
|
+
Task.create :title => title
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
redirect route('/')
|
589
|
+
rescue Sequel::DatabaseError
|
590
|
+
redirect route('/')
|
591
|
+
end
|
592
|
+
|
593
|
+
def close(title)
|
594
|
+
# ...
|
595
|
+
--------------------------------------------------------------------------------
|
596
|
+
|
597
|
+
Easy as pie, we can try to create as many identical tasks as we want, all we
|
598
|
+
get is the same old set.
|
599
|
+
|
600
|
+
|
601
|
+
== Ninth Step, Curing your RSI
|
602
|
+
|
603
|
+
Something you might notice is that every time you hit the submit button and you are redirected to `index`, the title you just input is gone.
|
604
|
+
What a waste of our honest effort to create a duplicate task, we all know if we
|
605
|
+
try often enough it will eventually have to work, so let's save us some typing.
|
606
|
+
|
607
|
+
In our 'view/index.xhtml' we modify the form input to have a default value:
|
608
|
+
|
609
|
+
[source,html]
|
610
|
+
--------------------------------------------------------------------------------
|
611
|
+
<form method="post" action="#{ route('create') }">
|
612
|
+
<fieldset>
|
613
|
+
<legend>Add a task by entering a title.</legend>
|
614
|
+
<label for="form-title">Task title:</label>
|
615
|
+
<input id="form-title" name="title" type="text" value="#{ @title }"/>
|
616
|
+
<input type="submit" value="Create" />
|
617
|
+
</fieldset>
|
618
|
+
</form>
|
619
|
+
--------------------------------------------------------------------------------
|
620
|
+
|
621
|
+
The `@title` is an instance-variable, those are shared between the Controller
|
622
|
+
and View.
|
623
|
+
We didn't set any such variable in the Controller yet, so do it now:
|
624
|
+
|
625
|
+
[source,ruby]
|
626
|
+
--------------------------------------------------------------------------------
|
627
|
+
class Tasks < Ramaze::Controller
|
628
|
+
map '/'
|
629
|
+
|
630
|
+
def index
|
631
|
+
@title = 'recharge DishBot9000'
|
632
|
+
end
|
633
|
+
|
634
|
+
def create
|
635
|
+
# ...
|
636
|
+
--------------------------------------------------------------------------------
|
637
|
+
|
638
|
+
Yes, that wasn't too bad, but is there a way to change the value of the
|
639
|
+
`@title` without editing the source all the time?
|
640
|
+
|
641
|
+
Turns out we have to revisit the `create` method to give us a hint in form of a
|
642
|
+
GET parameter and change `index` to pick it up.
|
643
|
+
|
644
|
+
[source,ruby]
|
645
|
+
--------------------------------------------------------------------------------
|
646
|
+
def index
|
647
|
+
@title = request[:title]
|
648
|
+
end
|
649
|
+
|
650
|
+
def create
|
651
|
+
if request.post? and title = request[:title]
|
652
|
+
title.strip!
|
653
|
+
|
654
|
+
unless title.empty?
|
655
|
+
Task.create :title => title
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
redirect route('/', :title => title)
|
660
|
+
rescue Sequel::DatabaseError
|
661
|
+
redirect route('/', :title => title)
|
662
|
+
end
|
663
|
+
--------------------------------------------------------------------------------
|
664
|
+
|
665
|
+
And that's it.
|
666
|
+
Endless hours of fun hitting the submit button lie before us!
|
667
|
+
|
668
|
+
|
669
|
+
== Tenth Step, Laying out a different View of things
|
670
|
+
|
671
|
+
We have one template, it's a nice one, but unfortunately we've got ourselves
|
672
|
+
into quite a mess here after creating hundreds of tasks.
|
673
|
+
|
674
|
+
Our way out of this is to provide some visual feedback -- when a task is done,
|
675
|
+
it's gone.
|
676
|
+
Not forever, but at least it will not show up anymore on the `index` action.
|
677
|
+
|
678
|
+
So we filter out all tasks that haven't been done yet in the
|
679
|
+
'view/index.xhtml':
|
680
|
+
|
681
|
+
[source,html]
|
682
|
+
--------------------------------------------------------------------------------
|
683
|
+
<ul>
|
684
|
+
<?r Task.filter(:done => false).each do |task| ?>
|
685
|
+
<li>
|
686
|
+
# ...
|
687
|
+
--------------------------------------------------------------------------------
|
688
|
+
|
689
|
+
|
690
|
+
So off we go and add a new template at 'view/done.xhtml'.
|
691
|
+
|
692
|
+
[source,html]
|
693
|
+
--------------------------------------------------------------------------------
|
694
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
695
|
+
<html>
|
696
|
+
<head>
|
697
|
+
<title>TodoList</title>
|
698
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
699
|
+
</head>
|
700
|
+
<body>
|
701
|
+
<h1>TodoList</h1>
|
702
|
+
|
703
|
+
<form method="post" action="#{ route('create') }">
|
704
|
+
<fieldset>
|
705
|
+
<legend>Add a task by entering a title.</legend>
|
706
|
+
<label for="form-title">Task title:</label>
|
707
|
+
<input id="form-title" name="title" type="text" value="#{ @title }"/>
|
708
|
+
<input type="submit" value="Create" />
|
709
|
+
</fieldset>
|
710
|
+
</form>
|
711
|
+
|
712
|
+
<h2>Tasks done</h2>
|
713
|
+
|
714
|
+
<ul>
|
715
|
+
<?r Task.filter(:done => true).each do |task| ?>
|
716
|
+
<li>
|
717
|
+
#{ h(task.title) }: #{ task.done },
|
718
|
+
(#{ anchor('open', route('open', url_encode(task.title))) })
|
719
|
+
(#{ anchor('delete', route('delete', url_encode(task.title))) })
|
720
|
+
</li>
|
721
|
+
<?r end ?>
|
722
|
+
</ul>
|
723
|
+
</body>
|
724
|
+
</html>
|
725
|
+
--------------------------------------------------------------------------------
|
726
|
+
|
727
|
+
Having a déjà vu?
|
728
|
+
|
729
|
+
Yes, me too, must be an error in the matrix.
|
730
|
+
|
731
|
+
If we want one thing from a web-framework, it's to spare us writing repetitive
|
732
|
+
code like this (I hope you did copy&paste).
|
733
|
+
|
734
|
+
What we actually wanted to do is _sharing_ the boilerplate around our listing
|
735
|
+
of tasks, that's what we call 'layout'.
|
736
|
+
|
737
|
+
Every action can have a layout associated with it, remember that empty 'layout'
|
738
|
+
directory in your application? That's exactly where we will put it.
|
739
|
+
|
740
|
+
[source,html]
|
741
|
+
--------------------------------------------------------------------------------
|
742
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
743
|
+
<html>
|
744
|
+
<head>
|
745
|
+
<title>TodoList</title>
|
746
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
747
|
+
</head>
|
748
|
+
<body>
|
749
|
+
<h1>TodoList</h1>
|
750
|
+
<form method="post" action="#{ route('create') }">
|
751
|
+
<fieldset>
|
752
|
+
<legend>Add a task by entering a title.</legend>
|
753
|
+
<label for="form-title">Task title:</label>
|
754
|
+
<input id="form-title" name="title" type="text" value="#{ @title }"/>
|
755
|
+
<input type="submit" value="Create" />
|
756
|
+
</fieldset>
|
757
|
+
</form>
|
758
|
+
#{ @content }
|
759
|
+
</body>
|
760
|
+
</html>
|
761
|
+
--------------------------------------------------------------------------------
|
762
|
+
|
763
|
+
And to tell Ramaze which layout to use for our `Tasks` we'll have to add a line
|
764
|
+
to the Controller.
|
765
|
+
|
766
|
+
[source,ruby]
|
767
|
+
--------------------------------------------------------------------------------
|
768
|
+
class Tasks < Ramaze::Controller
|
769
|
+
map '/'
|
770
|
+
layout 'default'
|
771
|
+
end
|
772
|
+
--------------------------------------------------------------------------------
|
773
|
+
|
774
|
+
And finally, since we are fond of valid HTML and just love to get rid of boring
|
775
|
+
boilerplate we can delete the slack from our templates.
|
776
|
+
|
777
|
+
'view/index.xhtml' becomes:
|
778
|
+
|
779
|
+
[source,html]
|
780
|
+
--------------------------------------------------------------------------------
|
781
|
+
<h2>Done Tasks</h2>
|
782
|
+
|
783
|
+
#{ anchor('Pending tasks', route('done')) }
|
784
|
+
|
785
|
+
<ul>
|
786
|
+
<?r Task.filter(:done => false).each do |task| ?>
|
787
|
+
<li>
|
788
|
+
#{ h(task.title) },
|
789
|
+
(#{ anchor('close', route('close', url_encode(task.title))) })
|
790
|
+
(#{ anchor('delete', route('delete', url_encode(task.title))) })
|
791
|
+
</li>
|
792
|
+
<?r end ?>
|
793
|
+
</ul>
|
794
|
+
--------------------------------------------------------------------------------
|
795
|
+
|
796
|
+
'view/done.xhtml' becomes:
|
797
|
+
|
798
|
+
[source,html]
|
799
|
+
--------------------------------------------------------------------------------
|
800
|
+
<h2>Pending Tasks</h2>
|
801
|
+
|
802
|
+
#{ anchor('Done tasks', route('done')) }
|
803
|
+
|
804
|
+
<ul>
|
805
|
+
<?r Task.filter(:done => true).each do |task| ?>
|
806
|
+
<li>
|
807
|
+
#{ h(task.title) },
|
808
|
+
(#{ anchor('open', route('open', url_encode(task.title))) })
|
809
|
+
(#{ anchor('delete', route('delete', url_encode(task.title))) })
|
810
|
+
</li>
|
811
|
+
<?r end ?>
|
812
|
+
</ul>
|
813
|
+
--------------------------------------------------------------------------------
|
814
|
+
|
815
|
+
Well, that's so much better, we even included links between the actions.
|
816
|
+
|
817
|
+
|
818
|
+
== Eleventh Step, not all that is gold glitters...
|
819
|
+
|
820
|
+
You have to admit, it's a lot of fun having such a sophisticated application,
|
821
|
+
but what good is it if it's too ugly to show it even to your closest friends?
|
822
|
+
They will never become addicted enough to your fancy todo-list to actually do
|
823
|
+
all the work for you.
|
824
|
+
|
825
|
+
Let's do things with style, with a style-sheet.
|
826
|
+
|
827
|
+
Now is the time to fire up your editor, point it at 'public/css/screen.css' and
|
828
|
+
churn out something of your liking.
|
829
|
+
|
830
|
+
We will not cover this part in the tutorial, an example style-sheet is located
|
831
|
+
in the example todo-list.
|
832
|
+
|
833
|
+
What we do cover is adding it to your application, or the `<head>` in
|
834
|
+
'layout/default.xhtml' to be exact:
|
835
|
+
|
836
|
+
[source,html]
|
837
|
+
--------------------------------------------------------------------------------
|
838
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
839
|
+
<html>
|
840
|
+
<head>
|
841
|
+
<title>TodoList</title>
|
842
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
843
|
+
<link rel="stylesheet" type="text/css" href="/css/screen.css" />
|
844
|
+
</head>
|
845
|
+
--------------------------------------------------------------------------------
|
846
|
+
|
847
|
+
Voilà, you now have acquired the Certificate of Ramazeness and all your friends
|
848
|
+
and enemies envy you.
|
849
|
+
|
850
|
+
|
851
|
+
== Twelfth Step, configuring configurable configurability
|
852
|
+
|
853
|
+
To round up this tutorial a bit, let's introduce you to configuration in Ramaze.
|
854
|
+
There are a number of ways to configure Ramaze, but here we'll just see the
|
855
|
+
most common ones with some options you'll most likely want to change.
|
856
|
+
|
857
|
+
First of all, you have been running your ramaze application always on the same
|
858
|
+
port, `7000`, which prevents you from starting more than one instance or other
|
859
|
+
applications.
|
860
|
+
|
861
|
+
To change the port, you can, for example:
|
862
|
+
|
863
|
+
[source,ruby]
|
864
|
+
--------------------------------------------------------------------------------
|
865
|
+
Ramaze.options.adapter.port = 80
|
866
|
+
--------------------------------------------------------------------------------
|
867
|
+
|
868
|
+
NOTE: Running a server on a port below 1024 will require root privileges and is
|
869
|
+
generally not advised for applications that don't drop their privileges
|
870
|
+
after establishing a connection.
|
871
|
+
Please have a look at http://wiki.ramaze.net/Deployment for better ways
|
872
|
+
to deploy your site using a reverse proxy like apache, lighttpd, or
|
873
|
+
nginx.
|
874
|
+
|
875
|
+
OK, a different port is fine, but how about some speed-boost? For this we will
|
876
|
+
need a faster server like http://mongrel.rubyforge.org[Mongrel] or
|
877
|
+
http://thin.rubyforge.org[Thin].
|
878
|
+
|
879
|
+
You can install either one via:
|
880
|
+
|
881
|
+
--------------------------------------------------------------------------------
|
882
|
+
gem install thin
|
883
|
+
gem install mongrel
|
884
|
+
--------------------------------------------------------------------------------
|
885
|
+
|
886
|
+
Now to the configuration:
|
887
|
+
|
888
|
+
[source,ruby]
|
889
|
+
--------------------------------------------------------------------------------
|
890
|
+
# The default is WEBrick
|
891
|
+
Ramaze.options.adapter.adapter = :webrick
|
892
|
+
|
893
|
+
# How about using Mongrel instead?
|
894
|
+
Ramaze.options.adapter.adapter = :mongrel
|
895
|
+
|
896
|
+
# Or maybe Thin?
|
897
|
+
Ramaze.options.adapter.adapter = :thin
|
898
|
+
--------------------------------------------------------------------------------
|
899
|
+
|
900
|
+
For the full performance, switch Ramaze into `:live` mode:
|
901
|
+
|
902
|
+
[source,ruby]
|
903
|
+
--------------------------------------------------------------------------------
|
904
|
+
# The default is :dev
|
905
|
+
Ramaze.options.mode = :live
|
906
|
+
|
907
|
+
# And here comes :live
|
908
|
+
Ramaze.options.mode = :live
|
909
|
+
--------------------------------------------------------------------------------
|
910
|
+
|
911
|
+
The major differences between `:dev` and `:live` are that in `:live` mode your
|
912
|
+
code won't be automatically reloaded if it has changed and we don't run every
|
913
|
+
request through `Rack::Lint`, which helps you to stay within the
|
914
|
+
request/response specifications required by Rack.
|
915
|
+
|
916
|
+
|
917
|
+
[[glossary]]
|
918
|
+
== Glossary
|
919
|
+
|
920
|
+
[glossary]
|
921
|
+
RDBMS::
|
922
|
+
Relational Database Management System
|
923
|
+
ORM::
|
924
|
+
Object Relationship Mapper: Maps data into objects and assists in querying
|
925
|
+
and manipulation
|
926
|
+
MVC::
|
927
|
+
Model, View, Controller: one of the patterns traditionally used for GUIs in Smalltalk.
|
928
|
+
Etanni::
|
929
|
+
Innate spelled backwards.
|
930
|
+
Innate::
|
931
|
+
Core of Ramaze.
|
932
|
+
Rack::
|
933
|
+
HTTP abstraction layer and interface used by the majority of Ruby web-frameworks.
|
934
|
+
Templating engine::
|
935
|
+
Used to process so-called templates with inlined source code or instructions
|
936
|
+
to produce dynamic resulting documents. Examples for traditional templating
|
937
|
+
engines are XSLT, SSI, ERB.
|
938
|
+
RSI::
|
939
|
+
Repetive Strain Injury, prevalent among the members of the church of Emacs.
|