rango 0.2 → 0.2.1.pre
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 +9 -0
- data/.gitmodules +3 -0
- data/CHANGELOG +5 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +20 -0
- data/LICENSE +1 -1
- data/README.textile +5 -4
- data/benchmarks/ab.rb +6 -0
- data/benchmarks/bm/boot.rb +20 -0
- data/{spec/rango/version_spec.rb → benchmarks/bm/callbacks.rb} +0 -0
- data/benchmarks/bm/request.rb +4 -0
- data/benchmarks/bm/routers.rb +22 -0
- data/benchmarks/bm/stack.rb +19 -0
- data/{spec/stubs/acqs/dir/lib.rb → benchmarks/bm/templates.rb} +0 -0
- data/benchmarks/helper.rb +7 -0
- data/benchmarks/stubs/merb-app/.gitignore +21 -0
- data/benchmarks/stubs/merb-app/Rakefile +35 -0
- data/benchmarks/stubs/merb-app/app/controllers/application.rb +4 -0
- data/benchmarks/stubs/merb-app/app/controllers/exceptions.rb +15 -0
- data/benchmarks/stubs/merb-app/app/helpers/global_helpers.rb +7 -0
- data/benchmarks/stubs/merb-app/app/models/user.rb +19 -0
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_found.html.erb +47 -0
- data/benchmarks/stubs/merb-app/app/views/layout/application.html.erb +12 -0
- data/benchmarks/stubs/merb-app/autotest/discover.rb +4 -0
- data/benchmarks/stubs/merb-app/autotest/merb.rb +154 -0
- data/benchmarks/stubs/merb-app/autotest/merb_rspec.rb +167 -0
- data/benchmarks/stubs/merb-app/config/database.yml +33 -0
- data/benchmarks/stubs/merb-app/config/dependencies.rb +36 -0
- data/benchmarks/stubs/merb-app/config/environments/development.rb +17 -0
- data/benchmarks/stubs/merb-app/config/environments/production.rb +12 -0
- data/benchmarks/stubs/merb-app/config/environments/rake.rb +13 -0
- data/benchmarks/stubs/merb-app/config/environments/staging.rb +12 -0
- data/benchmarks/stubs/merb-app/config/environments/test.rb +14 -0
- data/benchmarks/stubs/merb-app/config/init.rb +26 -0
- data/benchmarks/stubs/merb-app/config/rack.rb +13 -0
- data/benchmarks/stubs/merb-app/config/router.rb +46 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/merb_generator.rb +1364 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.rb +353 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/benchmarks/stubs/merb-app/merb/merb-auth/setup.rb +46 -0
- data/benchmarks/stubs/merb-app/merb/merb-auth/strategies.rb +13 -0
- data/benchmarks/stubs/merb-app/merb/session/session.rb +11 -0
- data/benchmarks/stubs/merb-app/public/.htaccess +17 -0
- 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 +1 -0
- data/benchmarks/stubs/merb-app/public/javascripts/jquery.js +19 -0
- data/benchmarks/stubs/merb-app/public/merb.fcgi +22 -0
- data/benchmarks/stubs/merb-app/public/robots.txt +5 -0
- data/benchmarks/stubs/merb-app/public/stylesheets/master.css +119 -0
- data/{spec/stubs/acqs/dir/lib_spec.rb → benchmarks/stubs/merb-app/spec/spec.opts} +0 -0
- data/benchmarks/stubs/merb-app/spec/spec_helper.rb +27 -0
- data/benchmarks/stubs/merb-app/tasks/doc.thor +151 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-core/.gitignore +21 -0
- data/benchmarks/stubs/merb-core/Rakefile +35 -0
- data/benchmarks/stubs/merb-core/app/controllers/application.rb +4 -0
- data/benchmarks/stubs/merb-core/app/controllers/exceptions.rb +15 -0
- data/benchmarks/stubs/merb-core/app/helpers/global_helpers.rb +7 -0
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_found.html.erb +47 -0
- data/benchmarks/stubs/merb-core/app/views/layout/application.html.erb +12 -0
- data/benchmarks/stubs/merb-core/autotest/discover.rb +1 -0
- data/benchmarks/stubs/merb-core/autotest/merb.rb +151 -0
- data/benchmarks/stubs/merb-core/autotest/merb_rspec.rb +167 -0
- data/benchmarks/stubs/merb-core/config/environments/development.rb +17 -0
- data/benchmarks/stubs/merb-core/config/environments/production.rb +12 -0
- data/benchmarks/stubs/merb-core/config/environments/rake.rb +13 -0
- data/benchmarks/stubs/merb-core/config/environments/staging.rb +12 -0
- data/benchmarks/stubs/merb-core/config/environments/test.rb +14 -0
- data/benchmarks/stubs/merb-core/config/init.rb +27 -0
- data/benchmarks/stubs/merb-core/config/rack.rb +13 -0
- data/benchmarks/stubs/merb-core/config/router.rb +43 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/merb_generator.rb +1364 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.rb +353 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/benchmarks/stubs/merb-core/public/.htaccess +17 -0
- 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 +1 -0
- data/benchmarks/stubs/merb-core/public/merb.fcgi +22 -0
- data/benchmarks/stubs/merb-core/public/robots.txt +5 -0
- data/benchmarks/stubs/merb-core/public/stylesheets/master.css +119 -0
- data/{spec/stubs/acqs/lib.rb → benchmarks/stubs/merb-core/spec/spec.opts} +0 -0
- data/benchmarks/stubs/merb-core/spec/spec_helper.rb +22 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-flat/.gitignore +21 -0
- data/benchmarks/stubs/merb-flat/README.txt +10 -0
- data/benchmarks/stubs/merb-flat/Rakefile +35 -0
- data/benchmarks/stubs/merb-flat/application.rb +17 -0
- data/benchmarks/stubs/merb-flat/config/framework.rb +9 -0
- data/benchmarks/stubs/merb-flat/config/init.rb +42 -0
- data/benchmarks/stubs/merb-flat/spec/spec_helper.rb +26 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-flat/views/foo.html.erb +3 -0
- data/benchmarks/stubs/merb-very-flat/.gitignore +21 -0
- data/benchmarks/stubs/merb-very-flat/Rakefile +35 -0
- data/benchmarks/stubs/merb-very-flat/merb-very-flat.rb +61 -0
- data/benchmarks/stubs/merb-very-flat/spec/spec_helper.rb +26 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/rails/README +243 -0
- data/benchmarks/stubs/rails/Rakefile +10 -0
- data/benchmarks/stubs/rails/app/controllers/application_controller.rb +12 -0
- data/benchmarks/stubs/rails/app/helpers/application_helper.rb +5 -0
- data/benchmarks/stubs/rails/config/boot.rb +112 -0
- data/benchmarks/stubs/rails/config/database.yml +22 -0
- data/benchmarks/stubs/rails/config/environment.rb +43 -0
- data/benchmarks/stubs/rails/config/environments/development.rb +19 -0
- data/benchmarks/stubs/rails/config/environments/production.rb +30 -0
- data/benchmarks/stubs/rails/config/environments/test.rb +30 -0
- data/benchmarks/stubs/rails/config/initializers/backtrace_silencers.rb +9 -0
- data/benchmarks/stubs/rails/config/initializers/inflections.rb +12 -0
- data/benchmarks/stubs/rails/config/initializers/mime_types.rb +7 -0
- data/benchmarks/stubs/rails/config/initializers/new_rails_defaults.rb +21 -0
- data/benchmarks/stubs/rails/config/initializers/session_store.rb +17 -0
- data/benchmarks/stubs/rails/config/locales/en.yml +5 -0
- data/benchmarks/stubs/rails/config/routes.rb +45 -0
- data/benchmarks/stubs/rails/doc/README_FOR_APP +2 -0
- data/{spec/stubs/acqs/tasks.thor → benchmarks/stubs/rails/log/development.log} +0 -0
- data/{stubs/stack/content/TODO.txt → benchmarks/stubs/rails/log/production.log} +0 -0
- data/benchmarks/stubs/rails/log/server.log +0 -0
- data/benchmarks/stubs/rails/log/test.log +0 -0
- data/benchmarks/stubs/rails/public/404.html +30 -0
- data/benchmarks/stubs/rails/public/422.html +30 -0
- data/benchmarks/stubs/rails/public/500.html +30 -0
- data/benchmarks/stubs/rails/public/favicon.ico +0 -0
- data/benchmarks/stubs/rails/public/images/rails.png +0 -0
- data/benchmarks/stubs/rails/public/index.html +275 -0
- data/benchmarks/stubs/rails/public/javascripts/application.js +2 -0
- data/benchmarks/stubs/rails/public/javascripts/controls.js +963 -0
- data/benchmarks/stubs/rails/public/javascripts/dragdrop.js +973 -0
- data/benchmarks/stubs/rails/public/javascripts/effects.js +1128 -0
- data/benchmarks/stubs/rails/public/javascripts/prototype.js +4320 -0
- data/benchmarks/stubs/rails/public/robots.txt +5 -0
- data/benchmarks/stubs/rails/script/about +4 -0
- data/benchmarks/stubs/rails/script/console +3 -0
- data/benchmarks/stubs/rails/script/dbconsole +3 -0
- data/benchmarks/stubs/rails/script/destroy +3 -0
- data/benchmarks/stubs/rails/script/generate +3 -0
- data/benchmarks/stubs/rails/script/performance/benchmarker +3 -0
- data/benchmarks/stubs/rails/script/performance/profiler +3 -0
- data/benchmarks/stubs/rails/script/plugin +3 -0
- data/benchmarks/stubs/rails/script/runner +3 -0
- data/benchmarks/stubs/rails/script/server +3 -0
- data/benchmarks/stubs/rails/test/performance/browsing_test.rb +11 -0
- data/benchmarks/stubs/rails/test/test_helper.rb +40 -0
- data/benchmarks/stubs/ramaze.rb +0 -0
- data/benchmarks/stubs/sinatra.rb +11 -0
- data/bin/rango +2 -2
- data/deps.rip +7 -0
- data/deps.rip.rbe +7 -0
- data/gems/cache/abstract-1.0.0.gem +0 -0
- 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/erubis-2.6.5.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/nake-0.0.8.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/rspec-1.3.0.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.rb +28 -28
- data/lib/rango/cli.rb +34 -0
- data/lib/rango/contrib/pagination/adapters/datamapper.rb +21 -17
- data/lib/rango/controller.rb +36 -4
- data/lib/rango/environments.rb +1 -15
- data/lib/rango/exceptions.rb +144 -86
- data/lib/rango/helpers.rb +10 -2
- data/lib/rango/mailer.rb +48 -0
- data/lib/rango/mixins/action_args.rb +5 -7
- data/lib/rango/mixins/filters.rb +18 -14
- data/lib/rango/mixins/message.rb +30 -24
- data/lib/rango/mixins/rendering.rb +54 -0
- data/lib/rango/orm/tasks/datamapper.nake +81 -0
- data/lib/rango/orm/tasks/sequel.nake +43 -0
- data/lib/rango/router/adapters/usher.rb +2 -1
- data/lib/rango/stacks/controller.rb +12 -0
- data/lib/rango/tasks/spec.nake +9 -0
- data/lib/rango/templates/exts/haml.rb +1 -1
- data/lib/rango/templates/exts/tilt.rb +10 -0
- data/lib/rango/templates/helpers.rb +29 -25
- data/lib/rango/templates/template.rb +7 -6
- data/rango.gemspec +52 -0
- data/rango.pre.gemspec +8 -0
- data/spec/rango/environments_spec.rb +1 -1
- data/spec/rango/exceptions_spec.rb +8 -7
- data/spec/rango/mixins/render_spec.rb +1 -1
- data/spec/rango/templates/template_spec.rb +1 -1
- data/stubs/stack/content/%name%.gemspec.rbt +52 -0
- data/stubs/stack/content/%name%.pre.gemspec.rbt +8 -0
- data/stubs/stack/content/CHANGELOG +0 -0
- data/stubs/stack/content/Gemfile.rbt +22 -11
- data/stubs/stack/content/README.textile.rbt +7 -0
- data/stubs/stack/content/config.ru.rbt +33 -62
- data/stubs/stack/content/deps.rip +0 -0
- data/stubs/stack/content/init.rb.rbt +14 -39
- data/stubs/stack/content/lib/%name%.rb.rbt +8 -0
- data/stubs/stack/content/lib/%name%/config.rb.rbt +0 -0
- data/stubs/stack/content/{environments.rb.rbt → lib/%name%/environments/development.rb.rbt} +5 -0
- data/stubs/stack/content/lib/%name%/environments/production.rb.rbt +0 -0
- data/stubs/stack/content/lib/%name%/environments/stagging.rb.rbt +0 -0
- data/stubs/stack/content/lib/%name%/initializers/middlewares.rb.rbt +5 -0
- data/stubs/stack/content/lib/%name%/initializers/urls.rb.rbt +24 -0
- data/stubs/stack/content/{models.rb.rbt → lib/%name%/models.rb.rbt} +7 -0
- data/stubs/stack/content/{views.rb.rbt → lib/%name%/views.rb.rbt} +2 -8
- data/stubs/stack/content/rackup.rb.rbt +41 -0
- data/stubs/stack/content/tasks.rb.rbt +52 -0
- data/stubs/stack/setup.rb +7 -1
- data/support/hooks/pre-commit +12 -0
- data/tasks.rb +49 -0
- metadata +250 -54
- data/Rakefile +0 -33
- data/lib/rango/rack/middlewares/email_obfuscator.rb +0 -25
- data/lib/rango/version.rb +0 -7
- data/stubs/stack/content/.rvmrc.rbt +0 -2
- data/stubs/stack/content/Rakefile.rbt +0 -12
|
@@ -3,6 +3,60 @@
|
|
|
3
3
|
require "rango/mixins/render"
|
|
4
4
|
|
|
5
5
|
module Rango
|
|
6
|
+
module FormatMixin
|
|
7
|
+
def self.extended
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def inherited
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
attr_writer :format
|
|
14
|
+
def formats
|
|
15
|
+
@formats ||= Hash.new { |hash, format| hash[:html] if hash.has_key?(:html) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# format(:json) do |object|
|
|
19
|
+
# object.to_json
|
|
20
|
+
# end
|
|
21
|
+
def format(format, &block)
|
|
22
|
+
self.formats[:format] = block
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
module StackRendering
|
|
26
|
+
include Rango::RenderMixin
|
|
27
|
+
def template_dirname
|
|
28
|
+
self.class.name.gsub("::", "/").camel_case
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def template_basename
|
|
32
|
+
request["router.action"]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#def template_basename
|
|
36
|
+
# case request["router.action"]
|
|
37
|
+
# when "show"
|
|
38
|
+
# self.class.name.singularize
|
|
39
|
+
# when "index"
|
|
40
|
+
# else
|
|
41
|
+
# end
|
|
42
|
+
#end
|
|
43
|
+
|
|
44
|
+
def template_path
|
|
45
|
+
File.join(template_dirname, template_basename)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def render(context = Hash.new)
|
|
49
|
+
super(self.template_path, self.scope, self.context.merge!(context))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def display(object)
|
|
53
|
+
render
|
|
54
|
+
rescue TemplateNotFound
|
|
55
|
+
callback = self.formats[request.action]
|
|
56
|
+
callback.call
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
6
60
|
module ExplicitRendering
|
|
7
61
|
include Rango::RenderMixin
|
|
8
62
|
def render(template, context = Hash.new)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# @since 0.0.2.1
|
|
4
|
+
# ./tasks.rb db:automigrate test
|
|
5
|
+
Task.new("db:automigrate") do |task|
|
|
6
|
+
task.description = "Automigrate the database. It will destroy all the data!"
|
|
7
|
+
task.define do |environment = "development", options|
|
|
8
|
+
Task[:environment].call(environment)
|
|
9
|
+
Rango.logger.info("[#{Rango.environment}] Migrating databases ...")
|
|
10
|
+
result = DataMapper.auto_migrate!
|
|
11
|
+
Rango.logger.debug("Result: #{result.inspect}")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @since 0.0.2.1
|
|
16
|
+
# ./tasks.rb db:autoupgrade test
|
|
17
|
+
Task.new("db:autoupgrade") do |task|
|
|
18
|
+
task.description = "Autoupgrade the database structure. Data should stay untouched."
|
|
19
|
+
task.define do |environment = "development", options|
|
|
20
|
+
Task[:environment].call(environment)
|
|
21
|
+
Rango.logger.info("[#{Rango.environment}] Upgrading databases ...")
|
|
22
|
+
result = DataMapper.auto_upgrade!
|
|
23
|
+
Rango.logger.debug("Result: #{result.inspect}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @since 0.0.2.1
|
|
28
|
+
# ./tasks.rb db:report test
|
|
29
|
+
Task.new("db:report") do |task|
|
|
30
|
+
task.description = "Report count of objects in database."
|
|
31
|
+
task.define do |environment = "development", options|
|
|
32
|
+
Task[:environment].call(environment)
|
|
33
|
+
ObjectSpace.classes.each do |klass|
|
|
34
|
+
if klass.included(DataMapper::Resource)
|
|
35
|
+
puts "#{model_class}: #{model_class.count}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Task.new("db:migrate") do |task|
|
|
42
|
+
task.hidden = true
|
|
43
|
+
task.define do |*args, options|
|
|
44
|
+
abort "Use #{$0} db:migrate:up version or #{$0} db:migrate:down version"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Task.new("db:migrate:load") do |task|
|
|
49
|
+
task.hidden = true
|
|
50
|
+
task.define do |environment, options|
|
|
51
|
+
Task[:environment].call(environment)
|
|
52
|
+
begin
|
|
53
|
+
require "dm-migrations/migration_runner"
|
|
54
|
+
rescue LoadError
|
|
55
|
+
abort "You have to install dm-migrations gem for this!"
|
|
56
|
+
end
|
|
57
|
+
Dir["db/migrations/*.rb"].each do |migration|
|
|
58
|
+
load migration
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @since 0.0.2.1
|
|
64
|
+
# ./tasks.rb db:migrate:up test --version=10
|
|
65
|
+
Task.new("db:migrate:up") do |task|
|
|
66
|
+
task.description = "Migrate up using migrations."
|
|
67
|
+
task.define do |environment = "development", options|
|
|
68
|
+
Task["db:migrate:load"].call(environment)
|
|
69
|
+
migrate_up!(options[:version])
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @since 0.0.2.1
|
|
74
|
+
# ./tasks.rb db:migrate:down test --version=10
|
|
75
|
+
Task.new("db:migrate:down") do |task|
|
|
76
|
+
task.description = "Migrate down using migrations."
|
|
77
|
+
task.define do |environment = "development", options|
|
|
78
|
+
Task["db:migrate:load"].call(environment)
|
|
79
|
+
migrate_down!(options[:version])
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# @since 0.0.2.1
|
|
4
|
+
# ./tasks.rb db:migrate test
|
|
5
|
+
Task.new("db:migrate") do |task|
|
|
6
|
+
task.description = "Perform migration using migrations in schema/migrations"
|
|
7
|
+
task.define do |environment = "development", options|
|
|
8
|
+
Task[:environment].call(environment)
|
|
9
|
+
require "sequel/extensions/migration"
|
|
10
|
+
Sequel::Migrator.apply(Sequel::Model.db, "db/migrations", options[:version])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @since 0.0.2.1
|
|
15
|
+
# ./tasks.rb db:drop:all test
|
|
16
|
+
Task.new("db:drop:all") do |task|
|
|
17
|
+
task.description = "Drop all the tables"
|
|
18
|
+
task.define do |environment = "development", options|
|
|
19
|
+
Task[:environment].call(environment)
|
|
20
|
+
Sequel::Model.db.drop_table *Sequel::Model.db.tables
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @since 0.0.2.1
|
|
25
|
+
# ./tasks.rb db:reset test
|
|
26
|
+
Task.new("db:reset") do |task|
|
|
27
|
+
task.description = "Drop all tables and perform migrations"
|
|
28
|
+
task.define do |environment = "development", options|
|
|
29
|
+
Task[:environment].call(environment)
|
|
30
|
+
Task["db:drop:all"].call
|
|
31
|
+
Task["db:migrate"]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @since 0.0.2.1
|
|
36
|
+
# ./tasks.rb db:truncate test
|
|
37
|
+
Task.new("db:truncate") do |task|
|
|
38
|
+
task.description = "Truncate all tables in database"
|
|
39
|
+
task.define do |environment = "development", options|
|
|
40
|
+
Task[:environment].call(environment)
|
|
41
|
+
Sequel::Model.db << "TRUNCATE #{db.tables.join(', ')} CASCADE;"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
require "usher"
|
|
4
4
|
|
|
5
5
|
Rango::Router.implement(:usher) do |env|
|
|
6
|
-
|
|
6
|
+
# when usher routes to the default app, then usher.params is nil
|
|
7
|
+
env["rango.router.params"] = env["usher.params"] || Hash.new
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
module Rango
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
require "rango"
|
|
4
|
+
require "rango/helpers"
|
|
4
5
|
require "rango/controller"
|
|
5
6
|
require "rango/environments"
|
|
7
|
+
require "rango/mixins/rendering"
|
|
8
|
+
require "rango/mixins/message"
|
|
9
|
+
require "rango/mixins/filters"
|
|
6
10
|
require "rango/rack/middlewares/basic"
|
|
11
|
+
|
|
12
|
+
module Rango
|
|
13
|
+
class StackController < Controller
|
|
14
|
+
include ExplicitRendering
|
|
15
|
+
include FiltersMixin
|
|
16
|
+
include MessageMixin
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# Attributes of each tag will reverse merged with his default attributes, so you
|
|
7
7
|
# don't have to write over and over that script tag has attribute `type` with value
|
|
8
8
|
# `text/javascript`. For example, `%script` compiles to `<script type="text/javascript"></script>`.
|
|
9
|
-
# Defaults to `{:
|
|
9
|
+
# Defaults to `{script: {type: "text/javascript"}, form: {method: "POST"}}`
|
|
10
10
|
|
|
11
11
|
module Haml
|
|
12
12
|
class Engine
|
|
@@ -14,13 +14,23 @@ module Tilt
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Tilt::HamlTemplate.options[:default_attributes] = {script: {type: "text/javascript"}, form: {method: "POST"}}
|
|
17
18
|
HamlTemplate.class_eval do
|
|
18
19
|
extend Chainable
|
|
20
|
+
|
|
21
|
+
def self.options
|
|
22
|
+
@options ||= Hash.new
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
chainable do
|
|
20
26
|
def initialize_engine
|
|
21
27
|
super
|
|
22
28
|
require "rango/templates/exts/haml"
|
|
23
29
|
end
|
|
30
|
+
|
|
31
|
+
def haml_options
|
|
32
|
+
super.merge!(self.class.options)
|
|
33
|
+
end
|
|
24
34
|
end
|
|
25
35
|
end
|
|
26
36
|
end
|
|
@@ -4,10 +4,12 @@ require "rango"
|
|
|
4
4
|
require "rango/templates/template"
|
|
5
5
|
|
|
6
6
|
module Rango
|
|
7
|
+
SubtemplateNotFound = Class.new(StandardError)
|
|
8
|
+
|
|
7
9
|
module TemplateHelpers
|
|
8
10
|
def self.extended(scope)
|
|
9
11
|
class << scope
|
|
10
|
-
attr_accessor :
|
|
12
|
+
attr_accessor :template
|
|
11
13
|
# @example Capture being used in a .html.erb page:
|
|
12
14
|
# <% @foo = capture do %>
|
|
13
15
|
# <p>Some Foo content!</p>
|
|
@@ -18,13 +20,13 @@ module Rango
|
|
|
18
20
|
# @return [String] The output of the block.
|
|
19
21
|
# @api private
|
|
20
22
|
def capture(*args, &block)
|
|
21
|
-
capture_method = "capture_#{self.
|
|
23
|
+
capture_method = "capture_#{self.template.adapter}"
|
|
22
24
|
if self.respond_to?(capture_method) # tilt doesn't support @_out_buf for haml
|
|
23
|
-
self.send("capture_#{self.
|
|
25
|
+
self.send("capture_#{self.template.adapter}", *args, &block)
|
|
24
26
|
else
|
|
25
27
|
# @_out_buf comes from tilt
|
|
26
28
|
unless self.instance_variable_defined?("@_out_buf")
|
|
27
|
-
raise "Adapter #{self.
|
|
29
|
+
raise "Adapter #{self.template.adapter} doesn't support capturing"
|
|
28
30
|
end
|
|
29
31
|
_old_buf, @_out_buf = @_out_buf, ""
|
|
30
32
|
block.call(*args)
|
|
@@ -33,13 +35,13 @@ module Rango
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def concat(string)
|
|
36
|
-
concat_method = "concat_#{self.
|
|
38
|
+
concat_method = "concat_#{self.template.adapter}"
|
|
37
39
|
if self.respond_to?(concat_method) # tilt doesn't support @_out_buf for haml
|
|
38
|
-
self.send("concat_#{self.
|
|
40
|
+
self.send("concat_#{self.template.adapter}", string)
|
|
39
41
|
else
|
|
40
42
|
# @_out_buf comes from tilt
|
|
41
43
|
unless self.instance_variable_defined?("@_out_buf")
|
|
42
|
-
raise "Adapter #{self.
|
|
44
|
+
raise "Adapter #{self.template.adapter} doesn't support concating"
|
|
43
45
|
end
|
|
44
46
|
@_out_buf << string
|
|
45
47
|
end
|
|
@@ -48,7 +50,7 @@ module Rango
|
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def self.included(scope_class)
|
|
51
|
-
scope_class.class_eval { attr_accessor :
|
|
53
|
+
scope_class.class_eval { attr_accessor :template }
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
# post/show.html: it's block is the block we like to see in output
|
|
@@ -59,15 +61,15 @@ module Rango
|
|
|
59
61
|
def block(name, value = nil, &block)
|
|
60
62
|
raise ArgumentError, "Block has to have a name!" if name.nil?
|
|
61
63
|
raise ArgumentError, "You have to provide value or block, not both of them!" if value && block
|
|
62
|
-
self.
|
|
63
|
-
return self.
|
|
64
|
+
self.template.blocks[name] ||= block ? self.template.scope.capture(&block) : value
|
|
65
|
+
return self.template.blocks[name]
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
# - extend_block(:head) do
|
|
67
69
|
# = pupu :lighter, syntax: "html", theme: "standard"
|
|
68
70
|
# = block(:head)
|
|
69
71
|
def extend_block(name, value = nil, &block)
|
|
70
|
-
unless self.
|
|
72
|
+
unless self.template.blocks[name]
|
|
71
73
|
raise NameError, "Block #{name.inspect} wasn't defined yet, you can't extend it!"
|
|
72
74
|
end
|
|
73
75
|
self.enhance_block(name, value, &block)
|
|
@@ -76,9 +78,9 @@ module Rango
|
|
|
76
78
|
def enhance_block(name, value = nil, &block)
|
|
77
79
|
raise ArgumentError, "Block has to have a name!" if name.nil?
|
|
78
80
|
raise ArgumentError, "You have to provide value or block, not both of them!" if value && block
|
|
79
|
-
value = self.
|
|
80
|
-
self.
|
|
81
|
-
return self.
|
|
81
|
+
value = self.template.scope.capture(&block) if value.nil? && block
|
|
82
|
+
self.template.blocks[name] = "#{self.template.blocks[name]}\n#{value}" if value
|
|
83
|
+
return self.template.blocks[name]
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
# Low-level rendering method for templates.
|
|
@@ -88,22 +90,24 @@ module Rango
|
|
|
88
90
|
# render "base.html"
|
|
89
91
|
# render "./base.html"
|
|
90
92
|
# render "../base.html"
|
|
91
|
-
def render(
|
|
92
|
-
normalize_template_path(
|
|
93
|
-
original_template = self.
|
|
94
|
-
template = Rango::Template.new(
|
|
95
|
-
self.
|
|
93
|
+
def render(path, context = Hash.new)
|
|
94
|
+
full_path = normalize_template_path(path)
|
|
95
|
+
original_template = self.template
|
|
96
|
+
template = Rango::Template.new(full_path, self) # self is scope
|
|
97
|
+
self.template = original_template
|
|
96
98
|
return template.render(context)
|
|
99
|
+
rescue Exceptions::TemplateNotFound # FIXME: this doesn't work
|
|
100
|
+
raise SubtemplateNotFound, "Template #{path} doesn't exist in #{full_path}"
|
|
97
101
|
end
|
|
98
102
|
|
|
99
103
|
# partial "products/list"
|
|
100
104
|
# @since 0.0.2
|
|
101
|
-
# @version 0.2
|
|
102
|
-
def partial(template,
|
|
105
|
+
# @version 0.2.1
|
|
106
|
+
def partial(template, extra_context = Hash.new)
|
|
103
107
|
# NOTE: we can't use File.split because it normalize the path,
|
|
104
108
|
# so "./base.html" will be the same as "base.html", but it shouldn't be
|
|
105
109
|
*path, basename = template.split("/")
|
|
106
|
-
render File.join(
|
|
110
|
+
render File.join(path.join("/"), "_#{basename}"), self.template.context.merge(extra_context)
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
# @since 0.2
|
|
@@ -116,15 +120,15 @@ module Rango
|
|
|
116
120
|
# @since 0.0.2
|
|
117
121
|
def extends(path)
|
|
118
122
|
# we can't just create a new template, because it has to do it after it reads the whole file
|
|
119
|
-
self.
|
|
123
|
+
self.template.supertemplate = normalize_template_path(path)
|
|
120
124
|
end
|
|
121
125
|
|
|
122
126
|
# @since 0.2
|
|
123
127
|
def normalize_template_path(template)
|
|
124
128
|
if template.start_with?("./")
|
|
125
|
-
File.expand_path(File.join(File.dirname(self.
|
|
129
|
+
File.expand_path(File.join(File.dirname(self.template.fullpath), template))
|
|
126
130
|
elsif template.start_with?("../")
|
|
127
|
-
File.expand_path(File.join(File.dirname(self.
|
|
131
|
+
File.expand_path(File.join(File.dirname(self.template.fullpath), "..", template))
|
|
128
132
|
else
|
|
129
133
|
template
|
|
130
134
|
end
|
|
@@ -6,7 +6,7 @@ require "rango/templates/helpers"
|
|
|
6
6
|
require "rango/exceptions"
|
|
7
7
|
|
|
8
8
|
module Rango
|
|
9
|
-
module
|
|
9
|
+
module Exceptions # so we can catch it with other HTTP errors
|
|
10
10
|
TemplateNotFound = Class.new(NotFound)
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ module Rango
|
|
|
17
17
|
|
|
18
18
|
# template -> supertemplate is the same relationship as class -> superclass
|
|
19
19
|
# @since 0.0.2
|
|
20
|
-
attr_accessor :path, :scope, :supertemplate
|
|
20
|
+
attr_accessor :path, :scope, :supertemplate, :context
|
|
21
21
|
|
|
22
22
|
# @since 0.0.2
|
|
23
23
|
attr_writer :blocks
|
|
@@ -29,7 +29,7 @@ module Rango
|
|
|
29
29
|
def initialize(path, scope = Object.new)
|
|
30
30
|
self.path = path#[scope.class.template_prefix.chomp("/"), template].join("/")
|
|
31
31
|
self.scope = scope.extend(TemplateHelpers)
|
|
32
|
-
self.scope.
|
|
32
|
+
self.scope.template = self
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# @since 0.0.2
|
|
@@ -57,10 +57,11 @@ module Rango
|
|
|
57
57
|
|
|
58
58
|
# @since 0.0.2
|
|
59
59
|
def render(context = Hash.new)
|
|
60
|
-
raise
|
|
60
|
+
raise Exceptions::TemplateNotFound.new("Template #{self.path} wasn't found in these template_paths: #{self.class.template_paths.inspect}") if self.fullpath.nil?
|
|
61
|
+
Rango.logger.info("Rendering template #{self.path} with context keys #{context.keys.inspect}")
|
|
62
|
+
self.context = context
|
|
61
63
|
value = self.template.render(self.scope, context)
|
|
62
|
-
Rango.logger.
|
|
63
|
-
# #Rango.logger.inspect(self.blocks)
|
|
64
|
+
Rango.logger.debug("Available blocks: #{self.blocks.keys.inspect}")
|
|
64
65
|
if self.supertemplate
|
|
65
66
|
Rango.logger.debug("Extends call: #{self.supertemplate}")
|
|
66
67
|
supertemplate = self.class.new(self.supertemplate, self.scope)
|
data/rango.gemspec
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env gem build
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
require "base64"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = "rango"
|
|
8
|
+
s.version = "0.2.1"
|
|
9
|
+
s.authors = ["Jakub Šťastný aka Botanicus"]
|
|
10
|
+
s.homepage = "http://github.com/botanicus/rango"
|
|
11
|
+
s.summary = "Rango is ultralightweight, ultracustomizable, ultracool web framework deeply inspired by Django."
|
|
12
|
+
s.description = "" # TODO: long description
|
|
13
|
+
s.cert_chain = nil
|
|
14
|
+
s.email = Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n")
|
|
15
|
+
s.has_rdoc = true
|
|
16
|
+
|
|
17
|
+
# files
|
|
18
|
+
s.files = `git ls-files`.split("\n")
|
|
19
|
+
|
|
20
|
+
Dir["bin/*"].map(&File.method(:basename))
|
|
21
|
+
s.default_executable = "rango"
|
|
22
|
+
s.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
# Ruby version
|
|
25
|
+
# Current JRuby with --1.9 switch has RUBY_VERSION set to "1.9.2dev"
|
|
26
|
+
# and RubyGems don't play well with it, so we have to set minimal
|
|
27
|
+
# Ruby version to 1.9, even if it actually is 1.9.1
|
|
28
|
+
s.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
|
|
29
|
+
|
|
30
|
+
# === Dependencies ===
|
|
31
|
+
# RubyGems has runtime dependencies (add_dependency) and
|
|
32
|
+
# development dependencies (add_development_dependency)
|
|
33
|
+
# Rango isn't a monolithic framework, so you might want
|
|
34
|
+
# to use just one specific part of it, so it has no sense
|
|
35
|
+
# to specify dependencies for the whole gem. If you want
|
|
36
|
+
# to install everything what you need for start with Rango,
|
|
37
|
+
# just run gem install rango --development
|
|
38
|
+
|
|
39
|
+
s.add_development_dependency "simple-templater", ">= 0.0.1.2"
|
|
40
|
+
s.add_development_dependency "bundler"
|
|
41
|
+
|
|
42
|
+
begin
|
|
43
|
+
require "changelog"
|
|
44
|
+
rescue LoadError
|
|
45
|
+
warn "You have to have changelog gem installed for post install message"
|
|
46
|
+
else
|
|
47
|
+
s.post_install_message = CHANGELOG.new.version_changes
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# RubyForge
|
|
51
|
+
s.rubyforge_project = "rango"
|
|
52
|
+
end
|