Pistos-ramaze 2009.02 → 2009.04.08
Sign up to get free protection for your applications and to get access to all the features.
- data/.mailmap +25 -0
- data/CHANGELOG +16546 -0
- data/MANIFEST +487 -0
- data/{README.md → README.markdown} +0 -5
- data/Rakefile +75 -242
- data/bin/ramaze +142 -55
- 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.nag +25 -0
- data/examples/app/auth/start.rb +23 -0
- data/examples/app/auth/view/index.nag +4 -0
- data/examples/app/auth/view/login.nag +20 -0
- data/examples/app/auth/view/secret.nag +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 +76 -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 +80 -28
- data/examples/app/blog/model/init.rb +10 -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/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/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/config.ru +17 -0
- data/lib/proto/controller/init.rb +2 -2
- data/lib/proto/layout/default.xhtml +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 +8 -11
- data/lib/proto/start.rb +3 -3
- data/lib/proto/view/index.xhtml +34 -27
- data/lib/ramaze/app.rb +124 -0
- 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/cache.rb +9 -104
- data/lib/ramaze/contrib/app_graph.rb +64 -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/relation.rb +4 -2
- data/lib/ramaze/controller/default.rb +12 -0
- data/lib/ramaze/controller.rb +63 -257
- 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/auth.rb +68 -104
- data/lib/ramaze/helper/bench.rb +0 -2
- data/lib/ramaze/helper/cache.rb +59 -122
- 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 +30 -5
- data/lib/ramaze/helper/gestalt.rb +1 -1
- data/lib/ramaze/helper/gravatar.rb +66 -19
- data/lib/ramaze/helper/httpdigest.rb +75 -66
- data/lib/ramaze/helper/link.rb +62 -109
- data/lib/ramaze/helper/localize.rb +128 -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 +16 -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/helper.rb +6 -81
- 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/log.rb +19 -7
- 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 +117 -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/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/spec.rb +37 -1
- data/lib/ramaze/tool/create.rb +1 -1
- data/lib/ramaze/version.rb +1 -4
- data/lib/ramaze/view/erubis.rb +23 -0
- data/lib/ramaze/view/ezamar.rb +23 -0
- data/lib/ramaze/view/haml.rb +15 -0
- data/lib/ramaze/view/liquid.rb +66 -0
- data/lib/ramaze/view/maruku.rb +14 -0
- data/lib/ramaze/view/nagoro/render_partial.rb +32 -0
- data/lib/ramaze/view/nagoro.rb +44 -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/ramaze/view.rb +44 -0
- data/lib/ramaze.rb +76 -129
- data/lib/vendor/etag.rb +20 -0
- data/lib/vendor/route_exceptions.rb +48 -0
- data/ramaze.gemspec +28 -612
- 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 +89 -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 +53 -44
- data/spec/ramaze/error.rb +56 -62
- data/spec/ramaze/files/public_1/plain.txt +1 -0
- data/spec/ramaze/files/public_2/rich.txt +1 -0
- data/spec/ramaze/files.rb +29 -0
- data/spec/ramaze/gestalt.rb +2 -4
- data/spec/ramaze/helper/auth.rb +53 -25
- data/spec/ramaze/helper/bench.rb +17 -0
- data/spec/ramaze/helper/cache.rb +38 -114
- data/spec/ramaze/helper/flash.rb +22 -110
- 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 +162 -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/partial.rb +23 -71
- 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 +40 -13
- data/spec/ramaze/helper/stack.rb +56 -35
- data/spec/ramaze/helper/user.rb +36 -9
- 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 +45 -181
- data/spec/ramaze/view/erubis/external.rhtml +8 -0
- data/spec/ramaze/view/erubis/sum.rhtml +1 -0
- data/spec/ramaze/view/erubis.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/ezamar.rb +73 -0
- data/spec/ramaze/view/haml/external.haml +5 -0
- data/spec/ramaze/view/haml/sum.haml +2 -0
- data/spec/ramaze/view/haml.rb +86 -0
- data/spec/ramaze/view/liquid/external.liquid +8 -0
- data/spec/ramaze/view/liquid/sum.liquid +1 -0
- data/spec/ramaze/view/liquid.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/nagoro.rb +73 -0
- data/spec/ramaze/view/redcloth/external.redcloth +8 -0
- data/spec/ramaze/view/redcloth.rb +66 -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/remarkably.rb +49 -0
- data/spec/ramaze/{template → view}/sass/file.css.sass +0 -0
- data/spec/ramaze/view/sass.rb +73 -0
- data/spec/ramaze/{template → view}/tagz/external.tagz +0 -0
- data/spec/ramaze/{template → view}/tagz/sum.tagz +0 -0
- data/spec/ramaze/{template → view}/tagz.rb +18 -29
- data/spec/ramaze/view/tenjin/external.rbhtml +8 -0
- data/spec/ramaze/view/tenjin/sum.rbhtml +1 -0
- data/spec/ramaze/view/tenjin.rb +57 -0
- data/spec/ramaze/view.rb +36 -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 +69 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/todo.rake +29 -0
- data/tasks/traits.rake +21 -0
- data/tasks/yard.rake +4 -0
- metadata +173 -290
- 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/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/render.rb +0 -192
- data/lib/ramaze/action.rb +0 -159
- 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/adapter.rb +0 -97
- 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/file_cache.rb +0 -3
- data/lib/ramaze/contrib/gems.rb +0 -78
- data/lib/ramaze/contrib/sequel/fill.rb +0 -12
- data/lib/ramaze/contrib/sequel_cache.rb +0 -92
- data/lib/ramaze/contrib.rb +0 -82
- 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/flash.rb +0 -88
- data/lib/ramaze/current/session/hash.rb +0 -62
- data/lib/ramaze/current/session.rb +0 -179
- 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/dispatcher.rb +0 -145
- 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/dsl.rb +0 -45
- data/lib/ramaze/option/holder.rb +0 -131
- data/lib/ramaze/option/merger.rb +0 -108
- data/lib/ramaze/option.rb +0 -156
- 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/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/spec/helper.rb +0 -135
- data/lib/ramaze/store/default.rb +0 -109
- 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/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/ezamar.rb +0 -42
- 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 -37
- 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/template.rb +0 -87
- 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/tool.rb +0 -9
- data/lib/ramaze/trinity.rb +0 -16
- data/lib/vendor/bacon.rb +0 -323
- data/rake_tasks/conf.rake +0 -85
- 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/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/adapter.rb +0 -49
- 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/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/amrita2/external.amrita +0 -6
- data/spec/ramaze/template/amrita2/sum.amrita +0 -1
- data/spec/ramaze/template/amrita2.rb +0 -50
- data/spec/ramaze/template/builder/external.rxml +0 -3
- data/spec/ramaze/template/builder.rb +0 -51
- data/spec/ramaze/template/erubis/sum.rhtml +0 -1
- data/spec/ramaze/template/erubis.rb +0 -41
- 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/ezamar.rb +0 -63
- 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/haml.rb +0 -66
- data/spec/ramaze/template/liquid/index.liquid +0 -1
- data/spec/ramaze/template/liquid/products.liquid +0 -45
- data/spec/ramaze/template/liquid.rb +0 -99
- data/spec/ramaze/template/markaby/external.mab +0 -8
- data/spec/ramaze/template/markaby/sum.mab +0 -1
- data/spec/ramaze/template/markaby.rb +0 -61
- 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/nagoro.rb +0 -64
- data/spec/ramaze/template/redcloth/external.redcloth +0 -1
- data/spec/ramaze/template/redcloth.rb +0 -38
- data/spec/ramaze/template/remarkably.rb +0 -58
- data/spec/ramaze/template/sass.rb +0 -69
- data/spec/ramaze/template/tenjin/external.tenjin +0 -1
- data/spec/ramaze/template/tenjin.rb +0 -47
- 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/ramaze/template/xslt.rb +0 -90
- data/spec/ramaze/template.rb +0 -128
- data/spec/snippets/ramaze/caller_info.rb +0 -39
- data/spec/snippets/ramaze/caller_lines.rb +0 -30
@@ -1,179 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'digest/sha2'
|
6
|
-
rescue LoadError
|
7
|
-
require 'digest/sha1'
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'ramaze/current/session/flash'
|
11
|
-
require 'ramaze/current/session/hash'
|
12
|
-
|
13
|
-
module Ramaze
|
14
|
-
|
15
|
-
# The purpose of Session is to hold key/value pairs like a Hash for a series
|
16
|
-
# of # request/response cycles from the same client.
|
17
|
-
#
|
18
|
-
# The persistence is achieved by setting a cookie with the session_id to
|
19
|
-
# the client, which is then passed back and forth until the cookie is either
|
20
|
-
# deleted or expires.
|
21
|
-
|
22
|
-
class Session
|
23
|
-
# The unique id for the current session which is also passed on to the cookie.
|
24
|
-
|
25
|
-
attr_accessor :session_id
|
26
|
-
|
27
|
-
# This variable holds the current SessionFlash
|
28
|
-
|
29
|
-
attr_accessor :flash
|
30
|
-
|
31
|
-
# Flag whether or not to drop this session on the floor
|
32
|
-
|
33
|
-
attr_accessor :dropped
|
34
|
-
|
35
|
-
# secret salt for client-side session data
|
36
|
-
|
37
|
-
trait :secret => 'change_me_please_123'
|
38
|
-
|
39
|
-
# the key used for the cookie
|
40
|
-
|
41
|
-
SESSION_KEY = '_ramaze_session_id' unless defined?(SESSION_KEY)
|
42
|
-
|
43
|
-
# Holds counter for IPs
|
44
|
-
|
45
|
-
IP_COUNT = ::Hash.new{|h,k| h[k] = OrderedSet.new} unless defined?(IP_COUNT)
|
46
|
-
|
47
|
-
# Limit the number of sessions one IP is allowed to hold.
|
48
|
-
|
49
|
-
IP_COUNT_LIMIT = 1000 unless defined?(IP_COUNT_LIMIT)
|
50
|
-
|
51
|
-
# Holds the default cookie used for sessions
|
52
|
-
|
53
|
-
COOKIE = { :path => '/' } unless defined?(COOKIE)
|
54
|
-
|
55
|
-
# Shortcut for Current.session
|
56
|
-
def self.current
|
57
|
-
Current.session
|
58
|
-
end
|
59
|
-
|
60
|
-
# called from Ramaze::startup and adds Cache.sessions if cookies are
|
61
|
-
# enabled
|
62
|
-
|
63
|
-
def self.startup(options = {})
|
64
|
-
Cache.add(:sessions) if Global.sessions
|
65
|
-
end
|
66
|
-
|
67
|
-
# retrieve a specific session given a session id
|
68
|
-
|
69
|
-
def self.[](sess_id)
|
70
|
-
Session.new(sess_id)
|
71
|
-
end
|
72
|
-
|
73
|
-
# generate a random (and hopefully unique) id for the current session.
|
74
|
-
#
|
75
|
-
# It consists of the current time, the current request, the current PID of
|
76
|
-
# ruby and object_id of this instance.
|
77
|
-
#
|
78
|
-
# All this is joined by some calls to Kernel#rand and returned as a
|
79
|
-
# Digest::SHA256::hexdigest
|
80
|
-
|
81
|
-
def self.random_key
|
82
|
-
h = [
|
83
|
-
Time.now.to_f.to_s, rand,
|
84
|
-
Current.request.hash, rand,
|
85
|
-
Process.pid, rand,
|
86
|
-
object_id, rand
|
87
|
-
].join
|
88
|
-
Digest::SHA256.hexdigest(h)
|
89
|
-
end
|
90
|
-
|
91
|
-
# Initialize a new Session, requires the original Rack::Request instance
|
92
|
-
# given to us from Dispatcher#setup_environment.
|
93
|
-
#
|
94
|
-
# sets @session_id and @session_flash
|
95
|
-
|
96
|
-
def initialize(sess_or_request = Current.request)
|
97
|
-
return unless Global.sessions
|
98
|
-
|
99
|
-
if sess_or_request.respond_to?(:cookies)
|
100
|
-
request = sess_or_request
|
101
|
-
@session_id = request.cookies[SESSION_KEY] || Session.random_key
|
102
|
-
else
|
103
|
-
request = nil
|
104
|
-
@session_id = sess_or_request
|
105
|
-
end
|
106
|
-
|
107
|
-
unless IP_COUNT.nil? or request.nil?
|
108
|
-
ip = request.ip
|
109
|
-
IP_COUNT[ip] << @session_id
|
110
|
-
sessions.delete(IP_COUNT[ip].shift) if IP_COUNT[ip].size > IP_COUNT_LIMIT
|
111
|
-
end
|
112
|
-
|
113
|
-
@flash = Session::Flash.new(self)
|
114
|
-
@current = nil
|
115
|
-
@dropped = false
|
116
|
-
end
|
117
|
-
|
118
|
-
# relay all messages we don't understand to the currently active session
|
119
|
-
|
120
|
-
def method_missing(*args, &block)
|
121
|
-
current.send(*args, &block)
|
122
|
-
end
|
123
|
-
|
124
|
-
# answers with the currently active session, which is set unless it is
|
125
|
-
# existing already, the session itself is an instance of SessionHash
|
126
|
-
|
127
|
-
def current
|
128
|
-
return @current if @current
|
129
|
-
@current = ( sessions[session_id] ||= Session::Hash.new(self) )
|
130
|
-
end
|
131
|
-
|
132
|
-
# shortcut to Cache.sessions
|
133
|
-
|
134
|
-
def sessions
|
135
|
-
Cache.sessions
|
136
|
-
end
|
137
|
-
|
138
|
-
# Inspect on Session.current
|
139
|
-
|
140
|
-
def inspect
|
141
|
-
current.inspect
|
142
|
-
end
|
143
|
-
|
144
|
-
# don't finish this session
|
145
|
-
|
146
|
-
def drop!
|
147
|
-
self.dropped = true
|
148
|
-
end
|
149
|
-
|
150
|
-
# at the end of a request delete the current[:FLASH] and assign it to
|
151
|
-
# current[:FLASH_PREVIOUS]
|
152
|
-
#
|
153
|
-
# this is needed so flash can iterate over requests
|
154
|
-
# and always just keep the current and previous key/value pairs.
|
155
|
-
#
|
156
|
-
# finalizes the session and assigns the key to the response via
|
157
|
-
# set_cookie.
|
158
|
-
|
159
|
-
def finish
|
160
|
-
return unless Global.sessions
|
161
|
-
return if dropped
|
162
|
-
|
163
|
-
old = current.delete(:FLASH)
|
164
|
-
current[:FLASH_PREVIOUS] = old if old
|
165
|
-
|
166
|
-
request, response = Current.request, Current.response
|
167
|
-
|
168
|
-
hash = {:value => session_id}.merge(COOKIE)
|
169
|
-
response.set_cookie(SESSION_KEY, hash)
|
170
|
-
|
171
|
-
# set client side session cookie
|
172
|
-
if val = request['session.client'] and
|
173
|
-
(!val.empty? or request.cookies["#{SESSION_KEY}-client"])
|
174
|
-
cookie = hash.merge(:value => marshal(val))
|
175
|
-
response.set_cookie("#{SESSION_KEY}-client", cookie)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
module Ramaze
|
5
|
-
class Dispatcher
|
6
|
-
|
7
|
-
# This dispatcher is responsible for relaying requests to Controller::handle
|
8
|
-
# and filtering the results using FILTER.
|
9
|
-
|
10
|
-
class Action
|
11
|
-
|
12
|
-
# The response is passed to each filter by sending .call(response) to it.
|
13
|
-
|
14
|
-
FILTER = OrderedSet[
|
15
|
-
# Ramaze::Tool::Localize,
|
16
|
-
] unless defined?(FILTER)
|
17
|
-
|
18
|
-
class << self
|
19
|
-
include Trinity
|
20
|
-
|
21
|
-
# Takes path, asks Controller to handle it and builds a response on
|
22
|
-
# success. The response is then passed to each member of FILTER for
|
23
|
-
# post-processing.
|
24
|
-
|
25
|
-
def call(path)
|
26
|
-
log(path)
|
27
|
-
|
28
|
-
catch(:respond) {
|
29
|
-
response.write Controller.handle(path)
|
30
|
-
}
|
31
|
-
|
32
|
-
FILTER.each{|f| f.call(response)}
|
33
|
-
response
|
34
|
-
rescue Ramaze::Error => ex
|
35
|
-
ex
|
36
|
-
end
|
37
|
-
|
38
|
-
# Logs the request via Log#info unless it's boring.
|
39
|
-
|
40
|
-
def log(path)
|
41
|
-
case path
|
42
|
-
when *Global.boring
|
43
|
-
else
|
44
|
-
Log.info("Dynamic request from #{request.ip}: #{request.request_uri}")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
module Ramaze
|
5
|
-
class Dispatcher
|
6
|
-
|
7
|
-
# Generates a directory listing, see Ramaze::Controller::Directory for more
|
8
|
-
# information and how to create your own directory listing page
|
9
|
-
class Directory
|
10
|
-
class << self
|
11
|
-
|
12
|
-
# Entry point from Dispatcher::filter.
|
13
|
-
# Just a forwarder to build_listing, automatticly exiting if there is
|
14
|
-
# an error (defined by returning false in build_listing)
|
15
|
-
def call(path)
|
16
|
-
if Global.list_directories
|
17
|
-
response = build_listing(path)
|
18
|
-
Response.current.build(*response) if response
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Makes a request for http://yourserver/dirlist/path and returns the
|
23
|
-
# result. Due to this method, you can overwrite the action and create your
|
24
|
-
# own page. See Ramaze::Controller::Directory for more.
|
25
|
-
def build_listing(path)
|
26
|
-
dir = ::File.expand_path(Global.public_root/::File.expand_path(path, '/'))
|
27
|
-
|
28
|
-
if ::File.directory?(dir)
|
29
|
-
Log.debug("Serving directory listing: #{dir}")
|
30
|
-
Session.current.drop! if Session.current
|
31
|
-
|
32
|
-
status = Ramaze::STATUS_CODE['OK']
|
33
|
-
header = {'Content-Type' => "text/html"}
|
34
|
-
body = list_for(dir)
|
35
|
-
[body, status, header]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Nicely formatted listing for given path, template is "stolen" from
|
40
|
-
# lighttpd
|
41
|
-
def list_for(path)
|
42
|
-
root = ::File.expand_path(Global.public_root)
|
43
|
-
display = path.gsub(/^#{Regexp.escape(root)}\/?/, '/')
|
44
|
-
wrapper =
|
45
|
-
%(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
46
|
-
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
47
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
48
|
-
<head>
|
49
|
-
<title>Directory listing of #{display}</title>
|
50
|
-
|
51
|
-
<style type="text/css"> /*<![CDATA[*/ a, a:active {text-decoration: none; color: blue;} a:visited {color: #48468F;} a:hover, a:focus {text-decoration: underline; color: red;} body {background-color: #F5F5F5;} h2 {margin-bottom: 12px;} table {margin-left: 12px;} th, td { font-family: "Courier New", Courier, monospace; font-size: 10pt; text-align: left;} th { font-weight: bold; padding-right: 14px; padding-bottom: 3px;} td {padding-right: 14px;} td.s, th.s {text-align: right;} div.list { background-color: white; border-top: 1px solid #646464; border-bottom: 1px solid #646464; padding-top: 10px; padding-bottom: 14px;} div.foot { font-family: "Courier New", Courier, monospace; font-size: 10pt; color: #787878; padding-top: 4px;} /*]]>*/ </style>
|
52
|
-
</head>
|
53
|
-
<body>
|
54
|
-
<h2>Directory listing of #{display}</h2>
|
55
|
-
<div class="list">
|
56
|
-
<table summary="Directory Listing" cellpadding="0" cellspacing="0">
|
57
|
-
<thead>
|
58
|
-
<tr>
|
59
|
-
<th class="n">Name</th>
|
60
|
-
<th class="m">Last Modified</th>
|
61
|
-
<th class="s">Size</th>
|
62
|
-
<th class="t">Type</th>
|
63
|
-
</tr>
|
64
|
-
</thead>
|
65
|
-
<tbody>
|
66
|
-
<tr>
|
67
|
-
<td class="n"><a href="#{display/'..'}/">Parent Directory</a>/</td>
|
68
|
-
<td class="m"> </td>
|
69
|
-
<td class="s">- </td>
|
70
|
-
<td class="t">Directory</td>
|
71
|
-
</tr>
|
72
|
-
%s
|
73
|
-
%s
|
74
|
-
</tbody>
|
75
|
-
</table>
|
76
|
-
</div>
|
77
|
-
<div class="foot">%s</div>
|
78
|
-
</body>
|
79
|
-
</html>
|
80
|
-
)
|
81
|
-
|
82
|
-
dirs, files = Dir[path/'*'].partition{|file| ::File.directory?(file) }
|
83
|
-
dir_body, file_body = [], []
|
84
|
-
|
85
|
-
dirs.sort.each do |dir|
|
86
|
-
basename = ::File.basename(dir)
|
87
|
-
dir_body << %[<tr>
|
88
|
-
<td class="n"><a href="#{display/basename}">#{basename}/</a></td>
|
89
|
-
<td class="m"> </td>
|
90
|
-
<td class="s">- </td>
|
91
|
-
<td class="t">Directory</td>
|
92
|
-
</tr>]
|
93
|
-
end
|
94
|
-
|
95
|
-
time_format = "%Y-%b-%d %H:%M:%S"
|
96
|
-
files.sort.each do |file|
|
97
|
-
basename = ::File.basename(file)
|
98
|
-
time = ::File.mtime(file).strftime(time_format)
|
99
|
-
size = ::File.size(file).filesize_format
|
100
|
-
mime = Tool::MIME.type_for(file)
|
101
|
-
file_body << %[<tr>
|
102
|
-
<td class="n"><a href="#{display/basename}">#{basename}</a></td>
|
103
|
-
<td class="m">#{time}</td>
|
104
|
-
<td class="s">#{size}</td>
|
105
|
-
<td class="t">#{mime}</td>
|
106
|
-
</tr>]
|
107
|
-
end
|
108
|
-
|
109
|
-
version = "ramaze/#{Ramaze::VERSION}"
|
110
|
-
wrapper % [
|
111
|
-
dir_body. join("\n "),
|
112
|
-
file_body.join("\n "),
|
113
|
-
version
|
114
|
-
]
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
module Ramaze
|
5
|
-
class Dispatcher
|
6
|
-
|
7
|
-
# Last resort dispatcher, tries to recover as much information as possible
|
8
|
-
# from the past request and takes the appropiate actions.
|
9
|
-
#
|
10
|
-
# You can configure it over the HANDLE_ERROR constant or by defining error
|
11
|
-
# actions in your controllers.
|
12
|
-
|
13
|
-
class Error
|
14
|
-
|
15
|
-
# The class of exception is matched when an error occurs and the status
|
16
|
-
# code is set. The absolute URLs are used as fallback in case of a total
|
17
|
-
# failure.
|
18
|
-
HANDLE_ERROR = {
|
19
|
-
Exception => [ 500, '/error' ],
|
20
|
-
Ramaze::Error::NoAction => [ 404, '/error' ],
|
21
|
-
Ramaze::Error::NoController => [ 404, '/error' ],
|
22
|
-
}
|
23
|
-
|
24
|
-
class << self
|
25
|
-
trait :last_error => nil
|
26
|
-
|
27
|
-
# Takes exception, of metainfo only :controller is used at the moment.
|
28
|
-
# Then goes on to try and find the correct response status and path.
|
29
|
-
# In case metainfo has a controller we try to get the action for the
|
30
|
-
# path on it, dispatching there if we find one.
|
31
|
-
# Otherwise a plain-text error message is set as response.
|
32
|
-
def call(error, metainfo = {})
|
33
|
-
log_error(error)
|
34
|
-
|
35
|
-
STATE[:exception] = error
|
36
|
-
response = Response.current
|
37
|
-
|
38
|
-
key = error.class.ancestors.find{|a| HANDLE_ERROR[a]}
|
39
|
-
status, path = *HANDLE_ERROR[key || Exception]
|
40
|
-
status ||= 500
|
41
|
-
|
42
|
-
if controller = metainfo[:controller]
|
43
|
-
newpath = (controller.mapping + path).squeeze('/')
|
44
|
-
action_response = Dispatcher::Action.call(newpath)
|
45
|
-
case action_response
|
46
|
-
when Ramaze::Error
|
47
|
-
Log.debug("No custom error page found on #{controller}, going to #{path}")
|
48
|
-
else
|
49
|
-
action_response.status = status
|
50
|
-
return action_response
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if path and error.message !~ /`#{path}'/
|
55
|
-
response.status = status
|
56
|
-
return Dispatcher.dispatch_to(path)
|
57
|
-
else
|
58
|
-
response.build(error.message, status)
|
59
|
-
end
|
60
|
-
rescue Object => ex
|
61
|
-
Log.error(ex)
|
62
|
-
begin
|
63
|
-
m = ex.message
|
64
|
-
c = ex.class
|
65
|
-
b = [ex.backtrace].flatten.join("\n")
|
66
|
-
body = <<-html
|
67
|
-
==== Error ====\n
|
68
|
-
#{ m } (#{ c })
|
69
|
-
#{ b }\n
|
70
|
-
==== Request ====\n
|
71
|
-
#{ Request.current.pretty }\n
|
72
|
-
==== Request ====\n
|
73
|
-
#{ Response.current.pretty }\n
|
74
|
-
==== Session ====\n
|
75
|
-
#{ Session.current.pretty }\n
|
76
|
-
==== Global ====\n
|
77
|
-
#{ Global.pretty }\n
|
78
|
-
html
|
79
|
-
response['Content-Type'] = 'text/plain'
|
80
|
-
response.build(body.unindent, status)
|
81
|
-
rescue Object
|
82
|
-
raise
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Only logs new errors with full backtrace, repeated errors are shown
|
87
|
-
# only with their message.
|
88
|
-
def log_error error
|
89
|
-
error_message = error.message
|
90
|
-
|
91
|
-
if trait[:last_error] == error_message or error.is_a? Ramaze::Error::NoAction
|
92
|
-
Log.error(error_message)
|
93
|
-
else
|
94
|
-
trait[:last_error] = error_message
|
95
|
-
Log.error(error)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Handle to current exception.
|
100
|
-
# Only works inside request/response cycle.
|
101
|
-
def current
|
102
|
-
STATE[:exception]
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require "time"
|
5
|
-
require 'digest/md5'
|
6
|
-
|
7
|
-
module Ramaze
|
8
|
-
class Dispatcher
|
9
|
-
|
10
|
-
# First of the dispatchers, looks up the public path and serves the
|
11
|
-
# file if found.
|
12
|
-
|
13
|
-
class File
|
14
|
-
# These names are checked for serving from public directory.
|
15
|
-
# They take priority over Actions which comes later in the FILTER
|
16
|
-
INDICES = %w[index.htm index.xhtml index.html index]
|
17
|
-
|
18
|
-
class << self
|
19
|
-
include Trinity
|
20
|
-
|
21
|
-
# Entry point from Dispatcher::filter.
|
22
|
-
# searches for the file and builds a response with status 200 if found.
|
23
|
-
|
24
|
-
def call(path)
|
25
|
-
return unless file = open_file(Rack::Utils.unescape(path))
|
26
|
-
Session.current.drop! if Session.current
|
27
|
-
if file == :NotModified
|
28
|
-
return response.build([], STATUS_CODE['Not Modified'])
|
29
|
-
end
|
30
|
-
response.build(file, STATUS_CODE['OK'])
|
31
|
-
end
|
32
|
-
|
33
|
-
# returns file-handle with the open file on success, setting the
|
34
|
-
# Content-Type as found in Tool::MIME
|
35
|
-
|
36
|
-
def open_file(path)
|
37
|
-
file = resolve_path(path)
|
38
|
-
|
39
|
-
if ::File.file?(file)
|
40
|
-
return unless in_public?(file)
|
41
|
-
response['Content-Type'] = Tool::MIME.type_for(file) unless ::File.extname(file).empty?
|
42
|
-
mtime = ::File.mtime(file)
|
43
|
-
response['Last-Modified'] = mtime.httpdate
|
44
|
-
response['ETag']= Digest::MD5.hexdigest(file+mtime.to_s).inspect
|
45
|
-
if modified_since = request.env['HTTP_IF_MODIFIED_SINCE']
|
46
|
-
return :NotModified unless Time.parse(modified_since) < mtime
|
47
|
-
elsif match = request.env['HTTP_IF_NONE_MATCH']
|
48
|
-
# Should be a unique string enclosed in ""
|
49
|
-
# To avoiding more file reading we use mtime and filepath
|
50
|
-
# we could throw in inode and size for more uniqueness
|
51
|
-
return :NotModified if response['ETag']==match
|
52
|
-
end
|
53
|
-
log(file)
|
54
|
-
::File.open(file, 'rb')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# If path matches a directory in public_root, return that directory path, unless
|
59
|
-
# there is an index file in that directory, in which case return path for that.
|
60
|
-
# If path is not a directory, simply return given path in public_root.
|
61
|
-
# Either way, the returned path always starts with public_root.
|
62
|
-
|
63
|
-
def resolve_path(path)
|
64
|
-
joined = ::File.join(Global.public_root, path)
|
65
|
-
|
66
|
-
if ::File.directory?(joined)
|
67
|
-
glob = ::File.join(joined, "{#{INDICES.join(',')}}")
|
68
|
-
Dir[glob].first || joined
|
69
|
-
else
|
70
|
-
joined
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Determine whether a path is in the public directory for better
|
75
|
-
# security.
|
76
|
-
def in_public?(path)
|
77
|
-
expand(path).start_with?(expand(Global.public_root))
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
# Shortcut for Ramaze::Dispatcher::File#expand_path(path).
|
83
|
-
# Returns the absolute path of passed argument e.g.
|
84
|
-
# "/Users/rikur/ramaze_tests/public/foo.txt"
|
85
|
-
|
86
|
-
def expand(path)
|
87
|
-
::File.expand_path(path)
|
88
|
-
end
|
89
|
-
|
90
|
-
def log(file)
|
91
|
-
case file
|
92
|
-
when *Global.boring
|
93
|
-
else
|
94
|
-
Log.debug("Serving static: #{file}")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/lib/ramaze/dispatcher.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'ramaze/error'
|
5
|
-
require 'ramaze/tool/mime'
|
6
|
-
|
7
|
-
require 'ramaze/dispatcher/action'
|
8
|
-
require 'ramaze/dispatcher/error'
|
9
|
-
require 'ramaze/dispatcher/file'
|
10
|
-
require 'ramaze/dispatcher/directory'
|
11
|
-
|
12
|
-
module Ramaze
|
13
|
-
|
14
|
-
# The Dispatcher receives requests from adapters and sets up the proper environment
|
15
|
-
# to process them and respond.
|
16
|
-
|
17
|
-
class Dispatcher
|
18
|
-
def initialize(*args)
|
19
|
-
Dispatcher.call(*args)
|
20
|
-
end
|
21
|
-
|
22
|
-
# requests are passed to every
|
23
|
-
FILTER = OrderedSet[ Dispatcher::File, Dispatcher::Action ]
|
24
|
-
|
25
|
-
# Response codes to cache the output of for repeated requests.
|
26
|
-
trait :shielded => [ STATUS_CODE["Not Found"] ]
|
27
|
-
|
28
|
-
class << self
|
29
|
-
include Trinity
|
30
|
-
|
31
|
-
# Entry point for Adapter#respond, takes a Rack::Request and
|
32
|
-
# Rack::Response, sets up the environment and the goes on to dispatch
|
33
|
-
# for the given path from rack_request.
|
34
|
-
#
|
35
|
-
# +env+ will be ignored, it's just for compatibility with rack middleware
|
36
|
-
def call(env = nil)
|
37
|
-
path = request.path_info.squeeze('/')
|
38
|
-
path.sub!(/^#{Regexp.escape(Global.prefix)}/, '/')
|
39
|
-
path.squeeze!('/')
|
40
|
-
|
41
|
-
if new_path = Rewrite.resolve(path)
|
42
|
-
path = new_path
|
43
|
-
Log.dev("Rewriting `#{path}' to `#{path}'")
|
44
|
-
end
|
45
|
-
|
46
|
-
case path
|
47
|
-
when *Global.ignore
|
48
|
-
unless ::File.exist?(Dispatcher::File.resolve_path(path))
|
49
|
-
return response.build(Global.ignore_body, Global.ignore_status)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
general_dispatch path
|
54
|
-
rescue Object => exception
|
55
|
-
error(exception)
|
56
|
-
end
|
57
|
-
alias handle call
|
58
|
-
|
59
|
-
# protects against recursive dispatch and reassigns the path_info in the
|
60
|
-
# request, the rest of the request is kept intact.
|
61
|
-
def dispatch_to(path)
|
62
|
-
if request.path_info == path
|
63
|
-
if error = STATE[:exception]
|
64
|
-
raise error
|
65
|
-
else
|
66
|
-
raise "Recursive redirect from #{path} to #{path}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
request.path_info = path
|
70
|
-
general_dispatch path
|
71
|
-
end
|
72
|
-
|
73
|
-
# splits up the dispatch based on Global.shield
|
74
|
-
def general_dispatch(path)
|
75
|
-
if Global.shield
|
76
|
-
shielded_dispatch path
|
77
|
-
else
|
78
|
-
dispatch path
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Protects somewhat against hammering of erroring paths, since error-pages
|
83
|
-
# take a while to build in the default mode it is possible to decrease
|
84
|
-
# overall speed quite a bit by hitting Ramaze with such paths.
|
85
|
-
# shielded_dispatch checks the path and caches erronous responses so they
|
86
|
-
# won't be recreated but simply pushed out again without stopping at the
|
87
|
-
# Controller.
|
88
|
-
# Please note that this is just minor protection and the best option is to
|
89
|
-
# create a performant error-page instead.
|
90
|
-
def shielded_dispatch(path)
|
91
|
-
shield_cache = Cache.shield
|
92
|
-
handled = shield_cache[path]
|
93
|
-
return handled if handled
|
94
|
-
|
95
|
-
dispatched = dispatch(path)
|
96
|
-
|
97
|
-
unless trait[:shielded].include?(dispatched.status)
|
98
|
-
dispatched
|
99
|
-
else
|
100
|
-
shield_cache[path] = dispatched
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# filters the path until a response or redirect is thrown or a filter is
|
105
|
-
# successful, builds a response from the returned hash in case of throws.
|
106
|
-
def dispatch(path)
|
107
|
-
catch(:respond){
|
108
|
-
redirected = catch(:redirect){
|
109
|
-
filter(path)
|
110
|
-
throw(:respond)
|
111
|
-
}
|
112
|
-
response.build(*redirected)
|
113
|
-
}
|
114
|
-
end
|
115
|
-
|
116
|
-
# Calls .call(path) on every object in Dispatcher::FILTER until one
|
117
|
-
# returns something else than false/nil.
|
118
|
-
|
119
|
-
def filter(path)
|
120
|
-
result = nil
|
121
|
-
FILTER.each do |dispatcher|
|
122
|
-
result = dispatcher.call(path)
|
123
|
-
return result if result and not result.respond_to?(:exception)
|
124
|
-
end
|
125
|
-
|
126
|
-
error(result, :path => path)
|
127
|
-
end
|
128
|
-
|
129
|
-
def error(obj, meta = {})
|
130
|
-
controller = STATE[:controller]
|
131
|
-
meta[:controller] ||= controller if controller
|
132
|
-
|
133
|
-
if Global.error_page
|
134
|
-
Dispatcher::Error.call(obj, meta)
|
135
|
-
else
|
136
|
-
message = "No action for '#{meta[:path]}'"
|
137
|
-
message << " on '#{Rack::Utils.escape_html(controller)}'" if controller
|
138
|
-
|
139
|
-
raise(obj) if obj.respond_to?(:message)
|
140
|
-
raise(Ramaze::Error, message)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|