ptomato-ramaze 2009.02
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.md +481 -0
- data/Rakefile +248 -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 +40 -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/partial.rb +28 -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 +108 -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 +11 -0
- data/lib/proto/controller/main.rb +20 -0
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/.htaccess +24 -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 +12 -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 +192 -0
- data/lib/ramaze/action.rb +159 -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/file.rb +71 -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 +114 -0
- data/lib/ramaze/contrib/email.rb +86 -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 +3 -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 +278 -0
- data/lib/ramaze/controller.rb +288 -0
- data/lib/ramaze/current/request.rb +231 -0
- data/lib/ramaze/current/response.rb +37 -0
- data/lib/ramaze/current/session/flash.rb +88 -0
- data/lib/ramaze/current/session/hash.rb +62 -0
- data/lib/ramaze/current/session.rb +179 -0
- data/lib/ramaze/current.rb +51 -0
- data/lib/ramaze/dispatcher/action.rb +50 -0
- data/lib/ramaze/dispatcher/directory.rb +119 -0
- data/lib/ramaze/dispatcher/error.rb +108 -0
- data/lib/ramaze/dispatcher/file.rb +100 -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/bench.rb +43 -0
- data/lib/ramaze/helper/cache.rb +140 -0
- data/lib/ramaze/helper/cgi.rb +39 -0
- data/lib/ramaze/helper/flash.rb +74 -0
- data/lib/ramaze/helper/form.rb +284 -0
- data/lib/ramaze/helper/formatting.rb +162 -0
- data/lib/ramaze/helper/gestalt.rb +15 -0
- data/lib/ramaze/helper/gravatar.rb +32 -0
- data/lib/ramaze/helper/httpdigest.rb +88 -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 +9 -0
- data/lib/ramaze/helper/nitroform.rb +14 -0
- data/lib/ramaze/helper/pager.rb +366 -0
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/partial.rb +105 -0
- data/lib/ramaze/helper/redirect.rb +100 -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 +87 -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/rotatinginformer.rb +168 -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/watch_inotify.rb +85 -0
- data/lib/ramaze/reloader/watch_stat.rb +58 -0
- data/lib/ramaze/reloader.rb +170 -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 +22 -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 +37 -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/acquire.rb +31 -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 +21 -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 +64 -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 +49 -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 +39 -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 +38 -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 +111 -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 +139 -0
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/conf.rake +71 -0
- data/rake_tasks/coverage.rake +45 -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 +611 -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 +76 -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 +70 -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/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 +14 -0
- data/spec/snippets/ordered_set.rb +63 -0
- data/spec/snippets/ramaze/acquire.rb +77 -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 +661 -0
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
6
|
+
# Shortcuts to some CGI methods
|
|
7
|
+
|
|
8
|
+
module Helper::CGI
|
|
9
|
+
|
|
10
|
+
# shortcut for Rack::Utils.escape
|
|
11
|
+
def url_encode(*args)
|
|
12
|
+
Rack::Utils.escape(*args.map{|a| a.to_s })
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# shortcut for Rack::Utils.unescape
|
|
16
|
+
def url_decode(*args)
|
|
17
|
+
Rack::Utils.unescape(*args.map{|a| a.to_s })
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# shortcut for Rack::Utils.escape_html
|
|
21
|
+
def html_escape(string)
|
|
22
|
+
Rack::Utils.escape_html(string)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# shortcut for CGI.unescapeHTML
|
|
26
|
+
def html_unescape(string)
|
|
27
|
+
::CGI.unescapeHTML(string.to_s)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# safely escape all HTML and code
|
|
31
|
+
def h(string)
|
|
32
|
+
Rack::Utils.escape_html(string).gsub(/#([{@$]@?)/, '#\1')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# one-letter versions help in case like #{h foo.inspect}
|
|
36
|
+
# ERb/ERuby/Rails compatible
|
|
37
|
+
alias u url_encode
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
|
|
6
|
+
# The purpose of this class is to provide an easy way of setting/retrieving
|
|
7
|
+
# from the current flash.
|
|
8
|
+
#
|
|
9
|
+
# Flash is a way to keep a temporary pairs of keys and values for the duration
|
|
10
|
+
# of two requests, the current and following.
|
|
11
|
+
#
|
|
12
|
+
# Very vague Example:
|
|
13
|
+
#
|
|
14
|
+
# On the first request, for example on registering:
|
|
15
|
+
#
|
|
16
|
+
# flash[:error] = "You should reconsider your username, it's taken already"
|
|
17
|
+
# redirect R(self, :register)
|
|
18
|
+
#
|
|
19
|
+
# This is the request from the redirect:
|
|
20
|
+
#
|
|
21
|
+
# do_stuff if flash[:error]
|
|
22
|
+
#
|
|
23
|
+
# On the request after this, flash[:error] is gone.
|
|
24
|
+
|
|
25
|
+
module Helper::Flash
|
|
26
|
+
trait :flashbox => "<div class='flash' id='flash_%key'>%value</div>"
|
|
27
|
+
# answers with Session.current.flash
|
|
28
|
+
|
|
29
|
+
def flash
|
|
30
|
+
Session.current.flash
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Use in your template to display all flash messages that may be stored.
|
|
34
|
+
# For example, given you stored:
|
|
35
|
+
#
|
|
36
|
+
# flash # => { :error => 'Pleae enter your name'
|
|
37
|
+
# :info => 'Do you see the fnords?' }
|
|
38
|
+
#
|
|
39
|
+
# Then a flashbox would display:
|
|
40
|
+
#
|
|
41
|
+
# <div class='flash' id='flash_error'>Please enter your name</div>
|
|
42
|
+
# <div class='flash' id='flash_info'>Do you see the fnords?</div>
|
|
43
|
+
#
|
|
44
|
+
#
|
|
45
|
+
# This can be customized permanently in your controller:
|
|
46
|
+
#
|
|
47
|
+
# class MainController < Ramaze::Controller
|
|
48
|
+
# trait :flashbox => "<div class='flash_%key'>%value</div>"
|
|
49
|
+
#
|
|
50
|
+
# def show_flashbox
|
|
51
|
+
# flashbox
|
|
52
|
+
# end
|
|
53
|
+
# end
|
|
54
|
+
#
|
|
55
|
+
# or on a per-usage basis in your action:
|
|
56
|
+
#
|
|
57
|
+
# class MainController < Ramaze::Controller
|
|
58
|
+
# def show_flashbox
|
|
59
|
+
# flashbox("<div class='flash_%key'>%value</div>")
|
|
60
|
+
# end
|
|
61
|
+
# end
|
|
62
|
+
#
|
|
63
|
+
# Where any occurrence of %key and %value will be replaced by the actual
|
|
64
|
+
# contents of each element of flash
|
|
65
|
+
|
|
66
|
+
def flashbox(tag = ancestral_trait[:flashbox])
|
|
67
|
+
flash.map{|key, *values|
|
|
68
|
+
values.flatten.map do |value|
|
|
69
|
+
tag.gsub(/%key/, key.to_s).gsub(/%value/, value.to_s)
|
|
70
|
+
end
|
|
71
|
+
}.flatten.join("\n")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,284 @@
|
|
|
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
|
+
# returns <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
|
+
# returns <textarea name='name'>#{value}</textarea>
|
|
228
|
+
|
|
229
|
+
def field_textarea(name, value)
|
|
230
|
+
"<textarea name='#{name}'>#{value}</textarea>"
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# returns <input type="text" name="name" value="value" />
|
|
234
|
+
|
|
235
|
+
def field_integer(name, value)
|
|
236
|
+
field_input(name, value)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# <input type="checkbox" ...
|
|
240
|
+
def field_boolean(name, value)
|
|
241
|
+
if value
|
|
242
|
+
checkbox :name => name, :value => value, :checked => :checked
|
|
243
|
+
else
|
|
244
|
+
checkbox :name => name, :value => value
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def field_date(name, value)
|
|
249
|
+
field_date_generic do |sel, range|
|
|
250
|
+
[ "<select name='#{name}[#{sel}]'>",
|
|
251
|
+
option_range_selected(range, value.send(sel)),
|
|
252
|
+
"</select>" ]
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def field_time(name, value)
|
|
257
|
+
field_time_generic do |sel, range|
|
|
258
|
+
[ "<select name='#{name}[#{sel}]'>",
|
|
259
|
+
option_range_selected(range, value.send(sel)),
|
|
260
|
+
"</select>" ]
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def option_range_selected(range, value)
|
|
265
|
+
range.map do |r|
|
|
266
|
+
if r == value
|
|
267
|
+
option(r, :value => r, :selected => :selected)
|
|
268
|
+
else
|
|
269
|
+
option(r, :value => r)
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def args_for(hash)
|
|
275
|
+
name = hash[:name]
|
|
276
|
+
[ name, @object.send(name) ]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Class for @object, atm Sequel specific?
|
|
280
|
+
def object_class
|
|
281
|
+
@object.class
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
end
|
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
# takes a string and optional argument for outputting compliance HTML
|
|
115
|
+
# instead of XHTML.
|
|
116
|
+
# e.g nl2br "a\nb\n\c" #=> 'a<br />b<br />c'
|
|
117
|
+
|
|
118
|
+
def nl2br(string, xhtml = true)
|
|
119
|
+
br = xhtml ? '<br />' : '<br>'
|
|
120
|
+
string.gsub(/\n/, br)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Maybe port to ruby < 1.8.7 ?
|
|
124
|
+
def obfuscate_email(string)
|
|
125
|
+
string = string.to_s
|
|
126
|
+
text = string.each_byte.map{|c| "&#%03d" % c}.join
|
|
127
|
+
%(<a href="mailto:#{string}">#{text}</a>)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Returns Hash with tags as keys and their weight as value.
|
|
131
|
+
#
|
|
132
|
+
# Example:
|
|
133
|
+
# tags = %w[ruby ruby code ramaze]
|
|
134
|
+
# tagcloud(tags)
|
|
135
|
+
# # => {"code"=>0.75, "ramaze"=>0.75, "ruby"=>1.0}
|
|
136
|
+
#
|
|
137
|
+
# The weight can be influenced by adjusting the +min+ and +max+ parameters,
|
|
138
|
+
# please make sure that +max+ is larger than +min+ to get meaningful output.
|
|
139
|
+
#
|
|
140
|
+
# This is not thought as immediate output to your template but rather to
|
|
141
|
+
# help either implementing your own algorithm or using the result as input
|
|
142
|
+
# for your tagcloud.
|
|
143
|
+
#
|
|
144
|
+
# Example:
|
|
145
|
+
# - tagcloud(tags).each do |tag, weight|
|
|
146
|
+
# - style = "font-size: %0.2fem" % weight
|
|
147
|
+
# %a{:style => style, :href => Rs(tag)}= h(tag)
|
|
148
|
+
|
|
149
|
+
def tagcloud(tags, min = 0.5, max = 1.5)
|
|
150
|
+
result = {}
|
|
151
|
+
total = tags.size.to_f
|
|
152
|
+
diff = max - min
|
|
153
|
+
|
|
154
|
+
tags.uniq.each do |tag|
|
|
155
|
+
count = tags.respond_to?(:count) ? tags.count(tag) : tags.select{|t| t==tag }.size
|
|
156
|
+
result[tag] = ((count / total) * diff) + min
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
result
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|