rango 0.2.3 → 0.2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -75,3 +75,12 @@
|
|
75
75
|
* [FIX] Cookies are passed into the redirect request
|
76
76
|
* [FIX] All non-http exceptions which occur in controller are captured and passed to rescue_http_error as a new instance of InternalServerError, except development environment where we want to get the Rack error screen.
|
77
77
|
* [FIX] Fixed encoding problem in messages. It's actually Rack fault, but hey.
|
78
|
+
|
79
|
+
= Version 0.2.4
|
80
|
+
* Removed all helpers, if you need some, use http://github.com/botanicus/helpers
|
81
|
+
* [FEATURE] Added rango/mailer with mail helper for sending e-mails
|
82
|
+
* Rango.root & Rango.media_path are now instances of Pathname rather than String
|
83
|
+
* rango/environments are no longer optional
|
84
|
+
* Ripple support in stack generator
|
85
|
+
* Removed Erubis support, since it doesn't support <%= block(&block) %> so it's useless for us
|
86
|
+
* Specs are green again
|
data/CONTRIBUTORS
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
bundle_path "gems"
|
5
|
-
bin_path "script"
|
6
|
-
disable_rubygems
|
3
|
+
source :gemcutter
|
7
4
|
|
8
|
-
# gems
|
9
5
|
gem "nake"
|
10
6
|
gem "code-cleaner"
|
11
7
|
|
@@ -15,6 +11,6 @@ gem "rack"
|
|
15
11
|
gem "haml"
|
16
12
|
gem "erubis"
|
17
13
|
|
18
|
-
|
14
|
+
group(:test) do
|
19
15
|
gem "rspec"
|
20
16
|
end
|
data/lib/rango.rb
CHANGED
@@ -5,29 +5,30 @@ if RUBY_VERSION < "1.9.1"
|
|
5
5
|
end
|
6
6
|
|
7
7
|
require "rango/cli"
|
8
|
+
require "rango/version"
|
9
|
+
require "rango/environments"
|
10
|
+
require "pathname"
|
8
11
|
|
9
12
|
module Rango
|
10
|
-
VERSION = "0.2.1"
|
11
|
-
|
12
13
|
# all the helpers are in Rango::Helpers
|
13
14
|
# so if you want to register your own, just
|
14
15
|
# Rango::Helpers.send(:include, Pupu::Helpers)
|
15
|
-
Helpers
|
16
|
+
module Helpers; end
|
16
17
|
|
17
18
|
def self.root=(root)
|
18
|
-
@@root = root
|
19
|
+
@@root = Pathname.new(root)
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.root
|
22
|
-
@@root ||= Dir.pwd
|
23
|
+
@@root ||= Pathname.new(Dir.pwd)
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.media_root=(media_root)
|
26
|
-
@@media_root = media_root
|
27
|
+
@@media_root = Pathname.new(media_root)
|
27
28
|
end
|
28
29
|
|
29
30
|
def self.media_root
|
30
|
-
@@media_root ||=
|
31
|
+
@@media_root ||= self.root.join("media")
|
31
32
|
end
|
32
33
|
|
33
34
|
# Basic environment support. Use rango/environments.rb for more advanced behaviour.
|
@@ -47,7 +48,9 @@ module Rango
|
|
47
48
|
def self.environment=(environment)
|
48
49
|
ENV["RACK_ENV"] = environment
|
49
50
|
@@environment = environment
|
51
|
+
verbose, $VERBOSE = $VERBOSE, nil
|
50
52
|
const_set(:RACK_ENV, environment)
|
53
|
+
$VERBOSE = verbose
|
51
54
|
end
|
52
55
|
|
53
56
|
def self.environment?(environment)
|
data/lib/rango/cli.rb
CHANGED
@@ -6,7 +6,7 @@ module Rango
|
|
6
6
|
# if you will run this script with -i argument, interactive session will begin
|
7
7
|
Rango.interactive if ARGV.delete("-i")
|
8
8
|
# so it can work as a runner
|
9
|
-
load ARGV.shift if ARGV.first && File.exist?(ARGV.first)
|
9
|
+
load ARGV.shift if ARGV.first && File.exist?(ARGV.first) && ARGV.first.end_with?(".rb")
|
10
10
|
end
|
11
11
|
|
12
12
|
# Start IRB interactive session
|
@@ -5,10 +5,14 @@ module Rango
|
|
5
5
|
module Sequel
|
6
6
|
module Dataset
|
7
7
|
# @since 0.2.2
|
8
|
-
|
8
|
+
# @example
|
9
|
+
# Sticker.paginate(page, 20, online: false)
|
10
|
+
# Sticker.filter(online: false).paginate(page)
|
11
|
+
def paginate(current = 1, per_page = Page.per_page, options = nil)
|
9
12
|
current = current ? current.to_i : 1 # current can be nil or "1"
|
10
13
|
page = Page.new(current: current, count: self.count, per_page: per_page)
|
11
|
-
|
14
|
+
dataset = options ? self.filter(options) : self
|
15
|
+
return page, dataset.limit(per_page, (current - 1) * per_page)
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/rango/controller.rb
CHANGED
@@ -59,7 +59,7 @@ module Rango
|
|
59
59
|
rescue HttpError => exception
|
60
60
|
self.rescue_http_error(exception)
|
61
61
|
rescue Exception => exception # so we can be sure that all the exceptions which occures in controller can be captured by rescue_http_error method
|
62
|
-
if Rango.development?
|
62
|
+
if Rango.development? or Rango.testing?
|
63
63
|
raise exception
|
64
64
|
else
|
65
65
|
message = "#{exception.class}: #{exception.message}"
|
@@ -91,7 +91,7 @@ module Rango
|
|
91
91
|
# @since 0.0.2
|
92
92
|
# @version 0.2.1
|
93
93
|
# @return [String] Escaped URL (which is RFC recommendation)
|
94
|
-
def redirect(location, status =
|
94
|
+
def redirect(location, status = 303, &block)
|
95
95
|
if (300..399).include?(status)
|
96
96
|
exception = Redirection.new(absolute_uri(location))
|
97
97
|
exception.status = status
|
@@ -119,26 +119,15 @@ module Rango
|
|
119
119
|
def_delegators :request, :cookies, :session
|
120
120
|
|
121
121
|
def router_params
|
122
|
-
@router_params ||=
|
123
|
-
params = self.env["rango.router.params"]
|
124
|
-
raise "rango.router.params property has to be setup at least to empty hash" if params.nil?
|
125
|
-
|
126
|
-
symbolize_keys = lambda do |hash|
|
127
|
-
hash.reduce(Hash.new) do |hash, pair|
|
128
|
-
if pair.last.is_a?(Hash)
|
129
|
-
hash.merge(pair.first.to_sym => symbolize_keys.call(pair.last))
|
130
|
-
else
|
131
|
-
hash.merge(pair.first.to_sym => pair.last)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
symbolize_keys.call(params)
|
137
|
-
end
|
122
|
+
@router_params ||= self.env["rango.router.params"]
|
138
123
|
end
|
139
124
|
|
140
125
|
def params
|
141
|
-
@params ||=
|
126
|
+
@params ||= begin
|
127
|
+
params = self.request.params
|
128
|
+
params.merge!(self.router_params) if router_params
|
129
|
+
params
|
130
|
+
end
|
142
131
|
end
|
143
132
|
|
144
133
|
# redefine this method for your controller if you want to provide custom error pages
|
@@ -152,7 +141,22 @@ module Rango
|
|
152
141
|
end
|
153
142
|
|
154
143
|
def render_http_error(exception)
|
155
|
-
"
|
144
|
+
exception.headers["Content-Type"] = "text/html"
|
145
|
+
if Rango.production?
|
146
|
+
<<-EOF
|
147
|
+
<h1>Application Error</h1>
|
148
|
+
<p>
|
149
|
+
The application you are trying to reach has currently some issues. Please contact our team and tell us about the troubles. Thank you.
|
150
|
+
</p>
|
151
|
+
EOF
|
152
|
+
else
|
153
|
+
<<-EOF
|
154
|
+
<h1>#{exception.class}: #{exception.message}</h1>
|
155
|
+
<ul>
|
156
|
+
<li>#{exception.backtrace.join("</li><li>")}</li>
|
157
|
+
</ul>
|
158
|
+
EOF
|
159
|
+
end
|
156
160
|
end
|
157
161
|
end
|
158
162
|
end
|
data/lib/rango/core_ext.rb
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module Enumerable
|
4
|
-
# similar to
|
5
|
-
def inject!(&block)
|
6
|
-
self.inject(self.class.new, &block)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
3
|
class String
|
11
|
-
##
|
12
4
|
# Convert to snake case.
|
13
|
-
#
|
14
5
|
# "FooBar".snake_case #=> "foo_bar"
|
15
6
|
# "HeadlineCNNNews".snake_case #=> "headline_cnn_news"
|
16
7
|
# "CNN".snake_case #=> "cnn"
|
17
8
|
#
|
18
9
|
# @return [String] Receiver converted to snake case.
|
19
|
-
#
|
20
10
|
# @api public
|
21
11
|
def snake_case
|
22
12
|
return self.downcase if self =~ /^[A-Z]+$/
|
@@ -24,43 +14,15 @@ class String
|
|
24
14
|
return $+.downcase
|
25
15
|
end
|
26
16
|
|
27
|
-
##
|
28
17
|
# Convert to camel case.
|
29
|
-
#
|
30
18
|
# "foo_bar".camel_case #=> "FooBar"
|
31
19
|
#
|
32
20
|
# @return [String] Receiver converted to camel case.
|
33
|
-
#
|
34
21
|
# @api public
|
35
22
|
def camel_case
|
36
23
|
return self if self !~ /_/ && self =~ /[A-Z]+.*/
|
37
24
|
split('_').map{|e| e.capitalize}.join
|
38
25
|
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# Convert a path string to a constant name.
|
42
|
-
#
|
43
|
-
# "merb/core_ext/string".to_const_string #=> "Merb::CoreExt::String"
|
44
|
-
#
|
45
|
-
# @return [String] Receiver converted to a constant name.
|
46
|
-
#
|
47
|
-
# @api public
|
48
|
-
def to_const_string
|
49
|
-
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
50
|
-
end
|
51
|
-
|
52
|
-
##
|
53
|
-
# Convert a constant name to a path, assuming a conventional structure.
|
54
|
-
#
|
55
|
-
# "FooBar::Baz".to_const_path # => "foo_bar/baz"
|
56
|
-
#
|
57
|
-
# @return [String] Path to the file containing the constant named by receiver
|
58
|
-
# (constantized string), assuming a conventional structure.
|
59
|
-
#
|
60
|
-
# @api public
|
61
|
-
def to_const_path
|
62
|
-
snake_case.gsub(/::/, "/")
|
63
|
-
end
|
64
26
|
end
|
65
27
|
|
66
28
|
class Hash
|
@@ -75,30 +37,63 @@ class Hash
|
|
75
37
|
result
|
76
38
|
end
|
77
39
|
end
|
40
|
+
end
|
78
41
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
42
|
+
module ParamsMixin
|
43
|
+
def self.switch_string_to_symbol_or_back(value)
|
44
|
+
if value.is_a?(String)
|
45
|
+
value.to_sym
|
46
|
+
elsif value.is_a?(Symbol)
|
47
|
+
value.to_s
|
48
|
+
else
|
49
|
+
value
|
50
|
+
end
|
86
51
|
end
|
87
52
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
53
|
+
def self.convert(hash)
|
54
|
+
hash.extend(ParamsMixin)
|
55
|
+
hash.each do |key, value|
|
56
|
+
self.convert(value) if value.is_a?(Hash)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def [](key)
|
61
|
+
if self.has_key?(key)
|
62
|
+
super(key)
|
63
|
+
elsif key2 = ParamsMixin.switch_string_to_symbol_or_back(key)
|
64
|
+
super(key2)
|
65
|
+
else # get the default value or run the default block
|
66
|
+
super(key)
|
102
67
|
end
|
103
68
|
end
|
69
|
+
|
70
|
+
def []=(key, value)
|
71
|
+
if self.has_key?(key)
|
72
|
+
super(key, value)
|
73
|
+
elsif key2 = ParamsMixin.switch_string_to_symbol_or_back(key)
|
74
|
+
super(key2, value)
|
75
|
+
else # get the default value or run the default block
|
76
|
+
super(key, value)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# This might be very nasty if you expect a symbol,
|
81
|
+
# but we can't just call #to_sym on it because of
|
82
|
+
# security. Symbols aren't GCed, so if someone would
|
83
|
+
# send a lot of requests with different keys, it will
|
84
|
+
# crash your app or even server because it would run
|
85
|
+
# out of memory.
|
86
|
+
def keys
|
87
|
+
super.map do |key|
|
88
|
+
key.is_a?(Symbol) ? key.to_s : key
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def merge(*args)
|
93
|
+
super(*args).extend(ParamsMixin)
|
94
|
+
end
|
95
|
+
|
96
|
+
def merge!(*args)
|
97
|
+
super(*args).extend(ParamsMixin)
|
98
|
+
end
|
104
99
|
end
|
data/lib/rango/exceptions.rb
CHANGED
@@ -83,7 +83,7 @@ module Rango
|
|
83
83
|
# @returns [String]
|
84
84
|
# @example NotFound.new.to_snakecase # "not_found"
|
85
85
|
def to_snakecase
|
86
|
-
self.class.name.
|
86
|
+
self.class.name.gsub(" ", "_").downcase
|
87
87
|
end
|
88
88
|
|
89
89
|
def to_response
|
@@ -137,7 +137,7 @@ module Rango
|
|
137
137
|
Error300 = MultipleChoices = Class.new(Redirection) { self.status ||= 300; self.name ||= "Multiple Choices" }
|
138
138
|
Error301 = MovedPermanently = Class.new(Redirection) { self.status ||= 301; self.name ||= "Moved Permanently" }
|
139
139
|
Error302 = MovedTemporarily = Class.new(Redirection) { self.status ||= 302; self.name ||= "Moved Temporarily" }
|
140
|
-
Error303 = SeeOther = Class.new(Redirection) { self.status ||= 303; self.name ||= "See Other" }
|
140
|
+
Error303 = SeeOther = Class.new(Redirection) { self.status ||= 303; self.name ||= "See Other" } # this is the redirect you want to use after POST
|
141
141
|
Error304 = NotModified = Class.new(Redirection) { self.status ||= 304; self.name ||= "Not Modified" }
|
142
142
|
Error305 = UseProxy = Class.new(Redirection) { self.status ||= 305; self.name ||= "Use Proxy" }
|
143
143
|
Error307 = TemporaryRedirect = Class.new(Redirection) { self.status ||= 307; self.name ||= "Temporary Redirect" }
|
data/lib/rango/gv/router.rb
CHANGED
@@ -32,7 +32,7 @@ module Rango
|
|
32
32
|
# any particular router and your router might not provide this
|
33
33
|
# functionality. In this case you can always use this generic view.
|
34
34
|
# get("/index.php").to(Rango::GV.redirect("/"))
|
35
|
-
def self.redirect(url, status =
|
35
|
+
def self.redirect(url, status = 301)
|
36
36
|
Rango::Mini.app do |request, response|
|
37
37
|
response.redirect(url, status)
|
38
38
|
return String.new
|
data/lib/rango/gv/scaffolding.rb
CHANGED
@@ -5,7 +5,6 @@ require "rango/mini"
|
|
5
5
|
require "rango/mixins/render"
|
6
6
|
|
7
7
|
require "rango" # Rango.root
|
8
|
-
Rango::Template.template_paths.push(File.join(Rango.root, "templates"))
|
9
8
|
|
10
9
|
# NOTE: this is just proof of concept, do not use it so far!
|
11
10
|
# However this is the way how we can use CRUD in Rango.
|
data/lib/rango/mailer.rb
CHANGED
@@ -1,48 +1,28 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Mailer.new("noreply@rangoproject.org", "RangoProject.org")
|
6
|
-
# self.to = "tony@example.com"
|
7
|
-
# self.subject = "Just hey"
|
8
|
-
# self.body = "Hey Tony, what's up?"
|
3
|
+
# mail("rango@project.org", "joe@doe.com", "Free VIAGRA") do
|
4
|
+
# render "mails/spam.html"
|
9
5
|
# end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
self.new(options[:from]).tap do |mailer|
|
16
|
-
mailer.body = options[:body]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_accessor :to, :to_alias
|
21
|
-
attr_accessor :from, :from_alias
|
22
|
-
attr_accessor :body, :subject
|
23
|
-
|
24
|
-
def initialize(from, from_alias = from, &block)
|
25
|
-
@from, @from_alias = from, from_alias
|
26
|
-
unless block.nil?
|
27
|
-
block.instance_eval(&block)
|
28
|
-
block.send
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def raw
|
33
|
-
<<-EOF
|
34
|
-
From: #{from_alias} <#{from}>
|
35
|
-
To: #{to_alias} <#{to}>
|
36
|
-
Subject: #{subject}
|
37
|
-
|
38
|
-
#{body}
|
39
|
-
EOF
|
40
|
-
end
|
6
|
+
begin
|
7
|
+
require "mail"
|
8
|
+
rescue LoadError
|
9
|
+
raise "You have to install mail gem!"
|
10
|
+
end
|
41
11
|
|
42
|
-
|
43
|
-
|
44
|
-
|
12
|
+
module Rango
|
13
|
+
module Mailing
|
14
|
+
def mail(to, from, subject, &block)
|
15
|
+
Mail.deliver do |mail|
|
16
|
+
mail.to = to
|
17
|
+
mail.from = from
|
18
|
+
mail.subject = subject
|
19
|
+
mail.body = block.call
|
20
|
+
puts self
|
45
21
|
end
|
22
|
+
rescue Errno::ECONNREFUSED
|
23
|
+
Rango.logger.error("E-mail from #{caller[0]} can't be send due to refused connection to the SMTP server")
|
46
24
|
end
|
47
25
|
end
|
48
26
|
end
|
27
|
+
|
28
|
+
Rango::Controller.send(:include, Rango::Mailing)
|