rango 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/CONTRIBUTORS +1 -0
- data/README.textile +4 -1
- data/bin/rango +1 -1
- data/lib/rango.rb +78 -12
- data/lib/rango/contrib/pagination.rb +2 -0
- data/lib/rango/controller.rb +58 -12
- data/lib/rango/environments.rb +26 -0
- data/lib/rango/exceptions.rb +2 -14
- data/lib/rango/gv.rb +7 -90
- data/lib/rango/gv/static.rb +22 -0
- data/lib/rango/helpers.rb +0 -1
- data/lib/rango/helpers/assets.rb +2 -0
- data/lib/rango/helpers/general.rb +1 -0
- data/lib/rango/helpers/syntax.rb +2 -0
- data/lib/rango/mini.rb +30 -0
- data/lib/rango/mixins/application.rb +5 -3
- data/lib/rango/mixins/configurable.rb +1 -0
- data/lib/rango/mixins/render.rb +13 -84
- data/lib/rango/orm/tasks/datamapper.rake +2 -2
- data/lib/rango/project.rb +2 -2
- data/lib/rango/rack/middlewares/basic.rb +15 -11
- data/lib/rango/rack/request.rb +5 -3
- data/lib/rango/router.rb +20 -2
- data/lib/rango/router/adapters/rack_mount.rb +0 -1
- data/lib/rango/router/adapters/rack_router.rb +0 -1
- data/lib/rango/router/adapters/urlmap.rb +0 -1
- data/lib/rango/router/adapters/usher.rb +0 -1
- data/lib/rango/settings/framework.rb +2 -43
- data/lib/rango/templates/{erubis.rb → exts/erubis.rb} +0 -19
- data/lib/rango/templates/exts/tilt.rb +16 -0
- data/lib/rango/templates/helpers.rb +107 -0
- data/lib/rango/templates/template.rb +44 -115
- data/lib/rango/utils.rb +9 -4
- data/spec/rango/controller_spec.rb +3 -1
- data/spec/rango/environments_spec.rb +68 -0
- data/spec/rango/gv_spec.rb +10 -0
- data/spec/rango/mini_spec.rb +58 -0
- data/spec/rango/project_spec.rb +1 -1
- data/spec/rango/templates/template_spec.rb +81 -0
- data/spec/rango/utils_spec.rb +33 -0
- data/spec/rango_spec.rb +3 -17
- data/spec/spec_helper.rb +5 -3
- data/spec/stubs/config.ru +5 -0
- data/spec/stubs/templates/capture.html.erb +1 -1
- data/spec/stubs/templates/erubis.html.erubis +2 -0
- data/spec/stubs/templates/inheritance/basic/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/basic/index.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/erb/base.html.erb +3 -0
- data/spec/stubs/templates/inheritance/capture/erb/index.html.erb +4 -0
- data/spec/stubs/templates/inheritance/capture/erubis/base.html.erubis +3 -0
- data/spec/stubs/templates/inheritance/capture/erubis/index.html.erubis +4 -0
- data/spec/stubs/templates/inheritance/capture/haml/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/haml/index.html.haml +3 -0
- data/spec/stubs/templates/test.html.haml +1 -0
- data/spec/stubs/templates/variables.html.haml +1 -0
- data/stubs/app/content/init.rb.rbt +2 -1
- data/stubs/app/content/views.rb.rbt +2 -0
- data/stubs/bigapp/content/views/%controller%.rb.rbt +2 -0
- data/stubs/project/content/config.ru.rbt +3 -0
- data/stubs/project/content/init.rb.rbt +11 -5
- data/stubs/project/content/settings.rb +0 -2
- data/stubs/project/content/settings_local.rb.rbt +1 -1
- data/stubs/project/content/templates/base.html.haml.rbt +1 -0
- metadata +42 -329
- data/examples/README.textile +0 -12
- data/examples/blog/Gemfile +0 -80
- data/examples/blog/Rakefile +0 -12
- data/examples/blog/TODO.txt +0 -0
- data/examples/blog/bin/autospec +0 -3
- data/examples/blog/bin/css2sass +0 -3
- data/examples/blog/bin/cucumber +0 -3
- data/examples/blog/bin/haml +0 -3
- data/examples/blog/bin/html2haml +0 -3
- data/examples/blog/bin/htmldiff +0 -3
- data/examples/blog/bin/launchy +0 -3
- data/examples/blog/bin/ldiff +0 -3
- data/examples/blog/bin/nokogiri +0 -3
- data/examples/blog/bin/racksh +0 -3
- data/examples/blog/bin/rackup +0 -3
- data/examples/blog/bin/rake +0 -3
- data/examples/blog/bin/rango +0 -3
- data/examples/blog/bin/sass +0 -3
- data/examples/blog/bin/shotgun +0 -3
- data/examples/blog/bin/simple-templater +0 -3
- data/examples/blog/bin/spec +0 -3
- data/examples/blog/bin/tt +0 -3
- data/examples/blog/blog/init.rb +0 -9
- data/examples/blog/blog/models.rb +0 -21
- data/examples/blog/blog/views.rb +0 -16
- data/examples/blog/config.ru +0 -19
- data/examples/blog/gems/cache/addressable-2.1.1.gem +0 -0
- data/examples/blog/gems/cache/builder-2.1.2.gem +0 -0
- data/examples/blog/gems/cache/bundler-0.7.0.gem +0 -0
- data/examples/blog/gems/cache/cli-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/configuration-1.1.0.gem +0 -0
- data/examples/blog/gems/cache/cucumber-0.4.4.gem +0 -0
- data/examples/blog/gems/cache/data_objects-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/diff-lcs-1.1.2.gem +0 -0
- data/examples/blog/gems/cache/dm-core-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/dm-timestamps-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/do_mysql-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/do_sqlite3-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/extlib-0.9.13.gem +0 -0
- data/examples/blog/gems/cache/fuzzyhash-0.0.9.gem +0 -0
- data/examples/blog/gems/cache/haml-2.2.14.gem +0 -0
- data/examples/blog/gems/cache/launchy-0.3.3.gem +0 -0
- data/examples/blog/gems/cache/media-path-0.1.gem +0 -0
- data/examples/blog/gems/cache/nokogiri-1.4.0.gem +0 -0
- data/examples/blog/gems/cache/polyglot-0.2.9.gem +0 -0
- data/examples/blog/gems/cache/rack-1.0.1.gem +0 -0
- data/examples/blog/gems/cache/rack-test-0.5.2.gem +0 -0
- data/examples/blog/gems/cache/racksh-0.9.4.2.gem +0 -0
- data/examples/blog/gems/cache/rake-0.8.7.gem +0 -0
- data/examples/blog/gems/cache/rango-0.1.0.gem +0 -0
- data/examples/blog/gems/cache/rspec-1.2.9.gem +0 -0
- data/examples/blog/gems/cache/rubyexts-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/shotgun-0.4.gem +0 -0
- data/examples/blog/gems/cache/simple-templater-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/examples/blog/gems/cache/treetop-1.4.2.gem +0 -0
- data/examples/blog/gems/cache/usher-0.5.11.gem +0 -0
- data/examples/blog/gems/cache/webrat-0.5.3.gem +0 -0
- data/examples/blog/init.rb +0 -49
- data/examples/blog/settings.rb +0 -15
- data/examples/blog/settings_local.rb +0 -6
- data/examples/blog/spec/blog/init_spec.rb +0 -7
- data/examples/blog/spec/blog/models_spec.rb +0 -28
- data/examples/blog/spec/blog/views_spec.rb +0 -22
- data/examples/blog/spec/spec.opts +0 -5
- data/examples/blog/spec/spec_helper.rb +0 -27
- data/examples/blog/templates/base.html.haml +0 -16
- data/examples/blog/templates/index.html.haml +0 -12
- data/lib/rango/boot.rb +0 -55
- data/lib/rango/helpers/README +0 -179
- data/lib/rango/helpers/merb-helpers.rb +0 -3
- data/lib/rango/helpers/merb-helpers/core_ext.rb +0 -58
- data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +0 -389
- data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +0 -146
- data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +0 -191
- data/lib/rango/helpers/merb-helpers/form/builder.rb +0 -450
- data/lib/rango/helpers/merb-helpers/form/helpers.rb +0 -453
- data/lib/rango/helpers/merb-helpers/form_helpers.rb +0 -21
- data/lib/rango/helpers/merb-helpers/tag_helpers.rb +0 -63
- data/lib/rango/helpers/merb-helpers/text_helpers.rb +0 -73
- data/lib/rango/loggers/logger.rb +0 -100
- data/lib/rango/mixins/chainable.rb +0 -68
- data/lib/rango/mixins/hookable.rb +0 -32
- data/lib/rango/mixins/import.rb +0 -89
- data/lib/rango/mixins/mini.rb +0 -29
- data/lib/rango/mixins/strategy.rb +0 -28
- data/lib/rango/rango.rb +0 -93
- data/lib/rango/router/specification.txt +0 -11
- data/lib/rango/templates/adapter.rb +0 -19
- data/lib/rango/templates/adapters/erb.rb +0 -63
- data/lib/rango/templates/adapters/erubis.rb +0 -65
- data/lib/rango/templates/adapters/haml.rb +0 -26
- data/lib/rango/templates/templates.txt +0 -39
- data/spec/factories.rb +0 -22
- data/spec/rango/boot_spec.rb +0 -15
- data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -21
- data/spec/rango/helpers/merb-helpers/date_time_formatting_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/date_time_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/application.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/custom_builder.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/delete_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/field_set.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/fields_for.rb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/foo.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form_for.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hacker.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/label.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/numeric_ext.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date_span.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/specs_controller.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/submit.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/tag_helper.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/helpers/global_helpers.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/fake_dm_model.rb +0 -27
- data/spec/rango/helpers/merb-helpers/fixture/app/models/first_generic_fake_model.rb +0 -59
- data/spec/rango/helpers/merb-helpers/fixture/app/models/hacker_generic_model.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/second_generic_fake_model.rb +0 -20
- data/spec/rango/helpers/merb-helpers/fixture/app/models/third_generic_fake_model.rb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/checked.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/errors.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/takes_string.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/with_label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/errors.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/grouped.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/nested.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_button_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/hashes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/mixed.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/override_id.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/multiple.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/prompt.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/disabled_button.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/simple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/to_string.html.erb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/unchecked.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/custom_builder_specs/everything.html.erb +0 -10
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/simple_delete.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/midstream.html.erb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/nil.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fieldset_specs/legend.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/makes_multipart.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_multipart_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_delete_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_put_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/get_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/post_by_default.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/resourceful_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/file_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/hidden_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/option_tag.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/password_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_button.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_group.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_area.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/two_digits.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/array.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/clean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/collection.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/multiple_selects.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/optgroups.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_prompt.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/unchecked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/hash.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/specific_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_today.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/multiple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/disabled_submit.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/nested_tags.html.erb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/nil.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/symbolized_name.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/development.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/production.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/test.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/init.rb +0 -48
- data/spec/rango/helpers/merb-helpers/fixture/config/rack.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/config/router.rb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/public/images/merb.jpg +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/public/merb.fcgi +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/public/stylesheets/master.css +0 -119
- data/spec/rango/helpers/merb-helpers/form/builder_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form/helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/merb_helpers_config_spec.rb +0 -85
- data/spec/rango/helpers/merb-helpers/merb_helpers_date_time_spec.rb +0 -270
- data/spec/rango/helpers/merb-helpers/merb_helpers_form_spec.rb +0 -1372
- data/spec/rango/helpers/merb-helpers/merb_helpers_tag_helper_spec.rb +0 -46
- data/spec/rango/helpers/merb-helpers/merb_helpers_text_spec.rb +0 -71
- data/spec/rango/helpers/merb-helpers/numeric_extlib_spec.rb +0 -138
- data/spec/rango/helpers/merb-helpers/ordinalize_spec.rb +0 -55
- data/spec/rango/helpers/merb-helpers/tag_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
- data/spec/rango/mixins/chainable_spec.rb +0 -0
- data/spec/rango/mixins/hookable_spec.rb +0 -0
- data/spec/rango/mixins/import_spec.rb +0 -0
- data/spec/rango/mixins/mini_spec.rb +0 -0
- data/spec/rango/mixins/strategy_spec.rb +0 -0
- data/spec/rango/rango_spec.rb +0 -0
- data/spec/rango/templates/adapter_spec.rb +0 -0
- data/spec/rango/templates/adapters/erb_spec.rb +0 -0
- data/spec/rango/templates/adapters/erubis_spec.rb +0 -117
- data/spec/rango/templates/adapters/haml_spec.rb +0 -0
- data/spec/rango/templates/adapters/template_helpers.rb +0 -38
data/CHANGELOG
CHANGED
data/CONTRIBUTORS
CHANGED
data/README.textile
CHANGED
@@ -2,6 +2,7 @@ h1. Installation via RubyGems
|
|
2
2
|
|
3
3
|
* Daily builds: @gem install rango --pre@ _(Daily builds currently doesn't work, I'm going to fix it till end of this week.)_
|
4
4
|
* Stable version: @gem install rango@
|
5
|
+
* JRuby: @jruby --1.9 -S gem install rango@
|
5
6
|
|
6
7
|
_We were using option @--development@ for installing development dependencies, unfortunately Rack has Mongrel as a development dependency and Mongrel compilation fails on Ruby 1.9, so I put everything into normal dependencies for now._
|
7
8
|
|
@@ -14,12 +15,14 @@ h1. Documentation
|
|
14
15
|
|
15
16
|
* "Wiki":http://wiki.github.com/botanicus/rango
|
16
17
|
* "Tutorial":http://wiki.github.com/botanicus/rango/tutorial
|
17
|
-
* "API Docs":http://rdoc.info/projects/botanicus/rango
|
18
|
+
* "RDoc.info API Docs":http://rdoc.info/projects/botanicus/rango
|
19
|
+
* "Yardoc.org API Docs":http://yardoc.org/docs/botanicus-rango
|
18
20
|
* "Examples":http://github.com/botanicus/rango-examples
|
19
21
|
* "Bug reporting":http://github.com/botanicus/rango/issues
|
20
22
|
|
21
23
|
h1. Community
|
22
24
|
|
25
|
+
* "Google Group":http://groups.google.com/group/rango-project
|
23
26
|
* "Rango Blog":http://botanicus.github.com/rango
|
24
27
|
* "Twitter":https://twitter.com/RangoProject
|
25
28
|
* IRC: #rango at irc://irc.freenode.net
|
data/bin/rango
CHANGED
data/lib/rango.rb
CHANGED
@@ -3,32 +3,98 @@
|
|
3
3
|
require "ostruct"
|
4
4
|
require "uri"
|
5
5
|
require "media-path"
|
6
|
-
require "rubyexts"
|
6
|
+
require "rubyexts/logger"
|
7
|
+
require "rango/mixins/application"
|
7
8
|
|
8
9
|
rango_lib = File.dirname(__FILE__)
|
9
10
|
unless $:.include?(rango_lib) || $:.include?(File.expand_path(rango_lib))
|
10
11
|
$:.unshift(rango_lib)
|
11
12
|
end
|
12
13
|
|
14
|
+
if RUBY_VERSION < "1.9.1"
|
15
|
+
raise "Rango requires at least Ruby 1.9.1. If you run JRuby, please ensure you used the --1.9 switch for JRuby command, for example jruby --1.9 -S rango create project blog"
|
16
|
+
end
|
17
|
+
|
13
18
|
# It should solve problems with encoding in URL (flash messages) and templates
|
14
19
|
Encoding.default_internal = "utf-8"
|
15
20
|
|
16
|
-
require_relative "rango/mixins/import"
|
17
|
-
require_relative "rango/mixins/application"
|
18
|
-
|
19
21
|
module Rango
|
20
|
-
VERSION ||= "0.1.
|
21
|
-
extend ImportMixin
|
22
|
+
VERSION ||= "0.1.1"
|
22
23
|
extend ApplicationMixin
|
23
24
|
|
24
25
|
def self.root
|
25
26
|
File.join(File.dirname(__FILE__), "rango")
|
26
27
|
end
|
27
|
-
|
28
|
-
# realoder
|
29
|
-
# require "rango/reloader"
|
30
|
-
# cattr_reader :reloader
|
31
|
-
# @@reloader = Rango::Reloader.new
|
32
28
|
end
|
33
29
|
|
34
|
-
|
30
|
+
require "rango/project"
|
31
|
+
|
32
|
+
module Rango
|
33
|
+
# all the helpers are in Rango::Helpers
|
34
|
+
# so if you want to register your own, just
|
35
|
+
# Rango::Helpers.send(:include, Pupu::Helpers)
|
36
|
+
Helpers ||= Module.new
|
37
|
+
|
38
|
+
class << self
|
39
|
+
# @since 0.0.2
|
40
|
+
# @example
|
41
|
+
# Rango.path
|
42
|
+
# # => /usr/lib/ruby/lib/ruby/site_ruby/1.8/rango
|
43
|
+
# @return [Path] Rango root path
|
44
|
+
def path
|
45
|
+
@path ||= MediaPath.new(self.root)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @since 0.0.1
|
49
|
+
# @example
|
50
|
+
# Rango.root
|
51
|
+
# # => /usr/lib/ruby/lib/ruby/site_ruby/1.8/rango
|
52
|
+
# @return [RubyExts::Logger] Logger for logging framework-related stuff. For logging project-relating stuff please use Project.logger.
|
53
|
+
# @see Project::logger
|
54
|
+
def logger
|
55
|
+
@logger ||= RubyExts::Logger.new
|
56
|
+
end
|
57
|
+
|
58
|
+
# @since 0.0.1
|
59
|
+
# @example
|
60
|
+
# Rango.boot # require init.rb
|
61
|
+
# Rango.boot { require_relative "config/init.rb" } # custom boot
|
62
|
+
# @param [Hash] options You can specify flat: true for sinatra-like flat application.
|
63
|
+
# @return [Boolean] Returns true if boot succeed or false if not. If ARGV includes "-i", IRB interactive session will start.
|
64
|
+
def boot(options = Hash.new, &block)
|
65
|
+
self.environment = options[:environment] if options[:environment]
|
66
|
+
block.call if block_given?
|
67
|
+
self.bootloaders.each do |name, bootloader|
|
68
|
+
logger.debug "Calling bootloader #{name}"
|
69
|
+
bootloader.call
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# @since 0.0.2
|
74
|
+
def reboot(options = Hash.new)
|
75
|
+
self.boot(options.merge(force: true))
|
76
|
+
end
|
77
|
+
|
78
|
+
attribute :bootloaders, Hash.new
|
79
|
+
def after_boot(name, &block)
|
80
|
+
self.bootloaders[name] = block
|
81
|
+
end
|
82
|
+
|
83
|
+
# Start IRB interactive session
|
84
|
+
# @since 0.0.1
|
85
|
+
def interactive
|
86
|
+
require "rango/utils"
|
87
|
+
require "rubyexts"
|
88
|
+
ARGV.delete("-i") # otherwise irb will read it
|
89
|
+
ENV["RACK_ENV"] = Rango.environment # for racksh
|
90
|
+
unless try_require("racksh/boot")
|
91
|
+
Rango.logger.info("For more goodies install racksh gem")
|
92
|
+
try_require "irb/completion" # some people can have ruby compliled without readline
|
93
|
+
Rango::Utils.load_rackup # so you can use Project.router etc
|
94
|
+
end
|
95
|
+
require "irb"
|
96
|
+
require "rango/utils"
|
97
|
+
IRB.start
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/rango/controller.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
# http://wiki.github.com/botanicus/rango/controllers
|
4
|
+
|
3
5
|
require "rango/mixins/render"
|
4
|
-
require "rango/
|
6
|
+
require "rango/exceptions"
|
7
|
+
require "rango/project"
|
8
|
+
require "rango/rack/request"
|
9
|
+
require "rango/router"
|
10
|
+
require "rango/templates/template"
|
5
11
|
|
6
12
|
module Rango
|
7
13
|
class Controller
|
8
14
|
include Rango::Helpers
|
9
15
|
include Rango::RenderMixin
|
10
|
-
include Rango::Templates::TemplateHelpers
|
11
16
|
|
12
17
|
class << self
|
13
18
|
# @since 0.0.2
|
@@ -50,11 +55,11 @@ module Rango
|
|
50
55
|
# [master] Change Merb::Controller to respond to #call and return a Rack Array. (wycats)http://rubyurl.com/BhoY
|
51
56
|
# @since 0.0.2
|
52
57
|
def call(env)
|
53
|
-
Rango::Router.
|
58
|
+
Rango::Router.set_rack_env(env) # See rango/router/adapters/*
|
54
59
|
request = Rango::Request.new(env)
|
55
60
|
options = env["rango.router.params"] || raise("rango.router.params property has to be setup at least to empty hash")
|
56
61
|
method = env["rango.controller.action"].to_sym
|
57
|
-
controller = self.new(
|
62
|
+
controller = self.new(env, options.merge(request.params))
|
58
63
|
begin
|
59
64
|
unless controller.respond_to?(method) # TODO: what about method_missing?
|
60
65
|
raise NotFound, "Controller #{self.name} doesn't have method #{method}"
|
@@ -100,12 +105,52 @@ module Rango
|
|
100
105
|
end
|
101
106
|
end
|
102
107
|
|
103
|
-
|
104
|
-
|
108
|
+
# @since 0.0.1
|
109
|
+
# @return [RubyExts::Logger] Logger for logging project related stuff.
|
110
|
+
# @see RubyExts::Logger
|
111
|
+
attribute :logger, Project.logger
|
112
|
+
attribute :status
|
113
|
+
attribute :headers, Hash.new
|
114
|
+
|
115
|
+
# @since 0.0.1
|
116
|
+
# @return [Rango::Request]
|
117
|
+
# @see Rango::Request
|
118
|
+
attr_accessor :request, :params, :cookies, :response
|
119
|
+
# @since 0.0.1
|
120
|
+
# @return [Hash] Hash with params from request. For example <code>{messages: {success: "You're logged in"}, post: {id: 2}}</code>
|
121
|
+
attr_accessor :params
|
122
|
+
|
123
|
+
# The rails-style flash messages
|
124
|
+
# @since 0.0.2
|
125
|
+
def message
|
126
|
+
@message ||= (request.GET[:msg] || Hash.new)
|
127
|
+
end
|
128
|
+
|
129
|
+
def render(template, locals = Hash.new)
|
130
|
+
super template, self.locals.merge!(locals)
|
131
|
+
end
|
132
|
+
|
133
|
+
# @since 0.0.2
|
134
|
+
def redirect(url, options = Hash.new)
|
135
|
+
self.status = 302
|
136
|
+
|
137
|
+
# for example ?msg[error]=foo
|
138
|
+
[:error, :success, :notice].each do |type|
|
139
|
+
if msg = (options[type] || message[type])
|
140
|
+
url.concat("?msg[#{type}]=#{msg}")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
self.headers["Location"] = URI.escape(url)
|
145
|
+
return String.new
|
146
|
+
end
|
147
|
+
|
148
|
+
def initialize(env, params = Hash.new)
|
149
|
+
@request = Rango::Request.new(env)
|
105
150
|
@response = Rack::Response.new
|
106
|
-
@params
|
107
|
-
@cookies
|
108
|
-
@session
|
151
|
+
@params = params
|
152
|
+
@cookies = request.cookies
|
153
|
+
@session = request.session
|
109
154
|
Rango.logger.inspect(params: params, cookies: cookies, session: session)
|
110
155
|
end
|
111
156
|
attr_reader :session
|
@@ -119,11 +164,12 @@ module Rango
|
|
119
164
|
# if you need to change just body of error message, define render_http_error method
|
120
165
|
# @api plugin
|
121
166
|
def rescue_http_error(exception)
|
167
|
+
status, headers, body = exception.to_response
|
122
168
|
if self.respond_to?(:render_http_error)
|
123
|
-
|
124
|
-
|
169
|
+
[status, headers, self.render_http_error(exception)]
|
170
|
+
else
|
171
|
+
[status, headers, body]
|
125
172
|
end
|
126
|
-
exception.to_response
|
127
173
|
end
|
128
174
|
|
129
175
|
# @since 0.0.2
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# http://wiki.github.com/botanicus/rango/environments-support
|
4
|
+
|
5
|
+
require "rubyexts/attribute"
|
6
|
+
|
7
|
+
module Rango
|
8
|
+
class << self
|
9
|
+
# @since 0.0.1
|
10
|
+
# @return [String] Returns current environment name.
|
11
|
+
attribute :environment, "development"
|
12
|
+
|
13
|
+
# clever environments support
|
14
|
+
attribute :development_environments, ["development"]
|
15
|
+
attribute :testing_environments, ["test", "spec", "cucumber"]
|
16
|
+
attribute :production_environments, ["stage", "production"]
|
17
|
+
|
18
|
+
questionable(:testing) { self.testing_environments.include?(Rango.environment) }
|
19
|
+
questionable(:development) { self.development_environments.include?(Rango.environment) }
|
20
|
+
questionable(:production) { self.production_environments.include?(Rango.environment) }
|
21
|
+
|
22
|
+
def environment?(environment)
|
23
|
+
self.environment.eql?(environment.to_s)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/rango/exceptions.rb
CHANGED
@@ -1,21 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class TemplateNotFound < StandardError # TODO: should inherit from NotFound
|
6
|
-
# @since 0.0.2
|
7
|
-
attr_accessor :message
|
8
|
-
|
9
|
-
# @since 0.0.2
|
10
|
-
def initialize(template, locations)
|
11
|
-
self.message = "Template '#{template}' wasn't found in any of these locations: #{locations.join(", ")}."
|
12
|
-
end
|
13
|
-
end
|
3
|
+
# http://wiki.github.com/botanicus/rango/errors-handling
|
14
4
|
|
15
5
|
# superclass of all the controller exceptions
|
16
6
|
module Rango
|
17
7
|
class HttpError < StandardError
|
18
|
-
CONTENT_TYPE ||= "text/
|
8
|
+
CONTENT_TYPE ||= "text/html"
|
19
9
|
|
20
10
|
attr_accessor :content_type, :headers
|
21
11
|
def initialize(*args)
|
@@ -88,8 +78,6 @@ module Rango
|
|
88
78
|
Error403 = Forbidden = Class.new(Rango::ClientError) { STATUS ||= 403 }
|
89
79
|
Error404 = NotFound = Class.new(Rango::ClientError) { STATUS ||= 404 }
|
90
80
|
ActionNotFound = Class.new(Rango::NotFound)
|
91
|
-
TemplateNotFound = Class.new(Rango::NotFound)
|
92
|
-
LayoutNotFound = Class.new(Rango::NotFound)
|
93
81
|
Error405 = MethodNotAllowed = Class.new(Rango::ClientError) { STATUS ||= 405 }
|
94
82
|
Error406 = NotAcceptable = Class.new(Rango::ClientError) { STATUS ||= 406 }
|
95
83
|
Error407 = ProxyAuthenticationRequired = Class.new(Rango::ClientError) { STATUS ||= 407 }
|
data/lib/rango/gv.rb
CHANGED
@@ -1,98 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
# what about filters?
|
7
|
-
# - include to controller or use directly (include Rango::GV, but what if I want to include just for example static gv?)
|
8
|
-
# - or Rango::GV.extend FiltersMixin
|
3
|
+
# Generic Views
|
4
|
+
# Use directly or include into a controller if you want to use filters or customize them
|
5
|
+
# http://wiki.github.com/botanicus/rango/generic-views
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
7
|
+
require "rango/mini"
|
8
|
+
require "rango/router"
|
9
|
+
require "rango/mixins/render"
|
14
10
|
|
15
11
|
module Rango
|
16
12
|
module GV
|
17
|
-
|
18
|
-
include Rango::Helpers
|
19
|
-
include Rango::RenderMixin
|
20
|
-
attr_reader :name, :definition
|
21
|
-
attr_accessor :args, :custom_block # we can't use just block because of block(:head)
|
22
|
-
attr_accessor :env, :request, :response
|
23
|
-
def initialize(name, &definition)
|
24
|
-
@name, @definition = name, definition
|
25
|
-
end
|
26
|
-
|
27
|
-
def setup(*args, &custom_block)
|
28
|
-
self.args = args
|
29
|
-
self.custom_block = custom_block
|
30
|
-
end
|
31
|
-
|
32
|
-
def call(env)
|
33
|
-
Rango::Router.new.set_rack_env(env) # so env["usher.params"] => env["rango.router.params"]
|
34
|
-
self.request = Rango::Request.new(env)
|
35
|
-
self.response = Rack::Response.new
|
36
|
-
self.env = env
|
37
|
-
|
38
|
-
# Welcome to Ruby 1.9 world! instance_exec is the same as instance_eval,
|
39
|
-
# but it can takes arguments for the custom_block
|
40
|
-
args = [*self.args, self.custom_block]
|
41
|
-
Rango.logger.debug("Calling generic view #{self.name} with #{args.inspect}")
|
42
|
-
body = self.instance_exec(*args, &self.definition)
|
43
|
-
|
44
|
-
# TODO: check how rack test if object is stringable, probably not this way
|
45
|
-
raise ArgumentError unless body.respond_to?(:each) || body.is_a?(String)
|
46
|
-
response.write(body)
|
47
|
-
response.finish
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.define(action, &definition)
|
52
|
-
# instance method for including
|
53
|
-
define_method(action, &definition)
|
54
|
-
|
55
|
-
# class method for direct usage
|
56
|
-
# TODO: clean this mess before someone start vomit
|
57
|
-
@@view = View.new(action, &definition)
|
58
|
-
module_eval <<-RUBY, __FILE__, __LINE__
|
59
|
-
def self.#{action}(*args, &block)
|
60
|
-
view = @@view.dup
|
61
|
-
view.setup(*args, &block)
|
62
|
-
view # has #call
|
63
|
-
end
|
64
|
-
RUBY
|
65
|
-
end
|
13
|
+
extend Rango::RenderMixin
|
66
14
|
end
|
67
15
|
end
|
68
|
-
|
69
|
-
# require params[:path]
|
70
|
-
# @example
|
71
|
-
# Usher::Interface.for(:rack) do
|
72
|
-
# get("/").to(Rango::GV.static("index"))
|
73
|
-
# get("/:template").to(::Static.dispatcher(:show)).name(:static)
|
74
|
-
# get("/:template").to(Rango::GenericViews.dispatcher(:static)).name(:static)
|
75
|
-
# get("/:template").to do |env|
|
76
|
-
# env["rango.params"][:template] # transform
|
77
|
-
# Rango::GV.static
|
78
|
-
# end
|
79
|
-
# end
|
80
|
-
|
81
|
-
# THE MAIN PROBLEM IS THIS CAN'T WORK WITH BLOCKS
|
82
|
-
# BECAUSE OF instance_exec(*args, &block, &definition) will cause syntax error in Ruby
|
83
|
-
|
84
|
-
###############
|
85
|
-
# This might be the best solution:
|
86
|
-
#Rango::GV.define(:static) do |view, template = nil, &block|
|
87
|
-
#end
|
88
|
-
|
89
|
-
# implementation: just definition.call(self, *self.args, &self.block)
|
90
|
-
###############
|
91
|
-
|
92
|
-
Rango::GV.define(:static) do |hook = nil|
|
93
|
-
require "rango/helpers" # for javascripts etc helpers
|
94
|
-
path = env["rango.router.params"][:template]
|
95
|
-
path = hook.call(path) unless hook.nil?
|
96
|
-
Rango.logger.debug("Rendering '#{path}'")
|
97
|
-
render path
|
98
|
-
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "rango/gv"
|
4
|
+
|
5
|
+
module Rango
|
6
|
+
module GV
|
7
|
+
def self.static(template, locals = nil, &hook)
|
8
|
+
Rango::Mini.app do |request, response|
|
9
|
+
path = template || request.env["rango.router.params"][:template]
|
10
|
+
path = hook.call(path) unless hook.nil?
|
11
|
+
path = "#{path}.html" unless path.match(/\./)
|
12
|
+
Rango.logger.debug("Rendering '#{path}'")
|
13
|
+
# Rango::RenderMixin.context
|
14
|
+
locals = locals.call(request) if locals.respond_to?(:call) # lambda { |request| {msg: request.message} }
|
15
|
+
render path, locals
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# you would usually define module Static with instance method static for
|
20
|
+
# including into controllers, but since controllers have render, it would be useless
|
21
|
+
end
|
22
|
+
end
|