rango 0.2.3 → 0.2.4.1
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/.gitignore +2 -2
- data/CHANGELOG +9 -0
- data/CONTRIBUTORS +0 -1
- data/Gemfile +2 -6
- data/lib/rango.rb +10 -7
- data/lib/rango/cli.rb +1 -1
- data/lib/rango/contrib/pagination/adapters/sequel.rb +6 -2
- data/lib/rango/controller.rb +24 -20
- data/lib/rango/core_ext.rb +54 -59
- data/lib/rango/exceptions.rb +2 -2
- data/lib/rango/gv/router.rb +1 -1
- data/lib/rango/gv/scaffolding.rb +0 -1
- data/lib/rango/mailer.rb +20 -40
- data/lib/rango/mixins/action_args.rb +8 -7
- data/lib/rango/mixins/filters.rb +1 -0
- data/lib/rango/mixins/message.rb +37 -33
- data/lib/rango/mixins/rack-flash.rb +44 -0
- data/{benchmarks/stubs/merb-app/spec/spec.opts → lib/rango/orm/tasks/ripple.nake} +0 -0
- data/lib/rango/rack/request.rb +12 -15
- data/lib/rango/router.rb +7 -3
- data/lib/rango/router/adapters/crudtree.rb +8 -1
- data/lib/rango/router/adapters/rack_mount.rb +5 -1
- data/lib/rango/router/adapters/usher.rb +5 -2
- data/lib/rango/stacks/controller.rb +0 -1
- data/lib/rango/templates/exts/haml.rb +14 -15
- data/lib/rango/templates/exts/tilt.rb +16 -23
- data/lib/rango/templates/helpers.rb +10 -1
- data/lib/rango/templates/template.rb +4 -4
- data/lib/rango/utils.rb +4 -2
- data/lib/rango/version.rb +5 -0
- data/rango.gemspec +3 -2
- data/{benchmarks/stubs/merb-core/spec/spec.opts → spec/rango/cli_spec.rb} +0 -0
- data/{benchmarks/stubs/rails/log/development.log → spec/rango/contrib/pagination/adapters/sequel_spec.rb} +0 -0
- data/spec/rango/controller_spec.rb +12 -0
- data/spec/rango/core_ext_spec.rb +61 -0
- data/spec/rango/environments_spec.rb +1 -0
- data/spec/rango/exceptions_spec.rb +1 -28
- data/{benchmarks/stubs/rails/log/production.log → spec/rango/mailer_spec.rb} +0 -0
- data/spec/rango/mixins/action_args_spec.rb +0 -4
- data/spec/rango/mixins/message_spec.rb +20 -10
- data/{benchmarks/stubs/rails/log/server.log → spec/rango/mixins/rack-flash_spec.rb} +0 -0
- data/spec/rango/rack/request_spec.rb +11 -0
- data/{benchmarks/stubs/rails/log/test.log → spec/rango/router/adapters/crudtree_spec.rb} +0 -0
- data/spec/rango/templates/helpers_spec.rb +19 -5
- data/spec/rango/templates/template_spec.rb +1 -20
- data/{benchmarks/stubs/rails/public/favicon.ico → spec/rango/version_spec.rb} +0 -0
- data/spec/spec_helper.rb +18 -4
- data/stubs/stack/content/%name%.gemspec.rbt +0 -0
- data/stubs/stack/content/%name%.pre.gemspec.rbt +1 -2
- data/stubs/stack/content/.gitignore +2 -5
- data/stubs/stack/content/Gemfile.rbt +23 -46
- data/stubs/stack/content/config.ru.rbt +9 -21
- data/stubs/stack/content/init.rb.rbt +10 -10
- data/stubs/stack/content/lib/%name%.rb.rbt +37 -4
- data/stubs/stack/content/lib/%name%/initializers/01_database.rb.rbt +16 -0
- data/stubs/stack/content/lib/%name%/initializers/05_templates.rb.rbt +13 -0
- data/stubs/stack/content/lib/%name%/initializers/10_pagination.rb.rbt +8 -0
- data/stubs/stack/content/lib/%name%/initializers/15_warden.rb.rbt +26 -0
- data/stubs/stack/content/lib/%name%/initializers/45_middlewares.rb.rbt +17 -0
- data/stubs/stack/content/lib/%name%/initializers/50_router.rb.rbt +7 -0
- data/stubs/stack/content/lib/%name%/{initializers/urls.rb.rbt → urls.rb.rbt} +3 -0
- data/stubs/stack/content/lib/%name%/views.rb.rbt +4 -1
- data/stubs/stack/content/templates/index.html.haml +1 -1
- data/{gems → vendor}/cache/abstract-1.0.0.gem +0 -0
- data/vendor/cache/code-cleaner-0.8.2.gem +0 -0
- data/{gems → vendor}/cache/erubis-2.6.5.gem +0 -0
- data/vendor/cache/haml-2.2.21.gem +0 -0
- data/{gems → vendor}/cache/nake-0.0.8.gem +0 -0
- data/vendor/cache/rack-1.1.0.gem +0 -0
- data/{gems → vendor}/cache/rspec-1.3.0.gem +0 -0
- data/vendor/cache/term-ansicolor-1.0.5.gem +0 -0
- data/vendor/cache/tilt-0.8.gem +0 -0
- metadata +63 -239
- data/benchmarks/stubs/merb-app/.gitignore +0 -21
- data/benchmarks/stubs/merb-app/Rakefile +0 -35
- data/benchmarks/stubs/merb-app/app/controllers/application.rb +0 -4
- data/benchmarks/stubs/merb-app/app/controllers/exceptions.rb +0 -15
- data/benchmarks/stubs/merb-app/app/helpers/global_helpers.rb +0 -7
- data/benchmarks/stubs/merb-app/app/models/user.rb +0 -19
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_acceptable.html.erb +0 -63
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_found.html.erb +0 -47
- data/benchmarks/stubs/merb-app/app/views/layout/application.html.erb +0 -12
- data/benchmarks/stubs/merb-app/autotest/discover.rb +0 -4
- data/benchmarks/stubs/merb-app/autotest/merb.rb +0 -154
- data/benchmarks/stubs/merb-app/autotest/merb_rspec.rb +0 -167
- data/benchmarks/stubs/merb-app/config/database.yml +0 -33
- data/benchmarks/stubs/merb-app/config/dependencies.rb +0 -36
- data/benchmarks/stubs/merb-app/config/environments/development.rb +0 -17
- data/benchmarks/stubs/merb-app/config/environments/production.rb +0 -12
- data/benchmarks/stubs/merb-app/config/environments/rake.rb +0 -13
- data/benchmarks/stubs/merb-app/config/environments/staging.rb +0 -12
- data/benchmarks/stubs/merb-app/config/environments/test.rb +0 -14
- data/benchmarks/stubs/merb-app/config/init.rb +0 -26
- data/benchmarks/stubs/merb-app/config/rack.rb +0 -13
- data/benchmarks/stubs/merb-app/config/router.rb +0 -46
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/merb_generator.rb +0 -1364
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/api_grease.js +0 -640
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/index.html.erb +0 -37
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.css +0 -252
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.rb +0 -353
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb_doc_styles.css +0 -492
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/prototype.js +0 -2515
- data/benchmarks/stubs/merb-app/merb/merb-auth/setup.rb +0 -46
- data/benchmarks/stubs/merb-app/merb/merb-auth/strategies.rb +0 -13
- data/benchmarks/stubs/merb-app/merb/session/session.rb +0 -11
- data/benchmarks/stubs/merb-app/public/.htaccess +0 -17
- data/benchmarks/stubs/merb-app/public/favicon.ico +0 -0
- data/benchmarks/stubs/merb-app/public/images/merb.jpg +0 -0
- data/benchmarks/stubs/merb-app/public/javascripts/application.js +0 -1
- data/benchmarks/stubs/merb-app/public/javascripts/jquery.js +0 -19
- data/benchmarks/stubs/merb-app/public/merb.fcgi +0 -22
- data/benchmarks/stubs/merb-app/public/robots.txt +0 -5
- data/benchmarks/stubs/merb-app/public/stylesheets/master.css +0 -119
- data/benchmarks/stubs/merb-app/spec/spec_helper.rb +0 -27
- data/benchmarks/stubs/merb-app/tasks/doc.thor +0 -151
- data/benchmarks/stubs/merb-app/tasks/merb.thor/app_script.rb +0 -33
- data/benchmarks/stubs/merb-app/tasks/merb.thor/common.rb +0 -70
- data/benchmarks/stubs/merb-app/tasks/merb.thor/gem_ext.rb +0 -127
- data/benchmarks/stubs/merb-app/tasks/merb.thor/main.thor +0 -152
- data/benchmarks/stubs/merb-app/tasks/merb.thor/ops.rb +0 -95
- data/benchmarks/stubs/merb-app/tasks/merb.thor/utils.rb +0 -42
- data/benchmarks/stubs/merb-core/.gitignore +0 -21
- data/benchmarks/stubs/merb-core/Rakefile +0 -35
- data/benchmarks/stubs/merb-core/app/controllers/application.rb +0 -4
- data/benchmarks/stubs/merb-core/app/controllers/exceptions.rb +0 -15
- data/benchmarks/stubs/merb-core/app/helpers/global_helpers.rb +0 -7
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_acceptable.html.erb +0 -63
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_found.html.erb +0 -47
- data/benchmarks/stubs/merb-core/app/views/layout/application.html.erb +0 -12
- data/benchmarks/stubs/merb-core/autotest/discover.rb +0 -1
- data/benchmarks/stubs/merb-core/autotest/merb.rb +0 -151
- data/benchmarks/stubs/merb-core/autotest/merb_rspec.rb +0 -167
- data/benchmarks/stubs/merb-core/config/environments/development.rb +0 -17
- data/benchmarks/stubs/merb-core/config/environments/production.rb +0 -12
- data/benchmarks/stubs/merb-core/config/environments/rake.rb +0 -13
- data/benchmarks/stubs/merb-core/config/environments/staging.rb +0 -12
- data/benchmarks/stubs/merb-core/config/environments/test.rb +0 -14
- data/benchmarks/stubs/merb-core/config/init.rb +0 -27
- data/benchmarks/stubs/merb-core/config/rack.rb +0 -13
- data/benchmarks/stubs/merb-core/config/router.rb +0 -43
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/merb_generator.rb +0 -1364
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/api_grease.js +0 -640
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/index.html.erb +0 -37
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.css +0 -252
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.rb +0 -353
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb_doc_styles.css +0 -492
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/prototype.js +0 -2515
- data/benchmarks/stubs/merb-core/public/.htaccess +0 -17
- data/benchmarks/stubs/merb-core/public/favicon.ico +0 -0
- data/benchmarks/stubs/merb-core/public/images/merb.jpg +0 -0
- data/benchmarks/stubs/merb-core/public/javascripts/application.js +0 -1
- data/benchmarks/stubs/merb-core/public/merb.fcgi +0 -22
- data/benchmarks/stubs/merb-core/public/robots.txt +0 -5
- data/benchmarks/stubs/merb-core/public/stylesheets/master.css +0 -119
- data/benchmarks/stubs/merb-core/spec/spec_helper.rb +0 -22
- data/benchmarks/stubs/merb-core/tasks/merb.thor/app_script.rb +0 -33
- data/benchmarks/stubs/merb-core/tasks/merb.thor/common.rb +0 -70
- data/benchmarks/stubs/merb-core/tasks/merb.thor/gem_ext.rb +0 -127
- data/benchmarks/stubs/merb-core/tasks/merb.thor/main.thor +0 -152
- data/benchmarks/stubs/merb-core/tasks/merb.thor/ops.rb +0 -95
- data/benchmarks/stubs/merb-core/tasks/merb.thor/utils.rb +0 -42
- data/benchmarks/stubs/merb-flat/.gitignore +0 -21
- data/benchmarks/stubs/merb-flat/README.txt +0 -10
- data/benchmarks/stubs/merb-flat/Rakefile +0 -35
- data/benchmarks/stubs/merb-flat/application.rb +0 -17
- data/benchmarks/stubs/merb-flat/config/framework.rb +0 -9
- data/benchmarks/stubs/merb-flat/config/init.rb +0 -42
- data/benchmarks/stubs/merb-flat/spec/spec_helper.rb +0 -26
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/app_script.rb +0 -33
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/common.rb +0 -70
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/gem_ext.rb +0 -127
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/main.thor +0 -152
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/ops.rb +0 -95
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/utils.rb +0 -42
- data/benchmarks/stubs/merb-flat/views/foo.html.erb +0 -3
- data/benchmarks/stubs/merb-very-flat/.gitignore +0 -21
- data/benchmarks/stubs/merb-very-flat/Rakefile +0 -35
- data/benchmarks/stubs/merb-very-flat/merb-very-flat.rb +0 -61
- data/benchmarks/stubs/merb-very-flat/spec/spec_helper.rb +0 -26
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/app_script.rb +0 -33
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/common.rb +0 -70
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/gem_ext.rb +0 -127
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/main.thor +0 -152
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/ops.rb +0 -95
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/utils.rb +0 -42
- data/benchmarks/stubs/rails/README +0 -243
- data/benchmarks/stubs/rails/Rakefile +0 -10
- data/benchmarks/stubs/rails/app/controllers/application_controller.rb +0 -12
- data/benchmarks/stubs/rails/app/helpers/application_helper.rb +0 -5
- data/benchmarks/stubs/rails/config/boot.rb +0 -112
- data/benchmarks/stubs/rails/config/database.yml +0 -22
- data/benchmarks/stubs/rails/config/environment.rb +0 -43
- data/benchmarks/stubs/rails/config/environments/development.rb +0 -19
- data/benchmarks/stubs/rails/config/environments/production.rb +0 -30
- data/benchmarks/stubs/rails/config/environments/test.rb +0 -30
- data/benchmarks/stubs/rails/config/initializers/backtrace_silencers.rb +0 -9
- data/benchmarks/stubs/rails/config/initializers/inflections.rb +0 -12
- data/benchmarks/stubs/rails/config/initializers/mime_types.rb +0 -7
- data/benchmarks/stubs/rails/config/initializers/new_rails_defaults.rb +0 -21
- data/benchmarks/stubs/rails/config/initializers/session_store.rb +0 -17
- data/benchmarks/stubs/rails/config/locales/en.yml +0 -5
- data/benchmarks/stubs/rails/config/routes.rb +0 -45
- data/benchmarks/stubs/rails/doc/README_FOR_APP +0 -2
- data/benchmarks/stubs/rails/public/404.html +0 -30
- data/benchmarks/stubs/rails/public/422.html +0 -30
- data/benchmarks/stubs/rails/public/500.html +0 -30
- data/benchmarks/stubs/rails/public/images/rails.png +0 -0
- data/benchmarks/stubs/rails/public/index.html +0 -275
- data/benchmarks/stubs/rails/public/javascripts/application.js +0 -2
- data/benchmarks/stubs/rails/public/javascripts/controls.js +0 -963
- data/benchmarks/stubs/rails/public/javascripts/dragdrop.js +0 -973
- data/benchmarks/stubs/rails/public/javascripts/effects.js +0 -1128
- data/benchmarks/stubs/rails/public/javascripts/prototype.js +0 -4320
- data/benchmarks/stubs/rails/public/robots.txt +0 -5
- data/benchmarks/stubs/rails/script/about +0 -4
- data/benchmarks/stubs/rails/script/console +0 -3
- data/benchmarks/stubs/rails/script/dbconsole +0 -3
- data/benchmarks/stubs/rails/script/destroy +0 -3
- data/benchmarks/stubs/rails/script/generate +0 -3
- data/benchmarks/stubs/rails/script/performance/benchmarker +0 -3
- data/benchmarks/stubs/rails/script/performance/profiler +0 -3
- data/benchmarks/stubs/rails/script/plugin +0 -3
- data/benchmarks/stubs/rails/script/runner +0 -3
- data/benchmarks/stubs/rails/script/server +0 -3
- data/benchmarks/stubs/rails/test/performance/browsing_test.rb +0 -11
- data/benchmarks/stubs/rails/test/test_helper.rb +0 -40
- data/benchmarks/stubs/ramaze.rb +0 -0
- data/benchmarks/stubs/sinatra.rb +0 -11
- data/gems/cache/code-cleaner-0.1.gem +0 -0
- data/gems/cache/code-cleaner-0.2.gem +0 -0
- data/gems/cache/code-cleaner-0.3.gem +0 -0
- data/gems/cache/code-cleaner-0.4.gem +0 -0
- data/gems/cache/code-cleaner-0.5.gem +0 -0
- data/gems/cache/code-cleaner-0.6.gem +0 -0
- data/gems/cache/code-cleaner-0.7.gem +0 -0
- data/gems/cache/code-cleaner-0.8.1.gem +0 -0
- data/gems/cache/code-cleaner-0.8.gem +0 -0
- data/gems/cache/extlib-0.9.14.gem +0 -0
- data/gems/cache/haml-2.2.16.gem +0 -0
- data/gems/cache/haml-2.2.17.gem +0 -0
- data/gems/cache/nake-0.0.2.gem +0 -0
- data/gems/cache/nake-0.0.3.gem +0 -0
- data/gems/cache/nake-0.0.5.gem +0 -0
- data/gems/cache/nake-0.0.6.gem +0 -0
- data/gems/cache/rack-1.0.1.gem +0 -0
- data/gems/cache/rack-1.1.0.gem +0 -0
- data/gems/cache/rspec-1.2.9.gem +0 -0
- data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/gems/cache/tilt-0.4.gem +0 -0
- data/gems/cache/tilt-0.5.gem +0 -0
- data/lib/rango/forms/form.rb +0 -30
- data/lib/rango/helpers.rb +0 -31
- data/lib/rango/helpers/assets.rb +0 -46
- data/lib/rango/helpers/general.rb +0 -53
- data/lib/rango/helpers/syntax.rb +0 -30
- data/lib/rango/mixins/chainable.rb +0 -66
- data/lib/rango/mixins/http_caching.rb +0 -78
- data/lib/rango/router/adapters/rack_router.rb +0 -7
- data/lib/rango/templates/exts/erubis.rb +0 -65
- data/spec/rango/forms/form_spec.rb +0 -0
- data/spec/rango/helpers/assets_spec.rb +0 -0
- data/spec/rango/helpers/general_spec.rb +0 -0
- data/spec/rango/helpers/syntax_spec.rb +0 -0
- data/spec/rango/helpers_spec.rb +0 -0
- data/spec/rango/rack/middlewares/email_obfuscator_spec.rb +0 -0
- data/spec/rango/router/adapters/rack_router_spec.rb +0 -0
- data/spec/rango/templates/exts/erubis_spec.rb +0 -0
- data/spec/stubs/templates/_basic.html.erb +0 -6
- data/spec/stubs/templates/basic.html.erb +0 -6
- data/spec/stubs/templates/capture.html.erb +0 -11
- data/spec/stubs/templates/context.html.erb +0 -6
- data/spec/stubs/templates/erubis.html.erubis +0 -2
- data/spec/stubs/templates/exception.html.erb +0 -1
- data/spec/stubs/templates/inheritance/capture/erb/base.html.erb +0 -3
- data/spec/stubs/templates/inheritance/capture/erb/index.html.erb +0 -4
- data/spec/stubs/templates/inheritance/capture/erubis/base.html.erubis +0 -3
- data/spec/stubs/templates/inheritance/capture/erubis/index.html.erubis +0 -4
- data/stubs/stack/content/lib/%name%/config.rb.rbt +0 -0
- data/stubs/stack/content/lib/%name%/initializers/middlewares.rb.rbt +0 -5
- data/stubs/stack/content/rackup.rb.rbt +0 -41
- data/support/hooks/pre-commit +0 -12
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
# method(:test).parameters
|
|
10
10
|
# => [[:req, :name], [:opt, :params], [:rest, :args]]
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
unless Kernel.method(:require).respond_to?(:parameters)
|
|
13
13
|
raise <<-EOF
|
|
14
|
-
Method#parameters
|
|
14
|
+
For action args mixin you need to have Method#parameters defined. This method is defined in 1.9.2 and higher or you can use genkhi/methopara on GitHub to get it working in Ruby 1.9.1, if it will work, but it never did for me.
|
|
15
15
|
EOF
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
module Rango
|
|
19
19
|
module ActionArgsMixin
|
|
20
20
|
def invoke_action(action)
|
|
21
|
-
view
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
view = self.method(action)
|
|
22
|
+
parameters = view.parameters.map! { |type, name| [type, name.to_s] }
|
|
23
|
+
names = parameters.map { |type, name| name }
|
|
24
|
+
types = parameters.map { |type, name| type }
|
|
25
|
+
required = parameters.map { |type, name| name if type.eql?(:req) }.compact
|
|
25
26
|
|
|
26
27
|
# validate types
|
|
27
28
|
if types.include?(:rest)
|
|
@@ -36,7 +37,7 @@ module Rango
|
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
args = Array.new
|
|
39
|
-
|
|
40
|
+
parameters.each do |type, name|
|
|
40
41
|
args.push(self.params[name]) if type.eql?(:req) || (type.eql?(:opt) && !self.params[name].nil?) # this is a bit complex, but we have to do because of rewriting optional args by nil value if we use just map with params[name]
|
|
41
42
|
end
|
|
42
43
|
puts "Rendering #{self.class}##{action} with #{args.map(&:inspect).join(", ")}"
|
data/lib/rango/mixins/filters.rb
CHANGED
data/lib/rango/mixins/message.rb
CHANGED
|
@@ -1,55 +1,59 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
require "rango/mixins/chainable"
|
|
4
|
-
|
|
5
3
|
module Rango
|
|
6
4
|
module MessageMixin
|
|
7
5
|
# The rails-style flash messages
|
|
8
6
|
# @since 0.0.2
|
|
9
7
|
# NOTE: it's important to include this mixin after ImplicitRendering mixin
|
|
10
8
|
def self.included(controller)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
controller.class_eval do
|
|
10
|
+
if self.method_defined?(:context)
|
|
11
|
+
Rango.logger.debug("Extending #{self}#context by message")
|
|
12
|
+
# This could be in the mixin itself, but we don't want
|
|
13
|
+
# to define it if the context method doesn't exist, so
|
|
14
|
+
# context.respond_to?(:context) as a detection of explicit
|
|
15
|
+
# rendering mixin and similar can work. BTW the following
|
|
16
|
+
# doesn't work with do/end syntax.
|
|
17
|
+
include Module.new {
|
|
19
18
|
def context
|
|
20
|
-
super.merge!(message: self.message)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def redirect(uri, status = 301, options = Hash.new, &block)
|
|
24
|
-
status, options = 301, status if status.is_a?(Hash)
|
|
25
|
-
if options.respond_to?(:inject)
|
|
26
|
-
# redirect "/post", error: "Try again"
|
|
27
|
-
# ?msg[error]="Try again"
|
|
28
|
-
uri = options.inject(uri) do |uri, pair|
|
|
29
|
-
type, message = pair
|
|
30
|
-
uri + "?msg[#{type}]=#{message}"
|
|
31
|
-
end
|
|
32
|
-
else
|
|
33
|
-
# redirect "/post", "Try again"
|
|
34
|
-
# ?msg="Try again"
|
|
35
|
-
uri.concat("?msg=#{options}")
|
|
36
|
-
end
|
|
37
|
-
super(uri, status)
|
|
19
|
+
@context ||= super.merge!(message: self.message)
|
|
38
20
|
end
|
|
39
|
-
|
|
21
|
+
}
|
|
22
|
+
else
|
|
23
|
+
Rango.logger.warn("Context #{self}#method isn't defined")
|
|
40
24
|
end
|
|
41
|
-
else
|
|
42
|
-
Rango.logger.warn("Context method isn't defined")
|
|
43
25
|
end
|
|
44
26
|
end
|
|
45
27
|
|
|
46
28
|
def message
|
|
47
29
|
@message ||= begin
|
|
48
30
|
messages = request.GET[:msg] || Hash.new
|
|
49
|
-
messages.
|
|
50
|
-
|
|
31
|
+
if messages.is_a?(String)
|
|
32
|
+
messages.force_encoding(Encoding.default_external)
|
|
33
|
+
elsif messages.is_a?(Hash)
|
|
34
|
+
messages.inject(Hash.new.extend(ParamsMixin)) do |result, pair| # TODO: here is the problem, Hash.new isn't params mixin
|
|
35
|
+
result.merge(pair[0] => pair[1].force_encoding(Encoding.default_external))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
alias_method :flash, :message
|
|
41
|
+
|
|
42
|
+
def redirect(uri, options = Hash.new, status = 303, &block)
|
|
43
|
+
# status, options = 303, status if status.is_a?(Hash)
|
|
44
|
+
if options.respond_to?(:inject)
|
|
45
|
+
# redirect "/post", error: "Try again"
|
|
46
|
+
# ?msg[error]="Try again"
|
|
47
|
+
uri = options.inject(uri) do |uri, pair|
|
|
48
|
+
type, message = pair
|
|
49
|
+
uri + "?msg[#{type}]=#{message}"
|
|
51
50
|
end
|
|
51
|
+
else
|
|
52
|
+
# redirect "/post", "Try again"
|
|
53
|
+
# ?msg="Try again"
|
|
54
|
+
uri.concat("?msg=#{options}")
|
|
52
55
|
end
|
|
56
|
+
super(uri, status)
|
|
53
57
|
end
|
|
54
58
|
end
|
|
55
59
|
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# @see http://nakajima.github.com/rack-flash
|
|
4
|
+
# @example
|
|
5
|
+
# use Rack::Flash
|
|
6
|
+
# message["notice"]
|
|
7
|
+
# flash["notice"]
|
|
8
|
+
# OR
|
|
9
|
+
# use Rack::Flash, accessorize: [:notice, :error]
|
|
10
|
+
# message.notice
|
|
11
|
+
# flash.notice
|
|
12
|
+
module Rango
|
|
13
|
+
module RackFlashMixin
|
|
14
|
+
# @since 0.2.4
|
|
15
|
+
# NOTE: it's important to include this mixin after ImplicitRendering mixin
|
|
16
|
+
def self.included(controller)
|
|
17
|
+
if controller.method_defined?(:context)
|
|
18
|
+
Rango.logger.debug("Extending context by message")
|
|
19
|
+
controller.class_eval do
|
|
20
|
+
include Module.new {
|
|
21
|
+
def context
|
|
22
|
+
@context ||= super.merge!(message: self.message)
|
|
23
|
+
end
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
Rango.logger.warn("Context method isn't defined")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def message
|
|
32
|
+
@message ||= begin
|
|
33
|
+
request.env["x-rack.flash"]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
alias_method :flash, :message
|
|
37
|
+
|
|
38
|
+
def redirect(uri, status = 303, options = Hash.new, &block)
|
|
39
|
+
status, options = 303, status if status.is_a?(Hash)
|
|
40
|
+
options.each { |type, message| flash[type] = message }
|
|
41
|
+
super(uri, status)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
File without changes
|
data/lib/rango/rack/request.rb
CHANGED
|
@@ -66,11 +66,11 @@ module Rango
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def GET
|
|
69
|
-
|
|
69
|
+
ParamsMixin.convert(super)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def POST
|
|
73
|
-
|
|
73
|
+
ParamsMixin.convert(super)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def PUT
|
|
@@ -85,7 +85,7 @@ module Rango
|
|
|
85
85
|
@env["rack.request.form_hash"] = Utils.parse_query(@env["rack.request.form_vars"])
|
|
86
86
|
@env["rack.input"].rewind if @env["rack.input"].respond_to?(:rewind)
|
|
87
87
|
end
|
|
88
|
-
|
|
88
|
+
ParamsMixin.convert(@env["rack.request.form_hash"])
|
|
89
89
|
else
|
|
90
90
|
{}
|
|
91
91
|
end
|
|
@@ -93,9 +93,13 @@ module Rango
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def params
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
@params ||= begin
|
|
97
|
+
input = [self.GET, self.POST, self.PUT]
|
|
98
|
+
ParamsMixin.convert(
|
|
99
|
+
input.inject(Hash.new) do |result, hash|
|
|
100
|
+
hash ? result.merge!(hash) : result
|
|
101
|
+
end
|
|
102
|
+
)
|
|
99
103
|
end
|
|
100
104
|
end
|
|
101
105
|
|
|
@@ -104,16 +108,14 @@ module Rango
|
|
|
104
108
|
end
|
|
105
109
|
|
|
106
110
|
def form
|
|
107
|
-
|
|
111
|
+
ParamsMixin.convert(env["rack.request.form_hash"] || Hash.new)
|
|
108
112
|
end
|
|
109
113
|
|
|
110
114
|
def session
|
|
111
115
|
@env['rack.session'] ||= {}
|
|
112
116
|
end
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
|
|
116
|
-
end
|
|
118
|
+
alias_method :ajax?, :xhr?
|
|
117
119
|
|
|
118
120
|
# @since 0.0.1
|
|
119
121
|
# @example: "cz"
|
|
@@ -156,10 +158,5 @@ module Rango
|
|
|
156
158
|
end
|
|
157
159
|
url
|
|
158
160
|
end
|
|
159
|
-
|
|
160
|
-
protected
|
|
161
|
-
def normalize_params(hash)
|
|
162
|
-
hash.deep_symbolize_keys.tap { |hash| hash.delete(:_method) }
|
|
163
|
-
end
|
|
164
161
|
end
|
|
165
162
|
end
|
data/lib/rango/router.rb
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
require "rango" # for helpers
|
|
4
4
|
|
|
5
5
|
module Rango
|
|
6
|
+
module Exceptions
|
|
7
|
+
class RouterNotInitialized < StandardError; end
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
module UrlHelper
|
|
7
11
|
# url(:login)
|
|
8
12
|
def url(*args)
|
|
@@ -16,8 +20,8 @@ module Rango
|
|
|
16
20
|
@@routers ||= Hash.new
|
|
17
21
|
def self.app
|
|
18
22
|
@@app
|
|
19
|
-
rescue
|
|
20
|
-
raise "You have to assign your router application to Rango::Router.app\nFor example Rango::Router.app = Usher::Interface.for(:rack, &block)"
|
|
23
|
+
rescue NameError
|
|
24
|
+
raise Exceptions::RouterNotInitialized, "You have to assign your router application to Rango::Router.app\nFor example Rango::Router.app = Usher::Interface.for(:rack, &block)"
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
def self.app=(app)
|
|
@@ -26,7 +30,7 @@ module Rango
|
|
|
26
30
|
|
|
27
31
|
def self.router
|
|
28
32
|
@@router
|
|
29
|
-
rescue
|
|
33
|
+
rescue NameError
|
|
30
34
|
raise "You have to run Rango::Router.use(router_name) first!"
|
|
31
35
|
end
|
|
32
36
|
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
2
3
|
require_relative "usher"
|
|
3
4
|
|
|
5
|
+
begin
|
|
6
|
+
require "crudtree/generator"
|
|
7
|
+
rescue LoadError
|
|
8
|
+
raise LoadError, "You have to install crudtree gem!"
|
|
9
|
+
end
|
|
10
|
+
|
|
4
11
|
module Rango
|
|
5
12
|
module UrlHelper
|
|
6
13
|
# resource(@post, :edit), resource(:posts)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
begin
|
|
4
|
+
require "rack/mount"
|
|
5
|
+
rescue LoadError
|
|
6
|
+
raise LoadError, "You have to install rack-mount gem!"
|
|
7
|
+
end
|
|
4
8
|
|
|
5
9
|
Rango::Router.implement(:rack_mount) do |env|
|
|
6
10
|
env["rango.router.params"] = env["rack.routing_args"]
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
begin
|
|
4
|
+
require "usher"
|
|
5
|
+
rescue LoadError
|
|
6
|
+
raise LoadError, "You have to install usher gem!"
|
|
7
|
+
end
|
|
4
8
|
|
|
5
9
|
Rango::Router.implement(:usher) do |env|
|
|
6
10
|
# when usher routes to the default app, then usher.params is nil
|
|
@@ -11,7 +15,6 @@ module Rango
|
|
|
11
15
|
module UrlHelper
|
|
12
16
|
# url(:login)
|
|
13
17
|
def url(*args)
|
|
14
|
-
raise "You have to asign your routes to Rango::Router.app, for example Rango::Router.app = Usher::Interface.for(:rack) { get('/') }" if Rango::Router.app.nil?
|
|
15
18
|
Rango::Router.app.router.generator.generate(*args)
|
|
16
19
|
end
|
|
17
20
|
end
|
|
@@ -9,26 +9,25 @@
|
|
|
9
9
|
# Defaults to `{script: {type: "text/javascript"}, form: {method: "POST"}}`
|
|
10
10
|
|
|
11
11
|
module Haml
|
|
12
|
-
class Engine
|
|
13
|
-
alias_method :__initialize__, :initialize
|
|
14
|
-
def initialize(template, options = Hash.new)
|
|
15
|
-
__initialize__(template, options)
|
|
16
|
-
@options[:default_attributes] = Hash.new
|
|
17
|
-
# symbolize keys
|
|
18
|
-
@options[:default_attributes] = @options[:default_attributes].inject(Hash.new) do |options, pair|
|
|
19
|
-
options.merge(pair.first.to_sym => pair.last)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
12
|
module Precompiler
|
|
25
13
|
alias_method :__prerender_tag__, :prerender_tag
|
|
26
14
|
def prerender_tag(name, self_close, attributes)
|
|
27
15
|
# merge given attributes with default attributes from options
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
end
|
|
16
|
+
defaults = Tilt::HamlTemplate.options[:default_attributes][name.to_sym]
|
|
17
|
+
attributes = defaults.merge(attributes) if defaults
|
|
31
18
|
__prerender_tag__(name, self_close, attributes)
|
|
32
19
|
end
|
|
33
20
|
end
|
|
21
|
+
|
|
22
|
+
class Buffer
|
|
23
|
+
alias_method :__open_tag__, :open_tag
|
|
24
|
+
def open_tag(name, self_closing, try_one_line, preserve_tag, escape_html, class_id,
|
|
25
|
+
nuke_outer_whitespace, nuke_inner_whitespace, obj_ref, content, *attributes_hashes)
|
|
26
|
+
defaults = Tilt::HamlTemplate.options[:default_attributes][name.to_sym]
|
|
27
|
+
attributes_hashes.unshift(defaults) if defaults
|
|
28
|
+
|
|
29
|
+
__open_tag__(name, self_closing, try_one_line, preserve_tag, escape_html, class_id,
|
|
30
|
+
nuke_outer_whitespace, nuke_inner_whitespace, obj_ref, content, *attributes_hashes)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
34
33
|
end
|
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
require "tilt"
|
|
4
|
-
require "rango/mixins/chainable"
|
|
5
4
|
|
|
6
|
-
module
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
module Rango
|
|
6
|
+
module TiltExtensions
|
|
7
|
+
# Tilt::HamlTemplate.options[:default_attributes] = {script: {type: "text/javascript"}, form: {method: "POST"}}
|
|
8
|
+
module Haml
|
|
9
|
+
def self.included(klass)
|
|
10
|
+
klass.send(:remove_method, :initialize_engine)
|
|
11
|
+
def klass.options
|
|
12
|
+
@options ||= Hash.new
|
|
13
|
+
end
|
|
13
14
|
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Tilt::HamlTemplate.options[:default_attributes] = {script: {type: "text/javascript"}, form: {method: "POST"}}
|
|
18
|
-
HamlTemplate.class_eval do
|
|
19
|
-
extend Chainable
|
|
20
15
|
|
|
21
|
-
def self.options
|
|
22
|
-
@options ||= Hash.new
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
chainable do
|
|
26
16
|
def initialize_engine
|
|
27
|
-
|
|
28
|
-
require "rango/templates/exts/haml"
|
|
17
|
+
require_template_library 'haml' unless defined? ::Haml::Engine
|
|
18
|
+
require "rango/templates/exts/haml" if self.class.options[:default_attributes]
|
|
29
19
|
end
|
|
30
20
|
|
|
31
|
-
def
|
|
32
|
-
super
|
|
21
|
+
def initialize(*args)
|
|
22
|
+
super
|
|
23
|
+
self.options.merge!(self.class.options)
|
|
33
24
|
end
|
|
34
25
|
end
|
|
35
26
|
end
|
|
36
27
|
end
|
|
28
|
+
|
|
29
|
+
Tilt::HamlTemplate.send(:include, Rango::TiltExtensions::Haml)
|
|
@@ -84,6 +84,15 @@ module Rango
|
|
|
84
84
|
return self.template.blocks[name]
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
# Clears default content of given block.
|
|
88
|
+
#
|
|
89
|
+
# @example
|
|
90
|
+
# clear_block(:flyout)
|
|
91
|
+
def clear_block(name)
|
|
92
|
+
raise ArgumentError, "You need to specify name of block to clear." if name.nil?
|
|
93
|
+
self.template.blocks[name] = String.new
|
|
94
|
+
end
|
|
95
|
+
|
|
87
96
|
# Low-level rendering method for templates.
|
|
88
97
|
#
|
|
89
98
|
# @since 0.2
|
|
@@ -113,7 +122,7 @@ module Rango
|
|
|
113
122
|
|
|
114
123
|
# @since 0.2
|
|
115
124
|
def includes(template, context = Hash.new)
|
|
116
|
-
render template, context
|
|
125
|
+
render normalize_template_path(template), context
|
|
117
126
|
return true
|
|
118
127
|
end
|
|
119
128
|
|