Pistos-ramaze 2008.09
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +481 -0
- data/Rakefile +228 -0
- data/benchmark/results.txt +131 -0
- data/benchmark/run.rb +362 -0
- data/benchmark/suite/minimal.rb +13 -0
- data/benchmark/suite/no_informer.rb +9 -0
- data/benchmark/suite/no_sessions.rb +10 -0
- data/benchmark/suite/no_template.rb +9 -0
- data/benchmark/suite/simple.rb +7 -0
- data/benchmark/suite/template_amrita2.rb +17 -0
- data/benchmark/suite/template_builder.rb +12 -0
- data/benchmark/suite/template_erubis.rb +10 -0
- data/benchmark/suite/template_ezamar.rb +10 -0
- data/benchmark/suite/template_haml.rb +15 -0
- data/benchmark/suite/template_liquid.rb +13 -0
- data/benchmark/suite/template_markaby.rb +11 -0
- data/benchmark/suite/template_nagoro.rb +10 -0
- data/benchmark/suite/template_redcloth.rb +15 -0
- data/benchmark/suite/template_tenjin.rb +10 -0
- data/benchmark/test.rb +35 -0
- data/bin/ramaze +80 -0
- data/doc/AUTHORS +29 -0
- data/doc/CHANGELOG +19530 -0
- data/doc/COPYING +56 -0
- data/doc/FAQ +92 -0
- data/doc/GPL +339 -0
- data/doc/INSTALL +92 -0
- data/doc/LEGAL +26 -0
- data/doc/TODO +29 -0
- data/doc/meta/announcement.txt +99 -0
- data/doc/meta/configuration.txt +163 -0
- data/doc/meta/internals.txt +278 -0
- data/doc/meta/users.kml +64 -0
- data/doc/readme_chunks/appendix.txt +10 -0
- data/doc/readme_chunks/examples.txt +38 -0
- data/doc/readme_chunks/features.txt +148 -0
- data/doc/readme_chunks/getting_help.txt +5 -0
- data/doc/readme_chunks/getting_started.txt +18 -0
- data/doc/readme_chunks/installing.txt +92 -0
- data/doc/readme_chunks/introduction.txt +18 -0
- data/doc/readme_chunks/principles.txt +56 -0
- data/doc/readme_chunks/thanks.txt +59 -0
- data/doc/tutorial/todolist.html +742 -0
- data/doc/tutorial/todolist.mkd +787 -0
- data/examples/app/auth/auth.rb +54 -0
- data/examples/app/auth/template/layout.haml +20 -0
- data/examples/app/auth/template/login.haml +16 -0
- data/examples/app/blog/README +3 -0
- data/examples/app/blog/controller/main.rb +29 -0
- data/examples/app/blog/model/entry.rb +30 -0
- data/examples/app/blog/public/styles/blog.css +132 -0
- data/examples/app/blog/spec/blog.rb +87 -0
- data/examples/app/blog/start.rb +7 -0
- data/examples/app/blog/view/edit.xhtml +17 -0
- data/examples/app/blog/view/index.xhtml +17 -0
- data/examples/app/blog/view/layout.xhtml +11 -0
- data/examples/app/blog/view/new.xhtml +16 -0
- data/examples/app/chat/model/history.rb +36 -0
- data/examples/app/chat/model/message.rb +7 -0
- data/examples/app/chat/public/css/chat.css +13 -0
- data/examples/app/chat/public/js/chat.js +22 -0
- data/examples/app/chat/public/js/jquery.js +3436 -0
- data/examples/app/chat/start.rb +40 -0
- data/examples/app/chat/view/chat.xhtml +9 -0
- data/examples/app/chat/view/index.xhtml +7 -0
- data/examples/app/chat/view/layout.xhtml +13 -0
- data/examples/app/localization/start.rb +35 -0
- data/examples/app/rapaste/Rakefile +34 -0
- data/examples/app/rapaste/controller/paste.rb +101 -0
- data/examples/app/rapaste/model/paste.rb +58 -0
- data/examples/app/rapaste/public/css/active4d.css +114 -0
- data/examples/app/rapaste/public/css/all_hallows_eve.css +72 -0
- data/examples/app/rapaste/public/css/amy.css +147 -0
- data/examples/app/rapaste/public/css/blackboard.css +88 -0
- data/examples/app/rapaste/public/css/brilliance_black.css +605 -0
- data/examples/app/rapaste/public/css/brilliance_dull.css +599 -0
- data/examples/app/rapaste/public/css/cobalt.css +149 -0
- data/examples/app/rapaste/public/css/dawn.css +121 -0
- data/examples/app/rapaste/public/css/display.css +197 -0
- data/examples/app/rapaste/public/css/eiffel.css +121 -0
- data/examples/app/rapaste/public/css/espresso_libre.css +109 -0
- data/examples/app/rapaste/public/css/idle.css +62 -0
- data/examples/app/rapaste/public/css/iplastic.css +80 -0
- data/examples/app/rapaste/public/css/lazy.css +73 -0
- data/examples/app/rapaste/public/css/mac_classic.css +123 -0
- data/examples/app/rapaste/public/css/magicwb_amiga.css +104 -0
- data/examples/app/rapaste/public/css/pastels_on_dark.css +188 -0
- data/examples/app/rapaste/public/css/slush_poppies.css +85 -0
- data/examples/app/rapaste/public/css/spacecadet.css +51 -0
- data/examples/app/rapaste/public/css/sunburst.css +180 -0
- data/examples/app/rapaste/public/css/twilight.css +137 -0
- data/examples/app/rapaste/public/css/zenburnesque.css +91 -0
- data/examples/app/rapaste/public/js/jquery.js +11 -0
- data/examples/app/rapaste/spec/rapaste.rb +51 -0
- data/examples/app/rapaste/start.rb +25 -0
- data/examples/app/rapaste/view/copy.xhtml +10 -0
- data/examples/app/rapaste/view/index.xhtml +9 -0
- data/examples/app/rapaste/view/layout.xhtml +25 -0
- data/examples/app/rapaste/view/list.xhtml +29 -0
- data/examples/app/rapaste/view/search.xhtml +41 -0
- data/examples/app/rapaste/view/view.xhtml +37 -0
- data/examples/app/sourceview/public/coderay.css +104 -0
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +11 -0
- data/examples/app/sourceview/public/jquery.treeview.css +48 -0
- data/examples/app/sourceview/public/jquery.treeview.js +223 -0
- data/examples/app/sourceview/public/sourceview.js +52 -0
- data/examples/app/sourceview/sourceview.rb +77 -0
- data/examples/app/sourceview/template/index.haml +59 -0
- data/examples/app/todolist/README +1 -0
- data/examples/app/todolist/public/favicon.ico +0 -0
- data/examples/app/todolist/public/js/jquery.js +1923 -0
- data/examples/app/todolist/public/ramaze.png +0 -0
- data/examples/app/todolist/spec/todolist.rb +132 -0
- data/examples/app/todolist/src/controller/main.rb +70 -0
- data/examples/app/todolist/src/element/page.rb +31 -0
- data/examples/app/todolist/src/model.rb +14 -0
- data/examples/app/todolist/start.rb +11 -0
- data/examples/app/todolist/template/index.xhtml +17 -0
- data/examples/app/todolist/template/new.xhtml +7 -0
- data/examples/app/upload/start.rb +19 -0
- data/examples/app/upload/view/index.xhtml +25 -0
- data/examples/app/whywiki/spec/whywiki.rb +58 -0
- data/examples/app/whywiki/start.rb +46 -0
- data/examples/app/whywiki/template/edit.xhtml +14 -0
- data/examples/app/whywiki/template/show.xhtml +18 -0
- data/examples/app/wikore/spec/wikore.rb +111 -0
- data/examples/app/wikore/src/controller.rb +80 -0
- data/examples/app/wikore/src/model.rb +53 -0
- data/examples/app/wikore/start.rb +9 -0
- data/examples/app/wikore/template/index.xhtml +8 -0
- data/examples/app/wiktacular/README +2 -0
- data/examples/app/wiktacular/mkd/link/2007-07-20_19-45-51.mkd +1 -0
- data/examples/app/wiktacular/mkd/link/current.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_16-31-33.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +2 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +2 -0
- data/examples/app/wiktacular/mkd/main/current.mkd +2 -0
- data/examples/app/wiktacular/mkd/markdown/current.mkd +3 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +2 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +3 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-46-01.mkd +11 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-46-32.mkd +13 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +17 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +17 -0
- data/examples/app/wiktacular/mkd/testing/current.mkd +17 -0
- data/examples/app/wiktacular/public/favicon.ico +0 -0
- data/examples/app/wiktacular/public/screen.css +72 -0
- data/examples/app/wiktacular/spec/wiktacular.rb +157 -0
- data/examples/app/wiktacular/src/controller.rb +55 -0
- data/examples/app/wiktacular/src/model.rb +102 -0
- data/examples/app/wiktacular/start.rb +8 -0
- data/examples/app/wiktacular/template/edit.xhtml +6 -0
- data/examples/app/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/app/wiktacular/template/index.xhtml +9 -0
- data/examples/app/wiktacular/template/new.xhtml +6 -0
- data/examples/basic/element.rb +45 -0
- data/examples/basic/gestalt.rb +27 -0
- data/examples/basic/hello.rb +15 -0
- data/examples/basic/layout.rb +28 -0
- data/examples/basic/linking.rb +29 -0
- data/examples/basic/simple.rb +56 -0
- data/examples/helpers/cache.rb +31 -0
- data/examples/helpers/form_with_sequel.rb +24 -0
- data/examples/helpers/httpdigest.rb +50 -0
- data/examples/helpers/identity.rb +18 -0
- data/examples/helpers/nitro_form.rb +23 -0
- data/examples/helpers/paginate.rb +71 -0
- data/examples/helpers/provide.rb +23 -0
- data/examples/helpers/rest.rb +28 -0
- data/examples/helpers/simple_captcha.rb +29 -0
- data/examples/misc/css.rb +37 -0
- data/examples/misc/facebook.rb +159 -0
- data/examples/misc/memleak_detector.rb +32 -0
- data/examples/misc/nagoro_element.rb +43 -0
- data/examples/misc/ramaise.rb +132 -0
- data/examples/misc/rapp.rb +45 -0
- data/examples/misc/sequel_scaffolding.rb +34 -0
- data/examples/misc/simple_auth.rb +35 -0
- data/examples/templates/template/external.amrita +19 -0
- data/examples/templates/template/external.haml +22 -0
- data/examples/templates/template/external.liquid +28 -0
- data/examples/templates/template/external.mab +30 -0
- data/examples/templates/template/external.nag +28 -0
- data/examples/templates/template/external.redcloth +19 -0
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +28 -0
- data/examples/templates/template/external.tenjin +28 -0
- data/examples/templates/template/external.xsl +57 -0
- data/examples/templates/template/external.zmr +28 -0
- data/examples/templates/template_amrita2.rb +74 -0
- data/examples/templates/template_erubis.rb +53 -0
- data/examples/templates/template_ezamar.rb +50 -0
- data/examples/templates/template_haml.rb +50 -0
- data/examples/templates/template_liquid.rb +65 -0
- data/examples/templates/template_markaby.rb +58 -0
- data/examples/templates/template_nagoro.rb +51 -0
- data/examples/templates/template_redcloth.rb +59 -0
- data/examples/templates/template_remarkably.rb +55 -0
- data/examples/templates/template_tenjin.rb +53 -0
- data/examples/templates/template_xslt.rb +49 -0
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +20 -0
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/css/ramaze_error.css +90 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +3549 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/spec/main.rb +25 -0
- data/lib/proto/start.rb +8 -0
- data/lib/proto/start.ru +16 -0
- data/lib/proto/view/error.xhtml +64 -0
- data/lib/proto/view/index.xhtml +34 -0
- data/lib/proto/view/page.xhtml +27 -0
- data/lib/ramaze/action/render.rb +191 -0
- data/lib/ramaze/action.rb +153 -0
- data/lib/ramaze/adapter/base.rb +128 -0
- data/lib/ramaze/adapter/cgi.rb +20 -0
- data/lib/ramaze/adapter/ebb.rb +18 -0
- data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
- data/lib/ramaze/adapter/fake.rb +12 -0
- data/lib/ramaze/adapter/fcgi.rb +18 -0
- data/lib/ramaze/adapter/lsws.rb +19 -0
- data/lib/ramaze/adapter/mongrel.rb +21 -0
- data/lib/ramaze/adapter/scgi.rb +18 -0
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
- data/lib/ramaze/adapter/thin.rb +17 -0
- data/lib/ramaze/adapter/webrick.rb +43 -0
- data/lib/ramaze/adapter.rb +97 -0
- data/lib/ramaze/cache/memcached.rb +69 -0
- data/lib/ramaze/cache/memory.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +68 -0
- data/lib/ramaze/cache.rb +113 -0
- data/lib/ramaze/contrib/auto_params/get_args.rb +58 -0
- data/lib/ramaze/contrib/auto_params.rb +135 -0
- data/lib/ramaze/contrib/email.rb +84 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +171 -0
- data/lib/ramaze/contrib/facebook.rb +23 -0
- data/lib/ramaze/contrib/file_cache.rb +65 -0
- data/lib/ramaze/contrib/gems.rb +78 -0
- data/lib/ramaze/contrib/gettext/mo.rb +155 -0
- data/lib/ramaze/contrib/gettext/parser.rb +46 -0
- data/lib/ramaze/contrib/gettext/po.rb +109 -0
- data/lib/ramaze/contrib/gettext.rb +113 -0
- data/lib/ramaze/contrib/gzip_filter.rb +69 -0
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/rest.rb +17 -0
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/contrib/sequel_cache.rb +92 -0
- data/lib/ramaze/contrib.rb +82 -0
- data/lib/ramaze/controller/error.rb +46 -0
- data/lib/ramaze/controller/main.rb +2 -0
- data/lib/ramaze/controller/resolve.rb +273 -0
- data/lib/ramaze/controller.rb +280 -0
- data/lib/ramaze/current/request.rb +205 -0
- data/lib/ramaze/current/response.rb +39 -0
- data/lib/ramaze/current/session/flash.rb +87 -0
- data/lib/ramaze/current/session/hash.rb +66 -0
- data/lib/ramaze/current/session.rb +181 -0
- data/lib/ramaze/current.rb +110 -0
- data/lib/ramaze/dispatcher/action.rb +48 -0
- data/lib/ramaze/dispatcher/directory.rb +119 -0
- data/lib/ramaze/dispatcher/error.rb +108 -0
- data/lib/ramaze/dispatcher/file.rb +95 -0
- data/lib/ramaze/dispatcher.rb +145 -0
- data/lib/ramaze/error.rb +24 -0
- data/lib/ramaze/gestalt.rb +124 -0
- data/lib/ramaze/helper/aspect.rb +106 -0
- data/lib/ramaze/helper/auth.rb +125 -0
- data/lib/ramaze/helper/cache.rb +140 -0
- data/lib/ramaze/helper/cgi.rb +39 -0
- data/lib/ramaze/helper/flash.rb +59 -0
- data/lib/ramaze/helper/form.rb +281 -0
- data/lib/ramaze/helper/formatting.rb +158 -0
- data/lib/ramaze/helper/gestalt.rb +15 -0
- data/lib/ramaze/helper/gravatar.rb +15 -0
- data/lib/ramaze/helper/httpdigest.rb +59 -0
- data/lib/ramaze/helper/identity.rb +119 -0
- data/lib/ramaze/helper/link.rb +122 -0
- data/lib/ramaze/helper/markaby.rb +31 -0
- data/lib/ramaze/helper/maruku.rb +7 -0
- data/lib/ramaze/helper/nitroform.rb +14 -0
- data/lib/ramaze/helper/pager.rb +366 -0
- data/lib/ramaze/helper/paginate.rb +234 -0
- data/lib/ramaze/helper/partial.rb +105 -0
- data/lib/ramaze/helper/redirect.rb +82 -0
- data/lib/ramaze/helper/rest.rb +43 -0
- data/lib/ramaze/helper/sendfile.rb +16 -0
- data/lib/ramaze/helper/sequel.rb +55 -0
- data/lib/ramaze/helper/simple_captcha.rb +31 -0
- data/lib/ramaze/helper/stack.rb +77 -0
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +110 -0
- data/lib/ramaze/helper/xhtml.rb +23 -0
- data/lib/ramaze/helper.rb +79 -0
- data/lib/ramaze/log/analogger.rb +40 -0
- data/lib/ramaze/log/growl.rb +38 -0
- data/lib/ramaze/log/hub.rb +41 -0
- data/lib/ramaze/log/informer.rb +128 -0
- data/lib/ramaze/log/knotify.rb +28 -0
- data/lib/ramaze/log/logger.rb +26 -0
- data/lib/ramaze/log/logging.rb +89 -0
- data/lib/ramaze/log/syslog.rb +51 -0
- data/lib/ramaze/log/xosd.rb +92 -0
- data/lib/ramaze/log.rb +27 -0
- data/lib/ramaze/option/dsl.rb +45 -0
- data/lib/ramaze/option/holder.rb +131 -0
- data/lib/ramaze/option/merger.rb +108 -0
- data/lib/ramaze/option.rb +156 -0
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/route.rb +97 -0
- data/lib/ramaze/setup.rb +50 -0
- data/lib/ramaze/snippets/array/put_within.rb +44 -0
- data/lib/ramaze/snippets/binding/locals.rb +25 -0
- data/lib/ramaze/snippets/blankslate.rb +7 -0
- data/lib/ramaze/snippets/dictionary.rb +504 -0
- data/lib/ramaze/snippets/divide.rb +20 -0
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +41 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +21 -0
- data/lib/ramaze/snippets/metaid.rb +17 -0
- data/lib/ramaze/snippets/numeric/filesize_format.rb +32 -0
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +19 -0
- data/lib/ramaze/snippets/object/pretty.rb +16 -0
- data/lib/ramaze/snippets/object/scope.rb +18 -0
- data/lib/ramaze/snippets/object/traits.rb +76 -0
- data/lib/ramaze/snippets/ordered_set.rb +51 -0
- data/lib/ramaze/snippets/proc/locals.rb +19 -0
- data/lib/ramaze/snippets/ramaze/caller_info.rb +30 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +51 -0
- data/lib/ramaze/snippets/ramaze/deprecated.rb +20 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +21 -0
- data/lib/ramaze/snippets/string/color.rb +31 -0
- data/lib/ramaze/snippets/string/each.rb +19 -0
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +34 -0
- data/lib/ramaze/snippets/string/ord.rb +21 -0
- data/lib/ramaze/snippets/string/snake_case.rb +21 -0
- data/lib/ramaze/snippets/string/start_with.rb +19 -0
- data/lib/ramaze/snippets/string/unindent.rb +28 -0
- data/lib/ramaze/snippets/thread/into.rb +18 -0
- data/lib/ramaze/snippets.rb +22 -0
- data/lib/ramaze/spec/helper/bacon.rb +7 -0
- data/lib/ramaze/spec/helper/browser.rb +88 -0
- data/lib/ramaze/spec/helper/mock_http.rb +63 -0
- data/lib/ramaze/spec/helper/pretty_output.rb +82 -0
- data/lib/ramaze/spec/helper/requester.rb +63 -0
- data/lib/ramaze/spec/helper/simple_http.rb +434 -0
- data/lib/ramaze/spec/helper/snippets.rb +14 -0
- data/lib/ramaze/spec/helper.rb +135 -0
- data/lib/ramaze/spec.rb +1 -0
- data/lib/ramaze/store/default.rb +109 -0
- data/lib/ramaze/template/amrita2.rb +45 -0
- data/lib/ramaze/template/builder.rb +28 -0
- data/lib/ramaze/template/erubis.rb +41 -0
- data/lib/ramaze/template/ezamar/element.rb +169 -0
- data/lib/ramaze/template/ezamar/engine.rb +76 -0
- data/lib/ramaze/template/ezamar/morpher.rb +135 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +31 -0
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/ezamar.rb +42 -0
- data/lib/ramaze/template/haml.rb +37 -0
- data/lib/ramaze/template/liquid.rb +36 -0
- data/lib/ramaze/template/markaby.rb +52 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/nagoro.rb +52 -0
- data/lib/ramaze/template/none.rb +14 -0
- data/lib/ramaze/template/redcloth.rb +25 -0
- data/lib/ramaze/template/remarkably.rb +38 -0
- data/lib/ramaze/template/sass.rb +37 -0
- data/lib/ramaze/template/tagz.rb +79 -0
- data/lib/ramaze/template/tenjin.rb +74 -0
- data/lib/ramaze/template/xslt.rb +100 -0
- data/lib/ramaze/template.rb +87 -0
- data/lib/ramaze/tool/create.rb +48 -0
- data/lib/ramaze/tool/daemonize.rb +37 -0
- data/lib/ramaze/tool/localize.rb +202 -0
- data/lib/ramaze/tool/mime.rb +35 -0
- data/lib/ramaze/tool/mime_types.yaml +615 -0
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/tool.rb +9 -0
- data/lib/ramaze/trinity.rb +16 -0
- data/lib/ramaze/version.rb +6 -0
- data/lib/ramaze.rb +133 -0
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/conf.rake +71 -0
- data/rake_tasks/coverage.rake +46 -0
- data/rake_tasks/gem.rake +74 -0
- data/rake_tasks/git.rake +41 -0
- data/rake_tasks/maintenance.rake +386 -0
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +76 -0
- data/rake_tasks/spec.rake +61 -0
- data/ramaze.gemspec +773 -0
- data/spec/contrib/auto_params.rb +121 -0
- data/spec/contrib/profiling.rb +29 -0
- data/spec/contrib/sequel/fill.rb +47 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/css.rb +15 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/linking.rb +18 -0
- data/spec/examples/simple.rb +45 -0
- data/spec/examples/simple_auth.rb +32 -0
- data/spec/examples/templates/template_amrita2.rb +16 -0
- data/spec/examples/templates/template_erubis.rb +23 -0
- data/spec/examples/templates/template_ezamar.rb +23 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +29 -0
- data/spec/examples/templates/template_markaby.rb +23 -0
- data/spec/examples/templates/template_redcloth.rb +28 -0
- data/spec/examples/templates/template_remarkably.rb +23 -0
- data/spec/examples/templates/template_tenjin.rb +28 -0
- data/spec/helper.rb +3 -0
- data/spec/ramaze/action/basics.rb +36 -0
- data/spec/ramaze/action/cache.rb +87 -0
- data/spec/ramaze/action/file_cache.rb +70 -0
- data/spec/ramaze/action/layout.rb +190 -0
- data/spec/ramaze/action/render.rb +31 -0
- data/spec/ramaze/action/view/bar.xhtml +1 -0
- data/spec/ramaze/action/view/instancevars/layout.xhtml +1 -0
- data/spec/ramaze/action/view/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/view/single_wrapper.xhtml +1 -0
- data/spec/ramaze/action/view/sub/sub_wrapper.xhtml +1 -0
- data/spec/ramaze/adapter/ebb.rb +12 -0
- data/spec/ramaze/adapter/mongrel.rb +12 -0
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/adapter/webrick.rb +12 -0
- data/spec/ramaze/adapter.rb +49 -0
- data/spec/ramaze/cache.rb +140 -0
- data/spec/ramaze/controller/actionless_templates.rb +32 -0
- data/spec/ramaze/controller/resolve.rb +32 -0
- data/spec/ramaze/controller/subclass.rb +36 -0
- data/spec/ramaze/controller/template_resolving.rb +113 -0
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/controller/view/greet.xhtml +1 -0
- data/spec/ramaze/controller/view/list.xhtml +1 -0
- data/spec/ramaze/controller/view/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/view/other_wrapper.xhtml +1 -0
- data/spec/ramaze/controller.rb +180 -0
- data/spec/ramaze/current/request.rb +30 -0
- data/spec/ramaze/current/session.rb +97 -0
- data/spec/ramaze/dispatcher/directory.rb +55 -0
- data/spec/ramaze/dispatcher/file.rb +60 -0
- data/spec/ramaze/dispatcher/public/favicon.ico +0 -0
- data/spec/ramaze/dispatcher/public/file name.txt +1 -0
- data/spec/ramaze/dispatcher/public/test_download.css +141 -0
- data/spec/ramaze/dispatcher.rb +31 -0
- data/spec/ramaze/element.rb +107 -0
- data/spec/ramaze/error.rb +94 -0
- data/spec/ramaze/gestalt.rb +131 -0
- data/spec/ramaze/helper/aspect.rb +101 -0
- data/spec/ramaze/helper/auth.rb +66 -0
- data/spec/ramaze/helper/cache.rb +160 -0
- data/spec/ramaze/helper/cgi.rb +43 -0
- data/spec/ramaze/helper/file.rb +18 -0
- data/spec/ramaze/helper/flash.rb +133 -0
- data/spec/ramaze/helper/form.rb +118 -0
- data/spec/ramaze/helper/formatting.rb +54 -0
- data/spec/ramaze/helper/link.rb +124 -0
- data/spec/ramaze/helper/pager.rb +99 -0
- data/spec/ramaze/helper/partial.rb +88 -0
- data/spec/ramaze/helper/redirect.rb +112 -0
- data/spec/ramaze/helper/simple_captcha.rb +22 -0
- data/spec/ramaze/helper/stack.rb +73 -0
- data/spec/ramaze/helper/user.rb +43 -0
- data/spec/ramaze/helper/view/locals.xhtml +1 -0
- data/spec/ramaze/helper/view/loop.xhtml +4 -0
- data/spec/ramaze/helper/view/num.xhtml +1 -0
- data/spec/ramaze/helper/view/partial.xhtml +1 -0
- data/spec/ramaze/helper/view/recursive.xhtml +8 -0
- data/spec/ramaze/helper/view/recursive_local_ivars.xhtml +7 -0
- data/spec/ramaze/helper/view/recursive_locals.xhtml +7 -0
- data/spec/ramaze/helper/view/test_template.xhtml +1 -0
- data/spec/ramaze/localize.rb +89 -0
- data/spec/ramaze/log/informer.rb +72 -0
- data/spec/ramaze/log/syslog.rb +73 -0
- data/spec/ramaze/morpher.rb +111 -0
- data/spec/ramaze/params.rb +157 -0
- data/spec/ramaze/public/error404.xhtml +1 -0
- data/spec/ramaze/public/favicon.ico +0 -0
- data/spec/ramaze/public/ramaze.png +0 -0
- data/spec/ramaze/public/test_download.css +141 -0
- data/spec/ramaze/request/ebb.rb +9 -0
- data/spec/ramaze/request/mongrel.rb +9 -0
- data/spec/ramaze/request/thin.rb +9 -0
- data/spec/ramaze/request/webrick.rb +5 -0
- data/spec/ramaze/request.rb +185 -0
- data/spec/ramaze/rewrite/file.css +1 -0
- data/spec/ramaze/rewrite.rb +36 -0
- data/spec/ramaze/route.rb +131 -0
- data/spec/ramaze/session.rb +94 -0
- data/spec/ramaze/store/default.rb +71 -0
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/amrita2/external.amrita +6 -0
- data/spec/ramaze/template/amrita2/sum.amrita +1 -0
- data/spec/ramaze/template/amrita2.rb +50 -0
- data/spec/ramaze/template/builder/external.rxml +3 -0
- data/spec/ramaze/template/builder.rb +51 -0
- data/spec/ramaze/template/erubis/sum.rhtml +1 -0
- data/spec/ramaze/template/erubis.rb +41 -0
- data/spec/ramaze/template/ezamar/another/long/action.zmr +1 -0
- data/spec/ramaze/template/ezamar/combined.zmr +1 -0
- data/spec/ramaze/template/ezamar/file_only.zmr +1 -0
- data/spec/ramaze/template/ezamar/index.zmr +1 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
- data/spec/ramaze/template/ezamar/some__long__action.zmr +1 -0
- data/spec/ramaze/template/ezamar/sum.zmr +1 -0
- data/spec/ramaze/template/ezamar.rb +63 -0
- data/spec/ramaze/template/haml/index.haml +5 -0
- data/spec/ramaze/template/haml/locals.haml +2 -0
- data/spec/ramaze/template/haml/with_vars.haml +4 -0
- data/spec/ramaze/template/haml.rb +66 -0
- data/spec/ramaze/template/liquid/index.liquid +1 -0
- data/spec/ramaze/template/liquid/products.liquid +45 -0
- data/spec/ramaze/template/liquid.rb +99 -0
- data/spec/ramaze/template/markaby/external.mab +8 -0
- data/spec/ramaze/template/markaby/sum.mab +1 -0
- data/spec/ramaze/template/markaby.rb +61 -0
- data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
- data/spec/ramaze/template/nagoro/combined.nag +1 -0
- data/spec/ramaze/template/nagoro/file_only.nag +1 -0
- data/spec/ramaze/template/nagoro/index.nag +1 -0
- data/spec/ramaze/template/nagoro/nested.nag +1 -0
- data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
- data/spec/ramaze/template/nagoro/sum.nag +1 -0
- data/spec/ramaze/template/nagoro.rb +64 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/ramaze/template/redcloth/external.redcloth +1 -0
- data/spec/ramaze/template/redcloth.rb +38 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- data/spec/ramaze/template/remarkably.rb +58 -0
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +69 -0
- data/spec/ramaze/template/tagz/external.tagz +8 -0
- data/spec/ramaze/template/tagz/sum.tagz +1 -0
- data/spec/ramaze/template/tagz.rb +62 -0
- data/spec/ramaze/template/tenjin/external.tenjin +1 -0
- data/spec/ramaze/template/tenjin.rb +47 -0
- data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
- data/spec/ramaze/template/xslt/index.xsl +14 -0
- data/spec/ramaze/template/xslt/products.xsl +32 -0
- data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
- data/spec/ramaze/template/xslt.rb +90 -0
- data/spec/ramaze/template.rb +128 -0
- data/spec/snippets/array/put_within.rb +33 -0
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/divide.rb +19 -0
- data/spec/snippets/kernel/constant.rb +23 -0
- data/spec/snippets/numeric/filesize_format.rb +12 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/object/__dir__.rb +8 -0
- data/spec/snippets/object/acquire.rb +71 -0
- data/spec/snippets/ordered_set.rb +63 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +30 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +24 -0
- data/spec/snippets/string/unindent.rb +43 -0
- data/spec/snippets/thread/into.rb +20 -0
- metadata +823 -0
@@ -0,0 +1,281 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module Helper
|
3
|
+
module Form
|
4
|
+
# Pass it an object for your ORM and options for the <form> tag
|
5
|
+
# Usage:
|
6
|
+
# form_for(User, :action => '/create')
|
7
|
+
# form_for(Tag, :action => '/find', :method => 'GET')
|
8
|
+
def form_for(object, options = {})
|
9
|
+
Ramaze::Form.pick(object, options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Form
|
15
|
+
attr_accessor :object, :options
|
16
|
+
|
17
|
+
YEARS, MONTHS, DAYS, HOURS, MINUTES, SECONDS =
|
18
|
+
(1900..2100), (1..12), (1..31), (0..23), (0..59), (0..59)
|
19
|
+
|
20
|
+
DATE_GENERIC = [
|
21
|
+
[ :day, DAYS ],
|
22
|
+
[ :month, MONTHS ],
|
23
|
+
[ :year, YEARS ] ]
|
24
|
+
|
25
|
+
TIME_GENERIC = [
|
26
|
+
[ :day, DAYS ],
|
27
|
+
[ :month, MONTHS ],
|
28
|
+
[ :year, YEARS ],
|
29
|
+
[ :hour, HOURS ],
|
30
|
+
[ :min, MINUTES ],
|
31
|
+
[ :sec, SECONDS ] ]
|
32
|
+
|
33
|
+
# TODO:
|
34
|
+
# How _elegant_ ...
|
35
|
+
# Tries to find the right module for extending the Form instance.
|
36
|
+
# It's problematic since the boundaries of what an model instance or model
|
37
|
+
# class looks like is very fuzzy, also a problem is that the ORM may not be
|
38
|
+
# available/required.
|
39
|
+
#
|
40
|
+
# Maybe we can abstract that a bit by going through an array of procs for
|
41
|
+
# testing?
|
42
|
+
def self.pick(object, options = {})
|
43
|
+
if defined?(Sequel::Model)
|
44
|
+
if object.is_a?(Sequel::Model)
|
45
|
+
options[:layer] ||= Layer::Sequel
|
46
|
+
InstanceForm.new(object, options)
|
47
|
+
elsif object.ancestors.include?(Sequel::Model)
|
48
|
+
options[:layer] ||= Layer::Sequel
|
49
|
+
ClassForm.new(object, options)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
raise "Unknown ORM for: %p" % object
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create new instance of Form plus the layer for the ORM
|
57
|
+
def initialize(object, options = {})
|
58
|
+
@object, @options = object, options
|
59
|
+
if layer = options.delete(:layer)
|
60
|
+
extend layer
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Generate and return the final form
|
65
|
+
def to_s
|
66
|
+
out = "<form #{form_attributes}>"
|
67
|
+
out << "<fieldset>"
|
68
|
+
out << generate
|
69
|
+
out << "</fieldset>"
|
70
|
+
out << '<input type="submit" />'
|
71
|
+
out << '<input type="reset" />'
|
72
|
+
out << "</form>"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Decide on the strucuture of the tag based on the hash
|
76
|
+
def field_for(hash)
|
77
|
+
return if hash[:primary_key]
|
78
|
+
args = args_for(hash)
|
79
|
+
|
80
|
+
inner =
|
81
|
+
case type = hash[:type]
|
82
|
+
when :integer
|
83
|
+
field_integer(*args)
|
84
|
+
when :boolean
|
85
|
+
field_boolean(*args)
|
86
|
+
when :text
|
87
|
+
field_textarea(*args)
|
88
|
+
when :varchar
|
89
|
+
field_input(*args)
|
90
|
+
when :date
|
91
|
+
field_date(*args)
|
92
|
+
when :time
|
93
|
+
field_time(*args)
|
94
|
+
else
|
95
|
+
Log.warn "Unknown field: %p" % hash
|
96
|
+
field_input(*args)
|
97
|
+
end
|
98
|
+
|
99
|
+
"<label>#{args.first}: </label>\n#{inner}"
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# inject to attributes for the <form>
|
105
|
+
def form_attributes
|
106
|
+
options.inject([]){|s,(k,v)| s << "#{k}='#{v}'" }.join(' ')
|
107
|
+
end
|
108
|
+
|
109
|
+
# Start tag with name and attributes
|
110
|
+
def start_tag(name, hash)
|
111
|
+
hash.inject("<#{name}"){|s,(k,v)| s << " #{k}='#{v}'" }
|
112
|
+
end
|
113
|
+
|
114
|
+
# Make a closed tag with name and attributes
|
115
|
+
def closed_tag(name, hash)
|
116
|
+
start_tag(name, hash) << ' />'
|
117
|
+
end
|
118
|
+
|
119
|
+
# Textarea with attributes from hash and the value from @object
|
120
|
+
def textarea(value, hash = {})
|
121
|
+
start_tag(:textarea, hash) << ">#{value}</textarea>"
|
122
|
+
end
|
123
|
+
|
124
|
+
# <input> with optional attributes from hash
|
125
|
+
def input(hash = {})
|
126
|
+
closed_tag(:input, hash)
|
127
|
+
end
|
128
|
+
|
129
|
+
# <input type="checkbox" with optional attributes from hash.
|
130
|
+
def checkbox(hash = {})
|
131
|
+
hash[:type] = :checkbox
|
132
|
+
input(hash)
|
133
|
+
end
|
134
|
+
|
135
|
+
# <option value="value"> with optional attributes from hash
|
136
|
+
def option(value, hash = {})
|
137
|
+
start_tag(:option, hash) << ">#{value}</option>"
|
138
|
+
end
|
139
|
+
|
140
|
+
# Yield method names and values for the Date instance
|
141
|
+
def field_date_generic
|
142
|
+
DATE_GENERIC.map{|(sel, range)|
|
143
|
+
yield(sel, range).join
|
144
|
+
}.join("\n")
|
145
|
+
end
|
146
|
+
|
147
|
+
# Yield method names and values for the Time/DateTime instance
|
148
|
+
def field_time_generic
|
149
|
+
TIME_GENERIC.map{|(sel, range)|
|
150
|
+
yield(sel, range).join
|
151
|
+
}.join("\n")
|
152
|
+
end
|
153
|
+
|
154
|
+
# Here go all the layers that are extended for specific ORMs
|
155
|
+
module Layer
|
156
|
+
# Layer for Sequel, only generate needs to be implemented, may change in
|
157
|
+
# future if we abstract more for different ORMs
|
158
|
+
module Sequel
|
159
|
+
# A bit nasty, get the @columns of the object and generate its
|
160
|
+
# field_for
|
161
|
+
def generate
|
162
|
+
columns = object_class.schema.instance_variable_get('@columns')
|
163
|
+
columns.map{|hash| field_for(hash) }.flatten.join("<br />\n")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Form for the model class itself, very similar to an empty instance.
|
170
|
+
class ClassForm < Form
|
171
|
+
# <input name="name" />
|
172
|
+
def field_input(name)
|
173
|
+
input :name => name
|
174
|
+
end
|
175
|
+
|
176
|
+
# <textarea name="name"></textarea>
|
177
|
+
def field_textarea(name)
|
178
|
+
textarea '', :name => name
|
179
|
+
end
|
180
|
+
|
181
|
+
# <input name="name" />
|
182
|
+
def field_integer(name)
|
183
|
+
input :name => name
|
184
|
+
end
|
185
|
+
|
186
|
+
# <input type="checkbox" name="name" />
|
187
|
+
def field_boolean(name)
|
188
|
+
checkbox :name => name
|
189
|
+
end
|
190
|
+
|
191
|
+
# <select> with lots of <option>s
|
192
|
+
def field_date(name)
|
193
|
+
field_date_generic{|sel, range|
|
194
|
+
[ "<select name='#{name}[#{sel}]'>",
|
195
|
+
range.map{|d| option(d, :value => d) },
|
196
|
+
"</select>" ]
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
# <select> with lots of <option>s
|
201
|
+
def field_time(name)
|
202
|
+
field_time_generic{|sel, range|
|
203
|
+
[ "<select name='#{name}[#{sel}]'>",
|
204
|
+
range.map{|d| option(d, :value => d) },
|
205
|
+
"</select>" ]
|
206
|
+
}
|
207
|
+
end
|
208
|
+
|
209
|
+
# picks the :name
|
210
|
+
def args_for(hash)
|
211
|
+
[ hash[:name] ]
|
212
|
+
end
|
213
|
+
|
214
|
+
# Should be that way, at least for Sequel
|
215
|
+
def object_class
|
216
|
+
@object
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# Form for instances of the model class
|
221
|
+
class InstanceForm < Form
|
222
|
+
# <input type='text' name='name' value='value' />
|
223
|
+
def field_input(name, value)
|
224
|
+
"<input type='text' name='#{name}' value='#{value}'/>"
|
225
|
+
end
|
226
|
+
|
227
|
+
def field_textarea(name, value)
|
228
|
+
"<textarea name='#{name}'>#{value}</textarea>"
|
229
|
+
end
|
230
|
+
|
231
|
+
# <input type="text" name="name" value="value" />
|
232
|
+
def field_integer(name, value)
|
233
|
+
field_input(name, value)
|
234
|
+
end
|
235
|
+
|
236
|
+
# <input type="checkbox" ...
|
237
|
+
def field_boolean(name, value)
|
238
|
+
if value
|
239
|
+
checkbox :name => name, :value => value, :checked => :checked
|
240
|
+
else
|
241
|
+
checkbox :name => name, :value => value
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def field_date(name, value)
|
246
|
+
field_date_generic do |sel, range|
|
247
|
+
[ "<select name='#{name}[#{sel}]'>",
|
248
|
+
option_range_selected(range, value.send(sel)),
|
249
|
+
"</select>" ]
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def field_time(name, value)
|
254
|
+
field_time_generic do |sel, range|
|
255
|
+
[ "<select name='#{name}[#{sel}]'>",
|
256
|
+
option_range_selected(range, value.send(sel)),
|
257
|
+
"</select>" ]
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def option_range_selected(range, value)
|
262
|
+
range.map do |r|
|
263
|
+
if r == value
|
264
|
+
option(r, :value => r, :selected => :selected)
|
265
|
+
else
|
266
|
+
option(r, :value => r)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def args_for(hash)
|
272
|
+
name = hash[:name]
|
273
|
+
[ name, @object.send(name) ]
|
274
|
+
end
|
275
|
+
|
276
|
+
# Class for @object, atm Sequel specific?
|
277
|
+
def object_class
|
278
|
+
@object.class
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
@@ -0,0 +1,158 @@
|
|
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
|
+
module Helper::Formatting
|
6
|
+
|
7
|
+
# Format a floating number nicely for display.
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
# number_format(123.123) # => '123.123'
|
11
|
+
# number_format(123456.12345) # => '123,456.12345'
|
12
|
+
# number_format(123456.12345, '.') # => '123.456,12345'
|
13
|
+
|
14
|
+
def number_format(n, delimiter = ',')
|
15
|
+
delim_l, delim_r = delimiter == ',' ? %w[, .] : %w[. ,]
|
16
|
+
h, r = n.to_s.split('.')
|
17
|
+
[h.reverse.scan(/\d{1,3}/).join(delim_l).reverse, r].compact.join(delim_r)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Answer with the ordinal version of a number.
|
21
|
+
#
|
22
|
+
# Usage:
|
23
|
+
# ordinal(1) # => "1st"
|
24
|
+
# ordinal(2) # => "2nd"
|
25
|
+
# ordinal(3) # => "3rd"
|
26
|
+
# ordinal(13) # => "13th"
|
27
|
+
# ordinal(33) # => "33rd"
|
28
|
+
# ordinal(100) # => "100th"
|
29
|
+
# ordinal(133) # => "133rd"
|
30
|
+
|
31
|
+
def ordinal(number)
|
32
|
+
number = number.to_i
|
33
|
+
|
34
|
+
case number % 100
|
35
|
+
when 11..13; "#{number}th"
|
36
|
+
else
|
37
|
+
case number % 10
|
38
|
+
when 1; "#{number}st"
|
39
|
+
when 2; "#{number}nd"
|
40
|
+
when 3; "#{number}rd"
|
41
|
+
else "#{number}th"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# stolen and adapted from rails
|
47
|
+
def time_diff from_time, to_time = Time.now, include_seconds = false
|
48
|
+
distance_in_minutes = (((to_time - from_time).abs)/60).round
|
49
|
+
distance_in_seconds = ((to_time - from_time).abs).round if include_seconds
|
50
|
+
|
51
|
+
case distance_in_minutes
|
52
|
+
when 0..1
|
53
|
+
return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds
|
54
|
+
case distance_in_seconds
|
55
|
+
when 0..4 then 'less than 5 seconds'
|
56
|
+
when 5..9 then 'less than 10 seconds'
|
57
|
+
when 10..19 then 'less than 20 seconds'
|
58
|
+
when 20..39 then 'half a minute'
|
59
|
+
when 40..59 then 'less than a minute'
|
60
|
+
else '1 minute'
|
61
|
+
end
|
62
|
+
|
63
|
+
when 2..44 then "#{distance_in_minutes} minutes"
|
64
|
+
when 45..89 then 'about 1 hour'
|
65
|
+
when 90..1439 then "about #{(distance_in_minutes.to_f / 60.0).round} hours"
|
66
|
+
when 1440..2879 then '1 day'
|
67
|
+
when 2880..43199 then "#{(distance_in_minutes / 1440).round} days"
|
68
|
+
when 43200..86399 then 'about 1 month'
|
69
|
+
when 86400..525959 then "#{(distance_in_minutes / 43200).round} months"
|
70
|
+
when 525960..1051919 then 'about 1 year'
|
71
|
+
else "over #{(distance_in_minutes / 525960).round} years"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# copied from actionpack
|
76
|
+
AUTO_LINK_RE = %r{
|
77
|
+
( # leading text
|
78
|
+
<\w+.*?>| # leading HTML tag, or
|
79
|
+
[^=!:'"/]| # leading punctuation, or
|
80
|
+
^ # beginning of line
|
81
|
+
)
|
82
|
+
(
|
83
|
+
(?:https?://)| # protocol spec, or
|
84
|
+
(?:www\.) # www.*
|
85
|
+
)
|
86
|
+
(
|
87
|
+
[-\w]+ # subdomain or domain
|
88
|
+
(?:\.[-\w]+)* # remaining subdomains or domain
|
89
|
+
(?::\d+)? # port
|
90
|
+
(?:/(?:(?:[~\w\+@%-]|(?:[,.;:][^\s$]))+)?)* # path
|
91
|
+
(?:\?[\w\+@%&=.;-]+)? # query string
|
92
|
+
(?:\#[\w\-]*)? # trailing anchor
|
93
|
+
)
|
94
|
+
([[:punct:]]|\s|<|$) # trailing text
|
95
|
+
}x unless defined? AUTO_LINK_RE
|
96
|
+
|
97
|
+
# Turns all urls into clickable links. If a block is given, each url
|
98
|
+
# is yielded and the result is used as the link text.
|
99
|
+
def auto_link(text, opts = {})
|
100
|
+
html_options = ' ' + opts.map{|k,v| "#{k}='#{v}'"}.join(' ') if opts.any?
|
101
|
+
text.gsub(AUTO_LINK_RE) do
|
102
|
+
all, a, b, c, d = $&, $1, $2, $3, $4
|
103
|
+
if a =~ /<a\s/i # don't replace URL's that are already linked
|
104
|
+
all
|
105
|
+
else
|
106
|
+
text = b + c
|
107
|
+
text = yield(text) if block_given?
|
108
|
+
%(#{a}<a href="#{b=="www."?"http://www.":b}#{c}"#{html_options}>#{text}</a>#{d})
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
alias autolink auto_link
|
113
|
+
|
114
|
+
def nl2br(string, xhtml = true)
|
115
|
+
br = xhtml ? '<br />' : '<br>'
|
116
|
+
string.gsub(/\n/, br)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Maybe port to ruby < 1.8.7 ?
|
120
|
+
def obfuscate_email(string)
|
121
|
+
string = string.to_s
|
122
|
+
text = string.each_byte.map{|c| "&#%03d" % c}.join
|
123
|
+
%(<a href="mailto:#{string}">#{text}</a>)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns Hash with tags as keys and their weight as value.
|
127
|
+
#
|
128
|
+
# Example:
|
129
|
+
# tags = %w[ruby ruby code ramaze]
|
130
|
+
# tagcloud(tags)
|
131
|
+
# # => {"code"=>0.75, "ramaze"=>0.75, "ruby"=>1.0}
|
132
|
+
#
|
133
|
+
# The weight can be influenced by adjusting the +min+ and +max+ parameters,
|
134
|
+
# please make sure that +max+ is larger than +min+ to get meaningful output.
|
135
|
+
#
|
136
|
+
# This is not thought as immediate output to your template but rather to
|
137
|
+
# help either implementing your own algorithm or using the result as input
|
138
|
+
# for your tagcloud.
|
139
|
+
#
|
140
|
+
# Example:
|
141
|
+
# - tagcloud(tags).each do |tag, weight|
|
142
|
+
# - style = "font-size: %0.2fem" % weight
|
143
|
+
# %a{:style => style, :href => Rs(tag)}= h(tag)
|
144
|
+
|
145
|
+
def tagcloud(tags, min = 0.5, max = 1.5)
|
146
|
+
result = {}
|
147
|
+
total = tags.size.to_f
|
148
|
+
diff = max - min
|
149
|
+
|
150
|
+
tags.uniq.each do |tag|
|
151
|
+
count = tags.respond_to?(:count) ? tags.count(tag) : tags.select{|t| t==tag }.size
|
152
|
+
result[tag] = ((count / total) * diff) + min
|
153
|
+
end
|
154
|
+
|
155
|
+
result
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module Helper
|
3
|
+
module Gravatar
|
4
|
+
def gravatar(email, size = 32, fallback_path = "/images/gravatar_default.jpg")
|
5
|
+
emailhash = Digest::MD5.hexdigest(email)
|
6
|
+
|
7
|
+
fallback = Request.current.domain
|
8
|
+
fallback.path = fallback_path
|
9
|
+
default = h(fallback.to_s)
|
10
|
+
|
11
|
+
return "http://www.gravatar.com/avatar.php?gravatar_id=#{emailhash}&default=#{default}&size=#{size}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'uuid'
|
2
|
+
require 'md5'
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module Helper
|
6
|
+
module HttpDigest
|
7
|
+
|
8
|
+
@session_nonce = "authentication_digest_nonce"
|
9
|
+
|
10
|
+
def httpdigest_logout
|
11
|
+
session.delete( @session_nonce )
|
12
|
+
end
|
13
|
+
|
14
|
+
def httpdigest(uid, realm)
|
15
|
+
session_opaque = "authentication_digest_opaque_#{uid}"
|
16
|
+
|
17
|
+
session[session_opaque] ||= UUID.new
|
18
|
+
|
19
|
+
authorized = false
|
20
|
+
|
21
|
+
if session[@session_nonce] and request.env['HTTP_AUTHORIZATION']
|
22
|
+
|
23
|
+
auth_split = request.env['HTTP_AUTHORIZATION'].split
|
24
|
+
authentication_type = auth_split[0]
|
25
|
+
authorization = Rack::Auth::Digest::Params.parse( auth_split[1..-1].join(' ') )
|
26
|
+
digest_response, username, nonce, nc, cnonce, qop =
|
27
|
+
authorization.values_at(*%w[response username nonce nc cnonce qop])
|
28
|
+
|
29
|
+
if authentication_type == 'Digest'
|
30
|
+
if nonce == session[@session_nonce]
|
31
|
+
ha1 = yield(username)
|
32
|
+
ha2 = MD5.hexdigest("#{request.request_method}:#{request.fullpath}")
|
33
|
+
md5 = MD5.hexdigest([ha1, nonce, nc, cnonce, qop, ha2].join(':'))
|
34
|
+
|
35
|
+
authorized = digest_response == md5
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
unless authorized
|
41
|
+
session[@session_nonce] = UUID.new
|
42
|
+
response['WWW-Authenticate'] =
|
43
|
+
%|Digest realm="#{realm}",| +
|
44
|
+
%|qop="auth,auth-int",| +
|
45
|
+
%|nonce="#{session[@session_nonce]}",| +
|
46
|
+
%|opaque="#{session[session_opaque]}"|
|
47
|
+
if respond_to?( :httpdigest_failure )
|
48
|
+
httpdigest_failure
|
49
|
+
else
|
50
|
+
respond('Unauthorized', 401)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
authorization["username"]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,119 @@
|
|
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 'openid'
|
5
|
+
require 'openid/store/filesystem'
|
6
|
+
require 'openid/extensions/pape'
|
7
|
+
require 'openid/extensions/sreg'
|
8
|
+
|
9
|
+
module Ramaze
|
10
|
+
|
11
|
+
openid_store_file = ::File.join(Dir.tmpdir, 'openid-store')
|
12
|
+
|
13
|
+
# Constant for storing meta-information persistent
|
14
|
+
OpenIDStore = OpenID::Store::Filesystem.new(openid_store_file)
|
15
|
+
|
16
|
+
# This is called Identity to avoid collisions with the original openid.rb
|
17
|
+
# It provides a nice and simple way to provide and control access over the
|
18
|
+
# OpenID authentication model.
|
19
|
+
|
20
|
+
module Helper
|
21
|
+
module Identity
|
22
|
+
LOOKUP << self
|
23
|
+
|
24
|
+
# Simple form for use or overwriting.
|
25
|
+
# Has to provide the same functionality when overwritten or directly
|
26
|
+
# embedded into a page.
|
27
|
+
def openid_login_form(caption="login")
|
28
|
+
%{
|
29
|
+
<form method="GET" action="#{Rs(:openid_begin)}">
|
30
|
+
Identity URL: <input type="text" name="url" />
|
31
|
+
<input type="submit" value="#{caption}"/>
|
32
|
+
</form>
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# We land here from the openid_login_form and if we can find a matching
|
37
|
+
# OpenID server we redirect the user to it, the browser will return to
|
38
|
+
# openid_complete when the authentication is complete.
|
39
|
+
def openid_begin
|
40
|
+
# The OpenID URL pointing to a user's OpenID page,
|
41
|
+
# for example: http://username.myopenid.com)
|
42
|
+
url = request['url']
|
43
|
+
redirect_referrer if url.to_s.empty?
|
44
|
+
session[:openid] ||= {}
|
45
|
+
session[:openid][:entry] = request.referrer
|
46
|
+
|
47
|
+
openid_request = openid_consumer.begin(url)
|
48
|
+
|
49
|
+
# We want these communications to be a secure as the server can
|
50
|
+
# support!
|
51
|
+
papereq = OpenID::PAPE::Request.new
|
52
|
+
papereq.add_policy_uri(OpenID::PAPE::AUTH_PHISHING_RESISTANT)
|
53
|
+
papereq.max_auth_age = 2*60*60
|
54
|
+
openid_request.add_extension(papereq)
|
55
|
+
|
56
|
+
# Request information about the person
|
57
|
+
sregreq = OpenID::SReg::Request.new
|
58
|
+
sregreq.request_fields(['fullname', 'nickname', 'dob', 'email',
|
59
|
+
'gender', 'postcode', 'country', 'language',
|
60
|
+
'timezone'])
|
61
|
+
openid_request.add_extension(sregreq)
|
62
|
+
openid_request.return_to_args['did_pape'] = 'y'
|
63
|
+
|
64
|
+
root = "http://#{request.http_host}/"
|
65
|
+
return_to = request.domain(Rs(:openid_complete)).to_s
|
66
|
+
immediate = false
|
67
|
+
|
68
|
+
if openid_request.send_redirect?(root, return_to, immediate)
|
69
|
+
redirect_url =
|
70
|
+
openid_request.redirect_url(root, return_to, immediate)
|
71
|
+
raw_redirect redirect_url
|
72
|
+
else
|
73
|
+
# what the hell is @form_text ?
|
74
|
+
end
|
75
|
+
|
76
|
+
rescue OpenID::OpenIDError => ex
|
77
|
+
flash[:error] = "Discovery failed for #{url}: #{ex}"
|
78
|
+
raw_redirect Rs(:/)
|
79
|
+
end
|
80
|
+
|
81
|
+
# After having authenticated at the OpenID server browsers are redirected
|
82
|
+
# back here and on success we set the session[:openid][:identity] and a little
|
83
|
+
# default flash message. Then we redirect to wherever session[:openid][:entry]
|
84
|
+
# points us to, which was set on openid_begin to the referrer
|
85
|
+
#
|
86
|
+
# TODO:
|
87
|
+
# - maybe using StackHelper, but this is a really minimal overlap?
|
88
|
+
def openid_complete
|
89
|
+
openid_response = openid_consumer.complete(request.params, request.url)
|
90
|
+
|
91
|
+
case openid_response.status
|
92
|
+
when OpenID::Consumer::FAILURE
|
93
|
+
flash[:error] = "OpenID - Verification failed: #{openid_response.message}"
|
94
|
+
when OpenID::Consumer::SUCCESS
|
95
|
+
# Backwards compatibility
|
96
|
+
session[:openid][:identity] = openid_response.identity_url
|
97
|
+
session[:openid][:sreg] = OpenID::SReg::Response.from_success_response(openid_response)
|
98
|
+
|
99
|
+
# Forward compatibility :)
|
100
|
+
session[:openid_identity] = openid_response.identity_url
|
101
|
+
session[:openid_sreg] = OpenID::SReg::Response.from_success_response(openid_response)
|
102
|
+
|
103
|
+
flash[:success] = 'OpenID - Verification done.'
|
104
|
+
end
|
105
|
+
|
106
|
+
session.delete(:_openid_consumer_service)
|
107
|
+
|
108
|
+
raw_redirect session[:openid][:entry]
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
# Fetch/Create a OpenID::Consumer for current session.
|
114
|
+
def openid_consumer
|
115
|
+
OpenID::Consumer.new(session, Ramaze::OpenIDStore)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|