From 674c3eed0e0df17f20229fd15154f8db989db1f7 Mon Sep 17 00:00:00 2001 From: Jonathan Martin Date: Fri, 24 Jan 2014 21:24:45 -0500 Subject: [PATCH 01/12] Update middleman.gemspec Bump Uglifier. --- middleman/middleman.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 0c44da8a..ee2f2d42 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| s.add_dependency("haml", [">= 3.1.6"]) s.add_dependency("sass", [">= 3.1.20"]) s.add_dependency("compass", [">= 0.12.2"]) - s.add_dependency("uglifier", ["~> 2.1.0"]) + s.add_dependency("uglifier", ["~> 2.4.0"]) s.add_dependency("coffee-script", ["~> 2.2.0"]) s.add_dependency("execjs", ["~> 1.4.0"]) s.add_dependency("kramdown", ["~> 1.2"]) From 3993034883057b76742ef1453edc5edac1950d1b Mon Sep 17 00:00:00 2001 From: Ivan Zarea Date: Mon, 27 Jan 2014 09:35:30 +0200 Subject: [PATCH 02/12] Fix dynamic pages link in the config template --- middleman-core/lib/middleman-core/templates/shared/config.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/templates/shared/config.tt b/middleman-core/lib/middleman-core/templates/shared/config.tt index 288f0813..f96e0a26 100755 --- a/middleman-core/lib/middleman-core/templates/shared/config.tt +++ b/middleman-core/lib/middleman-core/templates/shared/config.tt @@ -24,7 +24,7 @@ # page "/admin/*" # end -# Proxy pages (http://middlemanapp.com/dynamic-pages/) +# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/) # proxy "/this-page-has-no-template.html", "/template-file.html", :locals => { # :which_fake_page => "Rendering a fake page with a local variable" } From c2d85c35f27c27b574c33a241ad4462b68c3859c Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 27 Jan 2014 09:56:48 -0800 Subject: [PATCH 03/12] prep release --- CHANGELOG.md | 8 ++++++++ middleman-core/lib/middleman-core/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a660954..206b19fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ master === +3.2.2 +=== + +* Specify the full path to the NEWLINE constant +* Refactor some internals which were dependent on certain order of operations +* Updated i18n dep +* Updated Uglifier dep + 3.2.1 === diff --git a/middleman-core/lib/middleman-core/version.rb b/middleman-core/lib/middleman-core/version.rb index e0bac425..7f2f371f 100644 --- a/middleman-core/lib/middleman-core/version.rb +++ b/middleman-core/lib/middleman-core/version.rb @@ -1,5 +1,5 @@ module Middleman # Current Version # @return [String] - VERSION = '3.2.1' unless const_defined?(:VERSION) + VERSION = '3.2.2' unless const_defined?(:VERSION) end From f0fcebe1692eec740056a5aad6a6e58c47d65d96 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 28 Jan 2014 10:46:39 -0800 Subject: [PATCH 04/12] disable sass cache since it cant marshal the path to the MM instance --- middleman-core/lib/middleman-more/core_extensions/compass.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index 366d6196..cdf2c299 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -20,7 +20,8 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension ::Compass.configuration do |compass_config| compass_config.project_path = app.source_dir compass_config.environment = :development - compass_config.cache_path = app.config[:sass_cache_path] + compass_config.cache = false + # compass_config.cache_path = app.config[:sass_cache_path] compass_config.sass_dir = app.config[:css_dir] compass_config.css_dir = app.config[:css_dir] compass_config.javascripts_dir = app.config[:js_dir] From b056f4f1d1aac9e551c1fc5b6f2036b1b533ce74 Mon Sep 17 00:00:00 2001 From: Jeremy Green Date: Thu, 30 Jan 2014 23:26:17 -0600 Subject: [PATCH 05/12] Update the console to the new logger syntax. --- middleman-core/lib/middleman-core/cli/console.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/cli/console.rb b/middleman-core/lib/middleman-core/cli/console.rb index d647db2f..e75b1aa9 100644 --- a/middleman-core/lib/middleman-core/cli/console.rb +++ b/middleman-core/lib/middleman-core/cli/console.rb @@ -32,7 +32,7 @@ module Middleman::Cli set :environment, opts[:environment].to_sym end - logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false) + ::Middleman::Logger.singleton(opts[:debug] ? 0 : 1, opts[:instrumenting] || false) end # TODO: get file watcher / reload! working in console From 732532b72eb70e39da54af255b3d659ad4b14095 Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sat, 1 Feb 2014 23:45:46 +0100 Subject: [PATCH 06/12] upgraded hooks to 0.3.3; integrated custom changes as made for 0.2.0 Conflicts: middleman-core/lib/middleman-core/application.rb --- .../lib/middleman-core/application.rb | 2 +- .../hooks-0.2.0/CHANGES.textile | 9 - .../hooks-0.2.0/Gemfile | 3 - .../hooks-0.2.0/README.rdoc | 107 --------- .../hooks-0.2.0/test/hooks_test.rb | 141 ------------ .../test/inheritable_attribute_test.rb | 55 ----- .../hooks-0.2.0/test/test_helper.rb | 10 - .../hooks-0.3.3/.gitignore | 2 + .../hooks-0.3.3/.travis.yml | 5 + .../hooks-0.3.3/CHANGES.md | 33 +++ .../hooks-0.3.3/Gemfile | 3 + .../hooks-0.3.3/LICENSE.txt | 20 ++ .../hooks-0.3.3/README.md | 202 ++++++++++++++++ .../{hooks-0.2.0 => hooks-0.3.3}/Rakefile | 0 .../hooks.gemspec | 13 +- .../{hooks-0.2.0 => hooks-0.3.3}/lib/hooks.rb | 95 +++++--- .../hooks-0.3.3/lib/hooks/hook.rb | 81 +++++++ .../lib/hooks/inheritable_attribute.rb | 4 +- .../hooks-0.3.3/lib/hooks/instance_hooks.rb | 25 ++ .../hooks-0.3.3/lib/hooks/version.rb | 3 + .../hooks-0.3.3/test/hook_test.rb | 31 +++ .../hooks-0.3.3/test/hooks_test.rb | 216 ++++++++++++++++++ .../test/inheritable_attribute_test.rb | 53 +++++ .../hooks-0.3.3/test/instance_hooks_test.rb | 55 +++++ .../hooks-0.3.3/test/test_helper.rb | 3 + 25 files changed, 804 insertions(+), 367 deletions(-) delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/Rakefile (100%) rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/hooks.gemspec (71%) rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/lib/hooks.rb (54%) create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/lib/hooks/inheritable_attribute.rb (98%) create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 74c35285..0ae9a811 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -14,7 +14,7 @@ require 'active_support/core_ext/integer/inflections' require 'active_support/core_ext/float/rounding' # Simple callback library -require 'vendored-middleman-deps/hooks-0.2.0/lib/hooks' +require 'vendored-middleman-deps/hooks-0.3.3/lib/hooks' # Our custom logger require 'middleman-core/logger' diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile deleted file mode 100644 index 3beea91d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile +++ /dev/null @@ -1,9 +0,0 @@ -h2. 0.2.0 - -h3. Changes - * Callback blocks are now executed on the instance using @instance_exec@. If you need to access the class (former context) use @self.class@. - -h2. 0.1.4 - -h3. Bugfixes - * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile deleted file mode 100644 index a1b93f3e..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source :rubygems - -gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc deleted file mode 100644 index 4a209500..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc +++ /dev/null @@ -1,107 +0,0 @@ -= Hooks - -Generic hooks with callbacks for Ruby. - - -== Introduction - -_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! - -It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than 60 lines of code, one method compilation, no +method_missing+ and no magic. - -Also, you may pass additional arguments to your callbacks when invoking a hook. - -== Example - -Let's take... a cat. - - require 'hooks' - - class Cat - include Hooks - - define_hook :after_dinner - -Now you can add callbacks to your hook declaratively in your class. - - after_dinner do - puts "Ice cream for #{self}!" - end - - after_dinner :have_a_desert # => refers to Cat#have_a_desert - - def have_a_desert - puts "Hell, yeah!" - end - -This will run the block and #have_a_desert from above. - - cat.run_hook :after_dinner - # => Ice cream for #! - Hell, yeah! - -Callback blocks and methods will be executed with instance context. Note how +self+ in the block refers to the Cat instance. - - -== Inheritance - -Hooks are inherited, here's a complete example to put it all together. - - class Garfield < Cat - - after_dinner :want_some_more - - def want_some_more - puts "Is that all?" - end - end - - - Garfield.new.run_hook :after_dinner - # => Ice cream for #! - Hell, yeah! - Is that all? - -Note how the callbacks are invoked in the order they were inherited. - - -== Options for Callbacks - -You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. - - cat.run_hook :before_dinner, cat, Time.now - -The callbacks should be ready for receiving parameters. - - before_dinner :wash_pawns - before_dinner do |who, when| - ... - end - - def wash_pawns(who, when) - - -Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. - - -== Installation - - gem install hooks - - -== Anybody using it? - -* Hooks is already used in [Apotomo:http://github.com/apotonick/apotomo], a hot widget framework for Rails. Look at +lib/apotomo/widget.rb+ for examples and into +lib/apotomo/tree_node.rb+ to learn how modules-driven code might benefit from hooks. - -== Similar libraries - -* http://github.com/nakajima/aspectory -* http://github.com/auser/backcall -* http://github.com/mmcgrana/simple_callbacks - - -== License - -Copyright (c) 2010, Nick Sutterer - -Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb deleted file mode 100644 index 83cb24e4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'test_helper' - -class HooksTest < Test::Unit::TestCase - class TestClass - include Hooks - - def executed - @executed ||= []; - end - end - - - context "Hooks.define_hook" do - setup do - @klass = Class.new(TestClass) - - @mum = @klass.new - @mum.class.define_hook :after_eight - end - - should "provide accessors to the stored callbacks" do - assert_equal [], @klass._after_eight_callbacks - @klass._after_eight_callbacks << :dine - assert_equal [:dine], @klass._after_eight_callbacks - end - - should "respond to Class.callbacks_for_hook" do - assert_equal [], @klass.callbacks_for_hook(:after_eight) - @klass.after_eight :dine - assert_equal [:dine], @klass.callbacks_for_hook(:after_eight) - end - - context "creates a public writer for the hook that" do - should "accepts method names" do - @klass.after_eight :dine - assert_equal [:dine], @klass._after_eight_callbacks - end - - should "accepts blocks" do - @klass.after_eight do true; end - assert @klass._after_eight_callbacks.first.kind_of? Proc - end - - should "be inherited" do - @klass.after_eight :dine - subklass = Class.new(@klass) - - assert_equal [:dine], subklass._after_eight_callbacks - end - end - - context "Hooks#run_hook" do - should "run without parameters" do - @mum.instance_eval do - def a; executed << :a; nil; end - def b; executed << :b; end - - self.class.after_eight :b - self.class.after_eight :a - end - - @mum.run_hook(:after_eight) - - assert_equal [:b, :a], @mum.executed - end - - should "accept arbitrary parameters" do - @mum.instance_eval do - def a(me, arg); executed << arg+1; end - end - @mum.class.after_eight :a - @mum.class.after_eight lambda { |me, arg| me.executed << arg-1 } - - @mum.run_hook(:after_eight, @mum, 1) - - assert_equal [2, 0], @mum.executed - end - - should "execute block callbacks in instance context" do - @mum.class.after_eight { executed << :c } - @mum.run_hook(:after_eight) - assert_equal [:c], @mum.executed - end - end - - context "in class context" do - should "run a callback block" do - executed = [] - @klass.after_eight do - executed << :klass - end - @klass.run_hook :after_eight - - assert_equal [:klass], executed - end - - should "run a class methods" do - executed = [] - @klass.instance_eval do - after_eight :have_dinner - - def have_dinner(executed) - executed << :have_dinner - end - end - @klass.run_hook :after_eight, executed - - assert_equal [:have_dinner], executed - end - end - end - - context "Deriving" do - setup do - @klass = Class.new(TestClass) - - @mum = @klass.new - @mum.class.define_hook :after_eight - end - - should "inherit the hook" do - @klass.class_eval do - after_eight :take_shower - - def take_shower - executed << :take_shower - end - end - - @kid = Class.new(@klass) do - after_eight :have_dinner - - def have_dinner - executed << :have_dinner - end - end.new - - assert_equal [:take_shower, :have_dinner], @kid.run_hook(:after_eight) - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb deleted file mode 100644 index 27e10a2d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'test_helper' - -class HooksTest < Test::Unit::TestCase - context "Hooks.define_hook" do - setup do - @klass = Class.new(Object) do - extend Hooks::InheritableAttribute - end - - @mum = @klass.new - @klass.inheritable_attr :drinks - end - - should "provide a reader with empty inherited attributes, already" do - assert_equal nil, @klass.drinks - end - - should "provide a reader with empty inherited attributes in a derived class" do - assert_equal nil, Class.new(@klass).drinks - #@klass.drinks = true - #Class.new(@klass).drinks # TODO: crashes. - end - - should "provide an attribute copy in subclasses" do - @klass.drinks = [] - assert @klass.drinks.object_id != Class.new(@klass).drinks.object_id - end - - should "provide a writer" do - @klass.drinks = [:cabernet] - assert_equal [:cabernet], @klass.drinks - end - - should "inherit attributes" do - @klass.drinks = [:cabernet] - - subklass_a = Class.new(@klass) - subklass_a.drinks << :becks - - subklass_b = Class.new(@klass) - - assert_equal [:cabernet], @klass.drinks - assert_equal [:cabernet, :becks], subklass_a.drinks - assert_equal [:cabernet], subklass_b.drinks - end - - should "not inherit attributes if we set explicitely" do - @klass.drinks = [:cabernet] - subklass = Class.new(@klass) - - subklass.drinks = [:merlot] # we only want merlot explicitely. - assert_equal [:merlot], subklass.drinks # no :cabernet, here - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb deleted file mode 100644 index f0b0b3cd..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'rubygems' - -# wycats says... -require 'bundler' -Bundler.setup -require 'test/unit' -require 'shoulda' -require 'hooks' - -$:.unshift File.dirname(__FILE__) # add current dir to LOAD_PATHS diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore new file mode 100644 index 00000000..80e3957f --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore @@ -0,0 +1,2 @@ +Gemfile.lock + diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml new file mode 100644 index 00000000..03107eec --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml @@ -0,0 +1,5 @@ +language: ruby +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md new file mode 100644 index 00000000..277fda61 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md @@ -0,0 +1,33 @@ +## 0.3.3 + +* Fix a bug where the hook writer method (e.g. `#after_dark`) wasn't available on the instance even when `InstanceHooks` was included. + +## 0.3.2 + +* Added `Hooks::InstanceHooks` to add hooks and/or callbacks on instance level. Thanks to @mpapis for that suggestion. + +## 0.3.1 + +* Fix a bug, string hook names are now treated as symbols. + +## 0.3.0 + +* The callback chain can now be halted by configuring the hook as `halts_on_falsey: true` and returning `nil` or `false` from the callback. +* Internal refactorings: hooks are now encapsulated in `Hook` instances and run their callback chains. + +## 0.2.2 + +* `#run_hook` now returns the list of callback results. + +## 0.2.1 + +* You can now pass multiple hook names to `#define_hooks`. + +## 0.2.0 + +h3. Changes +* Callback blocks are now executed on the instance using `instance_exec`. If you need to access the class (former context) use `self.class`. + +## 0.1.4 + +* An uninitialized `inheritable_attr` doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile new file mode 100644 index 00000000..fa75df15 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt new file mode 100644 index 00000000..ffbc659d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011-2013 Nick Sutterer + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md new file mode 100644 index 00000000..436d988d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md @@ -0,0 +1,202 @@ +# Hooks + +_Generic hooks with callbacks for Ruby._ + + +## Introduction + +_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! + +It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than a few lines of code, one method compilation, no `method_missing` and no magic. + +Also, you may pass additional arguments to your callbacks when invoking a hook. + +## Example + +Let's take... a cat. + +```ruby +require 'hooks' + +class Cat + include Hooks + + define_hooks :before_dinner, :after_dinner +``` + +Now you can add callbacks to your hook declaratively in your class. + +```ruby + before_dinner :wash_paws + + after_dinner do + puts "Ice cream for #{self}!" + end + + after_dinner :have_a_desert # => refers to Cat#have_a_desert + + def have_a_desert + puts "Hell, yeah!" + end +``` + +This will run the block and `#have_a_desert` from above. + +```ruby +cat.run_hook :after_dinner +# => Ice cream for #! + Hell, yeah! +``` + +Callback blocks and methods will be executed with instance context. Note how `self` in the block refers to the Cat instance. + + +## Inheritance + +Hooks are inherited, here's a complete example to put it all together. + +```ruby +class Garfield < Cat + + after_dinner :want_some_more + + def want_some_more + puts "Is that all?" + end +end + + +Garfield.new.run_hook :after_dinner +# => Ice cream for #! + Hell, yeah! + Is that all? +``` + +Note how the callbacks are invoked in the order they were inherited. + + +## Options for Callbacks + +You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. + +```ruby +cat.run_hook :before_dinner, cat, Time.now +``` + +The callbacks should be ready for receiving parameters. + +```ruby +before_dinner :wash_pawns +before_dinner do |who, when| + ... +end + +def wash_pawns(who, when) +``` + +Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. + + +## Running And Halting Hooks + +Using `#run_hook` doesn't only run all callbacks for this hook but also returns an array of the results from each callback method or block. + +```ruby +class Garfield + include Hooks + define_hook :after_dark + + after_dark { "Chase mice" } + after_dark { "Enjoy supper" } +end + +Garfield.new.run_hook :after_dark +# => ["Chase mice", "Enjoy supper"] +``` + +This is handy if you need to collect data from your callbacks without having to access a global (brrr) variable. + +With the `:halts_on_falsey` option you can halt the callback chain when a callback returns `nil` or `false`. + +```ruby +class Garfield + include Hooks + define_hook :after_dark, halts_on_falsey: true + + after_dark { "Chase mice" } + after_dark { nil } + after_dark { "Enjoy supper" } +end + +result = Garfield.new.run_hook :after_dark +# => ["Chase mice"] +``` + +This will only run the first two callbacks. Note that the result doesn't contain the `nil` value. You even can check if the chain was halted. + +```ruby +result.halted? #=> true +``` + +## Instance Hooks + +You can also define hooks and/or add callbacks per instance. This is helpful if your class should define a basic set of hooks and callbacks that are then extended by instances. + +```ruby +class Cat + include Hooks + include Hooks::InstanceHooks + + define_hook :after_dark + + after_dark { "Chase mice" } +end +``` + +Note that you have to include `Hooks::InstanceHooks` to get this additional functionality. + +See how callbacks can be added to a separate object, now. + +```ruby +garfield = Cat.new + +garfield.after_dark :sleep +garfield.run_hook(:after_dark) # => invoke "Chase mice" hook and #sleep +``` + +This will copy all callbacks from the `after_dark` hook to the instance and add a second hook. This all happens on the `garfield` instance, only, and leaves the class untouched. + +Naturally, adding new hooks works like-wise. + +```ruby +garfield.define_hook :before_six +garfield.before_six { .. } +``` +This feature was added in 0.3.2. + + +## Installation + +In your Gemfile, do + +```ruby +gem "hooks" +``` + +## Anybody using it? + +* Hooks is already used in [Apotomo](http://github.com/apotonick/apotomo), a hot widget framework for Rails. +* The [datamappify](https://github.com/fredwu/datamappify) gem uses hooks and the author Fred Wu contributed to this gem! + +## Similar libraries + +* http://github.com/nakajima/aspectory +* http://github.com/auser/backcall +* http://github.com/mmcgrana/simple_callbacks + + +## License + +Copyright (c) 2013, Nick Sutterer + +Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec similarity index 71% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec index 326f75c0..fe7c1cf4 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec @@ -1,7 +1,7 @@ lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) -require 'hooks' +require 'hooks/version' Gem::Specification.new do |s| s.name = "hooks" @@ -9,14 +9,17 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.authors = ["Nick Sutterer"] s.email = ["apotonick@gmail.com"] - s.homepage = "http://nicksda.apotomo.de/tag/hooks" + s.homepage = "http://nicksda.apotomo.de/2010/09/hooks-and-callbacks-for-ruby-but-simple/" s.summary = %q{Generic hooks with callbacks for Ruby.} s.description = %q{Declaratively define hooks, add callbacks and run them with the options you like.} - + s.license = "MIT" + s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.require_paths = ["lib"] - - s.add_development_dependency "shoulda" + s.license = 'MIT' + + s.add_development_dependency "minitest", ">= 5.0.0" s.add_development_dependency "rake" + s.add_development_dependency "pry" end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb similarity index 54% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb index 9c4ca879..02ad0964 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb @@ -1,35 +1,41 @@ require File.join(File.dirname(__FILE__), "hooks/inheritable_attribute") +require File.join(File.dirname(__FILE__), "hooks/hook") # Almost like ActiveSupport::Callbacks but 76,6% less complex. # # Example: # # class CatWidget < Apotomo::Widget -# define_hook :after_dinner +# define_hooks :before_dinner, :after_dinner # # Now you can add callbacks to your hook declaratively in your class. # -# after_dinner do puts "Ice cream!" end +# before_dinner :wash_paws +# after_dinner { puts "Ice cream!" } # after_dinner :have_a_desert # => refers to CatWidget#have_a_desert # # Running the callbacks happens on instances. It will run the block and #have_a_desert from above. # # cat.run_hook :after_dinner module Hooks - VERSION = "0.2.0" - def self.included(base) - base.extend InheritableAttribute - base.extend ClassMethods + base.class_eval do + extend InheritableAttribute + extend ClassMethods + inheritable_attr :_hooks + self._hooks= HookSet.new + end end module ClassMethods - def define_hook(name) - accessor_name = "_#{name}_callbacks" + def define_hooks(*names) + options = extract_options!(names) - setup_hook_accessors(accessor_name) - define_hook_writer(name, accessor_name) + names.each do |name| + setup_hook(name, options) + end end + alias_method :define_hook, :define_hooks # Like Hooks#run_hook but for the class. Note that +:callbacks+ must be class methods. # @@ -46,13 +52,7 @@ module Hooks end def run_hook_for(name, scope, *args) - callbacks_for_hook(name).each do |callback| - if callback.kind_of? Symbol - scope.send(callback, *args) - else - scope.instance_exec(*args, &callback) - end - end + _hooks[name].run(scope, *args) end # Returns the callbacks for +name+. Handy if you want to run the callbacks yourself, say when @@ -67,28 +67,37 @@ module Hooks # # would run callbacks in the object _instance_ context, passing +self+ as block parameter. def callbacks_for_hook(name) - send("_#{name}_callbacks") + _hooks[name] end private - - def define_hook_writer(hook, accessor_name) - self.send(:define_method, hook.to_sym) do |&block| - if self.class.respond_to?(hook) - self.class.send(hook.to_sym, &block) - end - end - - instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def #{hook}(method=nil, &block) - #{accessor_name} << (block || method) - end - RUBY_EVAL + def setup_hook(name, options) + _hooks[name] = Hook.new(options) + define_hook_writer(name) end - def setup_hook_accessors(accessor_name) - inheritable_attr(accessor_name) - send("#{accessor_name}=", []) # initialize ivar. + def define_hook_writer(name) + self.send(:define_method, name.to_sym) do |&block| + if self.class.respond_to?(name) + self.class.send(name.to_sym, &block) + end + end + instance_eval *hook_writer_args(name) + end + + def hook_writer_args(name) + # DISCUSS: isn't there a simpler way to define a dynamic method? should the internal logic be handled by HooksSet instead? + str = <<-RUBY_EVAL + def #{name}(method=nil, &block) + _hooks[:#{name}] << (block || method) + end + RUBY_EVAL + + [str, __FILE__, __LINE__ + 1] + end + + def extract_options!(args) + args.last.is_a?(Hash) ? args.pop : {} end end @@ -106,4 +115,22 @@ module Hooks def run_hook(name, *args) self.class.run_hook_for(name, self, *args) end + + class HookSet < Hash + def [](name) + super(name.to_sym) + end + + def []=(name, values) + super(name.to_sym, values) + end + + def clone + super.tap do |cloned| + each { |name, callbacks| cloned[name] = callbacks.clone } + end + end + end end + +require File.join(File.dirname(__FILE__), "hooks/instance_hooks") diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb new file mode 100644 index 00000000..0f4d65a7 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb @@ -0,0 +1,81 @@ +module Hooks + class Hook < Array + def initialize(options) + super() + @options = options + end + + # The chain contains the return values of the executed callbacks. + # + # Example: + # + # class Person + # define_hook :before_eating + # + # before_eating :wash_hands + # before_eating :locate_food + # before_eating :sit_down + # + # def wash_hands; :washed_hands; end + # def locate_food; :located_food; false; end + # def sit_down; :sat_down; end + # end + # + # result = person.run_hook(:before_eating) + # result.chain #=> [:washed_hands, false, :sat_down] + # + # If :halts_on_falsey is enabled: + # + # class Person + # define_hook :before_eating, :halts_on_falsey => true + # # ... + # end + # + # result = person.run_hook(:before_eating) + # result.chain #=> [:washed_hands] + def run(scope, *args) + inject(Results.new) do |results, callback| + executed = execute_callback(scope, callback, *args) + + return results.halted! unless continue_execution?(executed) + results << executed + end + end + + private + def execute_callback(scope, callback, *args) + if callback.kind_of?(Symbol) + scope.send(callback, *args) + else + scope.instance_exec(*args, &callback) + end + end + + def continue_execution?(result) + @options[:halts_on_falsey] ? result : true + end + + class Results < Array + # so much code for nothing... + def initialize(*) + super + @halted = false + end + + def halted! + @halted = true + self + end + + # Returns true or false based on whether all callbacks + # in the hook chain were successfully executed. + def halted? + @halted + end + + def not_halted? + not @halted + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb similarity index 98% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb index 88f24b4f..352e28d6 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb @@ -22,12 +22,12 @@ module Hooks def #{name}=(v) @#{name} = v end - + def #{name} return @#{name} unless superclass.respond_to?(:#{name}) and value = superclass.#{name} @#{name} ||= value.clone # only do this once. end } end - end + end end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb new file mode 100644 index 00000000..0f523fa4 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb @@ -0,0 +1,25 @@ +module Hooks + module InstanceHooks + include ClassMethods + + def run_hook(name, *args) + run_hook_for(name, self, *args) + end + + private + def _hooks + @_hooks ||= self.class._hooks.clone # TODO: generify that with representable_attrs. + end + + module ClassMethods + def define_hook_writer(name) + super + class_eval *hook_writer_args(name) + end + end + + def self.included(base) + base.extend(ClassMethods) + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb new file mode 100644 index 00000000..788aaf77 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb @@ -0,0 +1,3 @@ +module Hooks + VERSION = "0.3.3" +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb new file mode 100644 index 00000000..5d539be1 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class HookTest < MiniTest::Spec + subject { Hooks::Hook.new({}) } + + it "exposes array behaviour for callbacks" do + subject << :play_music + subject << :drink_beer + + subject.to_a.must_equal [:play_music, :drink_beer] + end +end + +class ResultsTest < MiniTest::Spec + subject { Hooks::Hook::Results.new } + + describe "#halted?" do + it "defaults to false" do + subject.halted?.must_equal false + end + + it "responds to #halted!" do + subject.halted! + subject.halted?.must_equal true + end + + it "responds to #not_halted?" do + subject.not_halted?.must_equal true + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb new file mode 100644 index 00000000..151a4b3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb @@ -0,0 +1,216 @@ +require 'test_helper' + +class HooksTest < MiniTest::Spec + class TestClass + include Hooks + + def executed + @executed ||= []; + end + end + + + describe "::define_hook" do + let(:klass) do + Class.new(TestClass) do + define_hook :after_eight + end + end + + subject { klass.new } + + it "respond to Class.callbacks_for_hook" do + assert_equal [], klass.callbacks_for_hook(:after_eight) + klass.after_eight :dine + assert_equal [:dine], klass.callbacks_for_hook(:after_eight) + end + + it 'symbolizes strings when defining a hook' do + subject.class.define_hooks :before_one, 'after_one' + assert_equal [], klass.callbacks_for_hook(:before_one) + assert_equal [], klass.callbacks_for_hook(:after_one) + assert_equal [], klass.callbacks_for_hook('after_one') + end + + it "accept multiple hook names" do + subject.class.define_hooks :before_ten, :after_ten + assert_equal [], klass.callbacks_for_hook(:before_ten) + assert_equal [], klass.callbacks_for_hook(:after_ten) + end + + describe "creates a public writer for the hook that" do + it "accepts method names" do + klass.after_eight :dine + assert_equal [:dine], klass._hooks[:after_eight] + end + + it "accepts blocks" do + klass.after_eight do true; end + assert klass._hooks[:after_eight].first.kind_of? Proc + end + + it "be inherited" do + klass.after_eight :dine + subklass = Class.new(klass) + + assert_equal [:dine], subklass._hooks[:after_eight] + end + # TODO: check if options are not shared! + end + + describe "Hooks#run_hook" do + it "run without parameters" do + subject.instance_eval do + def a; executed << :a; nil; end + def b; executed << :b; end + + self.class.after_eight :b + self.class.after_eight :a + end + + subject.run_hook(:after_eight) + + assert_equal [:b, :a], subject.executed + end + + it "returns empty Results when no callbacks defined" do + subject.run_hook(:after_eight).must_equal Hooks::Hook::Results.new + end + + it "accept arbitrary parameters" do + subject.instance_eval do + def a(me, arg); executed << arg+1; end + end + subject.class.after_eight :a + subject.class.after_eight lambda { |me, arg| me.executed << arg-1 } + + subject.run_hook(:after_eight, subject, 1) + + assert_equal [2, 0], subject.executed + end + + it "execute block callbacks in instance context" do + subject.class.after_eight { executed << :c } + subject.run_hook(:after_eight) + assert_equal [:c], subject.executed + end + + it "returns all callbacks in order" do + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out, :party_hard, :taxi_home], results + assert_equal false, results.halted? + assert_equal true, results.not_halted? + end + + describe "halts_on_falsey: true" do + let(:klass) do + Class.new(TestClass) do + define_hook :after_eight, :halts_on_falsey => true + end + end + + [nil, false].each do |falsey| + it "returns successful callbacks in order (with #{falsey.inspect})" do + ordered = [] + + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard; falsey } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out], results + assert_equal true, results.halted? + end + end + end + + describe "halts_on_falsey: false" do + [nil, false].each do |falsey| + it "returns all callbacks in order (with #{falsey.inspect})" do + ordered = [] + + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard; falsey } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out, falsey, :taxi_home], results + assert_equal false, results.halted? + end + end + end + end + + describe "in class context" do + it "runs callback block" do + executed = [] + klass.after_eight do + executed << :klass + end + klass.run_hook(:after_eight) + + executed.must_equal([:klass]) + end + + it "runs instance methods" do + executed = [] + klass.instance_eval do + after_eight :have_dinner + + def have_dinner(executed) + executed << :have_dinner + end + end + klass.run_hook(:after_eight, executed) + + executed.must_equal([:have_dinner]) + end + end + end + + describe "Inheritance" do + let (:superclass) { + Class.new(TestClass) do + define_hook :after_eight + + after_eight :take_shower + end + } + + let (:subclass) { Class.new(superclass) do after_eight :have_dinner end } + + it "inherits callbacks from the hook" do + subclass.callbacks_for_hook(:after_eight).must_equal [:take_shower, :have_dinner] + end + + it "doesn't mix up superclass hooks" do + subclass.superclass.callbacks_for_hook(:after_eight).must_equal [:take_shower] + end + end +end + +class HookSetTest < MiniTest::Spec + subject { Hooks::HookSet.new } + + let (:first_hook) { Hooks::Hook.new(:halts_on_falsey => true) } + let (:second_hook) { Hooks::Hook.new(:halts_on_falsey => false) } + + it "responds to #clone" do + subject[:after_eight] = [first_hook] + + clone = subject.clone + + clone[:after_eight] << second_hook + + subject.must_equal(:after_eight => [first_hook]) + clone.must_equal(:after_eight => [first_hook, second_hook]) + end + # TODO: test if options get cloned. +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb new file mode 100644 index 00000000..4cc14e58 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb @@ -0,0 +1,53 @@ +require 'test_helper' + +class HooksTest < MiniTest::Spec + describe "Hooks.define_hook" do + subject { + Class.new(Object) do + extend Hooks::InheritableAttribute + inheritable_attr :drinks + end + } + + it "provides a reader with empty inherited attributes, already" do + assert_equal nil, subject.drinks + end + + it "provides a reader with empty inherited attributes in a derived class" do + assert_equal nil, Class.new(subject).drinks + #subject.drinks = true + #Class.new(subject).drinks # TODO: crashes. + end + + it "provides an attribute copy in subclasses" do + subject.drinks = [] + assert subject.drinks.object_id != Class.new(subject).drinks.object_id + end + + it "provides a writer" do + subject.drinks = [:cabernet] + assert_equal [:cabernet], subject.drinks + end + + it "inherits attributes" do + subject.drinks = [:cabernet] + + subklass_a = Class.new(subject) + subklass_a.drinks << :becks + + subklass_b = Class.new(subject) + + assert_equal [:cabernet], subject.drinks + assert_equal [:cabernet, :becks], subklass_a.drinks + assert_equal [:cabernet], subklass_b.drinks + end + + it "does not inherit attributes if we set explicitely" do + subject.drinks = [:cabernet] + subklass = Class.new(subject) + + subklass.drinks = [:merlot] # we only want merlot explicitely. + assert_equal [:merlot], subklass.drinks # no :cabernet, here + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb new file mode 100644 index 00000000..ffac3fb5 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb @@ -0,0 +1,55 @@ +require "test_helper" + +class InstanceHooksTest < HooksTest + describe "#define_hook" do + let(:klass) { Class.new(TestClass) do + include Hooks::InstanceHooks + end } + + subject { klass.new.tap do |obj| + obj.instance_eval do + def dine; executed << :dine; end + end + end } + + it "adds hook to instance" do + subject.define_hook :after_eight + + assert_equal [], subject.callbacks_for_hook(:after_eight) + end + + it "copies existing class hook" do + klass.define_hook :after_eight + klass.after_eight :dine + + assert_equal [:dine], subject.callbacks_for_hook(:after_eight) + end + + describe "#after_eight (adding callbacks)" do + before do + subject.define_hook :after_eight + subject.after_eight :dine + end + + it "adds #after_eight hook" do + assert_equal [:dine], subject.callbacks_for_hook(:after_eight) + end + + it "responds to #run_hook" do + subject.run_hook :after_eight + subject.executed.must_equal [:dine] + end + end + + describe "#after_eight from class (no define_hook in instance)" do + it "responds to #after_eight" do + klass.define_hook :after_eight + + subject.after_eight :dine + + subject.run_hook :after_eight + subject.executed.must_equal [:dine] + end + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb new file mode 100644 index 00000000..2ece0d0e --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb @@ -0,0 +1,3 @@ +require 'minitest/autorun' +require 'pry' +require 'hooks' From e5d95944c4843cedc485c0d08157055f8afe64cf Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sun, 2 Feb 2014 11:12:57 +0100 Subject: [PATCH 07/12] =?UTF-8?q?use=20instance=20hooks=20provided=20by=20?= =?UTF-8?q?hooks=20instead=20of=20changing=20the=20gem=E2=80=99s=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conflicts: middleman-core/lib/middleman-core/core_extensions/extensions.rb --- middleman-core/lib/middleman-core/application.rb | 7 +++++++ .../lib/middleman-more/core_extensions/compass.rb | 4 ++-- .../lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb | 5 ----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 0ae9a811..bf549708 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -32,6 +32,7 @@ module Middleman # Uses callbacks include Hooks + include Hooks::InstanceHooks # Before request hook define_hook :before @@ -223,6 +224,12 @@ module Middleman end alias :inspect :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s + # Hooks clones _hooks from the class to the instance. + # https://github.com/apotonick/hooks/blob/master/lib/hooks/instance_hooks.rb#L10 + # Middleman expects the same list of hooks for class and instance hooks: + def _hooks + self.class._hooks + end end end diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index cdf2c299..2aa46d47 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -49,7 +49,7 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension end # Call hook - app.run_hook :compass_config, ::Compass.configuration + app.run_hook_for :compass_config, app, ::Compass.configuration # Tell Tilt to use it as well (for inline sass blocks) ::Tilt.register 'sass', CompassSassTemplate @@ -73,4 +73,4 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension super.merge(::Compass.configuration.to_sass_engine_options) end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb index 02ad0964..d7c6d5dd 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb @@ -77,11 +77,6 @@ module Hooks end def define_hook_writer(name) - self.send(:define_method, name.to_sym) do |&block| - if self.class.respond_to?(name) - self.class.send(name.to_sym, &block) - end - end instance_eval *hook_writer_args(name) end From 0c3000c799fc2e0cccd3635c9611aef23286105e Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sun, 2 Feb 2014 11:18:25 +0100 Subject: [PATCH 08/12] =?UTF-8?q?as=20there=20are=20no=20more=20local=20ch?= =?UTF-8?q?anges=20in=20the=20hooks=E2=80=99=20source,=20it=20can=20be=20u?= =?UTF-8?q?nvendored=20and=20used=20as=20gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/middleman-core/application.rb | 2 +- .../hooks-0.3.3/.gitignore | 2 - .../hooks-0.3.3/.travis.yml | 5 - .../hooks-0.3.3/CHANGES.md | 33 --- .../hooks-0.3.3/Gemfile | 3 - .../hooks-0.3.3/LICENSE.txt | 20 -- .../hooks-0.3.3/README.md | 202 ---------------- .../hooks-0.3.3/Rakefile | 12 - .../hooks-0.3.3/hooks.gemspec | 25 -- .../hooks-0.3.3/lib/hooks.rb | 131 ----------- .../hooks-0.3.3/lib/hooks/hook.rb | 81 ------- .../lib/hooks/inheritable_attribute.rb | 33 --- .../hooks-0.3.3/lib/hooks/instance_hooks.rb | 25 -- .../hooks-0.3.3/lib/hooks/version.rb | 3 - .../hooks-0.3.3/test/hook_test.rb | 31 --- .../hooks-0.3.3/test/hooks_test.rb | 216 ------------------ .../test/inheritable_attribute_test.rb | 53 ----- .../hooks-0.3.3/test/instance_hooks_test.rb | 55 ----- .../hooks-0.3.3/test/test_helper.rb | 3 - middleman-core/middleman-core.gemspec | 1 + 20 files changed, 2 insertions(+), 934 deletions(-) delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index bf549708..13595135 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -14,7 +14,7 @@ require 'active_support/core_ext/integer/inflections' require 'active_support/core_ext/float/rounding' # Simple callback library -require 'vendored-middleman-deps/hooks-0.3.3/lib/hooks' +require 'hooks' # Our custom logger require 'middleman-core/logger' diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore deleted file mode 100644 index 80e3957f..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Gemfile.lock - diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml deleted file mode 100644 index 03107eec..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: ruby -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md deleted file mode 100644 index 277fda61..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md +++ /dev/null @@ -1,33 +0,0 @@ -## 0.3.3 - -* Fix a bug where the hook writer method (e.g. `#after_dark`) wasn't available on the instance even when `InstanceHooks` was included. - -## 0.3.2 - -* Added `Hooks::InstanceHooks` to add hooks and/or callbacks on instance level. Thanks to @mpapis for that suggestion. - -## 0.3.1 - -* Fix a bug, string hook names are now treated as symbols. - -## 0.3.0 - -* The callback chain can now be halted by configuring the hook as `halts_on_falsey: true` and returning `nil` or `false` from the callback. -* Internal refactorings: hooks are now encapsulated in `Hook` instances and run their callback chains. - -## 0.2.2 - -* `#run_hook` now returns the list of callback results. - -## 0.2.1 - -* You can now pass multiple hook names to `#define_hooks`. - -## 0.2.0 - -h3. Changes -* Callback blocks are now executed on the instance using `instance_exec`. If you need to access the class (former context) use `self.class`. - -## 0.1.4 - -* An uninitialized `inheritable_attr` doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile deleted file mode 100644 index fa75df15..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt deleted file mode 100644 index ffbc659d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2011-2013 Nick Sutterer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md deleted file mode 100644 index 436d988d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md +++ /dev/null @@ -1,202 +0,0 @@ -# Hooks - -_Generic hooks with callbacks for Ruby._ - - -## Introduction - -_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! - -It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than a few lines of code, one method compilation, no `method_missing` and no magic. - -Also, you may pass additional arguments to your callbacks when invoking a hook. - -## Example - -Let's take... a cat. - -```ruby -require 'hooks' - -class Cat - include Hooks - - define_hooks :before_dinner, :after_dinner -``` - -Now you can add callbacks to your hook declaratively in your class. - -```ruby - before_dinner :wash_paws - - after_dinner do - puts "Ice cream for #{self}!" - end - - after_dinner :have_a_desert # => refers to Cat#have_a_desert - - def have_a_desert - puts "Hell, yeah!" - end -``` - -This will run the block and `#have_a_desert` from above. - -```ruby -cat.run_hook :after_dinner -# => Ice cream for #! - Hell, yeah! -``` - -Callback blocks and methods will be executed with instance context. Note how `self` in the block refers to the Cat instance. - - -## Inheritance - -Hooks are inherited, here's a complete example to put it all together. - -```ruby -class Garfield < Cat - - after_dinner :want_some_more - - def want_some_more - puts "Is that all?" - end -end - - -Garfield.new.run_hook :after_dinner -# => Ice cream for #! - Hell, yeah! - Is that all? -``` - -Note how the callbacks are invoked in the order they were inherited. - - -## Options for Callbacks - -You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. - -```ruby -cat.run_hook :before_dinner, cat, Time.now -``` - -The callbacks should be ready for receiving parameters. - -```ruby -before_dinner :wash_pawns -before_dinner do |who, when| - ... -end - -def wash_pawns(who, when) -``` - -Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. - - -## Running And Halting Hooks - -Using `#run_hook` doesn't only run all callbacks for this hook but also returns an array of the results from each callback method or block. - -```ruby -class Garfield - include Hooks - define_hook :after_dark - - after_dark { "Chase mice" } - after_dark { "Enjoy supper" } -end - -Garfield.new.run_hook :after_dark -# => ["Chase mice", "Enjoy supper"] -``` - -This is handy if you need to collect data from your callbacks without having to access a global (brrr) variable. - -With the `:halts_on_falsey` option you can halt the callback chain when a callback returns `nil` or `false`. - -```ruby -class Garfield - include Hooks - define_hook :after_dark, halts_on_falsey: true - - after_dark { "Chase mice" } - after_dark { nil } - after_dark { "Enjoy supper" } -end - -result = Garfield.new.run_hook :after_dark -# => ["Chase mice"] -``` - -This will only run the first two callbacks. Note that the result doesn't contain the `nil` value. You even can check if the chain was halted. - -```ruby -result.halted? #=> true -``` - -## Instance Hooks - -You can also define hooks and/or add callbacks per instance. This is helpful if your class should define a basic set of hooks and callbacks that are then extended by instances. - -```ruby -class Cat - include Hooks - include Hooks::InstanceHooks - - define_hook :after_dark - - after_dark { "Chase mice" } -end -``` - -Note that you have to include `Hooks::InstanceHooks` to get this additional functionality. - -See how callbacks can be added to a separate object, now. - -```ruby -garfield = Cat.new - -garfield.after_dark :sleep -garfield.run_hook(:after_dark) # => invoke "Chase mice" hook and #sleep -``` - -This will copy all callbacks from the `after_dark` hook to the instance and add a second hook. This all happens on the `garfield` instance, only, and leaves the class untouched. - -Naturally, adding new hooks works like-wise. - -```ruby -garfield.define_hook :before_six -garfield.before_six { .. } -``` -This feature was added in 0.3.2. - - -## Installation - -In your Gemfile, do - -```ruby -gem "hooks" -``` - -## Anybody using it? - -* Hooks is already used in [Apotomo](http://github.com/apotonick/apotomo), a hot widget framework for Rails. -* The [datamappify](https://github.com/fredwu/datamappify) gem uses hooks and the author Fred Wu contributed to this gem! - -## Similar libraries - -* http://github.com/nakajima/aspectory -* http://github.com/auser/backcall -* http://github.com/mmcgrana/simple_callbacks - - -## License - -Copyright (c) 2013, Nick Sutterer - -Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile deleted file mode 100644 index 4799b87b..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile +++ /dev/null @@ -1,12 +0,0 @@ -require 'rake' -require 'rake/testtask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the hooks plugin.' -Rake::TestTask.new(:test) do |test| - test.libs << 'test' - test.test_files = FileList['test/*_test.rb'] - test.verbose = true -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec deleted file mode 100644 index fe7c1cf4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec +++ /dev/null @@ -1,25 +0,0 @@ -lib = File.expand_path('../lib/', __FILE__) -$:.unshift lib unless $:.include?(lib) - -require 'hooks/version' - -Gem::Specification.new do |s| - s.name = "hooks" - s.version = Hooks::VERSION - s.platform = Gem::Platform::RUBY - s.authors = ["Nick Sutterer"] - s.email = ["apotonick@gmail.com"] - s.homepage = "http://nicksda.apotomo.de/2010/09/hooks-and-callbacks-for-ruby-but-simple/" - s.summary = %q{Generic hooks with callbacks for Ruby.} - s.description = %q{Declaratively define hooks, add callbacks and run them with the options you like.} - s.license = "MIT" - - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.require_paths = ["lib"] - s.license = 'MIT' - - s.add_development_dependency "minitest", ">= 5.0.0" - s.add_development_dependency "rake" - s.add_development_dependency "pry" -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb deleted file mode 100644 index d7c6d5dd..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb +++ /dev/null @@ -1,131 +0,0 @@ -require File.join(File.dirname(__FILE__), "hooks/inheritable_attribute") -require File.join(File.dirname(__FILE__), "hooks/hook") - -# Almost like ActiveSupport::Callbacks but 76,6% less complex. -# -# Example: -# -# class CatWidget < Apotomo::Widget -# define_hooks :before_dinner, :after_dinner -# -# Now you can add callbacks to your hook declaratively in your class. -# -# before_dinner :wash_paws -# after_dinner { puts "Ice cream!" } -# after_dinner :have_a_desert # => refers to CatWidget#have_a_desert -# -# Running the callbacks happens on instances. It will run the block and #have_a_desert from above. -# -# cat.run_hook :after_dinner -module Hooks - def self.included(base) - base.class_eval do - extend InheritableAttribute - extend ClassMethods - inheritable_attr :_hooks - self._hooks= HookSet.new - end - end - - module ClassMethods - def define_hooks(*names) - options = extract_options!(names) - - names.each do |name| - setup_hook(name, options) - end - end - alias_method :define_hook, :define_hooks - - # Like Hooks#run_hook but for the class. Note that +:callbacks+ must be class methods. - # - # Example: - # - # class Cat - # after_eight :grab_a_beer - # - # def self.grab_a_beer(*) # and so on... - # - # where Cat.run_hook :after_eight will call the class method +grab_a_beer+. - def run_hook(name, *args) - run_hook_for(name, self, *args) - end - - def run_hook_for(name, scope, *args) - _hooks[name].run(scope, *args) - end - - # Returns the callbacks for +name+. Handy if you want to run the callbacks yourself, say when - # they should be executed in another context. - # - # Example: - # - # def initialize - # self.class.callbacks_for_hook(:after_eight).each do |callback| - # instance_exec(self, &callback) - # end - # - # would run callbacks in the object _instance_ context, passing +self+ as block parameter. - def callbacks_for_hook(name) - _hooks[name] - end - - private - def setup_hook(name, options) - _hooks[name] = Hook.new(options) - define_hook_writer(name) - end - - def define_hook_writer(name) - instance_eval *hook_writer_args(name) - end - - def hook_writer_args(name) - # DISCUSS: isn't there a simpler way to define a dynamic method? should the internal logic be handled by HooksSet instead? - str = <<-RUBY_EVAL - def #{name}(method=nil, &block) - _hooks[:#{name}] << (block || method) - end - RUBY_EVAL - - [str, __FILE__, __LINE__ + 1] - end - - def extract_options!(args) - args.last.is_a?(Hash) ? args.pop : {} - end - end - - # Runs the callbacks (method/block) for the specified hook +name+. Additional arguments will - # be passed to the callback. - # - # Example: - # - # cat.run_hook :after_dinner, "i want ice cream!" - # - # will invoke the callbacks like - # - # desert("i want ice cream!") - # block.call("i want ice cream!") - def run_hook(name, *args) - self.class.run_hook_for(name, self, *args) - end - - class HookSet < Hash - def [](name) - super(name.to_sym) - end - - def []=(name, values) - super(name.to_sym, values) - end - - def clone - super.tap do |cloned| - each { |name, callbacks| cloned[name] = callbacks.clone } - end - end - end -end - -require File.join(File.dirname(__FILE__), "hooks/instance_hooks") diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb deleted file mode 100644 index 0f4d65a7..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb +++ /dev/null @@ -1,81 +0,0 @@ -module Hooks - class Hook < Array - def initialize(options) - super() - @options = options - end - - # The chain contains the return values of the executed callbacks. - # - # Example: - # - # class Person - # define_hook :before_eating - # - # before_eating :wash_hands - # before_eating :locate_food - # before_eating :sit_down - # - # def wash_hands; :washed_hands; end - # def locate_food; :located_food; false; end - # def sit_down; :sat_down; end - # end - # - # result = person.run_hook(:before_eating) - # result.chain #=> [:washed_hands, false, :sat_down] - # - # If :halts_on_falsey is enabled: - # - # class Person - # define_hook :before_eating, :halts_on_falsey => true - # # ... - # end - # - # result = person.run_hook(:before_eating) - # result.chain #=> [:washed_hands] - def run(scope, *args) - inject(Results.new) do |results, callback| - executed = execute_callback(scope, callback, *args) - - return results.halted! unless continue_execution?(executed) - results << executed - end - end - - private - def execute_callback(scope, callback, *args) - if callback.kind_of?(Symbol) - scope.send(callback, *args) - else - scope.instance_exec(*args, &callback) - end - end - - def continue_execution?(result) - @options[:halts_on_falsey] ? result : true - end - - class Results < Array - # so much code for nothing... - def initialize(*) - super - @halted = false - end - - def halted! - @halted = true - self - end - - # Returns true or false based on whether all callbacks - # in the hook chain were successfully executed. - def halted? - @halted - end - - def not_halted? - not @halted - end - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb deleted file mode 100644 index 352e28d6..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Hooks - module InheritableAttribute - # Creates an inheritable attribute with accessors in the singleton class. Derived classes inherit the - # attributes. This is especially helpful with arrays or hashes that are extended in the inheritance - # chain. Note that you have to initialize the inheritable attribute. - # - # Example: - # - # class Cat - # inheritable_attr :drinks - # self.drinks = ["Becks"] - # - # class Garfield < Cat - # self.drinks << "Fireman's 4" - # - # and then, later - # - # Cat.drinks #=> ["Becks"] - # Garfield.drinks #=> ["Becks", "Fireman's 4"] - def inheritable_attr(name) - instance_eval %Q{ - def #{name}=(v) - @#{name} = v - end - - def #{name} - return @#{name} unless superclass.respond_to?(:#{name}) and value = superclass.#{name} - @#{name} ||= value.clone # only do this once. - end - } - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb deleted file mode 100644 index 0f523fa4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Hooks - module InstanceHooks - include ClassMethods - - def run_hook(name, *args) - run_hook_for(name, self, *args) - end - - private - def _hooks - @_hooks ||= self.class._hooks.clone # TODO: generify that with representable_attrs. - end - - module ClassMethods - def define_hook_writer(name) - super - class_eval *hook_writer_args(name) - end - end - - def self.included(base) - base.extend(ClassMethods) - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb deleted file mode 100644 index 788aaf77..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Hooks - VERSION = "0.3.3" -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb deleted file mode 100644 index 5d539be1..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'test_helper' - -class HookTest < MiniTest::Spec - subject { Hooks::Hook.new({}) } - - it "exposes array behaviour for callbacks" do - subject << :play_music - subject << :drink_beer - - subject.to_a.must_equal [:play_music, :drink_beer] - end -end - -class ResultsTest < MiniTest::Spec - subject { Hooks::Hook::Results.new } - - describe "#halted?" do - it "defaults to false" do - subject.halted?.must_equal false - end - - it "responds to #halted!" do - subject.halted! - subject.halted?.must_equal true - end - - it "responds to #not_halted?" do - subject.not_halted?.must_equal true - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb deleted file mode 100644 index 151a4b3d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb +++ /dev/null @@ -1,216 +0,0 @@ -require 'test_helper' - -class HooksTest < MiniTest::Spec - class TestClass - include Hooks - - def executed - @executed ||= []; - end - end - - - describe "::define_hook" do - let(:klass) do - Class.new(TestClass) do - define_hook :after_eight - end - end - - subject { klass.new } - - it "respond to Class.callbacks_for_hook" do - assert_equal [], klass.callbacks_for_hook(:after_eight) - klass.after_eight :dine - assert_equal [:dine], klass.callbacks_for_hook(:after_eight) - end - - it 'symbolizes strings when defining a hook' do - subject.class.define_hooks :before_one, 'after_one' - assert_equal [], klass.callbacks_for_hook(:before_one) - assert_equal [], klass.callbacks_for_hook(:after_one) - assert_equal [], klass.callbacks_for_hook('after_one') - end - - it "accept multiple hook names" do - subject.class.define_hooks :before_ten, :after_ten - assert_equal [], klass.callbacks_for_hook(:before_ten) - assert_equal [], klass.callbacks_for_hook(:after_ten) - end - - describe "creates a public writer for the hook that" do - it "accepts method names" do - klass.after_eight :dine - assert_equal [:dine], klass._hooks[:after_eight] - end - - it "accepts blocks" do - klass.after_eight do true; end - assert klass._hooks[:after_eight].first.kind_of? Proc - end - - it "be inherited" do - klass.after_eight :dine - subklass = Class.new(klass) - - assert_equal [:dine], subklass._hooks[:after_eight] - end - # TODO: check if options are not shared! - end - - describe "Hooks#run_hook" do - it "run without parameters" do - subject.instance_eval do - def a; executed << :a; nil; end - def b; executed << :b; end - - self.class.after_eight :b - self.class.after_eight :a - end - - subject.run_hook(:after_eight) - - assert_equal [:b, :a], subject.executed - end - - it "returns empty Results when no callbacks defined" do - subject.run_hook(:after_eight).must_equal Hooks::Hook::Results.new - end - - it "accept arbitrary parameters" do - subject.instance_eval do - def a(me, arg); executed << arg+1; end - end - subject.class.after_eight :a - subject.class.after_eight lambda { |me, arg| me.executed << arg-1 } - - subject.run_hook(:after_eight, subject, 1) - - assert_equal [2, 0], subject.executed - end - - it "execute block callbacks in instance context" do - subject.class.after_eight { executed << :c } - subject.run_hook(:after_eight) - assert_equal [:c], subject.executed - end - - it "returns all callbacks in order" do - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out, :party_hard, :taxi_home], results - assert_equal false, results.halted? - assert_equal true, results.not_halted? - end - - describe "halts_on_falsey: true" do - let(:klass) do - Class.new(TestClass) do - define_hook :after_eight, :halts_on_falsey => true - end - end - - [nil, false].each do |falsey| - it "returns successful callbacks in order (with #{falsey.inspect})" do - ordered = [] - - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard; falsey } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out], results - assert_equal true, results.halted? - end - end - end - - describe "halts_on_falsey: false" do - [nil, false].each do |falsey| - it "returns all callbacks in order (with #{falsey.inspect})" do - ordered = [] - - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard; falsey } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out, falsey, :taxi_home], results - assert_equal false, results.halted? - end - end - end - end - - describe "in class context" do - it "runs callback block" do - executed = [] - klass.after_eight do - executed << :klass - end - klass.run_hook(:after_eight) - - executed.must_equal([:klass]) - end - - it "runs instance methods" do - executed = [] - klass.instance_eval do - after_eight :have_dinner - - def have_dinner(executed) - executed << :have_dinner - end - end - klass.run_hook(:after_eight, executed) - - executed.must_equal([:have_dinner]) - end - end - end - - describe "Inheritance" do - let (:superclass) { - Class.new(TestClass) do - define_hook :after_eight - - after_eight :take_shower - end - } - - let (:subclass) { Class.new(superclass) do after_eight :have_dinner end } - - it "inherits callbacks from the hook" do - subclass.callbacks_for_hook(:after_eight).must_equal [:take_shower, :have_dinner] - end - - it "doesn't mix up superclass hooks" do - subclass.superclass.callbacks_for_hook(:after_eight).must_equal [:take_shower] - end - end -end - -class HookSetTest < MiniTest::Spec - subject { Hooks::HookSet.new } - - let (:first_hook) { Hooks::Hook.new(:halts_on_falsey => true) } - let (:second_hook) { Hooks::Hook.new(:halts_on_falsey => false) } - - it "responds to #clone" do - subject[:after_eight] = [first_hook] - - clone = subject.clone - - clone[:after_eight] << second_hook - - subject.must_equal(:after_eight => [first_hook]) - clone.must_equal(:after_eight => [first_hook, second_hook]) - end - # TODO: test if options get cloned. -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb deleted file mode 100644 index 4cc14e58..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'test_helper' - -class HooksTest < MiniTest::Spec - describe "Hooks.define_hook" do - subject { - Class.new(Object) do - extend Hooks::InheritableAttribute - inheritable_attr :drinks - end - } - - it "provides a reader with empty inherited attributes, already" do - assert_equal nil, subject.drinks - end - - it "provides a reader with empty inherited attributes in a derived class" do - assert_equal nil, Class.new(subject).drinks - #subject.drinks = true - #Class.new(subject).drinks # TODO: crashes. - end - - it "provides an attribute copy in subclasses" do - subject.drinks = [] - assert subject.drinks.object_id != Class.new(subject).drinks.object_id - end - - it "provides a writer" do - subject.drinks = [:cabernet] - assert_equal [:cabernet], subject.drinks - end - - it "inherits attributes" do - subject.drinks = [:cabernet] - - subklass_a = Class.new(subject) - subklass_a.drinks << :becks - - subklass_b = Class.new(subject) - - assert_equal [:cabernet], subject.drinks - assert_equal [:cabernet, :becks], subklass_a.drinks - assert_equal [:cabernet], subklass_b.drinks - end - - it "does not inherit attributes if we set explicitely" do - subject.drinks = [:cabernet] - subklass = Class.new(subject) - - subklass.drinks = [:merlot] # we only want merlot explicitely. - assert_equal [:merlot], subklass.drinks # no :cabernet, here - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb deleted file mode 100644 index ffac3fb5..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "test_helper" - -class InstanceHooksTest < HooksTest - describe "#define_hook" do - let(:klass) { Class.new(TestClass) do - include Hooks::InstanceHooks - end } - - subject { klass.new.tap do |obj| - obj.instance_eval do - def dine; executed << :dine; end - end - end } - - it "adds hook to instance" do - subject.define_hook :after_eight - - assert_equal [], subject.callbacks_for_hook(:after_eight) - end - - it "copies existing class hook" do - klass.define_hook :after_eight - klass.after_eight :dine - - assert_equal [:dine], subject.callbacks_for_hook(:after_eight) - end - - describe "#after_eight (adding callbacks)" do - before do - subject.define_hook :after_eight - subject.after_eight :dine - end - - it "adds #after_eight hook" do - assert_equal [:dine], subject.callbacks_for_hook(:after_eight) - end - - it "responds to #run_hook" do - subject.run_hook :after_eight - subject.executed.must_equal [:dine] - end - end - - describe "#after_eight from class (no define_hook in instance)" do - it "responds to #after_eight" do - klass.define_hook :after_eight - - subject.after_eight :dine - - subject.run_hook :after_eight - subject.executed.must_equal [:dine] - end - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb deleted file mode 100644 index 2ece0d0e..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'minitest/autorun' -require 'pry' -require 'hooks' diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 954a2325..1d98baa6 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |s| s.add_dependency("bundler", ["~> 1.1"]) s.add_dependency("rack", [">= 1.4.5"]) s.add_dependency("tilt", ["~> 1.4.1"]) + s.add_dependency("hooks", ["~> 0.3"]) # Builder s.add_dependency("rack-test", ["~> 0.6.1"]) From 8d346e74a57b0446475c5bae671da5e621a45dbb Mon Sep 17 00:00:00 2001 From: Jonathan Soeder Date: Tue, 4 Feb 2014 23:03:24 -0600 Subject: [PATCH 09/12] Adding before build hook --- middleman-core/lib/middleman-core/application.rb | 3 +++ middleman-core/lib/middleman-core/cli/build.rb | 2 ++ middleman-core/lib/middleman-core/extensions.rb | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 13595135..98a04717 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -40,6 +40,9 @@ module Middleman # Ready (all loading and parsing of extensions complete) hook define_hook :ready + # Runs before the build is started + define_hook :before_build + # Runs after the build is finished define_hook :after_build diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index 33365949..dde2a1b2 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -65,6 +65,8 @@ module Middleman::Cli opts[:glob] = options['glob'] if options.has_key?('glob') opts[:clean] = options['clean'] + self.class.shared_instance.run_hook :before_build, self + action BuildAction.new(self, opts) self.class.shared_instance.run_hook :after_build, self diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index 2c97fea0..65e1fbe9 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -175,6 +175,7 @@ module Middleman # Bind app hooks to local methods bind_before_configuration bind_after_configuration + bind_before_build bind_after_build end @@ -233,6 +234,19 @@ module Middleman end end + def bind_before_build + ext = self + if ext.respond_to?(:before_build) + @klass.before_build do |builder| + if ext.method(:before_build).arity === 1 + ext.before_build(builder) + else + ext.before_build + end + end + end + end + def bind_after_build ext = self if ext.respond_to?(:after_build) From 3995ad850c46d9624d35fd5e22365a31ee430f1e Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 18 Feb 2014 18:30:29 -0800 Subject: [PATCH 10/12] update padrino. --- CHANGELOG.md | 4 + Gemfile | 2 +- .../features/markdown_redcarpet.feature | 4 +- .../features/sass_cache_path.feature | 22 -- .../asciidoc-app/source/layouts/default.erb | 1 - .../source/capture_html_haml.html.haml | 2 +- .../source/content_for_haml.html.haml | 2 +- .../source/layouts/override.erb | 3 +- .../source/layouts/override.erb | 3 +- .../link-to-app/source/link_to_haml.html.haml | 2 +- .../link-to-app/source/link_to_slim.html.slim | 2 +- .../source/layouts/inner_haml.haml | 2 +- .../source/layouts/inner_slim.slim | 2 +- .../source/layouts/outer_haml.haml | 2 +- .../source/layouts/outer_slim.slim | 2 +- .../sass-cache-path-custom-app/config.rb | 3 - .../source/stylesheets/plain.css.sass | 4 - .../sass-cache-path-default-app/config.rb | 3 - .../source/stylesheets/plain.css.sass | 4 - .../lib/middleman-core/application.rb | 2 +- .../meta_pages/sitemap_resource.rb | 4 +- .../lib/middleman-core/renderers/erb.rb | 26 +- .../lib/middleman-core/renderers/haml.rb | 10 + .../lib/middleman-core/renderers/sass.rb | 4 - .../lib/middleman-core/renderers/slim.rb | 19 +- middleman-core/lib/middleman-core/version.rb | 2 +- .../middleman-more/core_extensions/compass.rb | 1 - .../core_extensions/default_helpers.rb | 30 +- .../application/rendering/extensions/slim.rb | 14 - .../lib/padrino-core/reloader.rb | 341 ------------------ .../test/test_csrf_protection.rb | 80 ---- .../.document | 0 .../.gitignore | 0 .../.yardopts | 0 .../LICENSE.txt | 0 .../README.rdoc | 0 .../Rakefile | 0 .../bin/padrino | 0 .../lib/padrino-core.rb | 62 ++-- .../lib/padrino-core/application.rb | 201 ++++++++--- .../application/authenticity_token.rb | 25 ++ .../lib/padrino-core/application/flash.rb | 0 .../lib/padrino-core/application/rendering.rb | 20 +- .../rendering/extensions/erubis.rb | 18 +- .../application/rendering/extensions/haml.rb | 5 +- .../application/rendering/extensions/slim.rb | 21 ++ .../lib/padrino-core/application/routing.rb | 101 ++++-- .../application/show_exceptions.rb} | 0 .../lib/padrino-core/caller.rb | 2 +- .../lib/padrino-core/cli/adapter.rb | 0 .../lib/padrino-core/cli/base.rb | 35 +- .../lib/padrino-core/cli/console.rb | 0 .../lib/padrino-core/cli/rake.rb | 0 .../lib/padrino-core/cli/rake_tasks.rb | 10 + .../lib/padrino-core/command.rb | 0 .../lib/padrino-core/images/404.png | Bin .../lib/padrino-core/images/500.png | Bin .../lib/padrino-core/loader.rb | 136 +++---- .../lib/padrino-core/locale/cs.yml | 0 .../lib/padrino-core/locale/da.yml | 0 .../lib/padrino-core/locale/de.yml | 0 .../lib/padrino-core/locale/en.yml | 0 .../lib/padrino-core/locale/es.yml | 0 .../lib/padrino-core/locale/fr.yml | 0 .../lib/padrino-core/locale/hu.yml | 0 .../lib/padrino-core/locale/it.yml | 0 .../lib/padrino-core/locale/ja.yml | 0 .../lib/padrino-core/locale/lv.yml | 0 .../lib/padrino-core/locale/nl.yml | 2 +- .../lib/padrino-core/locale/no.yml | 0 .../lib/padrino-core/locale/pl.yml | 0 .../lib/padrino-core/locale/pt_br.yml | 0 .../lib/padrino-core/locale/ro.yml | 0 .../lib/padrino-core/locale/ru.yml | 0 .../lib/padrino-core/locale/sv.yml | 0 .../lib/padrino-core/locale/tr.yml | 0 .../lib/padrino-core/locale/uk.yml | 0 .../lib/padrino-core/locale/zh_cn.yml | 12 +- .../lib/padrino-core/locale/zh_tw.yml | 0 .../lib/padrino-core/logger.rb | 14 +- .../lib/padrino-core/module.rb | 0 .../lib/padrino-core/mounter.rb | 15 +- .../lib/padrino-core/reloader.rb | 250 +++++++++++++ .../lib/padrino-core/reloader/rack.rb | 26 ++ .../lib/padrino-core/reloader/storage.rb | 55 +++ .../lib/padrino-core/router.rb | 23 +- .../lib/padrino-core/server.rb | 5 + .../lib/padrino-core/support_lite.rb | 65 ++-- .../lib/padrino-core/tasks.rb | 0 .../lib/padrino-core/version.rb | 2 +- .../padrino-core.gemspec | 3 +- .../test/fixtures/app_gem/Gemfile | 0 .../test/fixtures/app_gem/app/app.rb | 0 .../test/fixtures/app_gem/app_gem.gemspec | 0 .../test/fixtures/app_gem/lib/app_gem.rb | 2 +- .../fixtures/app_gem/lib/app_gem/version.rb | 0 .../test/fixtures/apps/.components | 0 .../test/fixtures/apps/.gitignore | 0 .../test/fixtures/apps/complex.rb | 0 .../fixtures/apps/helpers/system_helpers.rb | 8 + .../test/fixtures/apps/kiq.rb | 3 + .../test/fixtures/apps/lib/myklass.rb | 2 + .../fixtures/apps/lib/myklass/mysubklass.rb | 4 + .../test/fixtures/apps/models/child.rb | 2 + .../test/fixtures/apps/models/parent.rb | 5 + .../test/fixtures/apps/render.rb | 13 + .../test/fixtures/apps/simple.rb | 2 +- .../test/fixtures/apps/static.rb | 10 + .../test/fixtures/apps/system.rb | 13 + .../test/fixtures/apps/views/blog/post.erb | 1 + .../test/fixtures/dependencies/a.rb | 0 .../test/fixtures/dependencies/b.rb | 0 .../test/fixtures/dependencies/c.rb | 0 .../test/fixtures/dependencies/circular/e.rb | 0 .../test/fixtures/dependencies/circular/f.rb | 0 .../test/fixtures/dependencies/circular/g.rb | 0 .../test/fixtures/dependencies/d.rb | 0 .../test/fixtures/layouts/layout.erb | 1 + .../test/helper.rb | 4 +- .../test/mini_shoulda.rb | 8 +- .../test/test_application.rb | 18 +- .../test/test_core.rb | 21 +- .../test/test_csrf_protection.rb | 161 +++++++++ .../test/test_dependencies.rb | 15 +- .../test/test_filters.rb | 0 .../test/test_flash.rb | 0 .../test/test_locale.rb | 0 .../test/test_logger.rb | 0 .../test/test_mounter.rb | 56 ++- .../test/test_reloader_complex.rb | 4 +- .../test/test_reloader_simple.rb | 2 +- .../test/test_reloader_system.rb | 64 ++++ .../test/test_rendering.rb | 61 ++++ .../test/test_rendering_extensions.rb | 0 .../test/test_restful_routing.rb | 0 .../test/test_router.rb | 123 ++++++- .../test/test_routing.rb | 152 +++++++- .../test/test_support_lite.rb | 0 .../output_helpers/abstract_handler.rb | 96 ----- .../output_helpers/erb_handler.rb | 78 ---- .../output_helpers/haml_handler.rb | 63 ---- .../output_helpers/slim_handler.rb | 78 ---- .../markup_app/views/simple_partial.slim | 1 - .../render_app/views/double_capture_erb.erb | 3 - .../render_app/views/double_capture_haml.haml | 2 - .../render_app/views/double_capture_slim.slim | 2 - .../.document | 0 .../.gitignore | 0 .../.yardopts | 0 .../LICENSE.txt | 0 .../README.rdoc | 12 +- .../Rakefile | 0 .../lib/padrino-helpers.rb | 1 + .../lib/padrino-helpers/asset_tag_helpers.rb | 59 ++- .../lib/padrino-helpers/breadcrumb_helpers.rb | 0 .../form_builder/abstract_form_builder.rb | 47 ++- .../form_builder/standard_form_builder.rb | 0 .../lib/padrino-helpers/form_helpers.rb | 248 ++++++------- .../lib/padrino-helpers/format_helpers.rb | 2 +- .../lib/padrino-helpers/locale/cs.yml | 0 .../lib/padrino-helpers/locale/da.yml | 0 .../lib/padrino-helpers/locale/de.yml | 0 .../lib/padrino-helpers/locale/en.yml | 0 .../lib/padrino-helpers/locale/es.yml | 0 .../lib/padrino-helpers/locale/fr.yml | 0 .../lib/padrino-helpers/locale/hu.yml | 0 .../lib/padrino-helpers/locale/it.yml | 0 .../lib/padrino-helpers/locale/ja.yml | 0 .../lib/padrino-helpers/locale/lv.yml | 2 +- .../lib/padrino-helpers/locale/nl.yml | 0 .../lib/padrino-helpers/locale/no.yml | 0 .../lib/padrino-helpers/locale/pl.yml | 0 .../lib/padrino-helpers/locale/pt_br.yml | 0 .../lib/padrino-helpers/locale/ro.yml | 0 .../lib/padrino-helpers/locale/ru.yml | 0 .../lib/padrino-helpers/locale/sv.yml | 0 .../lib/padrino-helpers/locale/tr.yml | 0 .../lib/padrino-helpers/locale/uk.yml | 0 .../lib/padrino-helpers/locale/zh_cn.yml | 0 .../lib/padrino-helpers/locale/zh_tw.yml | 0 .../lib/padrino-helpers/number_helpers.rb | 0 .../lib/padrino-helpers/output_helpers.rb | 39 +- .../output_helpers/abstract_handler.rb | 61 ++++ .../output_helpers/erb_handler.rb | 27 ++ .../output_helpers/haml_handler.rb | 25 ++ .../output_helpers/slim_handler.rb | 18 + .../lib/padrino-helpers/render_helpers.rb | 39 +- .../lib/padrino-helpers/tag_helpers.rb | 2 +- .../padrino-helpers/translation_helpers.rb | 0 .../padrino-helpers.gemspec | 3 +- .../test/fixtures/markup_app/app.rb | 24 +- .../fixtures/markup_app/views/button_to.erb | 0 .../fixtures/markup_app/views/button_to.haml | 4 +- .../fixtures/markup_app/views/button_to.slim | 0 .../markup_app/views/capture_concat.erb | 0 .../markup_app/views/capture_concat.haml | 6 +- .../markup_app/views/capture_concat.slim | 6 +- .../fixtures/markup_app/views/content_for.erb | 11 +- .../markup_app/views/content_for.haml | 11 +- .../markup_app/views/content_for.slim | 9 +- .../fixtures/markup_app/views/content_tag.erb | 2 + .../markup_app/views/content_tag.haml | 6 +- .../markup_app/views/content_tag.slim | 4 +- .../markup_app/views/current_engine.erb | 0 .../markup_app/views/current_engine.haml | 0 .../markup_app/views/current_engine.slim | 0 .../fixtures/markup_app/views/fields_for.erb | 0 .../markup_app/views/fields_for.haml} | 0 .../markup_app/views/fields_for.slim} | 8 +- .../fixtures/markup_app/views/form_for.erb | 0 .../fixtures/markup_app/views/form_for.haml | 6 +- .../fixtures/markup_app/views/form_for.slim | 0 .../fixtures/markup_app/views/form_tag.erb | 0 .../fixtures/markup_app/views/form_tag.haml | 12 +- .../fixtures/markup_app/views/form_tag.slim | 0 .../fixtures/markup_app/views/link_to.erb | 0 .../fixtures/markup_app/views/link_to.haml | 2 +- .../fixtures/markup_app/views/link_to.slim | 0 .../fixtures/markup_app/views/mail_to.erb | 0 .../fixtures/markup_app/views/mail_to.haml | 0 .../fixtures/markup_app/views/mail_to.slim | 0 .../fixtures/markup_app/views/meta_tag.erb | 0 .../fixtures/markup_app/views/meta_tag.haml | 0 .../fixtures/markup_app/views/meta_tag.slim | 0 .../markup_app/views/partials/_erb.erb | 0 .../markup_app/views/partials/_haml.haml | 0 .../markup_app/views/partials/_slim.slim | 0 .../markup_app/views/simple_partial.erb | 0 .../markup_app/views/simple_partial.haml | 0 .../markup_app/views/simple_partial.slim | 1 + .../test/fixtures/render_app/app.rb | 22 +- .../test/fixtures/render_app/views/_deep.erb | 3 + .../test/fixtures/render_app/views/_deep.haml | 2 + .../test/fixtures/render_app/views/_deep.slim | 2 + .../render_app/views/_partial_block_erb.erb | 10 + .../render_app/views/_partial_block_haml.haml | 7 + .../render_app/views/_partial_block_slim.slim | 7 + .../render_app/views/current_engine.haml | 0 .../render_app/views/current_engines/_erb.erb | 0 .../views/current_engines/_haml.haml | 0 .../views/current_engines/_slim.slim | 0 .../render_app/views/double_capture_erb.erb | 3 + .../render_app/views/double_capture_haml.haml | 2 + .../render_app/views/double_capture_slim.slim | 2 + .../fixtures/render_app/views/erb/test.erb | 0 .../render_app/views/explicit_engine.haml | 0 .../fixtures/render_app/views/haml/test.haml | 0 .../render_app/views/render_block_erb.erb | 5 + .../render_app/views/render_block_haml.haml | 4 + .../render_app/views/render_block_slim.slim | 4 + .../render_app/views/template/_user.haml | 0 .../views/template/haml_template.haml | 0 .../views/template/some_template.haml | 0 .../render_app/views/wrong_capture_erb.erb | 3 + .../render_app/views/wrong_capture_haml.haml | 2 + .../render_app/views/wrong_capture_slim.slim | 2 + .../test/helper.rb | 0 .../test/test_asset_tag_helpers.rb | 34 ++ .../test/test_breadcrumb_helpers.rb | 0 .../test/test_form_builder.rb | 27 ++ .../test/test_form_helpers.rb | 42 +-- .../test/test_format_helpers.rb | 10 + .../test/test_locale.rb | 0 .../test/test_number_helpers.rb | 0 .../test/test_output_helpers.rb | 47 +-- .../test/test_render_helpers.rb | 67 ++++ .../test/test_tag_helpers.rb | 14 + middleman-core/middleman-core.gemspec | 1 + 268 files changed, 2330 insertions(+), 1477 deletions(-) delete mode 100644 middleman-core/features/sass_cache_path.feature delete mode 100644 middleman-core/fixtures/sass-cache-path-custom-app/config.rb delete mode 100644 middleman-core/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass delete mode 100644 middleman-core/fixtures/sass-cache-path-default-app/config.rb delete mode 100644 middleman-core/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/.document (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/.gitignore (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/.yardopts (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/LICENSE.txt (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/README.rdoc (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/Rakefile (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/bin/padrino (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core.rb (78%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application.rb (61%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/authenticity_token.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application/flash.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application/rendering.rb (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application/rendering/extensions/erubis.rb (68%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application/rendering/extensions/haml.rb (82%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/slim.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/application/routing.rb (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4/lib/padrino-core/application/showexceptions.rb => padrino-core-0.12.0/lib/padrino-core/application/show_exceptions.rb} (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/caller.rb (96%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/cli/adapter.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/cli/base.rb (79%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/cli/console.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/cli/rake.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/cli/rake_tasks.rb (85%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/command.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/images/404.png (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/images/500.png (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/loader.rb (64%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/cs.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/da.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/de.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/en.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/es.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/fr.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/hu.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/it.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/ja.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/lv.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/nl.yml (93%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/no.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/pl.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/pt_br.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/ro.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/ru.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/sv.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/tr.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/uk.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/zh_cn.yml (75%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/locale/zh_tw.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/logger.rb (98%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/module.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/mounter.rb (91%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/rack.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/storage.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/router.rb (79%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/server.rb (90%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/support_lite.rb (89%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/tasks.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/lib/padrino-core/version.rb (87%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/padrino-core.gemspec (96%) mode change 100755 => 100644 rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/app_gem/Gemfile (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/app_gem/app/app.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/app_gem/app_gem.gemspec (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/app_gem/lib/app_gem.rb (95%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/app_gem/lib/app_gem/version.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/apps/.components (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/apps/.gitignore (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/apps/complex.rb (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/helpers/system_helpers.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/kiq.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass/mysubklass.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/child.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/parent.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/render.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/apps/simple.rb (90%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/static.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/system.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/views/blog/post.erb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/a.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/b.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/c.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/circular/e.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/circular/f.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/circular/g.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/fixtures/dependencies/d.rb (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/layouts/layout.erb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/helper.rb (95%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/mini_shoulda.rb (78%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_application.rb (89%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_core.rb (81%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_csrf_protection.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_dependencies.rb (75%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_filters.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_flash.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_locale.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_logger.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_mounter.rb (78%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_reloader_complex.rb (95%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_reloader_simple.rb (98%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_system.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_rendering.rb (88%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_rendering_extensions.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_restful_routing.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_router.rb (60%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_routing.rb (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-core-0.11.4 => padrino-core-0.12.0}/test/test_support_lite.rb (100%) delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml delete mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/.document (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/.gitignore (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/.yardopts (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/LICENSE.txt (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/README.rdoc (97%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/Rakefile (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers.rb (98%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/asset_tag_helpers.rb (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/breadcrumb_helpers.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/form_builder/abstract_form_builder.rb (90%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/form_builder/standard_form_builder.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/form_helpers.rb (82%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/format_helpers.rb (99%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/cs.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/da.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/de.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/en.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/es.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/fr.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/hu.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/it.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/ja.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/lv.yml (99%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/nl.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/no.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/pl.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/pt_br.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/ro.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/ru.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/sv.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/tr.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/uk.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/zh_cn.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/locale/zh_tw.yml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/number_helpers.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/output_helpers.rb (87%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/abstract_handler.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/haml_handler.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/slim_handler.rb rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/render_helpers.rb (57%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/tag_helpers.rb (99%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/lib/padrino-helpers/translation_helpers.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/padrino-helpers.gemspec (93%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/app.rb (80%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/button_to.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/button_to.haml (59%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/button_to.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/capture_concat.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/capture_concat.haml (56%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/capture_concat.slim (55%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_for.erb (59%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_for.haml (54%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_for.slim (62%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_tag.erb (88%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_tag.haml (54%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/content_tag.slim (81%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/current_engine.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/current_engine.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/current_engine.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/fields_for.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.slim => padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.haml} (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml => padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.slim} (66%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_for.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_for.haml (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_for.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_tag.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_tag.haml (90%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/form_tag.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/link_to.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/link_to.haml (63%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/link_to.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/mail_to.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/mail_to.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/mail_to.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/meta_tag.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/meta_tag.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/meta_tag.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/partials/_erb.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/partials/_haml.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/partials/_slim.slim (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/simple_partial.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/markup_app/views/simple_partial.haml (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/app.rb (78%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.erb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.haml create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.slim create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_erb.erb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_haml.haml create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_slim.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/current_engine.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/current_engines/_erb.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/current_engines/_haml.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/current_engines/_slim.slim (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_erb.erb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_haml.haml create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_slim.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/erb/test.erb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/explicit_engine.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/haml/test.haml (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_erb.erb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_haml.haml create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_slim.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/template/_user.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/template/haml_template.haml (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/fixtures/render_app/views/template/some_template.haml (100%) create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_erb.erb create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_haml.haml create mode 100644 middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_slim.slim rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/helper.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_asset_tag_helpers.rb (92%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_breadcrumb_helpers.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_form_builder.rb (97%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_form_helpers.rb (97%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_format_helpers.rb (96%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_locale.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_number_helpers.rb (100%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_output_helpers.rb (77%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_render_helpers.rb (58%) rename middleman-core/lib/vendored-middleman-deps/{padrino-helpers-0.11.4 => padrino-helpers-0.12.0}/test/test_tag_helpers.rb (87%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 206b19fd..b755cbe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ master === +* Update Padrino to 0.12.0. Introduces BREAKING CHANGE for Haml. Helpers which take blocks used to require `-` instead of `=` to work correctly. Now, all helpers which output content should use `=`. See: http://www.padrinorb.com/blog/upgrading-padrino-from-0-11-x-to-0-12-0-guide +* Depend on Erubis and remove support for specifying another ERb engine. +* Removed the ability to set the `sass_cache_path`. + 3.2.2 === diff --git a/Gemfile b/Gemfile index 5e98142c..a055afd7 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'asciidoctor', :require => false platforms :ruby do gem 'therubyracer' - gem 'redcarpet', '~> 3.0' + gem 'redcarpet', '~> 3.1' gem 'pry', :require => false, :group => :development gem 'pry-debugger', :require => false, :group => :development end diff --git a/middleman-core/features/markdown_redcarpet.feature b/middleman-core/features/markdown_redcarpet.feature index 39acc839..7eec709b 100644 --- a/middleman-core/features/markdown_redcarpet.feature +++ b/middleman-core/features/markdown_redcarpet.feature @@ -86,8 +86,8 @@ Feature: Markdown (Redcarpet) support Then I should see "![dust mite](http://dust.mite/image.png)" And I should not see " <%= yield %> - diff --git a/middleman-core/fixtures/capture-html-app/source/capture_html_haml.html.haml b/middleman-core/fixtures/capture-html-app/source/capture_html_haml.html.haml index bbff7ff5..20eaef40 100644 --- a/middleman-core/fixtures/capture-html-app/source/capture_html_haml.html.haml +++ b/middleman-core/fixtures/capture-html-app/source/capture_html_haml.html.haml @@ -1,4 +1,4 @@ -- capture_html :from_template do += capture_html :from_template do %h1= "I am the yielded content haml" %p I am in the template \ No newline at end of file diff --git a/middleman-core/fixtures/content-for-app/source/content_for_haml.html.haml b/middleman-core/fixtures/content-for-app/source/content_for_haml.html.haml index 13645ee7..76b29096 100644 --- a/middleman-core/fixtures/content-for-app/source/content_for_haml.html.haml +++ b/middleman-core/fixtures/content-for-app/source/content_for_haml.html.haml @@ -1,4 +1,4 @@ -- content_for :from_template do += content_for :from_template do = "I am the yielded content haml with html tags" %p I am in the template \ No newline at end of file diff --git a/middleman-core/fixtures/frontmatter-settings-app/source/layouts/override.erb b/middleman-core/fixtures/frontmatter-settings-app/source/layouts/override.erb index fcf39dc0..56bf1342 100644 --- a/middleman-core/fixtures/frontmatter-settings-app/source/layouts/override.erb +++ b/middleman-core/fixtures/frontmatter-settings-app/source/layouts/override.erb @@ -1,2 +1 @@ -<%= yield %> - Override. \ No newline at end of file +<%= yield %> Override. \ No newline at end of file diff --git a/middleman-core/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb b/middleman-core/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb index fcf39dc0..56bf1342 100644 --- a/middleman-core/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb +++ b/middleman-core/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb @@ -1,2 +1 @@ -<%= yield %> - Override. \ No newline at end of file +<%= yield %> Override. \ No newline at end of file diff --git a/middleman-core/fixtures/link-to-app/source/link_to_haml.html.haml b/middleman-core/fixtures/link-to-app/source/link_to_haml.html.haml index 7258f001..7c0ee402 100644 --- a/middleman-core/fixtures/link-to-app/source/link_to_haml.html.haml +++ b/middleman-core/fixtures/link-to-app/source/link_to_haml.html.haml @@ -1,2 +1,2 @@ -- link_to "/" do += link_to "/" do %s haml with html tags \ No newline at end of file diff --git a/middleman-core/fixtures/link-to-app/source/link_to_slim.html.slim b/middleman-core/fixtures/link-to-app/source/link_to_slim.html.slim index 847b9732..2758a64c 100644 --- a/middleman-core/fixtures/link-to-app/source/link_to_slim.html.slim +++ b/middleman-core/fixtures/link-to-app/source/link_to_slim.html.slim @@ -1,2 +1,2 @@ -- link_to "/" do += link_to "/" do s slim with html tags \ No newline at end of file diff --git a/middleman-core/fixtures/nested-layout-app/source/layouts/inner_haml.haml b/middleman-core/fixtures/nested-layout-app/source/layouts/inner_haml.haml index e3976d7c..a8c1938d 100644 --- a/middleman-core/fixtures/nested-layout-app/source/layouts/inner_haml.haml +++ b/middleman-core/fixtures/nested-layout-app/source/layouts/inner_haml.haml @@ -1,3 +1,3 @@ -- wrap_layout :outer_haml do += wrap_layout :outer_haml do Inner = yield \ No newline at end of file diff --git a/middleman-core/fixtures/nested-layout-app/source/layouts/inner_slim.slim b/middleman-core/fixtures/nested-layout-app/source/layouts/inner_slim.slim index d639b7e8..49f1ab6f 100644 --- a/middleman-core/fixtures/nested-layout-app/source/layouts/inner_slim.slim +++ b/middleman-core/fixtures/nested-layout-app/source/layouts/inner_slim.slim @@ -1,3 +1,3 @@ -- wrap_layout :outer_slim do += wrap_layout :outer_slim do h3 Inner == yield \ No newline at end of file diff --git a/middleman-core/fixtures/nested-layout-app/source/layouts/outer_haml.haml b/middleman-core/fixtures/nested-layout-app/source/layouts/outer_haml.haml index 641e42c5..eaf1671f 100644 --- a/middleman-core/fixtures/nested-layout-app/source/layouts/outer_haml.haml +++ b/middleman-core/fixtures/nested-layout-app/source/layouts/outer_haml.haml @@ -1,3 +1,3 @@ -- wrap_layout :master_haml do += wrap_layout :master_haml do Outer = yield diff --git a/middleman-core/fixtures/nested-layout-app/source/layouts/outer_slim.slim b/middleman-core/fixtures/nested-layout-app/source/layouts/outer_slim.slim index 738e5bb7..0c17185b 100644 --- a/middleman-core/fixtures/nested-layout-app/source/layouts/outer_slim.slim +++ b/middleman-core/fixtures/nested-layout-app/source/layouts/outer_slim.slim @@ -1,3 +1,3 @@ -- wrap_layout :master_slim do += wrap_layout :master_slim do h2 Outer == yield diff --git a/middleman-core/fixtures/sass-cache-path-custom-app/config.rb b/middleman-core/fixtures/sass-cache-path-custom-app/config.rb deleted file mode 100644 index c8e4e776..00000000 --- a/middleman-core/fixtures/sass-cache-path-custom-app/config.rb +++ /dev/null @@ -1,3 +0,0 @@ - - -set :sass_cache_path, File.join('/tmp', "#{File.basename(Dir.pwd)}-custom-sass_cache_path") diff --git a/middleman-core/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass b/middleman-core/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass deleted file mode 100644 index 79115283..00000000 --- a/middleman-core/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass +++ /dev/null @@ -1,4 +0,0 @@ -@import "compass/reset" - -red - color: blue \ No newline at end of file diff --git a/middleman-core/fixtures/sass-cache-path-default-app/config.rb b/middleman-core/fixtures/sass-cache-path-default-app/config.rb deleted file mode 100644 index 77b161b6..00000000 --- a/middleman-core/fixtures/sass-cache-path-default-app/config.rb +++ /dev/null @@ -1,3 +0,0 @@ - -# Using default setting -# set :sass_cache_path, File.join(Dir.pwd, '.sass-cache') diff --git a/middleman-core/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass b/middleman-core/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass deleted file mode 100644 index 79115283..00000000 --- a/middleman-core/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass +++ /dev/null @@ -1,4 +0,0 @@ -@import "compass/reset" - -red - color: blue \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 98a04717..c0ea9d07 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -6,7 +6,7 @@ require 'i18n' # Don't fail on invalid locale, that's not what our current # users expect. -::I18n.config.enforce_available_locales = false +::I18n.enforce_available_locales = false # Use ActiveSupport JSON require 'active_support/json' diff --git a/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb b/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb index b283ce77..3c753c3c 100644 --- a/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb +++ b/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb @@ -1,6 +1,6 @@ if !defined?(::Padrino::Helpers) - require 'vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite' - require 'vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers' + require 'vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite' + require 'vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers' end module Middleman diff --git a/middleman-core/lib/middleman-core/renderers/erb.rb b/middleman-core/lib/middleman-core/renderers/erb.rb index 9ebebd82..87f91c82 100644 --- a/middleman-core/lib/middleman-core/renderers/erb.rb +++ b/middleman-core/lib/middleman-core/renderers/erb.rb @@ -7,30 +7,28 @@ module Middleman # once registered def registered(app) - # Setup a default ERb engine - app.config.define_setting :erb_engine, :erb, 'The engine to use for rendering ERb templates' - app.config.define_setting :erb_engine_prefix, ::Tilt, 'The parent module for ERb template engines' - app.before_configuration do template_extensions :erb => :html end # After config app.after_configuration do - # Find the user's prefered engine - # Convert symbols to classes - if config[:erb_engine].is_a? Symbol - engine = engine.to_s - engine = engine == 'erb' ? 'ERB' : engine.camelize - config[:erb_engine] = config[:erb_engine_prefix].const_get("#{engine}Template") - end - - # Tell Tilt to use the preferred engine - ::Tilt.prefer(config[:erb_engine]) + ::Tilt.prefer(Template, :erb) end end alias :included :registered end + + class Template < ::Tilt::ErubisTemplate + ## + # In preamble we need a flag `__in_erb_template` and SafeBuffer for padrino apps. + # + def precompiled_preamble(locals) + original = super + "__in_erb_template = true\n" << original + #.rpartition("\n").first << "#{@outvar} = _buf = ActiveSupport::SafeBuffer.new\n" + end + end end end end diff --git a/middleman-core/lib/middleman-core/renderers/haml.rb b/middleman-core/lib/middleman-core/renderers/haml.rb index 5d68d568..29c2d2fb 100644 --- a/middleman-core/lib/middleman-core/renderers/haml.rb +++ b/middleman-core/lib/middleman-core/renderers/haml.rb @@ -1,6 +1,16 @@ # Require gem require 'haml' +module SafeTemplate + def render(*) + super.html_safe + end +end + +class Tilt::HamlTemplate + include SafeTemplate +end + module Middleman module Renderers diff --git a/middleman-core/lib/middleman-core/renderers/sass.rb b/middleman-core/lib/middleman-core/renderers/sass.rb index d8c33fd8..fedc8578 100644 --- a/middleman-core/lib/middleman-core/renderers/sass.rb +++ b/middleman-core/lib/middleman-core/renderers/sass.rb @@ -14,10 +14,6 @@ module Middleman # Default sass options app.config.define_setting :sass, {}, 'Sass engine options' - # Location of SASS .sass-cache directory. - # @return [String] - app.config.define_setting :sass_cache_path, File.join(app.root_path, '.sass-cache'), 'Location of sass cache' # runtime compile of path - app.before_configuration do template_extensions :scss => :css, :sass => :css diff --git a/middleman-core/lib/middleman-core/renderers/slim.rb b/middleman-core/lib/middleman-core/renderers/slim.rb index 55457f3b..f9f6a28f 100644 --- a/middleman-core/lib/middleman-core/renderers/slim.rb +++ b/middleman-core/lib/middleman-core/renderers/slim.rb @@ -1,6 +1,20 @@ # Load gem require 'slim' +module SafeTemplate + def render(*) + super.html_safe + end +end + +class Slim::Template + include SafeTemplate + + def precompiled_preamble(locals) + "__in_slim_template = true\n" << super + end +end + module Middleman module Renderers @@ -29,10 +43,9 @@ module Middleman :context => self } - slim_embedded = defined?(::Slim::Embedded) ? ::Slim::Embedded : ::Slim::EmbeddedEngine - + ::Slim::Embedded::SassEngine.disable_option_validator! %w(sass scss markdown).each do |engine| - slim_embedded.default_options[engine.to_sym] = context_hack + ::Slim::Embedded.default_options[engine.to_sym] = context_hack end end end diff --git a/middleman-core/lib/middleman-core/version.rb b/middleman-core/lib/middleman-core/version.rb index 7f2f371f..7695bd73 100644 --- a/middleman-core/lib/middleman-core/version.rb +++ b/middleman-core/lib/middleman-core/version.rb @@ -1,5 +1,5 @@ module Middleman # Current Version # @return [String] - VERSION = '3.2.2' unless const_defined?(:VERSION) + VERSION = '3.3.0' unless const_defined?(:VERSION) end diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index 2aa46d47..75b04ab3 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -21,7 +21,6 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension compass_config.project_path = app.source_dir compass_config.environment = :development compass_config.cache = false - # compass_config.cache_path = app.config[:sass_cache_path] compass_config.sass_dir = app.config[:css_dir] compass_config.css_dir = app.config[:css_dir] compass_config.javascripts_dir = app.config[:js_dir] diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index ce6d245d..43b4c897 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -1,16 +1,20 @@ if !defined?(::Padrino::Helpers) - require 'vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite' - require 'vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers' + require 'vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite' + require 'vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers' + + # Don't fail on invalid locale, that's not what our current + # users expect. + ::I18n.enforce_available_locales = false end class Padrino::Helpers::OutputHelpers::ErbHandler # Force Erb capture not to use safebuffer def capture_from_template(*args, &block) self.output_buffer, _buf_was = '', self.output_buffer - captured_block = block.call(*args) - ret = eval('@_out_buf', block.binding) + raw = block.call(*args) + captured = template.instance_variable_get(:@_out_buf) self.output_buffer = _buf_was - [ ret, captured_block ] + engine_matches?(block) ? captured : raw end end @@ -48,6 +52,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension attributes = tag_attributes(options) output = ActiveSupport::SafeBuffer.new output.safe_concat "<#{name}#{attributes}>" + if content.respond_to?(:each) && !content.is_a?(String) content.each { |c| output.safe_concat c; output.safe_concat ::Padrino::Helpers::TagHelpers::NEWLINE } else @@ -59,19 +64,18 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension end def capture_html(*args, &block) - handler = auto_find_proper_handler(&block) - captured_block, captured_html = nil, '' - if handler && handler.is_type? && handler.block_is_type?(block) - captured_html, captured_block = handler.capture_from_template(*args, &block) + if handler = auto_find_proper_handler(&block) + handler.capture_from_template(*args, &block) + else + block.call(*args) end - # invoking the block directly if there was no template - captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank? - captured_html end def auto_find_proper_handler(&block) engine = block_given? ? File.extname(block.source_location[0])[1..-1].to_sym : current_engine - ::Padrino::Helpers::OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(engine) && h.is_type? } + return if engine == :slim && engine == current_engine + handler_class = ::Padrino::Helpers::OutputHelpers.handlers[engine] + handler_class && handler_class.new(self) end # Disable Padrino cache buster diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb deleted file mode 100644 index e89043a8..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb +++ /dev/null @@ -1,14 +0,0 @@ -begin - require 'slim' - - if defined? Padrino::Rendering - Padrino::Rendering.engine_configurations[:slim] = - {:generator => Temple::Generators::RailsOutputBuffer, - :buffer => "@_out_buf", :use_html_safe => true} - - class Slim::Template - include Padrino::Rendering::SafeTemplate - end - end -rescue LoadError -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb deleted file mode 100644 index b785ca59..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb +++ /dev/null @@ -1,341 +0,0 @@ -require 'pathname' - -module Padrino - ## - # High performance source code reloader middleware - # - module Reloader - ## - # This reloader is suited for use in a many environments because each file - # will only be checked once and only one system call to stat(2) is made. - # - # Please note that this will not reload files in the background, and does so - # only when explicitly invoked. - # - - # The modification times for every file in a project. - MTIMES = {} - # The list of files loaded as part of a project. - LOADED_FILES = {} - # The list of object constants and classes loaded as part of the project. - LOADED_CLASSES = {} - - class << self - ## - # Specified folders can be excluded from the code reload detection process. - # Default excluded directories at Padrino.root are: test, spec, features, tmp, config, db and public - # - def exclude - @_exclude ||= %w(test spec tmp features config public db).map { |path| Padrino.root(path) } - end - - ## - # Specified constants can be excluded from the code unloading process. - # - def exclude_constants - @_exclude_constants ||= Set.new - end - - ## - # Specified constants can be configured to be reloaded on every request. - # Default included constants are: [none] - # - def include_constants - @_include_constants ||= Set.new - end - - ## - # Reload all files with changes detected. - # - def reload! - # Detect changed files - rotation do |file, mtime| - # Retrive the last modified time - new_file = MTIMES[file].nil? - previous_mtime = MTIMES[file] ||= mtime - logger.devel "Detected a new file #{file}" if new_file - # We skip to next file if it is not new and not modified - next unless new_file || mtime > previous_mtime - # Now we can reload our file - apps = mounted_apps_of(file) - if apps.present? - apps.each { |app| app.app_obj.reload! } - else - safe_load(file, :force => new_file) - # Reload also apps - Padrino.mounted_apps.each do |app| - app.app_obj.reload! if app.app_obj.dependencies.include?(file) - end - end - end - end - - ## - # Remove files and classes loaded with stat - # - def clear! - clear_modification_times - clear_loaded_classes - clear_loaded_files_and_features - end - - ## - # Returns true if any file changes are detected and populates the MTIMES cache - # - def changed? - changed = false - rotation do |file, mtime| - new_file = MTIMES[file].nil? - previous_mtime = MTIMES[file] - changed = true if new_file || mtime > previous_mtime - end - changed - end - alias :run! :changed? - - ## - # We lock dependencies sets to prevent reloading of protected constants - # - def lock! - klasses = ObjectSpace.classes do |klass| - klass._orig_klass_name.split('::')[0] - end - - klasses = klasses | Padrino.mounted_apps.map { |app| app.app_class } - Padrino::Reloader.exclude_constants.merge(klasses) - end - - ## - # A safe Kernel::require which issues the necessary hooks depending on results - # - def safe_load(file, options={}) - began_at = Time.now - force = options[:force] - file = figure_path(file) - reload = should_reload?(file) - m_time = modification_time(file) - - return if !force && m_time && !reload - - remove_loaded_file_classes(file) - remove_loaded_file_features(file) - - # Duplicate objects and loaded features before load file - klasses = ObjectSpace.classes - files = Set.new($LOADED_FEATURES.dup) - - reload_deps_of_file(file) - - # And finally load the specified file - begin - logger.devel :loading, began_at, file if !reload - logger.debug :reload, began_at, file if reload - - $LOADED_FEATURES.delete(file) if files.include?(file) - Padrino::Utils.silence_output - loaded = false - require(file) - loaded = true - update_modification_time(file) - rescue SyntaxError => e - logger.error "Cannot require #{file} due to a syntax error: #{e.message}" - ensure - Padrino::Utils.unsilence_output - new_constants = ObjectSpace.new_classes(klasses) - if loaded - process_loaded_file(:file => file, - :constants => new_constants, - :files => files) - else - logger.devel "Failed to load #{file}; removing partially defined constants" - unload_constants(new_constants) - end - end - end - - ## - # Returns true if the file is defined in our padrino root. - # - def figure_path(file) - return file if Pathname.new(file).absolute? - $:.each do |path| - found = File.join(path, file) - return File.expand_path(found) if File.exist?(found) - end - file - end - - ## - # Removes the specified class and constant. - # - def remove_constant(const) - return if exclude_constants.any? { |c| const._orig_klass_name.index(c) == 0 } && - !include_constants.any? { |c| const._orig_klass_name.index(c) == 0 } - begin - parts = const.to_s.sub(/^::(Object)?/, 'Object::').split('::') - object = parts.pop - base = parts.empty? ? Object : Inflector.constantize(parts * '::') - base.send :remove_const, object - logger.devel "Removed constant: #{const} from #{base}" - rescue NameError; end - end - - private - - ### - # Clear instance variables that keep track of # loaded features/files/mtimes. - # - def clear_modification_times - MTIMES.clear - end - - def clear_loaded_classes - LOADED_CLASSES.each do |file, klasses| - klasses.each { |klass| remove_constant(klass) } - LOADED_CLASSES.delete(file) - end - end - - def clear_loaded_files_and_features - LOADED_FILES.each do |file, dependencies| - dependencies.each { |dependency| $LOADED_FEATURES.delete(dependency) } - $LOADED_FEATURES.delete(file) - end - end - - ### - # Macro for mtime query. - # - def modification_time(file) - MTIMES[file] - end - - ### - # Macro for mtime update. - # - def update_modification_time(file) - MTIMES[file] = File.mtime(file) - end - - ### - # Tracks loaded file features/classes/constants: - # - def process_loaded_file(*args) - options = args.extract_options! - new_constants = options[:constants] - files = options[:files] - file = options[:file] - - # Store the file details - LOADED_CLASSES[file] = new_constants - LOADED_FILES[file] = Set.new($LOADED_FEATURES) - files - [file] - - # Track only features in our Padrino.root - LOADED_FILES[file].delete_if { |feature| !in_root?(feature) } - end - - ### - # Unloads all constants in new_constants. - # - def unload_constants(new_constants) - new_constants.each { |klass| remove_constant(klass) } - end - - ### - # Safe load dependencies of a file. - # - def reload_deps_of_file(file) - if features = LOADED_FILES.delete(file) - features.each { |feature| safe_load(feature, :force => true) } - end - end - - ## - # Check if file was changed or if force a reload. - # - def should_reload?(file) - MTIMES[file] && File.mtime(file) > MTIMES[file] - end - - ## - # Removes all classes declared in the specified file. - # - def remove_loaded_file_classes(file) - if klasses = LOADED_CLASSES.delete(file) - klasses.each { |klass| remove_constant(klass) } - end - end - - ## - # Remove all loaded fatures with our file. - # - def remove_loaded_file_features(file) - if features = LOADED_FILES[file] - features.each { |feature| $LOADED_FEATURES.delete(feature) } - end - end - - ## - # Return the mounted_apps providing the app location. - # Can be an array because in one app.rb we can define multiple Padrino::Application. - # - def mounted_apps_of(file) - file = figure_path(file) - Padrino.mounted_apps.find_all { |app| File.identical?(file, app.app_file) } - end - - ## - # Returns true if file is in our Padrino.root. - # - def in_root?(file) - # This is better but slow: - # Pathname.new(Padrino.root).find { |f| File.identical?(Padrino.root(f), figure_path(file)) } - figure_path(file).index(Padrino.root) == 0 - end - - ## - # Searches Ruby files in your +Padrino.load_paths+ , Padrino::Application.load_paths - # and monitors them for any changes. - # - def rotation - files_for_rotation.uniq.map do |file| - file = File.expand_path(file) - next if Padrino::Reloader.exclude.any? { |base| file.index(base) == 0 } || !File.exist?(file) - yield file, File.mtime(file) - end.compact - end - - ## - # Creates an array of paths for use in #rotation. - # - def files_for_rotation - files = Padrino.load_paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten - files = files | Padrino.mounted_apps.map { |app| app.app_file } - files = files | Padrino.mounted_apps.map { |app| app.app_obj.dependencies }.flatten - end - end # self - - ## - # This class acts as a Rack middleware to be added to the application stack. - # This middleware performs a check and reload for source files at the start - # of each request, but also respects a specified cool down time - # during which no further action will be taken. - # - class Rack - def initialize(app, cooldown=1) - @app = app - @cooldown = cooldown - @last = (Time.now - cooldown) - end - - # Invoked in order to perform the reload as part of the request stack. - def call(env) - if @cooldown && Time.now > @last + @cooldown - Thread.list.size > 1 ? Thread.exclusive { Padrino.reload! } : Padrino.reload! - @last = Time.now - end - @app.call(env) - end - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb deleted file mode 100644 index fd6c7bd7..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb +++ /dev/null @@ -1,80 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/helper') - -describe "Application" do - before { Padrino.clear! } - after { remove_views } - - context 'CSRF protection' do - context "with CSRF protection on" do - before do - mock_app do - enable :sessions - enable :protect_from_csrf - post('/'){ 'HI' } - end - end - - should "not allow requests without tokens" do - post "/" - assert_equal 403, status - end - - should "allow requests with correct tokens" do - post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "a"} - assert_equal 200, status - end - - should "not allow requests with incorrect tokens" do - post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "b"} - assert_equal 403, status - end - end - - context "without CSRF protection on" do - before do - mock_app do - enable :sessions - disable :protect_from_csrf - post('/'){ 'HI' } - end - end - - should "allows requests without tokens" do - post "/" - assert_equal 200, status - end - - should "allow requests with correct tokens" do - post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "a"} - assert_equal 200, status - end - - should "allow requests with incorrect tokens" do - post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "b"} - assert_equal 200, status - end - end - - context "with optional CSRF protection" do - before do - mock_app do - enable :sessions - enable :protect_from_csrf - set :allow_disabled_csrf, true - post('/on') { 'HI' } - post('/off', :csrf_protection => false) { 'HI' } - end - end - - should "allow access to routes with csrf_protection off" do - post "/off" - assert_equal 200, status - end - - should "not allow access to routes with csrf_protection on" do - post "/on" - assert_equal 403, status - end - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.document b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.document similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.document rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.document diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.gitignore b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.gitignore similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.gitignore rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.gitignore diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.yardopts b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.yardopts similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/.yardopts rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/.yardopts diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/LICENSE.txt similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/LICENSE.txt rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/LICENSE.txt diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/README.rdoc b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/README.rdoc similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/README.rdoc rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/README.rdoc diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/Rakefile b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/Rakefile similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/Rakefile rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/Rakefile diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/bin/padrino b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/bin/padrino similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/bin/padrino rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/bin/padrino diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core.rb similarity index 78% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core.rb index e2ebdd24..7fc58233 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core.rb @@ -14,14 +14,19 @@ require 'padrino-core/server' require 'padrino-core/tasks' require 'padrino-core/module' - -PADRINO_ENV = ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= "development" unless defined?(PADRINO_ENV) +if ENV["PADRINO_ENV"] + warn 'Environment variable PADRINO_ENV is deprecated. Please, use RACK_ENV.' + ENV["RACK_ENV"] ||= ENV["PADRINO_ENV"] +end +RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined?(RACK_ENV) PADRINO_ROOT = ENV["PADRINO_ROOT"] ||= File.dirname(Padrino.first_caller) unless defined?(PADRINO_ROOT) module Padrino class ApplicationLoadError < RuntimeError # @private end + extend Loader + class << self ## # Helper method for file references. @@ -42,13 +47,13 @@ module Padrino end ## - # Helper method that return {PADRINO_ENV}. + # Helper method that return {RACK_ENV}. # # @return [Symbol] # The Padrino Environment. # def env - @_env ||= PADRINO_ENV.to_s.downcase.to_sym + @_env ||= RACK_ENV.to_s.downcase.to_sym end ## @@ -61,18 +66,10 @@ module Padrino # No applications were mounted. # def application - raise ApplicationLoadError, "At least one app must be mounted!" unless Padrino.mounted_apps && Padrino.mounted_apps.any? + raise ApplicationLoadError, "At least one app must be mounted!" unless Padrino.mounted_apps.present? router = Padrino::Router.new Padrino.mounted_apps.each { |app| app.map_onto(router) } - - if middleware.present? - builder = Rack::Builder.new - middleware.each { |c,a,b| builder.use(c, *a, &b) } - builder.run(router) - builder.to_app - else - router - end + middleware.present? ? add_middleware(router) : router end ## @@ -90,21 +87,14 @@ module Padrino # def configure_apps(&block) return unless block_given? - @@_global_configurations ||= [] - @@_global_configurations << block - @_global_configuration = lambda do |app| - @@_global_configurations.each do |configuration| - app.class_eval(&configuration) - end - end + global_configurations << block end ## - # Returns project-wide configuration settings defined in - # {configure_apps} block. + # Stores global configuration blocks. # - def apps_configuration - @_global_configuration + def global_configurations + @_global_configurations ||= [] end ## @@ -119,15 +109,21 @@ module Padrino # @return [NilClass] # def set_encoding - if RUBY_VERSION < '1.9' - $KCODE='u' - else - Encoding.default_external = Encoding::UTF_8 - Encoding.default_internal = Encoding::UTF_8 - end + Encoding.default_external = Encoding::UTF_8 + Encoding.default_internal = Encoding::UTF_8 nil end + ## + # Creates Rack stack with the router added to the middleware chain. + # + def add_middleware(router) + builder = Rack::Builder.new + middleware.each{ |mw,args,block| builder.use(mw, *args, &block) } + builder.run(router) + builder.to_app + end + ## # A Rack::Builder object that allows to add middlewares in front of all # Padrino applications. @@ -161,8 +157,8 @@ module Padrino # @yield [] # The given block will be passed to the initialized middleware. # - def use(m, *args, &block) - middleware << [m, args, block] + def use(mw, *args, &block) + middleware << [mw, args, block] end ## diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application.rb similarity index 61% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application.rb index 67c5c4ab..fed2d1c5 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application.rb @@ -1,12 +1,10 @@ require 'padrino-core/application/flash' require 'padrino-core/application/rendering' require 'padrino-core/application/routing' -require 'padrino-core/application/showexceptions' +require 'padrino-core/application/show_exceptions' +require 'padrino-core/application/authenticity_token' module Padrino - class ApplicationSetupError < RuntimeError - end - ## # Subclasses of this become independent Padrino applications # (stemming from Sinatra::Application). @@ -26,20 +24,24 @@ module Padrino Padrino.logger end + # TODO: Remove this hack after getting rid of thread-unsafe http_router: + alias_method :original_call, :call + def call(*args) + settings.init_mutex.synchronize do + instance_eval{ undef :call } + class_eval{ alias_method :call, :original_call } + instance_eval{ undef :original_call } + super(*args) + end + end + class << self def inherited(base) begun_at = Time.now CALLERS_TO_IGNORE.concat(PADRINO_IGNORE_CALLERS) base.default_configuration! - base.prerequisites.concat([ - File.join(base.root, '/models.rb'), - File.join(base.root, '/models/**/*.rb'), - File.join(base.root, '/lib.rb'), - File.join(base.root, '/lib/**/*.rb') - ]).uniq! - Padrino.require_dependencies(base.prerequisites) logger.devel :setup, begun_at, base - super(base) # Loading the subclass inherited method + super(base) end ## @@ -54,10 +56,10 @@ module Padrino # MyApp.reload! # def reload! - logger.devel "Reloading #{settings}" + logger.devel "Reloading application #{settings}" reset! reset_router! - Padrino.require_dependencies(settings.app_file, :force => true) # Reload the app file + Padrino.require_dependencies(settings.app_file, :force => true) require_dependencies default_filters! default_routes! @@ -90,6 +92,26 @@ module Padrino router.routes end + ## + # Returns an absolute path of view in application views folder. + # + # @example + # Admin.view_path 'users/index' #=> "/home/user/test/admin/views/users/index" + # + def view_path(view) + File.expand_path(view, views) + end + + ## + # Returns an absolute path of application layout. + # + # @example + # Admin.layout_path :application #=> "/home/user/test/admin/views/layouts/application" + # + def layout_path(layout) + view_path("layouts/#{layout}") + end + ## # Setup the application by registering initializers, load paths and logger. # Invoked automatically when an application is first instantiated. @@ -103,11 +125,11 @@ module Padrino settings.default_routes! settings.default_errors! if defined?(I18n) + Reloader.special_files += settings.locale_path I18n.load_path << settings.locale_path I18n.reload! end @_configured = true - @_configured end ## @@ -127,7 +149,13 @@ module Padrino # directory that need to be added to +$LOAD_PATHS+ from this application # def load_paths - @_load_paths ||= %w[models lib mailers controllers helpers].map { |path| File.join(settings.root, path) } + @_load_paths ||= [ + 'models', + 'lib', + 'mailers', + 'controllers', + 'helpers', + ].map { |path| File.join(settings.root, path) } end ## @@ -143,8 +171,14 @@ module Padrino # def dependencies [ - 'urls.rb', 'config/urls.rb', 'mailers/*.rb', 'mailers.rb', - 'controllers/**/*.rb', 'controllers.rb', 'helpers/**/*.rb', 'helpers.rb' + 'urls.rb', + 'config/urls.rb', + 'mailers/*.rb', + 'mailers.rb', + 'controllers/**/*.rb', + 'controllers.rb', + 'helpers/**/*.rb', + 'helpers.rb', ].map { |file| Dir[File.join(settings.root, file)] }.flatten end @@ -167,38 +201,67 @@ module Padrino @_prerequisites ||= [] end + def default(option, *args, &block) + set(option, *args, &block) unless respond_to?(option) + end + protected + ## # Defines default settings for Padrino application. # def default_configuration! - # Overwriting Sinatra defaults - set :app_file, File.expand_path(caller_files.first || $0) # Assume app file is first caller + set :app_file, File.expand_path(caller_files.first || $0) + set :app_name, settings.to_s.underscore.to_sym + set :environment, Padrino.env set :reload, Proc.new { development? } set :logging, Proc.new { development? } + set :method_override, true - set :sessions, false - set :public_folder, Proc.new { Padrino.root('public', uri_root) } - set :views, Proc.new { File.join(root, 'views') } - set :images_path, Proc.new { File.join(public_folder, 'images') } - set :protection, true - - set :haml, { :ugly => (Padrino.env == :production) } if defined?(Haml) - - # Padrino specific - set :uri_root, '/' - set :app_name, settings.to_s.underscore.to_sym set :default_builder, 'StandardFormBuilder' + + # TODO: Remove this hack after getting rid of thread-unsafe http_router: + set :init_mutex, Mutex.new + + # TODO: Remove this line after sinatra version up. + set :add_charset, %w[javascript xml xhtml+xml].map {|t| "application/#{t}" } + + default_paths! + default_security! + global_configuration! + setup_prerequisites! + end + + def setup_prerequisites! + prerequisites.concat(default_prerequisites).uniq! + Padrino.require_dependencies(prerequisites) + end + + def default_paths! + set :locale_path, Proc.new { Dir.glob File.join(root, 'locale/**/*.{rb,yml}') } + set :views, Proc.new { File.join(root, 'views') } + + set :uri_root, '/' + set :public_folder, Proc.new { Padrino.root('public', uri_root) } + set :images_path, Proc.new { File.join(public_folder, 'images') } + end + + def default_security! + set :protection, :except => :path_traversal set :authentication, false - - set :locale_path, Proc.new { Dir[File.join(settings.root, '/locale/**/*.{rb,yml}')] } - - # Authenticity token + set :sessions, false set :protect_from_csrf, false set :allow_disabled_csrf, false - # Load the Global Configurations - class_eval(&Padrino.apps_configuration) if Padrino.apps_configuration + end + + ## + # Applies global padrino configuration blocks to current application. + # + def global_configuration! + Padrino.global_configurations.each do |configuration| + class_eval(&configuration) + end end ## @@ -220,9 +283,7 @@ module Padrino # def default_filters! before do - unless @_content_type - response['Content-Type'] = 'text/html;charset=utf-8' - end + response['Content-Type'] = 'text/html;charset=utf-8' unless @_content_type end end @@ -249,7 +310,20 @@ module Padrino Padrino.require_dependencies(dependencies, :force => true) end + ## + # Returns globs of default paths of application prerequisites. + # + def default_prerequisites + [ + '/models.rb', + '/models/**/*.rb', + '/lib.rb', + '/lib/**/*.rb', + ].map{ |glob| File.join(settings.root, glob) } + end + private + # Overrides the default middleware for Sinatra based on Padrino conventions. # Also initializes the application after setting up the middleware. def setup_default_middleware(builder) @@ -267,9 +341,33 @@ module Padrino # sets up csrf protection for the app: def setup_csrf_protection(builder) - if protect_from_csrf? && !sessions? - raise(<<-ERROR) -`protect_from_csrf` is activated, but `sessions` are not. To enable csrf + check_csrf_protection_dependency + + if protect_from_csrf? + options = options_for_csrf_protection_setup + options.merge!(protect_from_csrf) if protect_from_csrf.kind_of?(Hash) + builder.use(options[:except] ? Padrino::AuthenticityToken : Rack::Protection::AuthenticityToken, options) + end + end + + # returns the options used in the builder for csrf protection setup + def options_for_csrf_protection_setup + options = { :logger => logger } + + if allow_disabled_csrf? + options.merge!({ + :reaction => :report, + :report_key => 'protection.csrf.failed' + }) + end + options + end + + # throw an exception if the protect_from_csrf is active but sessions not. + def check_csrf_protection_dependency + if (protect_from_csrf? && !sessions?) && !defined?(Padrino::IGNORE_CSRF_SETUP_WARNING) + warn(<<-ERROR) +`protect_from_csrf` is activated, but `sessions` seem to be off. To enable csrf protection, use: enable :sessions @@ -277,19 +375,12 @@ protection, use: or deactivate protect_from_csrf: disable :protect_from_csrf -ERROR - end - if protect_from_csrf? - if allow_disabled_csrf? - builder.use Rack::Protection::AuthenticityToken, - :reaction => :report, - :report_key => 'protection.csrf.failed', - :logger => logger - else - builder.use Rack::Protection::AuthenticityToken, - :logger => logger - end +If you use a different session store, ignore this warning using: + + # in boot.rb: + Padrino::IGNORE_CSRF_SETUP_WARNING = true + ERROR end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/authenticity_token.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/authenticity_token.rb new file mode 100644 index 00000000..2515c864 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/authenticity_token.rb @@ -0,0 +1,25 @@ +module Padrino + class AuthenticityToken < Rack::Protection::AuthenticityToken + def initialize(app, options = {}) + @app = app + @except = options[:except] + @except = Array(@except) unless @except.is_a?(Proc) + super + end + + def call(env) + if except?(env) + @app.call(env) + else + super + end + end + + def except?(env) + return false unless @except + path_info = env['PATH_INFO'] + @except.is_a?(Proc) ? @except.call(env) : @except.any?{|path| + path.is_a?(Regexp) ? path.match(path_info) : path == path_info } + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/flash.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/flash.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/flash.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/flash.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering.rb similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering.rb index 4b71d840..cda7a205 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering.rb @@ -195,14 +195,16 @@ module Padrino options[:layout] = @layout if options[:layout].nil? || options[:layout] == true # Resolve layouts similar to in Rails if options[:layout].nil? && !settings.templates.has_key?(:layout) - layout_path, layout_engine = *resolved_layout + layout_path = settings.fetch_layout_path(options[:layout]) + is_included_extension = %w[.slim .erb .haml].include?(File.extname(layout_path.to_s)) + layout_path, layout_engine = *(is_included_extension ? resolve_template(layout_path) : resolved_layout) # We need to force layout false so sinatra don't try to render it options[:layout] = layout_path || false - options[:layout] = false unless layout_engine == engine # TODO allow different layout engine + options[:layout] = false unless is_included_extension ? layout_engine : layout_engine == engine options[:layout_engine] = layout_engine || engine if options[:layout] elsif options[:layout].present? - options[:layout] = settings.fetch_layout_path(options[:layout] || @layout) + options[:layout], options[:layout_engine] = *resolve_template(settings.fetch_layout_path(options[:layout]), options) end # Default to original layout value if none found. options[:layout] ||= layout_was @@ -272,15 +274,21 @@ module Padrino end # Resolve view path and options. - options.reverse_merge!(DEFAULT_RENDERING_OPTIONS) + options = DEFAULT_RENDERING_OPTIONS.merge(options) view_path = options.delete(:views) || settings.views || "./views" target_extension = File.extname(template_path)[1..-1] || "none" # explicit template extension template_path = template_path.chomp(".#{target_extension}") + template_glob = + if respond_to?(:request) && request.controller.present? + File.join("{,#{request.controller}}", template_path) + else + template_path + end # Generate potential template candidates - templates = Dir[File.join(view_path, template_path) + ".*"].map do |file| + templates = Dir[File.join(view_path, template_glob) + ".*"].map do |file| template_engine = File.extname(file)[1..-1].to_sym # Retrieves engine extension - template_file = file.sub(view_path, '').chomp(".#{template_engine}").to_sym # retrieves template filename + template_file = file.squeeze('/').sub(view_path, '').chomp(".#{template_engine}").to_sym # retrieves template filename [template_file, template_engine] unless IGNORE_FILE_PATTERN.any? { |pattern| template_engine.to_s =~ pattern } end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/erubis.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/erubis.rb similarity index 68% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/erubis.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/erubis.rb index b53433c0..c225c71c 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/erubis.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/erubis.rb @@ -40,15 +40,18 @@ begin def render(*args) app = args.first app_class = app.class - @padrino_app = app.kind_of?(Padrino::Application) || - (app_class.respond_to?(:erb) && app_class.erb[:engine_class] == Padrino::Erubis::SafeBufferTemplate) + @is_padrino_app = app.kind_of?(Padrino::Application) || + (app_class.respond_to?(:erb) && app_class.erb[:engine_class] == Padrino::Erubis::SafeBufferTemplate) super end + ## + # In preamble we need a flag `__in_erb_template` and SafeBuffer for padrino apps. + # def precompiled_preamble(locals) - buf = @padrino_app ? "ActiveSupport::SafeBuffer.new" : "''" - old_postamble = super.split("\n")[0..-2] - [old_postamble, "#{@outvar} = _buf = (#{@outvar} || #{buf})"].join("\n") + original = super + return original unless @is_padrino_app + "__in_erb_template = true\n" << original.rpartition("\n").first << "#{@outvar} = _buf = ActiveSupport::SafeBuffer.new\n" end end end @@ -57,8 +60,9 @@ begin Tilt.prefer(Padrino::Erubis::Template, :erb) if defined? Padrino::Rendering - Padrino::Rendering.engine_configurations[:erb] = - {:engine_class => Padrino::Erubis::SafeBufferTemplate} + Padrino::Rendering.engine_configurations[:erb] = { + :engine_class => Padrino::Erubis::SafeBufferTemplate, + } end rescue LoadError end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/haml.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/haml.rb similarity index 82% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/haml.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/haml.rb index 064ea41a..c1e67903 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/haml.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/haml.rb @@ -17,8 +17,9 @@ begin end if defined? Padrino::Rendering - Padrino::Rendering.engine_configurations[:haml] = - {:escape_html => true} + Padrino::Rendering.engine_configurations[:haml] = { + :escape_html => true, + } class Tilt::HamlTemplate include Padrino::Rendering::SafeTemplate diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/slim.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/slim.rb new file mode 100644 index 00000000..afd9ad56 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/rendering/extensions/slim.rb @@ -0,0 +1,21 @@ +begin + require 'slim' + + if defined? Padrino::Rendering + Padrino::Rendering.engine_configurations[:slim] = { + :generator => Temple::Generators::RailsOutputBuffer, + :buffer => "@_out_buf", + :use_html_safe => true, + :disable_capture => true, + } + + class Slim::Template + include Padrino::Rendering::SafeTemplate + + def precompiled_preamble(locals) + "__in_slim_template = true\n" << super + end + end + end +rescue LoadError +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/routing.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/routing.rb similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/routing.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/routing.rb index 526bbdba..8a3c7944 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/routing.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/routing.rb @@ -15,6 +15,19 @@ class Sinatra::Request end end +## +# This patches Sinatra to accept UTF-8 urls on JRuby 1.7.6 +# +if RUBY_ENGINE == 'jruby' && defined?(JRUBY_VERSION) && JRUBY_VERSION > '1.7.4' + class Sinatra::Base + class << self + alias_method :old_generate_method, :generate_method + def generate_method(method_name, &block) + old_generate_method(method_name.to_sym, &block) + end + end + end +end class HttpRouter def rewrite_partial_path_info(env, request); end @@ -61,7 +74,7 @@ class HttpRouter class Route VALID_HTTP_VERBS.replace %w[GET POST PUT PATCH DELETE HEAD OPTIONS LINK UNLINK] - attr_accessor :use_layout, :controller, :action, :cache, :cache_key, :cache_expires_in, :parent + attr_accessor :use_layout, :controller, :action, :cache, :cache_key, :cache_expires, :parent def before_filters(&block) @_before_filters ||= [] @@ -172,6 +185,7 @@ class HttpRouter env['router.request'] = request env['router.params'] ||= {} #{"env['router.params'].merge!(Hash[#{param_names.inspect}.zip(request.params)])" if dynamic?} + env['router.params'] = env['router.params'].with_indifferent_access @router.rewrite#{"_partial" if route.match_partially}_path_info(env, request) response = @router.process_destination_path(#{path_ivar}, env) return response unless router.pass_on_response(response) @@ -193,7 +207,7 @@ module Padrino def apply?(request) detect = @args.any? do |arg| case arg - when Symbol then request.route_obj && (request.route_obj.name == arg or request.route_obj.name == [@scoped_controller, arg].flatten.join("_").to_sym) + when Symbol then request.route_obj && (request.route_obj.name == arg or request.route_obj.name == [@scoped_controller, arg].flatten.join(" ").to_sym) else arg === request.path_info end end || @options.any? do |name, val| @@ -500,7 +514,13 @@ module Padrino def compiled_router if @deferred_routes - deferred_routes.each { |routes| routes.each { |(route, dest)| route.to(dest) } } + deferred_routes.each do |routes| + routes.each do |(route, dest)| + route.to(dest) + route.before_filters.flatten! + route.after_filters.flatten! + end + end @deferred_routes = nil router.sort! end @@ -557,10 +577,10 @@ module Padrino def url(*args) params = args.extract_options! # parameters is hash at end names, params_array = args.partition{|a| a.is_a?(Symbol)} - name = names.join("_").to_sym # route name is concatenated with underscores + name = names[0, 2].join(" ").to_sym # route name is concatenated with underscores if params.is_a?(Hash) params[:format] = params[:format].to_s unless params[:format].nil? - params = value_to_param(params) + params = value_to_param(params.symbolize_keys) end url = if params_array.empty? @@ -568,10 +588,7 @@ module Padrino else compiled_router.path(name, *(params_array << params)) end - url[0,0] = conform_uri(uri_root) if defined?(uri_root) - url[0,0] = conform_uri(ENV['RACK_BASE_URI']) if ENV['RACK_BASE_URI'] - url = "/" if url.blank? - url + rebase_url(url) rescue HttpRouter::InvalidRouteException route_error = "route mapping for url(#{name.inspect}) could not be found!" raise Padrino::Routing::UnrecognizedException.new(route_error) @@ -586,6 +603,17 @@ module Padrino route('HEAD', path, *args, &block) end + def rebase_url(url) + if url.start_with?('/') + new_url = '' + new_url << conform_uri(uri_root) if defined?(uri_root) + new_url << conform_uri(ENV['RACK_BASE_URI']) if ENV['RACK_BASE_URI'] + new_url << url + else + url.blank? ? '/' : url + end + end + private # Parse params from the url method def value_to_param(value) @@ -702,8 +730,8 @@ module Padrino invoke_hook(:padrino_route_added, route, verb, path, args, options, block) # Add Application defaults. - route.before_filters.concat(@filters[:before]) - route.after_filters.concat(@filters[:after]) + route.before_filters << @filters[:before] + route.after_filters << @filters[:after] if @_controller route.use_layout = @layout route.controller = Array(@_controller)[0].to_s @@ -786,7 +814,7 @@ module Padrino name = options.delete(:name) if name.nil? && options.key?(:name) if name controller_name = controller.join("_") - name = "#{controller_name}_#{name}".to_sym unless controller_name.blank? + name = "#{controller_name} #{name}".to_sym unless controller_name.blank? end # Merge in option defaults. @@ -856,9 +884,10 @@ module Padrino def provides(*types) @_use_format = true condition do - mime_types = types.map { |t| mime_type(t) }.compact - url_format = params[:format].to_sym if params[:format] - accepts = request.accept.map(&:to_str) + mime_types = types.map { |t| mime_type(t) }.compact + url_format = params[:format].to_sym if params[:format] + accepts = request.accept.map(&:to_str) + accepts.clear if accepts == ["*/*"] # Per rfc2616-sec14: # Assume */* if no ACCEPT header is given. @@ -890,7 +919,12 @@ module Padrino if matched_format @_content_type = url_format || accept_format || :html - content_type(@_content_type, :charset => 'utf-8') + + if @_content_type != :json + content_type(@_content_type, :charset => 'utf-8') + else + content_type(@_content_type) + end end matched_format @@ -924,17 +958,24 @@ module Padrino # url(:show, :id => 1) # url(:show, :name => :test) # url(:show, 1) - # url("/foo") + # url("/foo", false, false) # # @see Padrino::Routing::ClassMethods#url # def url(*args) - # Delegate to Sinatra 1.2 for simple url("/foo") - # http://www.sinatrarb.com/intro#Generating%20URLs - return super if args.first.is_a?(String) && !args[1].is_a?(Hash) - - # Delegate to Padrino named route URL generation. - settings.url(*args) + if args.first.is_a?(String) + url_path = settings.rebase_url(args.shift) + if args.empty? + url_path + else + # Delegate sinatra-style urls to Sinatra. Ex: url("/foo", false, false) + # http://www.sinatrarb.com/intro#Generating%20URLs + super url_path, *args + end + else + # Delegate to Padrino named route URL generation. + settings.url(*args) + end end alias :url_for :url @@ -944,9 +985,15 @@ module Padrino # @example # absolute_url(:show, :id => 1) # => http://example.com/show?id=1 # absolute_url(:show, 24) # => https://example.com/admin/show/24 + # absolute_url('/foo/bar') # => https://example.com/admin/foo/bar + # absolute_url('baz') # => https://example.com/admin/foo/baz # - def absolute_url( *args ) - uri url(*args), true, false + def absolute_url(*args) + url_path = args.shift + if url_path.is_a?(String) && !url_path.start_with?('/') + url_path = request.env['PATH_INFO'].rpartition('/').first << '/' << url_path + end + uri url(url_path, *args), true, false end def recognize_path(path) @@ -958,10 +1005,12 @@ module Padrino # def current_path(*path_params) if path_params.last.is_a?(Hash) - path_params[-1] = params.merge(path_params[-1]) + path_params[-1] = params.merge(path_params[-1].with_indifferent_access) else path_params << params end + + path_params[-1] = path_params[-1].symbolize_keys @route.path(*path_params) end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/showexceptions.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/show_exceptions.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/showexceptions.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/application/show_exceptions.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/caller.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/caller.rb similarity index 96% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/caller.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/caller.rb index 6b7837b0..f3129eb3 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/caller.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/caller.rb @@ -5,7 +5,7 @@ module Padrino %r{lib/padrino-.*$}, %r{/padrino-.*/(lib|bin)}, %r{/bin/padrino$}, - %r{/sinatra(/(base|main|showexceptions))?\.rb$}, + %r{/sinatra(/(base|main|show_?exceptions))?\.rb$}, %r{lib/tilt.*\.rb$}, %r{lib/rack.*\.rb$}, %r{lib/mongrel.*\.rb$}, diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/adapter.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/adapter.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/adapter.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/adapter.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/base.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/base.rb similarity index 79% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/base.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/base.rb index 81b36de0..2a87cde6 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/base.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/base.rb @@ -18,11 +18,19 @@ module Padrino method_option :daemonize, :type => :boolean, :aliases => "-d", :desc => "Run daemonized in the background." method_option :pid, :type => :string, :aliases => "-i", :desc => "File to store pid." method_option :debug, :type => :boolean, :desc => "Set debugging flags." + method_option :options, :type => :array, :aliases => "-O", :desc => "--options NAME=VALUE NAME2=VALUE2'. pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} --server_options" + method_option :server_options, :type => :boolean, :desc => "Tells the current server handler's options that can be used with --options" + def start prepare :start require File.expand_path("../adapter", __FILE__) require File.expand_path('config/boot.rb') - Padrino::Cli::Adapter.start(options) + + if options[:server_options] + puts server_options(options) + else + Padrino::Cli::Adapter.start(options) + end end desc "stop", "Stops the Padrino application (alternatively use 'st')." @@ -116,7 +124,7 @@ module Padrino help(task.to_s) raise SystemExit end - ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= options.environment.to_s + ENV["RACK_ENV"] ||= options.environment.to_s chdir(options.chdir) unless File.exist?('config/boot.rb') puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!" @@ -124,6 +132,29 @@ module Padrino end end + # https://github.com/rack/rack/blob/master/lib/rack/server.rb\#L100 + def server_options(options) + begin + info = [] + server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options) + if server && server.respond_to?(:valid_options) + info << "" + info << "Server-specific options for #{server.name}:" + + has_options = false + server.valid_options.each do |name, description| + next if name.to_s.match(/^(Host|Port)[^a-zA-Z]/) # ignore handler's host and port options, we do our own. + info << " -O %-21s %s" % [name, description] + has_options = true + end + return "" if !has_options + end + info.join("\n") + rescue NameError + return "Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options" + end + end + protected def self.banner(task=nil, *args) diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/console.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/console.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/console.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/console.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/rake.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/rake.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake_tasks.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/rake_tasks.rb similarity index 85% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake_tasks.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/rake_tasks.rb index bed51675..9d3e1e4d 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake_tasks.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/cli/rake_tasks.rb @@ -16,6 +16,16 @@ task :environment do end end +# Loads skeleton Padrino environment, no models, no application settings. +task :skeleton do + module Padrino::Reloader + def self.safe_load(file, options) + super unless file.include?('/models/') + end + end + require File.expand_path('config/boot.rb', Rake.application.original_dir) +end + desc "Generate a secret key" task :secret do shell.say SecureRandom.hex(32) diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/command.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/command.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/command.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/command.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/404.png b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/images/404.png similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/404.png rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/images/404.png diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/500.png b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/images/500.png similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/500.png rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/images/500.png diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/loader.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/loader.rb similarity index 64% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/loader.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/loader.rb index 894a0ca2..8b75276c 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/loader.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/loader.rb @@ -1,5 +1,5 @@ module Padrino - class << self + module Loader ## # Hooks to be called before a load/reload. # @@ -40,17 +40,6 @@ module Padrino @_after_load end - ## - # The used +$LOAD_PATHS+ from Padrino. - # - # @return [Array] - # The load paths used by Padrino. - # - def load_paths - @_load_paths_was = %w(lib models shared).map { |path| Padrino.root(path) } - @_load_paths ||= @_load_paths_was - end - ## # Requires necessary dependencies as well as application files from root # lib and models. @@ -60,21 +49,18 @@ module Padrino # def load! return false if loaded? - t = Time.now - + began_at = Time.now @_called_from = first_caller - Padrino.set_encoding - Padrino.set_load_paths(*load_paths) - Padrino::Logger.setup! # Initialize our logger - Padrino.require_dependencies("#{root}/config/database.rb", :nodeps => true) # Be sure to don't remove constants from dbs. - Padrino::Reloader.lock! # Now we can remove constant from here to down - Padrino.before_load.each(&:call) # Run before hooks - Padrino.dependency_paths.each { |path| Padrino.require_dependencies(path) } - Padrino.after_load.each(&:call) # Run after hooks - Padrino::Reloader.run! + set_encoding + set_load_paths(*load_paths) + Logger.setup! + require_dependencies("#{root}/config/database.rb") + Reloader.lock! + before_load.each(&:call) + require_dependencies(*dependency_paths) + after_load.each(&:call) + logger.devel "Loaded Padrino in #{Time.now - began_at} seconds" Thread.current[:padrino_loaded] = true - - Padrino.logger.devel "Loaded Padrino in #{Time.now - t} seconds" end ## @@ -83,14 +69,14 @@ module Padrino # @return [NilClass] # def clear! - Padrino.clear_middleware! - Padrino.mounted_apps.clear + clear_middleware! + mounted_apps.clear @_load_paths = nil @_dependency_paths = nil @_global_configuration = nil - Padrino.before_load.clear - Padrino.after_load.clear - Padrino::Reloader.clear! + before_load.clear + after_load.clear + Reloader.clear! Thread.current[:padrino_loaded] = nil end @@ -98,10 +84,10 @@ module Padrino # Method for reloading required applications and their files. # def reload! - return unless Padrino::Reloader.changed? - Padrino.before_load.each(&:call) # Run before hooks - Padrino::Reloader.reload! # detects the modified files - Padrino.after_load.each(&:call) # Run after hooks + return unless Reloader.changed? + before_load.each(&:call) + Reloader.reload! + after_load.each(&:call) end ## @@ -147,38 +133,55 @@ module Padrino # require_dependencies("#{Padrino.root}/lib/**/*.rb") # def require_dependencies(*paths) - options = paths.extract_options! - - # Extract all files to load - files = paths.flatten.map { |path| Dir[path] }.flatten.uniq.sort + options = paths.extract_options!.merge( :cyclic => true ) + files = paths.flatten.map{|path| Dir[path].sort_by{|v| v.count('/') }}.flatten.uniq while files.present? - errors, failed = [], [] + error, fatal, loaded = nil, nil, nil - size_at_start = files.size - - # Now we try to require our dependencies, we dup files - # so we don't perform delete on the original array during - # iteration, this prevent problems with Rubinus files.dup.each do |file| begin - Padrino::Reloader.safe_load(file, options.dup) + Reloader.safe_load(file, options) files.delete(file) + loaded = true rescue NameError, LoadError => e - Padrino.logger.devel "Problem while loading #{file}: #{e}" - errors << e - failed << file + logger.devel "Cyclic dependency reload for #{e.class}: #{e.message}" + error = e rescue Exception => e - raise e + fatal = e + break end end - # Stop processing if nothing loads or if everything has loaded - raise errors.last if files.size == size_at_start && files.present? - break if files.empty? + if fatal || !loaded + e = fatal || error + logger.error "#{e.class}: #{e.message}; #{e.backtrace.first}" + raise e + end end end + ## + # Concat to +$LOAD_PATH+ the given paths. + # + # @param [Array] paths + # The paths to concat. + # + def set_load_paths(*paths) + load_paths.concat(paths).uniq! + $LOAD_PATH.concat(paths).uniq! + end + + ## + # The used +$LOAD_PATHS+ from Padrino. + # + # @return [Array] + # The load paths used by Padrino. + # + def load_paths + @_load_paths ||= load_paths_was.dup + end + ## # Returns default list of path globs to load as dependencies. # Appends custom dependency patterns to the be loaded for Padrino. @@ -190,35 +193,32 @@ module Padrino # Padrino.dependency_paths << "#{Padrino.root}/uploaders/*.rb" # def dependency_paths - @_dependency_paths ||= (dependency_paths_was + Array(module_paths)) - end - - ## - # Concat to +$LOAD_PATH+ the given paths. - # - # @param [Array] paths - # The paths to concat. - # - def set_load_paths(*paths) - $:.concat(paths); load_paths.concat(paths) - $:.uniq!; load_paths.uniq! + @_dependency_paths ||= dependency_paths_was + module_paths end private def module_paths - Padrino.modules.map(&:dependency_paths).flatten! + modules.map(&:dependency_paths).flatten + end + + def load_paths_was + @_load_paths_was ||= [ + "#{root}/lib", + "#{root}/models", + "#{root}/shared", + ].freeze end def dependency_paths_was - [ + @_dependency_paths_was ||= [ "#{root}/config/database.rb", "#{root}/lib/**/*.rb", - "#{root}/shared/lib/**/*.rb", "#{root}/models/**/*.rb", + "#{root}/shared/lib/**/*.rb", "#{root}/shared/models/**/*.rb", "#{root}/config/apps.rb" - ] + ].freeze end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/cs.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/cs.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/cs.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/cs.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/da.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/da.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/da.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/da.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/de.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/de.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/de.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/de.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/en.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/en.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/en.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/en.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/es.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/es.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/es.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/es.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/fr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/fr.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/fr.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/fr.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/hu.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/hu.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/hu.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/hu.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/it.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/it.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/it.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/it.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ja.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ja.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ja.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ja.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/lv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/lv.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/lv.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/lv.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/nl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/nl.yml similarity index 93% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/nl.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/nl.yml index 868087be..905d40b3 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/nl.yml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/nl.yml @@ -11,7 +11,7 @@ nl: day_names: [zondag, maandag, dinsdag, woensdag, donderdag, vrijdag, zaterdag] abbr_day_names: [zo, ma, di, wo, do, vr, za] - month_names: [~, januari, februari, maart, april, mei, juni, juli, augustus, september, oktober, november] + month_names: [~, januari, februari, maart, april, mei, juni, juli, augustus, september, oktober, november, december] abbr_month_names: [~, jan, feb, maa, apr, mei, jun, jul, aug, sep, okt, nov, dec] order: - day diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/no.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/no.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/no.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/no.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/pl.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pl.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/pl.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pt_br.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/pt_br.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pt_br.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/pt_br.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ro.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ro.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ro.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ro.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ru.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ru.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ru.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/ru.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/sv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/sv.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/sv.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/sv.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/tr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/tr.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/tr.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/tr.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/uk.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/uk.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/uk.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/uk.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_cn.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/zh_cn.yml similarity index 75% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_cn.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/zh_cn.yml index 1cde0a12..d5aed381 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_cn.yml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/zh_cn.yml @@ -4,9 +4,9 @@ zh_cn: # Use the strftime parameters for formats. # When no format has been given, it uses default. # You can provide other formats here if you like! - default: "%Y 年 %m 月 %d 日" - short: "%b 月 %d 日" - long: "公元 %Y 年 %B 月 %d 日" + default: "%Y年%m月%d日" + short: "%b月%d日" + long: "%Y年%B月%d日" only_day: "%e" day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六] @@ -20,9 +20,9 @@ zh_cn: time: formats: - default: "%Y 年 %b 月 %d 日 %H:%M:%S %z" - short: "%d 月 %b 日 %H:%M" - long: "%Y 年 %B 月 %d 日 %H 时 %M 分" + default: "%Y年%b月%d日 %H:%M:%S %z" + short: "%b月%d日 %H:%M" + long: "%Y年%B%d日 %H时%M分" am: "上午" pm: "下午" diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_tw.yml b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/zh_tw.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_tw.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/locale/zh_tw.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/logger.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/logger.rb similarity index 98% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/logger.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/logger.rb index bd863f8b..ad4f6645 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/logger.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/logger.rb @@ -52,10 +52,10 @@ module Padrino # :devel:: Development-related information that is unnecessary in debug mode # Levels = { - :fatal => 7, - :error => 6, - :warn => 4, - :info => 3, + :fatal => 4, + :error => 3, + :warn => 2, + :info => 1, :debug => 0, :devel => -1, } unless defined?(Levels) @@ -194,13 +194,13 @@ module Padrino # def colorize(string, *colors) colors.each do |c| - string = string.send(c) + string = string.colorize(c) end string end def stylized_level(level) - style = ColoredLevels[level].map { |c| "\e[%dm" % String.colors[c] } * '' + style = ColoredLevels[level].map { |c| "\e[%dm" % String::Colorizer.colors[c] } * '' [style, super, "\e[0m"] * '' end end @@ -280,7 +280,7 @@ module Padrino stream = case config[:stream] when :to_file - FileUtils.mkdir_p(Padrino.root('log')) unless File.exists?(Padrino.root('log')) + FileUtils.mkdir_p(Padrino.root('log')) unless File.exist?(Padrino.root('log')) File.new(Padrino.root('log', "#{Padrino.env}.log"), 'a+') when :null then StringIO.new when :stdout then $stdout diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/module.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/module.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/module.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/module.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/mounter.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/mounter.rb similarity index 91% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/mounter.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/mounter.rb index 76901dab..1bb9086e 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/mounter.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/mounter.rb @@ -8,10 +8,11 @@ module Padrino # Mounter.new("blog_app", :app_file => "/path/to/blog/app.rb").to("/blog") # class Mounter + DEFAULT_CASCADE = [404, 405] class MounterException < RuntimeError end - attr_accessor :name, :uri_root, :app_file, :app_class, :app_root, :app_obj, :app_host + attr_accessor :name, :uri_root, :app_file, :app_class, :app_root, :app_obj, :app_host, :cascade ## # @param [String, Padrino::Application] name @@ -31,8 +32,9 @@ module Padrino @app_file = options[:app_file] || locate_app_file @app_obj = options[:app_obj] || app_constant || locate_app_object ensure_app_file! || ensure_app_object! - @app_root = options[:app_root] || File.dirname(@app_file) + @app_root = options[:app_root] || (@app_obj.respond_to?(:root) && @app_obj.root || File.dirname(@app_file)) @uri_root = "/" + @cascade = options[:cascade] ? true == options[:cascade] ? DEFAULT_CASCADE.dup : Array(options[:cascade]) : [] Padrino::Reloader.exclude_constants << @app_class end @@ -82,11 +84,12 @@ module Padrino def map_onto(router) app_data, app_obj = self, @app_obj app_obj.set :uri_root, app_data.uri_root - app_obj.set :app_name, app_data.name + app_obj.set :app_name, app_data.app_obj.app_name.to_s app_obj.set :app_file, app_data.app_file unless ::File.exist?(app_obj.app_file) app_obj.set :root, app_data.app_root unless app_data.app_root.blank? - app_obj.set :public_folder, Padrino.root('public', app_data.uri_root) unless File.exists?(app_obj.public_folder) + app_obj.set :public_folder, Padrino.root('public', app_data.uri_root) unless File.exist?(app_obj.public_folder) app_obj.set :static, File.exist?(app_obj.public_folder) if app_obj.nil? + app_obj.set :cascade, app_data.cascade app_obj.setup_application! # Initializes the app here with above settings. router.map(:to => app_obj, :path => app_data.uri_root, :host => app_data.app_host) end @@ -106,7 +109,9 @@ module Padrino # def named_routes app_obj.routes.map { |route| - name_array = "(#{route.name.to_s.split("_").map { |piece| %Q[:#{piece}] }.join(", ")})" + route_name = route.name.to_s + route_name.sub!(/^#{route.controller} /, "") if route.controller + name_array = "(#{route.controller ? %Q[:#{route.controller}] + ", " : ""}:#{route_name})" request_method = route.request_methods.first next if route.name.blank? || request_method == 'HEAD' original_path = route.original_path.is_a?(Regexp) ? route.original_path.inspect : route.original_path diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader.rb new file mode 100644 index 00000000..0a56e42e --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader.rb @@ -0,0 +1,250 @@ +require 'pathname' +require 'padrino-core/reloader/rack' +require 'padrino-core/reloader/storage' + +module Padrino + ## + # High performance source code reloader middleware + # + module Reloader + ## + # This reloader is suited for use in a many environments because each file + # will only be checked once and only one system call to stat(2) is made. + # + # Please note that this will not reload files in the background, and does so + # only when explicitly invoked. + # + extend self + + # The modification times for every file in a project. + MTIMES = {} + + ## + # Specified folders can be excluded from the code reload detection process. + # Default excluded directories at Padrino.root are: test, spec, features, tmp, config, db and public + # + def exclude + @_exclude ||= Set.new %w(test spec tmp features config public db).map{ |path| Padrino.root(path) } + end + + ## + # Specified constants can be excluded from the code unloading process. + # + def exclude_constants + @_exclude_constants ||= Set.new + end + + ## + # Specified constants can be configured to be reloaded on every request. + # Default included constants are: [none] + # + def include_constants + @_include_constants ||= Set.new + end + + ## + # Reload apps and files with changes detected. + # + def reload! + rotation do |file| + next unless file_changed?(file) + reload_special(file) || reload_regular(file) + end + end + + ## + # Remove files and classes loaded with stat + # + def clear! + MTIMES.clear + Storage.clear! + end + + ## + # Returns true if any file changes are detected. + # + def changed? + rotation do |file| + break true if file_changed?(file) + end + end + + ## + # We lock dependencies sets to prevent reloading of protected constants + # + def lock! + klasses = ObjectSpace.classes do |klass| + klass._orig_klass_name.split('::').first + end + klasses |= Padrino.mounted_apps.map(&:app_class) + exclude_constants.merge(klasses) + end + + ## + # A safe Kernel::require which issues the necessary hooks depending on results + # + def safe_load(file, options={}) + began_at = Time.now + file = figure_path(file) + return unless options[:force] || file_changed?(file) + + Storage.prepare(file) # might call #safe_load recursively + logger.devel(file_new?(file) ? :loading : :reload, began_at, file) + begin + with_silence{ require(file) } + Storage.commit(file) + update_modification_time(file) + rescue Exception => e + unless options[:cyclic] + logger.error "#{e.class}: #{e.message}; #{e.backtrace.first}" + logger.error "Failed to load #{file}; removing partially defined constants" + end + Storage.rollback(file) + raise e + end + end + + ## + # Removes the specified class and constant. + # + def remove_constant(const) + return if constant_excluded?(const) + base, _, object = const.to_s.rpartition('::') + base = base.empty? ? Object : base.constantize + base.send :remove_const, object + logger.devel "Removed constant #{const} from #{base}" + rescue NameError + end + + ## + # Returns the list of special tracked files for Reloader. + # + def special_files + @special_files ||= Set.new + end + + ## + # Sets the list of special tracked files for Reloader. + # + def special_files=(files) + @special_files = Set.new(files) + end + + private + + ## + # Returns absolute path of the file. + # + def figure_path(file) + return file if Pathname.new(file).absolute? + $LOAD_PATH.each do |path| + found = File.join(path, file) + return File.expand_path(found) if File.file?(found) + end + file + end + + ## + # Reloads the file if it's special. For now it's only I18n locale files. + # + def reload_special(file) + return unless special_files.any?{ |f| File.identical?(f, file) } + if defined?(I18n) + began_at = Time.now + I18n.reload! + update_modification_time(file) + logger.devel :reload, began_at, file + end + true + end + + ## + # Reloads ruby file and applications dependent on it. + # + def reload_regular(file) + apps = mounted_apps_of(file) + if apps.present? + apps.each { |app| app.app_obj.reload! } + update_modification_time(file) + else + safe_load(file) + reloadable_apps.each do |app| + app.app_obj.reload! if app.app_obj.dependencies.include?(file) + end + end + end + + ### + # Macro for mtime update. + # + def update_modification_time(file) + MTIMES[file] = File.mtime(file) + end + + ### + # Returns true if the file is new or it's modification time changed. + # + def file_changed?(file) + file_new?(file) || File.mtime(file) > MTIMES[file] + end + + ### + # Returns true if the file is new. + # + def file_new?(file) + MTIMES[file].nil? + end + + ## + # Return the mounted_apps providing the app location. + # Can be an array because in one app.rb we can define multiple Padrino::Application. + # + def mounted_apps_of(file) + Padrino.mounted_apps.select { |app| File.identical?(file, app.app_file) } + end + + ## + # Searches Ruby files in your +Padrino.load_paths+ , Padrino::Application.load_paths + # and monitors them for any changes. + # + def rotation + files_for_rotation.each do |file| + file = File.expand_path(file) + next if Reloader.exclude.any? { |base| file.start_with?(base) } || !File.file?(file) + yield file + end + nil + end + + ## + # Creates an array of paths for use in #rotation. + # + def files_for_rotation + files = Set.new + Padrino.load_paths.each{ |path| files += Dir.glob("#{path}/**/*.rb") } + reloadable_apps.each do |app| + files << app.app_file + files += app.app_obj.dependencies + end + files + special_files + end + + def constant_excluded?(const) + (exclude_constants - include_constants).any?{ |c| const._orig_klass_name.start_with?(c) } + end + + def reloadable_apps + Padrino.mounted_apps.select{ |app| app.app_obj.respond_to?(:reload) && app.app_obj.reload? } + end + + ## + # Disables output, yields block, switches output back. + # + def with_silence + verbosity_level, $-v = $-v, nil + yield + ensure + $-v = verbosity_level + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/rack.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/rack.rb new file mode 100644 index 00000000..a1b0d059 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/rack.rb @@ -0,0 +1,26 @@ +module Padrino + module Reloader + ## + # This class acts as a Rack middleware to be added to the application stack. + # This middleware performs a check and reload for source files at the start + # of each request, but also respects a specified cool down time + # during which no further action will be taken. + # + class Rack + def initialize(app, cooldown=1) + @app = app + @cooldown = cooldown + @last = (Time.now - cooldown) + end + + # Invoked in order to perform the reload as part of the request stack. + def call(env) + if @cooldown && Time.now > @last + @cooldown + Thread.list.size > 1 ? Thread.exclusive { Padrino.reload! } : Padrino.reload! + @last = Time.now + end + @app.call(env) + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/storage.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/storage.rb new file mode 100644 index 00000000..34630e27 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/reloader/storage.rb @@ -0,0 +1,55 @@ +module Padrino + module Reloader + module Storage + extend self + + def clear! + files.each_key do |file| + remove(file) + $LOADED_FEATURES.delete(file) + end + @files = {} + end + + def remove(name) + file = files[name] || return + file[:constants].each{ |constant| Reloader.remove_constant(constant) } + file[:features].each{ |feature| $LOADED_FEATURES.delete(feature) } + files.delete(name) + end + + def prepare(name) + file = remove(name) + @old_entries ||= {} + @old_entries[name] = { + :constants => ObjectSpace.classes, + :features => old_features = Set.new($LOADED_FEATURES.dup) + } + features = file && file[:features] || [] + features.each{ |feature| Reloader.safe_load(feature, :force => true) } + $LOADED_FEATURES.delete(name) if old_features.include?(name) + end + + def commit(name) + entry = { + :constants => ObjectSpace.new_classes(@old_entries[name][:constants]), + :features => Set.new($LOADED_FEATURES) - @old_entries[name][:features] - [name] + } + files[name] = entry + @old_entries.delete(name) + end + + def rollback(name) + new_constants = ObjectSpace.new_classes(@old_entries[name][:constants]) + new_constants.each{ |klass| Reloader.remove_constant(klass) } + @old_entries.delete(name) + end + + private + + def files + @files ||= {} + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/router.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/router.rb similarity index 79% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/router.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/router.rb index 1d0a9af9..4ffd78aa 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/router.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/router.rb @@ -62,14 +62,15 @@ module Padrino host = Regexp.new("^#{Regexp.quote(host)}$", true, 'n') unless host.nil? || host.is_a?(Regexp) @mapping << [host, path, match, app] - sort! end # The call handler setup to route a request given the mappings specified. def call(env) + began_at = Time.now path_info = env["PATH_INFO"].to_s script_name = env['SCRIPT_NAME'] http_host = env['HTTP_HOST'] + last_result = nil @mapping.each do |host, path, match, app| next unless host.nil? || http_host =~ host @@ -78,18 +79,16 @@ module Padrino rest = "/" if rest.empty? - return app.call( - env.merge( - 'SCRIPT_NAME' => (script_name + path), - 'PATH_INFO' => rest)) + last_result = app.call(env.merge('SCRIPT_NAME' => script_name + path, 'PATH_INFO' => rest)) + + cascade_setting = app.respond_to?(:cascade) ? app.cascade : true + cascade_statuses = cascade_setting.respond_to?(:include?) ? cascade_setting : Mounter::DEFAULT_CASCADE + break unless cascade_setting && cascade_statuses.include?(last_result[0]) + end + last_result || begin + Padrino::Logger::Rack.new(nil,'/').send(:log, env, 404, {}, began_at) if logger.debug? + [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path_info}"]] end - [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path_info}"]] - end - - private - - def sort! - @mapping = @mapping.sort_by { |h, p, m, a| -p.size } end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/server.rb similarity index 90% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/server.rb index f8dd3323..2601e078 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/server.rb @@ -31,6 +31,11 @@ module Padrino FileUtils.mkdir_p(File.dirname(options[:pid])) end options[:server] = detect_rack_handler if options[:server].blank? + if options[:options].is_a?(Array) + parsed_server_options = options.delete(:options).map { |opt| opt.split('=', 2) }.flatten + server_options = Hash[*parsed_server_options].symbolize_keys! + options.merge!(server_options) + end new(options, app).start end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite.rb similarity index 89% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite.rb index 97cbe518..a511d396 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite.rb @@ -2,8 +2,9 @@ # This file loads certain extensions required by Padrino from ActiveSupport. # require 'active_support/core_ext/module/aliasing' # alias_method_chain -require 'active_support/core_ext/hash/keys' # symbolize_keys require 'active_support/core_ext/hash/reverse_merge' # reverse_merge +require 'active_support/core_ext/hash/keys' # symbolize_keys +require 'active_support/core_ext/hash/indifferent_access' # params[:foo] require 'active_support/core_ext/hash/slice' # slice require 'active_support/core_ext/object/blank' # present? require 'active_support/core_ext/array/extract_options' # extract_options @@ -199,27 +200,41 @@ end # puts help.red.bold # class String - def self.colors - @_colors ||= { - :clear => 0, - :bold => 1, - :black => 30, - :red => 31, - :green => 32, - :yellow => 33, - :blue => 34, - :magenta => 35, - :cyan => 36, - :white => 37 - } + # colorize(:red) + def colorize(color) + Colorizer.send(color, self) end - colors.each do |color, value| - define_method(color) do - ["\e[", value.to_s, "m", self, "\e[", self.class.colors[:clear], "m"] * '' + # Used to colorize strings for the shell + class Colorizer + # Returns colors integer mapping + def self.colors + @_colors ||= { + :clear => 0, + :bold => 1, + :black => 30, + :red => 31, + :green => 32, + :yellow => 33, + :blue => 34, + :magenta => 35, + :cyan => 36, + :white => 37 + } + end + + # Defines class level color methods + # i.e Colorizer.red("hello") + class << self + Colorizer.colors.each do |color, value| + define_method(color) do |target| + "\e[#{value}m" << target << "\e[0m" + end + end end end + # Strip unnecessary indentation of the front of a string def undent gsub(/^.{#{slice(/^ +/).size}}/, '') end @@ -242,19 +257,3 @@ I18n.load_path += Dir["#{File.dirname(__FILE__)}/locale/*.yml"] if defined?(I18n # Used to determine if this file has already been required # module SupportLite; end - -module Padrino - class Utils - ### - # Silences output verbosity level so load - # errors are not visible when safe_load(file) - # - def self.silence_output - @verbosity_level, $-v = $-v, nil - end - - def self.unsilence_output - $-v = @verbosity_level - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/tasks.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/tasks.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/tasks.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/tasks.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/version.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/version.rb similarity index 87% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/version.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/version.rb index d61bd265..023e2eb6 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/version.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/version.rb @@ -6,7 +6,7 @@ # module Padrino # The version constant for the current version of Padrino. - VERSION = '0.11.4' unless defined?(Padrino::VERSION) + VERSION = '0.12.0' unless defined?(Padrino::VERSION) # # The current Padrino version. diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/padrino-core.gemspec b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/padrino-core.gemspec old mode 100755 new mode 100644 similarity index 96% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/padrino-core.gemspec rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/padrino-core.gemspec index 114296fe..56488b67 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/padrino-core.gemspec +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/padrino-core.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.version = Padrino.version s.date = Time.now.strftime("%Y-%m-%d") + s.license = "MIT" s.extra_rdoc_files = Dir["*.rdoc"] s.files = `git ls-files`.split("\n") @@ -38,6 +39,6 @@ Gem::Specification.new do |s| end s.add_dependency("http_router", "~> 0.11.0") s.add_dependency("thor", "~> 0.17.0") - s.add_dependency("activesupport", ">= 3.1", "< 4.0") + s.add_dependency("activesupport", ">= 3.1") s.add_dependency("rack-protection", ">= 1.5.0") end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/Gemfile b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/Gemfile similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/Gemfile rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/Gemfile diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app/app.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/app/app.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app/app.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/app/app.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app_gem.gemspec b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/app_gem.gemspec similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app_gem.gemspec rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/app_gem.gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/lib/app_gem.rb similarity index 95% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/lib/app_gem.rb index e4a4b239..39a09987 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/lib/app_gem.rb @@ -4,4 +4,4 @@ module AppGem extend Padrino::Module gem! 'app_gem' -end \ No newline at end of file +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem/version.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/lib/app_gem/version.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem/version.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/app_gem/lib/app_gem/version.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.components b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/.components similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.components rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/.components diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.gitignore b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/.gitignore similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.gitignore rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/.gitignore diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/complex.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/complex.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/complex.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/complex.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/helpers/system_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/helpers/system_helpers.rb new file mode 100644 index 00000000..105ff085 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/helpers/system_helpers.rb @@ -0,0 +1,8 @@ +require 'resolv' + +SystemDemo.helpers do + def resolv + Resolv.name + end +end + diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/kiq.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/kiq.rb new file mode 100644 index 00000000..5e60b547 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/kiq.rb @@ -0,0 +1,3 @@ +class Kiq < ::Sinatra::Base + set :root, '/weird' +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass.rb new file mode 100644 index 00000000..ad5a865d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass.rb @@ -0,0 +1,2 @@ +class MyKlass < OpenStruct +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass/mysubklass.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass/mysubklass.rb new file mode 100644 index 00000000..e2fde456 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/lib/myklass/mysubklass.rb @@ -0,0 +1,4 @@ +class MyKlass + class MySubKlass + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/child.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/child.rb new file mode 100644 index 00000000..2876c100 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/child.rb @@ -0,0 +1,2 @@ +class Child < Parent +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/parent.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/parent.rb new file mode 100644 index 00000000..f0aedee6 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/models/parent.rb @@ -0,0 +1,5 @@ +class Parent + def family + 'Danes' + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/render.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/render.rb new file mode 100644 index 00000000..db6d68f8 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/render.rb @@ -0,0 +1,13 @@ +PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT + +class RenderDemo < Padrino::Application + set :reload, true +end + +RenderDemo.controllers :blog do + get '/' do + render 'post' + end +end + +Padrino.load! diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/simple.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/simple.rb similarity index 90% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/simple.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/simple.rb index fd9d3bc8..8263ef1d 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/simple.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/simple.rb @@ -1,5 +1,5 @@ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT -# Remove this comment if you want do some like this: ruby PADRINO_ENV=test app.rb +# Remove this comment if you want do some like this: ruby RACK_ENV=test app.rb # # require 'rubygems' # require 'padrino-core' diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/static.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/static.rb new file mode 100644 index 00000000..ca8828c8 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/static.rb @@ -0,0 +1,10 @@ +PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT + +class StaticDemo < Padrino::Application + disable :reload + def self.reload! + fail 'reload! called' + end +end + +Padrino.load! diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/system.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/system.rb new file mode 100644 index 00000000..5cc4e8ae --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/system.rb @@ -0,0 +1,13 @@ +PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT + +class SystemDemo < Padrino::Application + set :reload, true +end + +SystemDemo.controllers do + get '/' do + resolv + end +end + +Padrino.load! diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/views/blog/post.erb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/views/blog/post.erb new file mode 100644 index 00000000..9f8d6f24 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/apps/views/blog/post.erb @@ -0,0 +1 @@ +okay \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/a.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/a.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/a.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/a.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/b.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/b.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/b.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/b.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/c.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/c.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/c.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/c.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/e.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/e.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/e.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/e.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/f.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/f.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/f.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/f.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/g.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/g.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/g.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/circular/g.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/d.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/d.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/d.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/dependencies/d.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/layouts/layout.erb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/layouts/layout.erb new file mode 100644 index 00000000..c1de6be7 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/fixtures/layouts/layout.erb @@ -0,0 +1 @@ +<%= yield %> absolute layout \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/helper.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/helper.rb similarity index 95% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/helper.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/helper.rb index ba921acf..972be7e4 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/helper.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/helper.rb @@ -1,4 +1,4 @@ -ENV['PADRINO_ENV'] = 'test' +ENV['RACK_ENV'] = 'test' PADRINO_ROOT = File.dirname(__FILE__) unless defined?(PADRINO_ROOT) require File.expand_path('../../../load_paths', __FILE__) @@ -56,7 +56,7 @@ class MiniTest::Spec path = "/views/#{name}" path += ".#{options.delete(:locale)}" if options[:locale].present? path += ".#{options[:format]}" if options[:format].present? - path += ".erb" unless options[:format].to_s =~ /haml|rss|atom/ + path += ".erb" unless options[:format].to_s =~ /erb|slim|haml|rss|atom/ path += ".builder" if options[:format].to_s =~ /rss|atom/ file = File.dirname(__FILE__) + path File.open(file, 'w') { |io| io.write content } diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/mini_shoulda.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/mini_shoulda.rb similarity index 78% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/mini_shoulda.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/mini_shoulda.rb index b61816a3..ed61ab5b 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/mini_shoulda.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/mini_shoulda.rb @@ -29,10 +29,10 @@ class ColoredIO def print(o) case o - when "." then @io.send(:print, o.green) - when "E" then @io.send(:print, o.red) - when "F" then @io.send(:print, o.yellow) - when "S" then @io.send(:print, o.magenta) + when "." then @io.send(:print, o.colorize(:green)) + when "E" then @io.send(:print, o.colorize(:red)) + when "F" then @io.send(:print, o.colorize(:yellow)) + when "S" then @io.send(:print, o.colorize(:magenta)) else @io.send(:print, o) end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_application.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_application.rb similarity index 89% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_application.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_application.rb index 5c8b5632..6dac258a 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_application.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_application.rb @@ -25,19 +25,6 @@ describe "Application" do assert !Padrino.configure_apps end - should 'check haml options on production' do - assert defined?(Haml), 'Haml not defined' - assert_equal :test, PadrinoPristine.environment - assert !PadrinoPristine.haml[:ugly] - Padrino.stub :env, :production do - PadrinoPristine.send :default_configuration! - assert_equal :production, Padrino.env - assert_equal :production, PadrinoPristine.environment - assert PadrinoPristine.haml[:ugly] - PadrinoPristine.environment = :test - end - end - should 'check padrino specific options' do assert !PadrinoPristine.instance_variable_get(:@_configured) PadrinoPristine.send(:setup_application!) @@ -97,6 +84,11 @@ describe "Application" do assert_equal "Foo in nil", body end + should "resolve views and layouts paths" do + assert_equal Padrino.root('views')+'/users/index', PadrinoPristine.view_path('users/index') + assert_equal Padrino.root('views')+'/layouts/app', PadrinoPristine.layout_path(:app) + end + context "errors" do should "haven't mapped errors on development" do mock_app { get('/'){ 'HI' } } diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_core.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_core.rb similarity index 81% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_core.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_core.rb index 546b1686..5ee1a255 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_core.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_core.rb @@ -27,12 +27,8 @@ describe "Core" do should 'set correct utf-8 encoding' do Padrino.set_encoding - if RUBY_VERSION <'1.9' - assert_equal 'UTF8', $KCODE - else - assert_equal Encoding.default_external, Encoding::UTF_8 - assert_equal Encoding.default_internal, Encoding::UTF_8 - end + assert_equal Encoding.default_external, Encoding::UTF_8 + assert_equal Encoding.default_internal, Encoding::UTF_8 end should 'have load paths' do @@ -73,5 +69,18 @@ describe "Core" do res = Rack::MockRequest.new(Padrino.application).get("/") assert_equal "yes", res["Middleware-Called"] end + + should "properly set default options" do + mock_app do + default :foo, :bar + default :zoo, :baz + set :foo, :bam + set :moo, :bam + default :moo, :ban + end + assert_equal @app.settings.foo, :bam + assert_equal @app.settings.zoo, :baz + assert_equal @app.settings.moo, :bam + end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_csrf_protection.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_csrf_protection.rb new file mode 100644 index 00000000..3e2977d5 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_csrf_protection.rb @@ -0,0 +1,161 @@ +require File.expand_path(File.dirname(__FILE__) + '/helper') + +describe "Application" do + before { Padrino.clear! } + after { remove_views } + + context 'CSRF protection' do + context "with CSRF protection on" do + before do + mock_app do + enable :sessions + enable :protect_from_csrf + post('/'){ 'HI' } + end + end + + should "not allow requests without tokens" do + post "/" + assert_equal 403, status + end + + should "allow requests with correct tokens" do + post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "a"} + assert_equal 200, status + end + + should "not allow requests with incorrect tokens" do + post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "b"} + assert_equal 403, status + end + end + + context "without CSRF protection on" do + before do + mock_app do + enable :sessions + disable :protect_from_csrf + post('/'){ 'HI' } + end + end + + should "allows requests without tokens" do + post "/" + assert_equal 200, status + end + + should "allow requests with correct tokens" do + post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "a"} + assert_equal 200, status + end + + should "allow requests with incorrect tokens" do + post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "b"} + assert_equal 200, status + end + end + + context "with optional CSRF protection" do + before do + mock_app do + enable :sessions + enable :protect_from_csrf + set :allow_disabled_csrf, true + post('/on') { 'HI' } + post('/off', :csrf_protection => false) { 'HI' } + end + end + + should "allow access to routes with csrf_protection off" do + post "/off" + assert_equal 200, status + end + + should "not allow access to routes with csrf_protection on" do + post "/on" + assert_equal 403, status + end + end + + context "with :except option that is using Proc" do + before do + mock_app do + enable :sessions + set :protect_from_csrf, :except => proc{|env| ["/", "/foo"].any?{|path| path == env['PATH_INFO'] }} + post("/") { "Hello" } + post("/foo") { "Hello, foo" } + post("/bar") { "Hello, bar" } + end + end + + should "allow ignoring CSRF protection on specific routes" do + post "/" + assert_equal 200, status + post "/foo" + assert_equal 200, status + post "/bar" + assert_equal 403, status + end + end + + context "with :except option that is using String and Regexp" do + before do + mock_app do + enable :sessions + set :protect_from_csrf, :except => ["/a", %r{^/a.c$}] + post("/a") { "a" } + post("/abc") { "abc" } + post("/foo") { "foo" } + end + end + + should "allow ignoring CSRF protection on specific routes" do + post "/a" + assert_equal 200, status + post "/abc" + assert_equal 200, status + post "/foo" + assert_equal 403, status + end + end + + context "with custom protection options" do + before do + mock_app do + enable :sessions + set :protect_from_csrf, :authenticity_param => 'foobar' + post("/a") { "a" } + end + end + + should "allow configuring protection options" do + post "/a", {"foobar" => "a"}, 'rack.session' => {:csrf => "a"} + assert_equal 200, status + end + end + + context "with middleware" do + before do + class Middleware < Sinatra::Base + post("/middleware") { "Hello, middleware" } + post("/dummy") { "Hello, dummy" } + end + mock_app do + enable :sessions + set :protect_from_csrf, :except => proc{|env| ["/", "/middleware"].any?{|path| path == env['PATH_INFO'] }} + use Middleware + post("/") { "Hello" } + end + end + + should "allow ignoring CSRF protection on specific routes of middleware" do + post "/" + assert_equal 200, status + post "/middleware" + assert_equal 200, status + post "/dummy" + assert_equal 403, status + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_dependencies.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_dependencies.rb similarity index 75% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_dependencies.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_dependencies.rb index 4e2cfdd0..85fccf90 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_dependencies.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_dependencies.rb @@ -2,6 +2,17 @@ require File.expand_path(File.dirname(__FILE__) + '/helper') describe "Dependencies" do context 'when we require a dependency that have another dependency' do + setup do + @log_level = Padrino::Logger::Config[:test] + @io = StringIO.new + Padrino::Logger::Config[:test] = { :log_level => :error, :stream => @io } + Padrino::Logger.setup! + end + + teardown do + Padrino::Logger::Config[:test] = @log_level + Padrino::Logger.setup! + end should 'raise an error without reloading it twice' do capture_io do @@ -15,6 +26,7 @@ describe "Dependencies" do end end assert_equal 1, D + assert_match /RuntimeError: SomeThing/, @io.string end should 'resolve dependency problems' do @@ -27,6 +39,7 @@ describe "Dependencies" do end assert_equal ["B", "C"], A_result assert_equal "C", B_result + assert_equal "", @io.string end should 'remove partially loaded constants' do @@ -37,8 +50,8 @@ describe "Dependencies" do Padrino.root("fixtures/dependencies/circular/g.rb") ) end - assert_equal ["name"], F.fields + assert_equal "", @io.string end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_filters.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_filters.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_filters.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_filters.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_flash.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_flash.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_flash.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_flash.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_locale.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_locale.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_locale.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_locale.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_logger.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_logger.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_logger.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_logger.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_mounter.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_mounter.rb similarity index 78% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_mounter.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_mounter.rb index 097be4b7..c05a73a1 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_mounter.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_mounter.rb @@ -24,7 +24,14 @@ describe "Mounter" do assert_equal "TestApp", mounter.app_class assert_equal "/path/to/test.rb", mounter.app_file assert_equal "/test_app", mounter.uri_root - assert_equal File.dirname(mounter.app_file), mounter.app_root + assert_equal Padrino.root, mounter.app_root + end + + should 'use app.root if available' do + require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/kiq') + mounter = Padrino::Mounter.new("kiq", :app_class => "Kiq") + mounter.to("/test_app") + assert_equal '/weird', mounter.app_root end should 'check locate_app_file with __FILE__' do @@ -53,6 +60,17 @@ describe "Mounter" do assert_equal ["some_namespace/an_app"], Padrino.mounted_apps.map(&:name) end + should 'correctly set a name of a namespaced app' do + module ::SomeNamespace2 + class AnApp < Padrino::Application + get(:index) { settings.app_name } + end + end + Padrino.mount("SomeNamespace2::AnApp").to("/") + res = Rack::MockRequest.new(Padrino.application).get("/") + assert_equal "some_namespace2/an_app", res.body + end + should 'mount a primary app to root uri' do mounter = Padrino.mount("test_app", :app_file => __FILE__).to("/") assert_equal "test_app", mounter.name @@ -130,30 +148,56 @@ describe "Mounter" do put(:update) { "users update" } delete(:destroy) { "users delete" } end + controllers :foo_bar do + get(:index) { "foo bar index" } + get(:new) { "foo bar new" } + post(:create) { "foo bar create" } + put(:update) { "foo bar update" } + delete(:destroy) { "foo bar delete" } + end end Padrino.mount("one_app").to("/") Padrino.mount("two_app").to("/two_app") assert_equal 15, Padrino.mounted_apps[0].routes.size - assert_equal 7, Padrino.mounted_apps[1].routes.size + assert_equal 14, Padrino.mounted_apps[1].routes.size assert_equal 6, Padrino.mounted_apps[0].named_routes.size - assert_equal 5, Padrino.mounted_apps[1].named_routes.size + assert_equal 10, Padrino.mounted_apps[1].named_routes.size first_route = Padrino.mounted_apps[0].named_routes[3] - assert_equal "posts_show", first_route.identifier.to_s + assert_equal "posts show", first_route.identifier.to_s assert_equal "(:posts, :show)", first_route.name assert_equal "GET", first_route.verb assert_equal "/posts/show/:id(.:format)", first_route.path another_route = Padrino.mounted_apps[1].named_routes[2] - assert_equal "users_create", another_route.identifier.to_s + assert_equal "users create", another_route.identifier.to_s assert_equal "(:users, :create)", another_route.name assert_equal "POST", another_route.verb assert_equal "/two_app/users/create", another_route.path regexp_route = Padrino.mounted_apps[0].named_routes[5] - assert_equal "posts_regexp", regexp_route.identifier.to_s + assert_equal "posts regexp", regexp_route.identifier.to_s assert_equal "(:posts, :regexp)", regexp_route.name assert_equal "/\\/foo|\\/baz/", regexp_route.path + foo_bar_route = Padrino.mounted_apps[1].named_routes[5] + assert_equal "(:foo_bar, :index)", foo_bar_route.name + end + + should "configure cascade apps" do + class ::App1 < Padrino::Application + get(:index) { halt 404, 'index1' } + end + class ::App2 < Padrino::Application + get(:index) { halt 404, 'index2' } + end + class ::App3 < Padrino::Application + get(:index) { halt 404, 'index3' } + end + Padrino.mount('app1', :cascade => true).to('/foo') + Padrino.mount('app2').to('/foo') + Padrino.mount('app3').to('/foo') + res = Rack::MockRequest.new(Padrino.application).get("/foo") + assert_equal 'index2', res.body end should 'correctly instantiate a new padrino application' do diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_complex.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_complex.rb similarity index 95% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_complex.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_complex.rb index d64af1a2..b2006cb1 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_complex.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_complex.rb @@ -47,7 +47,7 @@ describe "ComplexReloader" do new_buffer.gsub!(/get\(:destroy\)/, 'get(:destroy, :with => :id)') begin File.open(Complex1Demo.app_file, "w") { |f| f.write(new_buffer) } - sleep 1.2 # We need at least a cooldown of 1 sec. + sleep 1.1 # We need at least a cooldown of 1 sec. get "/complex_2_demo" assert_equal new_phrase, body @@ -65,7 +65,7 @@ describe "ComplexReloader" do assert_equal 200, status get "/complex_2_demo/var/destroy/variable" - assert_equal '{:id=>"variable"}', body + assert_equal '{"id"=>"variable"}', body ensure # Now we need to prevent to commit a new changed file so we revert it File.open(Complex1Demo.app_file, "w") { |f| f.write(buffer) } diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_simple.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_simple.rb similarity index 98% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_simple.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_simple.rb index ffcc37f4..4d4ecf10 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_simple.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_simple.rb @@ -61,7 +61,7 @@ describe "SimpleReloader" do buffer = File.read(SimpleDemo.app_file) new_buffer = buffer.gsub(/The magick number is: \d+!/, new_phrase) File.open(SimpleDemo.app_file, "w") { |f| f.write(new_buffer) } - sleep 2 # We need at least a cooldown of 1 sec. + sleep 1.1 # We need at least a cooldown of 1 sec. get "/" assert_equal new_phrase, body diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_system.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_system.rb new file mode 100644 index 00000000..1105d792 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_reloader_system.rb @@ -0,0 +1,64 @@ +require File.expand_path(File.dirname(__FILE__) + '/helper') +require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/kiq') +require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/system') +require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/static') + +describe "SystemReloader" do + context 'for wierd and difficult reload events' do + should 'reload system features if they were required only in helper' do + @app = SystemDemo + @app.reload! + get '/' + assert_equal 'Resolv', body + end + + should 'reload children on parent change' do + @app = SystemDemo + assert_equal Child.new.family, 'Danes' + parent_file = File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/models/parent.rb') + new_class = <<-DOC + class Parent + def family + 'Dancy' + end + def shmamily + 'Shmancy' + end + end + DOC + begin + backup = File.read(parent_file) + Padrino::Reloader.reload! + assert_equal 'Danes', Parent.new.family + assert_equal 'Danes', Child.new.family + File.open(parent_file, "w") { |f| f.write(new_class) } + Padrino::Reloader.reload! + assert_equal 'Dancy', Parent.new.family + assert_equal 'Shmancy', Parent.new.shmamily + assert_equal 'Dancy', Child.new.family + assert_equal 'Shmancy', Child.new.shmamily + ensure + File.open(parent_file, "w") { |f| f.write(backup) } + end + end + + should 'tamper with LOAD_PATH' do + SystemDemo.load_paths.each do |lib_dir| + assert_includes $LOAD_PATH, lib_dir + end + Padrino.send(:load_paths_was).each do |lib_dir| + assert_includes $LOAD_PATH, lib_dir + end + end + + should 'not fail horribly on reload event with non-padrino apps' do + Padrino.mount("kiq").to("/") + Padrino.reload! + end + + should 'not reload apps with disabled reload' do + Padrino.mount(StaticDemo).to("/") + Padrino.reload! + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_rendering.rb similarity index 88% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_rendering.rb index 8cceffaf..2c915294 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_rendering.rb @@ -209,6 +209,43 @@ describe "Rendering" do assert_equal "haml", body.chomp end + should 'allow to render template with layout option that using other template engine.' do + create_layout :"layouts/foo", "application layout for <%= yield %>", :format => :erb + create_view :slim, "| slim", :format => :slim + create_view :haml, "haml", :format => :haml + create_view :erb, "erb", :format => :erb + mock_app do + get("/slim") { render("slim.slim", :layout => "foo.erb") } + get("/haml") { render("haml.haml", :layout => "foo.erb") } + get("/erb") { render("erb.erb", :layout => "foo.erb") } + end + get "/slim" + assert_equal "application layout for slim", body.chomp + get "/haml" + assert_equal "application layout for haml", body.chomp + get "/erb" + assert_equal "application layout for erb", body.chomp + end + + should 'allow to use extension with layout method.' do + create_layout :"layouts/bar", "application layout for <%= yield %>", :format => :erb + create_view :slim, "| slim", :format => :slim + create_view :haml, "haml", :format => :haml + create_view :erb, "erb", :format => :erb + mock_app do + layout "bar.erb" + get("/slim") { render("slim.slim") } + get("/haml") { render("haml.haml") } + get("/erb") { render("erb.erb") } + end + get "/slim" + assert_equal "application layout for slim", body.chomp + get "/haml" + assert_equal "application layout for haml", body.chomp + get "/erb" + assert_equal "application layout for erb", body.chomp + end + context 'for application render functionality' do should "work properly with logging and missing layout" do @@ -385,11 +422,15 @@ describe "Rendering" do mock_app do get("/foo", :provides => [:html, :js]) { render :foo } end + + I18n.enforce_available_locales = false I18n.locale = :none get "/foo.js" assert_equal "Im Js", body get "/foo" assert_equal "Im Erb", body + I18n.enforce_available_locales = true + I18n.locale = :en get "/foo" assert_equal "Im English Erb", body @@ -407,6 +448,14 @@ describe "Rendering" do assert_equal 404, status end + should 'resolve templates and layouts located in absolute paths' do + mock_app do + get("/foo") { render 'apps/views/blog/post', :layout => 'layout', :views => File.dirname(__FILE__)+'/fixtures' } + end + get '/foo' + assert_match /okay absolute layout/, body + end + should 'resolve template content_type and locale with layout' do create_layout :foo, "Hello <%= yield %> in a Js layout", :format => :js create_layout :foo, "Hello <%= yield %> in a Js-En layout", :format => :js, :locale => :en @@ -425,11 +474,15 @@ describe "Rendering" do layout :foo get("/bar", :provides => [:html, :js, :json]) { render :bar } end + + I18n.enforce_available_locales = false I18n.locale = :none get "/bar.js" assert_equal "Hello Im Js in a Js layout", body get "/bar" assert_equal "Hello Im Erb in a Erb layout", body + I18n.enforce_available_locales = true + I18n.locale = :en get "/bar" assert_equal "Hello Im English Erb in a Erb-En layout", body @@ -447,6 +500,14 @@ describe "Rendering" do assert_equal "Im a json", body get "/bar.pk" assert_equal 404, status + + end + + should 'resolve template location relative to controller name' do + require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/render') + @app = RenderDemo + get '/blog' + assert_equal 'okay', body end should 'renders erb with blocks' do diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering_extensions.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_rendering_extensions.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering_extensions.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_rendering_extensions.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_restful_routing.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_restful_routing.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_restful_routing.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_restful_routing.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_router.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_router.rb similarity index 60% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_router.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_router.rb index 0bb7767d..61e0af73 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_router.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_router.rb @@ -17,8 +17,8 @@ describe "Router" do } map = Padrino::Router.new( { :path => '/bar', :to => app }, - { :path => '/foo', :to => app }, - { :path => '/foo/bar', :to => app } + { :path => '/foo/bar', :to => app }, + { :path => '/foo', :to => app } ) res = Rack::MockRequest.new(map).get("/") @@ -69,6 +69,125 @@ describe "Router" do assert_equal "/", res["X-PathInfo"] end + should "dispatch requests to cascade mounted apps" do + app = lambda { |env| + scary = !!env['PATH_INFO'].match(/scary/) + [scary ? 404 : 200, { + 'X-ScriptName' => env['SCRIPT_NAME'], + 'X-PathInfo' => env['PATH_INFO'], + 'Content-Type' => 'text/plain' + }, [""]] + } + api = lambda { |env| + spooky = !!env['QUERY_STRING'].match(/spooky/) + [spooky ? 200 : 404, { + 'X-API' => spooky, + 'X-ScriptName' => env['SCRIPT_NAME'], + 'X-PathInfo' => env['PATH_INFO'], + 'Content-Type' => 'application/json' + }, [""]] + } + map = Padrino::Router.new( + { :path => '/bar', :to => api }, + { :path => '/bar', :to => app } + ) + + res = Rack::MockRequest.new(map).get("/werewolf") + assert_equal 404, res.status + assert_equal nil, res["X-API"] + assert_equal nil, res["X-ScriptName"] + assert_equal nil, res["X-PathInfo"] + + res = Rack::MockRequest.new(map).get("/bar/mitzvah") + assert res.ok? + assert_equal nil, res["X-API"] + assert_equal 'text/plain', res["Content-Type"] + assert_equal "/bar", res["X-ScriptName"] + assert_equal "/mitzvah", res["X-PathInfo"] + + res = Rack::MockRequest.new(map).get("/bar?spooky") + assert res.ok? + assert_equal true, res["X-API"] + assert_equal 'application/json', res["Content-Type"] + assert_equal "/bar", res["X-ScriptName"] + assert_equal "/", res["X-PathInfo"] + + res = Rack::MockRequest.new(map).get("/bar/scary") + assert_equal 404, res.status + assert_equal nil, res["X-API"] + assert_equal 'text/plain', res["Content-Type"] + assert_equal "/bar", res["X-ScriptName"] + assert_equal "/scary", res["X-PathInfo"] + end + + should "dispatch requests to cascade mounted apps and not cascade ok statuses" do + + api = mock_app do + get 'scary' do + "1" + end + set :cascade, true + end + + app = mock_app do + get 'scary' do + "2" + end + set :cascade, false + end + + app2 = mock_app do + get 'terrifying' do + "" + end + end + + map = Padrino::Router.new( + { :path => '/bar', :to => api }, + { :path => '/bar', :to => app }, + { :path => '/bar', :to => app2 } + ) + + res = Rack::MockRequest.new(map).get("/bar/scary") + assert res.ok? + #asserting that on ok we're good to go + assert_equal "1", res.body + + res = Rack::MockRequest.new(map).get("/bar/terrifying") + assert !res.ok? + + end + + should "dispatch requests to cascade mounted apps until it sees a cascade == false or []g" do + app = mock_app do + get 'scary' do + "" + end + set :cascade, [] + end + + app2 = mock_app do + get 'terrifying' do + "" + end + end + + map = Padrino::Router.new( + { :path => '/bar', :to => app }, + { :path => '/bar', :to => app2 } + ) + + request_case = lambda { + Rack::MockRequest.new(map).get("/bar/terrifying") + } + + app.cascade = false + assert !request_case.call.ok? + + app.cascade = true + assert request_case.call.ok? + end + should "dispatches hosts correctly" do map = Padrino::Router.new( { :host => "foo.org", :to => lambda { |env| diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_routing.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_routing.rb similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_routing.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_routing.rb index dfad8e48..29c61e5f 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_routing.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_routing.rb @@ -1,4 +1,4 @@ -#encoding: utf-8 +#encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/helper') class FooError < RuntimeError; end @@ -56,6 +56,32 @@ describe "Routing" do } end + should 'fail with unrecognized route exception when namespace is invalid' do + mock_app do + controller :foo_bar do + get(:index){ "okey" } + get(:test_baz){ "okey" } + end + end + assert_equal "/foo_bar", @app.url_for(:foo_bar, :index) + assert_raises(Padrino::Routing::UnrecognizedException) { + get @app.url_for(:foo, :bar, :index) + } + assert_raises(Padrino::Routing::UnrecognizedException) { + get @app.url_for(:foo, :bar_index) + } + assert_equal "/foo_bar/test_baz", @app.url_for(:foo_bar, :test_baz) + assert_raises(Padrino::Routing::UnrecognizedException) { + get @app.url_for(:foo_bar, :test, :baz) + } + assert_raises(Padrino::Routing::UnrecognizedException) { + get @app.url_for(:foo, :bar_test, :baz) + } + assert_raises(Padrino::Routing::UnrecognizedException) { + get @app.url_for(:foo, :bar_test_baz) + } + end + should 'accept regexp routes' do mock_app do get(%r./fob|/baz.) { "regexp" } @@ -102,11 +128,11 @@ describe "Routing" do end should 'parse routes that are encoded' do - mock_app do + mock_app do get('/щч') { 'success!' } end get(URI.escape('/щч')) - assert_equal 'success!', body + assert_equal 'success!', body end should 'parse routes that include encoded slash' do @@ -120,9 +146,7 @@ describe "Routing" do end should 'encode params using UTF-8' do - skip unless ''.respond_to?(:encoding) # for 1.8.7 - - mock_app do + mock_app do get('/:foo') { params[:foo].encoding.name } end get '/bar' @@ -260,6 +284,14 @@ describe "Routing" do assert_equal "https://example.org/hash/1", body end + should 'generate absolute urls from stringified keys' do + mock_app do + get(:hash, with: :id) { absolute_url(:hash, "id" => 1) } + end + get "/hash/2" + assert_equal "http://example.org/hash/1", body + end + should 'generate proper absolute urls for mounted apps' do class Test < Padrino::Application get :foo do @@ -272,6 +304,24 @@ describe "Routing" do assert_equal 'http://example.org/test/foo?id=1', body end + should 'rebase simple string urls to app uri_root' do + mock_app do + set :uri_root, '/app' + get(:a){ url('/foo') } + get(:b){ url('bar') } + get(:c){ absolute_url('/foo') } + get(:d, :map => '/d/e/f'){ absolute_url('bar') } + end + get "/a" + assert_equal "/app/foo", body + get "/b" + assert_equal "bar", body + get "/c" + assert_equal "http://example.org/app/foo", body + get "/d/e/f" + assert_equal "http://example.org/app/d/e/bar", body + end + should 'allow regex url with format' do mock_app do get(/.*/, :provides => :any) { "regexp" } @@ -354,7 +404,7 @@ describe "Routing" do get("/foo"){ content_type(:json); content_type.to_s } end get "/foo" - assert_equal 'application/json;charset=utf-8', content_type + assert_equal 'application/json', content_type assert_equal 'json', body end @@ -367,7 +417,7 @@ describe "Routing" do end should "allow .'s in param values" do - skip + skip # TODO fix this? mock_app do get('/id/:email', :provides => [:json]) { |email, format| [email, format] * '/' } end @@ -474,7 +524,7 @@ describe "Routing" do end end get "/posts" - assert_equal "posts_index", body + assert_equal "posts index", body end should "preserve the format if you set it manually" do @@ -640,7 +690,7 @@ describe "Routing" do assert_equal 'application/javascript;charset=utf-8', response["Content-Type"] get "/a.json" assert_equal "json", body - assert_equal 'application/json;charset=utf-8', response["Content-Type"] + assert_equal 'application/json', response["Content-Type"] get "/a.foo" assert_equal "foo", body assert_equal 'application/foo;charset=utf-8', response["Content-Type"] @@ -676,8 +726,8 @@ describe "Routing" do assert_equal "1", body get "/admin/show/1" assert_equal "show 1", body - assert_equal "/admin/1", @app.url(:admin_index, :id => 1) - assert_equal "/admin/show/1", @app.url(:admin_show, :id => 1) + assert_equal "/admin/1", @app.url(:admin, :index, :id => 1) + assert_equal "/admin/show/1", @app.url(:admin, :show, :id => 1) get "/foo/bar" assert_equal "foo_bar_index", body end @@ -1446,6 +1496,51 @@ describe "Routing" do assert_equal '{"test"=>"what"}', body end + should "work only for the given controller and route when using before-filter with route's name" do + mock_app do + controller :foo do + before(:index) { @a = "only to :index" } + get(:index) { @a } + get(:main) { @a } + end + end + get '/foo/' + assert_equal 'only to :index', body + get '/foo/main' + assert_equal '', body + end + + should "work only for the given controller and route when using after-filter with route's name" do + mock_app do + controller :after_controller do + global = "global variable" + get(:index) { global } + get(:main) { global } + after(:index) { global = nil } + end + end + get '/after_controller' + assert_equal 'global variable', body + get '/after_controller' + assert_equal '', body + end + + should "execute the before/after filters when they are inserted after the target route" do + mock_app do + controller :after_test do + global = "global variable" + get(:index) { global } + get(:foo) { global } + before(:index) { global.delete!(" ") } + after(:index) { global = "after" } + end + end + get '/after_test' + assert_equal 'globalvariable', body + get '/after_test/foo' + assert_equal 'after', body + end + should 'work with controller and arbitrary params' do mock_app do get(:testing) { params[:foo] } @@ -1790,6 +1885,33 @@ describe "Routing" do assert ok? end + should 'return params as a HashWithIndifferentAccess object via GET' do + mock_app do + get('/foo/:bar') { "#{params["bar"]} #{params[:bar]}" } + get(:foo, :map => '/prefix/:var') { "#{params["var"]} #{params[:var]}" } + end + + get('/foo/some_text') + assert_equal "some_text some_text", body + + get('/prefix/var') + assert_equal "var var", body + end + + should 'return params as a HashWithIndifferentAccess object via POST' do + mock_app do + post('/user') do + "#{params["user"]["full_name"]} #{params[:user][:full_name]}" + end + end + + post '/user', {:user => {:full_name => 'example user'}} + assert_equal "example user example user", body + + post '/user', {"user" => {"full_name" => 'example user'}} + assert_equal "example user example user", body + end + should 'have MethodOverride middleware with more options' do mock_app do put('/hi', :provides => [:json]) { 'hi' } @@ -1840,7 +1962,7 @@ describe "Routing" do end should 'render a custom error page using error method' do - skip + skip # TODO sinatra bug? mock_app do error(404) { "custom 404 error" } end @@ -1867,8 +1989,8 @@ describe "Routing" do get(:simple, :map => "/simple/:id") { } get(:with_format, :with => :id, :provides => :js) { } end - assert_equal [:foo_bar, { :id => "fantastic" }], @app.recognize_path(@app.url(:foo, :bar, :id => :fantastic)) - assert_equal [:foo_bar, { :id => "18" }], @app.recognize_path(@app.url(:foo, :bar, :id => 18)) + assert_equal [:"foo bar", { :id => "fantastic" }], @app.recognize_path(@app.url(:foo, :bar, :id => :fantastic)) + assert_equal [:"foo bar", { :id => "18" }], @app.recognize_path(@app.url(:foo, :bar, :id => 18)) assert_equal [:simple, { :id => "bar" }], @app.recognize_path(@app.url(:simple, :id => "bar")) assert_equal [:simple, { :id => "true" }], @app.recognize_path(@app.url(:simple, :id => true)) assert_equal [:simple, { :id => "9" }], @app.recognize_path(@app.url(:simple, :id => 9)) diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_support_lite.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_support_lite.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_support_lite.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-core-0.12.0/test/test_support_lite.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb deleted file mode 100644 index 0ba38600..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb +++ /dev/null @@ -1,96 +0,0 @@ -module Padrino - module Helpers - module OutputHelpers - ## - # Returns the list of all available template handlers. - # - # @example - # OutputHelpers.handlers => [, ] - # - def self.handlers - @_template_handlers ||= [] - end - - ## - # Registers a new handler as available to the output helpers. - # - # @example - # OutputHelpers.register(OutputHelpers::HamlHandler) - # - def self.register(handler) - handlers << handler - end - - # @abstract Extend this to create a template handler. - class AbstractHandler - attr_reader :template - - def initialize(template) - @template = template - end - - ## - # Returns extension of the template. - # - # @example - # @handler.template_extension => "erb" - # - def template_extension - caller.find { |c| c =~ /\/views\// }[/\.([\w]*?)\:/, 1] rescue nil - # "/some/path/app/views/posts/foo.html.erb:3:in `evaluate_source'" - # => "erb" - end - - ## - # Returns an array of engines used for the template. - # - # @example - # @handler.engines => [:erb, :erubis] - # - def engines - # Implemented in subclass. - end - - ## - # Returns true if the current template type is same as this handlers; false otherwise. - # - # @example - # @handler.is_type? => true - # - def is_type? - # Implemented in subclass. - end - - ## - # Returns true if the block given is of the handler's template type; false otherwise. - # - # @example - # @handler.block_is_type?(block) => true - # - def block_is_type?(block) - # Implemented in subclass. - end - - ## - # Captures the html from a block of template code for this handler. - # - # @example - # @handler.capture_from_template(&block) => "...html..." - # - def capture_from_template(*args, &block) - # Implemented in subclass. - end - - ## - # Outputs the given text to the templates buffer directly. - # - # @example - # @handler.concat_to_template("This will be output to the template buffer") - # - def concat_to_template(text="") - # Implemented in subclass. - end - end - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb deleted file mode 100644 index 3d073177..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb +++ /dev/null @@ -1,78 +0,0 @@ -module Padrino - module Helpers - module OutputHelpers - ## - # Handler for reading and writing from an erb template. - # - class ErbHandler < AbstractHandler - attr_reader :output_buffer - - def initialize(template) - super - @output_buffer = template.instance_variable_get(:@_out_buf) - end - - ## - # Returns true if the current template type is same as this handlers; false otherwise. - # - # @example - # @handler.is_type? => true - # - def is_type? - !self.output_buffer.nil? - end - - ## - # Captures the html from a block of template code for this handler. - # - # @example - # @handler.capture_from_template(&block) => "...html..." - # - def capture_from_template(*args, &block) - self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer - captured_block = block.call(*args) - ret = eval("@_out_buf", block.binding) - self.output_buffer = _buf_was - [ ret, captured_block ] - end - - ## - # Outputs the given text to the templates buffer directly. - # - # @example - # @handler.concat_to_template("This will be output to the template buffer") - # - def concat_to_template(text="") - self.output_buffer << text if is_type? && text - nil - end - - ## - # Returns true if the block given is of the handler's template type; false otherwise. - # - # @example - # @handler.block_is_type?(block) => true - # - def block_is_type?(block) - is_type? || (block && eval('defined?(__in_erb_template)', block.binding)) - end - - ## - # Returns an array of engines used for the template. - # - # @example - # @handler.engines => [:erb, :erubis] - # - def engines - @_engines ||= [:erb, :erubis] - end - - protected - def output_buffer=(val) - template.instance_variable_set(:@_out_buf, val) - end - end - OutputHelpers.register(ErbHandler) - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb deleted file mode 100644 index dd57fd97..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb +++ /dev/null @@ -1,63 +0,0 @@ -module Padrino - module Helpers - module OutputHelpers - ## - # Handler for reading and writing from a haml template. - # - class HamlHandler < AbstractHandler - ## - # Returns true if the current template type is same as this handlers; false otherwise. - # - # @example - # @handler.is_type? => true - # - def is_type? - template.respond_to?(:is_haml?) && template.is_haml? - end - - ## - # Returns true if the block given is of the handler's template type; false otherwise. - # - # @example - # @handler.block_is_type?(block) => true - # - def block_is_type?(block) - template.block_is_haml?(block) - end - - ## - # Captures the html from a block of template code for this handler. - # - # @example - # @handler.capture_from_template(&block) => "...html..." - # - def capture_from_template(*args, &block) - eval("_hamlout ||= @haml_buffer", block.binding) - template.capture_haml(*args, &block) - end - - ## - # Outputs the given text to the templates buffer directly. - # - # @example - # @handler.concat_to_template("This will be output to the template buffer") - # - def concat_to_template(text="") - template.haml_concat(text) - nil - end - - ## - # Returns an array of engines used for the template. - # - # @example - # @handler.engines => [:haml] - # - def engines - @_engines ||= [:haml] - end - end - OutputHelpers.register(HamlHandler) - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb deleted file mode 100644 index 3b8ab5be..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb +++ /dev/null @@ -1,78 +0,0 @@ -module Padrino - module Helpers - module OutputHelpers - ## - # Handler for reading and writing from a slim template. - # - class SlimHandler < AbstractHandler - attr_reader :output_buffer - - def initialize(template) - super - @output_buffer = template.instance_variable_get(:@_out_buf) - end - - ## - # Returns true if the current template type is same as this handlers; false otherwise. - # - # @example - # @handler.is_type? => true - # - def is_type? - !self.output_buffer.nil? - end - - ## - # Captures the html from a block of template code for this handler. - # - # @example - # @handler.capture_from_template(&block) => "...html..." - # - def capture_from_template(*args, &block) - self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer - captured_block = block.call(*args) - ret = eval("@_out_buf", block.binding) - self.output_buffer = _buf_was - [ ret, captured_block ] - end - - ## - # Outputs the given text to the templates buffer directly. - # - # @example - # @handler.concat_to_template("This will be output to the template buffer") - # - def concat_to_template(text="") - self.output_buffer << text if is_type? && text - nil - end - - ## - # Returns true if the block given is of the handler's template type; false otherwise. - # - # @example - # @handler.block_is_type?(block) => true - # - def block_is_type?(block) - is_type? || (block && eval('defined? __in_erb_template', block.binding)) - end - - ## - # Returns an array of engines used for the template. - # - # @example - # @handler.engines => [:erb, :erubis] - # - def engines - @_engines ||= [:slim] - end - - protected - def output_buffer=(val) - template.instance_variable_set(:@_out_buf, val) - end - end - OutputHelpers.register(SlimHandler) - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim deleted file mode 100644 index ca16c418..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim +++ /dev/null @@ -1 +0,0 @@ -p.slim= partial 'partials/slim', :engine => "slim" \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb deleted file mode 100644 index c7f7e123..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% form_for( :object, '/' ) do |f| %> - <%= $number_of_captures += 1 %> -<% end %> \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml deleted file mode 100644 index 26102762..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml +++ /dev/null @@ -1,2 +0,0 @@ -- form_for :object, '/' do |f| - = $number_of_captures += 1 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim deleted file mode 100644 index 26102762..00000000 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim +++ /dev/null @@ -1,2 +0,0 @@ -- form_for :object, '/' do |f| - = $number_of_captures += 1 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.document b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.document similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.document rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.document diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.gitignore b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.gitignore similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.gitignore rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.gitignore diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.yardopts b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.yardopts similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.yardopts rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/.yardopts diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/LICENSE.txt similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/LICENSE.txt rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/LICENSE.txt diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/README.rdoc b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/README.rdoc similarity index 97% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/README.rdoc rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/README.rdoc index ec68bac6..0e2049d0 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/README.rdoc +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/README.rdoc @@ -102,9 +102,9 @@ For more information on using asset helpers, check out the guide for Form helpers are the 'standard' form tag helpers you would come to expect when building forms. A simple example of constructing a non-object form would be: - - form_tag '/destroy', :class => 'destroy-form', :method => 'delete' do + = form_tag '/destroy', :class => 'destroy-form', :method => 'delete' do = flash_tag(:notice) - - field_set_tag do + = field_set_tag do %p = label_tag :username, :class => 'first' = text_field_tag :username, :value => params[:username] @@ -116,7 +116,7 @@ example of constructing a non-object form would be: = select_tag :strategy, :options => ['delete', 'destroy'], :selected => 'delete' %p = check_box_tag :confirm_delete - - field_set_tag(:class => 'buttons') do + = field_set_tag(:class => 'buttons') do = submit_tag "Remove" For more information on using form helpers, check out the guide for @@ -129,7 +129,7 @@ using a simple, intuitive syntax. A form_for using these basic fields might look like: - - form_for @user, '/register', :id => 'register' do |f| + = form_for @user, '/register', :id => 'register' do |f| = f.error_messages %p = f.label :username, :caption => "Nickname" @@ -147,7 +147,7 @@ A form_for using these basic fields might look like: = f.label :color, :caption => "Favorite Color?" = f.select :color, :options => ['red', 'black'] %p - - fields_for @user.location do |location| + = fields_for @user.location do |location| = location.text_field :street = location.text_field :city %p @@ -159,7 +159,7 @@ There is also an additional StandardFormBuilder which builds on the abstract fie A form_for using these standard fields might be: - - form_for @user, '/register', :id => 'register' do |f| + = form_for @user, '/register', :id => 'register' do |f| = f.error_messages = f.text_field_block :name, :caption => "Full name" = f.text_field_block :email diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/Rakefile b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/Rakefile similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/Rakefile rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/Rakefile diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers.rb similarity index 98% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers.rb index 2d51c6fd..0aac0e1e 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers.rb @@ -9,6 +9,7 @@ require 'active_support/inflector' # humanize FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__) I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-helpers/locale/*.yml"] +I18n.enforce_available_locales = true module Padrino ## diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/asset_tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/asset_tag_helpers.rb similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/asset_tag_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/asset_tag_helpers.rb index d7c25265..53131196 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/asset_tag_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/asset_tag_helpers.rb @@ -4,9 +4,12 @@ module Padrino # Helpers related to producing assets (images, stylesheets, js, etc) within templates. # module AssetTagHelpers - FRAGMENT_HASH = "#".html_safe.freeze APPEND_ASSET_EXTENSIONS = ["js", "css"] ABSOLUTE_URL_PATTERN = %r{^(https?://)} + ASSET_FOLDERS = { + :js => 'javascripts', + :css => 'stylesheets', + } ## # Creates a div to display the flash of given type if it exists. @@ -79,34 +82,16 @@ module Padrino options = args.extract_options! fragment = options.delete(:anchor).to_s if options[:anchor] fragment = options.delete(:fragment).to_s if options[:fragment] - - url = ActiveSupport::SafeBuffer.new - if block_given? - if args[0] - url.concat(args[0]) - url.concat(FRAGMENT_HASH).concat(fragment) if fragment - else - url.concat(FRAGMENT_HASH) - url.concat(fragment) if fragment - end - options.reverse_merge!(:href => url) - link_content = capture_html(&block) - return '' unless parse_conditions(url, options) - result_link = content_tag(:a, link_content, options) - block_is_template?(block) ? concat_content(result_link) : result_link + name = block_given? ? '' : args.shift + if url = args.first + url << '#' << fragment if fragment else - if args[1] - url.concat(args[1]) - url.safe_concat(FRAGMENT_HASH).concat(fragment) if fragment - else - url = FRAGMENT_HASH - url.concat(fragment) if fragment - end - name = args[0] - return name unless parse_conditions(url, options) - options.reverse_merge!(:href => url) - content_tag(:a, name, options) + url = '#' + url << fragment if fragment end + options.reverse_merge!(:href => url) + return name unless parse_conditions(url, options) + block_given? ? content_tag(:a, options, &block) : content_tag(:a, name, options) end ## @@ -312,9 +297,13 @@ module Padrino # # Generates: /images/example.jpg?1269008689 # asset_path :images, 'example.jpg' # - def asset_path(kind, source) + # # Generates: /uploads/file.ext?1269008689 + # asset_path 'uploads/file.ext' + # + def asset_path(kind, source = nil) + kind, source = source, kind if source.nil? source = asset_normalize_extension(kind, URI.escape(source.to_s)) - return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\// # absolute source + return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\// source = File.join(asset_folder_name(kind), source) timestamp = asset_timestamp(source) result_path = uri_root_path(source) @@ -322,6 +311,7 @@ module Padrino end private + ## # Returns the URI root of the application with optional paths appended. # @@ -353,16 +343,19 @@ module Padrino ### # Returns the asset folder given a kind. # + # Configureable by setting kind_asset_folder. + # # @example # asset_folder_name(:css) => 'stylesheets' # asset_folder_name(:js) => 'javascripts' # asset_folder_name(:images) => 'images' + # asset_folder_name(:abrakadabrah) => 'abrakadabrah' # def asset_folder_name(kind) - case kind - when :css then 'stylesheets' - when :js then 'javascripts' - else kind.to_s + if self.class.respond_to? "#{kind}_asset_folder" + self.class.send "#{kind}_asset_folder" + else + (ASSET_FOLDERS[kind] || kind).to_s end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/breadcrumb_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/breadcrumb_helpers.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/breadcrumb_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/breadcrumb_helpers.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/abstract_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_builder/abstract_form_builder.rb similarity index 90% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/abstract_form_builder.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_builder/abstract_form_builder.rb index efbf1c30..a2a2486d 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/abstract_form_builder.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_builder/abstract_form_builder.rb @@ -32,51 +32,43 @@ module Padrino end def text_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.text_field_tag field_name(field), options end def number_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.number_field_tag field_name(field), options end def telephone_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.telephone_field_tag field_name(field), options end alias_method :phone_field, :telephone_field def email_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.email_field_tag field_name(field), options end def search_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.search_field_tag field_name(field), options end def url_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.url_field_tag field_name(field), options end def text_area(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.text_area_tag field_name(field), options end def password_field(field, options={}) - options.reverse_merge!(:value => field_value(field), :id => field_id(field)) - options.merge!(:class => field_error(field, options)) + merge_default_options!(field, options) @template.password_field_tag field_name(field), options end @@ -143,13 +135,23 @@ module Padrino # f.fields_for :addresses # f.fields_for :addresses, address # f.fields_for :addresses, @addresses - def fields_for(child_association, instance_or_collection=nil, &block) + # f.fields_for :addresses, address, index: i + def fields_for(child_association, instance_or_collection=nil, options={}, &block) default_collection = self.object.send(child_association) + include_index = default_collection.respond_to?(:each) + custom_index = options.has_key?(:index) + nested_options = { :parent => self, :association => child_association } nested_objects = instance_or_collection ? Array(instance_or_collection) : Array(default_collection) nested_objects.each_with_index.map do |child_instance, index| - nested_options[:index] = include_index ? index : nil + if custom_index + nested_options[:index] = options[:index] + elsif include_index + nested_options[:index] = index + else + nested_options[:index] = nil + end @template.fields_for(child_instance, { :nested => nested_options }, &block) end.join("\n").html_safe end @@ -246,6 +248,7 @@ module Padrino # Returns the object's models name. # def object_model_name(explicit_object=object) + return @options[:as] if root_form? && @options[:as].is_a?(Symbol) explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_') end @@ -280,7 +283,8 @@ module Padrino end variants.inject(''.html_safe) do |html, variant| variant[2] = "#{field_id(field)}_#{variant[1]}" - html << @template.label_tag("#{field_name(field)}[]", :for => variant[2], :caption => "#{yield(variant)} #{variant[0]}") + caption = yield(variant) << ' ' << variant[0] + html << @template.label_tag("#{field_name(field)}[]", :for => variant[2], :caption => caption) end end @@ -311,6 +315,11 @@ module Padrino :attributes_name => "#{@options[:nested][:association]}_attributes" } end + + def merge_default_options!(field, options) + options.reverse_merge!(:value => field_value(field), :id => field_id(field)) + options.merge!(:class => field_error(field, options)) + end end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/standard_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_builder/standard_form_builder.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/standard_form_builder.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_builder/standard_form_builder.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_helpers.rb similarity index 82% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_helpers.rb index 2f39ed27..b714d22e 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/form_helpers.rb @@ -19,6 +19,8 @@ module Padrino # Also accepts HTML options. # @option settings [String] :builder ("StandardFormBuilder") # The FormBuilder class to use such as StandardFormBuilder. + # @option settings [Symbol] :as + # Sets custom form object name. # @param [Proc] block # The fields and content inside this form. # @@ -29,12 +31,14 @@ module Padrino # @example # form_for :user, '/register' do |f| ... end # form_for @user, '/register', :id => 'register' do |f| ... end + # form_for @user, '/register', :as => :customer do |f| ... end # def form_for(object, url, settings={}, &block) instance = builder_instance(object, settings) html = capture_html(instance, &block) settings[:multipart] = instance.multipart unless settings.include?(:multipart) settings.delete(:namespace) + settings.delete(:as) form_tag(url, settings) { html } end @@ -78,6 +82,7 @@ module Padrino # form_tag '/register', :class => "registration_form" do ... end # def form_tag(url, options={}, &block) + options = options.dup desired_method = options[:method].to_s options.delete(:method) unless desired_method =~ /get|post/i options.reverse_merge!(:method => 'post', @@ -90,9 +95,7 @@ module Padrino inner_form_html << csrf_token_field end inner_form_html << mark_safe(capture_html(&block)) - not_concat = options.delete(:not_concat) - form_html = content_tag(:form, inner_form_html, options) - not_concat ? form_html : concat_content(form_html) + concat_content content_tag(:form, inner_form_html, options) end ## @@ -172,50 +175,45 @@ module Padrino # def error_messages_for(*objects) options = objects.extract_options!.symbolize_keys - objects = objects.map { |object_name| - object_name.is_a?(Symbol) ? instance_variable_get("@#{object_name}") : object_name - }.compact - count = objects.inject(0) { |sum, object| sum + object.errors.count } + objects = objects.map{ |obj| resolve_object(obj) }.compact + count = objects.inject(0){ |sum, object| sum + object.errors.count } + return ''.html_safe if count.zero? - unless count.zero? - html = {} - [:id, :class, :style].each do |key| - if options.include?(key) - value = options[key] - html[key] = value unless value.blank? - else - html[key] = 'field-errors' unless key == :style - end + html_options = {} + [:id, :class, :style].each do |key| + if options.include?(key) + value = options[key] + html_options[key] = value unless value.blank? + else + html_options[key] = 'field-errors' unless key == :style + end + end + + I18n.with_options :locale => options[:locale], :scope => [:models, :errors, :template] do |locale| + object_name = options[:object_name] || objects.first.class.to_s.underscore.gsub(/\//, ' ') + + header_message = if options.include?(:header_message) + options[:header_message] + else + model_name = I18n.t(:name, :default => object_name.humanize, :scope => [:models, object_name], :count => 1) + locale.t :header, :count => count, :model => model_name end - options[:object_name] ||= objects.first.class.to_s.underscore.gsub(/\//, ' ') + body_message = options[:message] || locale.t(:body) - I18n.with_options :locale => options[:locale], :scope => [:models, :errors, :template] do |locale| - header_message = if options.include?(:header_message) - options[:header_message] - else - object_name = options[:object_name] - object_name = I18n.t(:name, :default => object_name.humanize, :scope => [:models, object_name], :count => 1) - locale.t :header, :count => count, :model => object_name + error_messages = objects.inject(''.html_safe) do |text, object| + object.errors.each do |field, message| + field_name = I18n.t(field, :default => field.to_s.humanize, :scope => [:models, object_name, :attributes]) + text << content_tag(:li, "#{field_name} #{message}") end - message = options.include?(:message) ? options[:message] : locale.t(:body) - error_messages = objects.map { |object| - object_name = options[:object_name] - object.errors.map { |f, msg| - field = I18n.t(f, :default => f.to_s.humanize, :scope => [:models, object_name, :attributes]) - content_tag(:li, "%s %s" % [field, msg]) - } - }.join - - contents = ActiveSupport::SafeBuffer.new - contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank? - contents << content_tag(:p, message) unless message.blank? - contents << safe_content_tag(:ul, error_messages) - - content_tag(:div, contents, html) + text end - else - '' + + contents = ActiveSupport::SafeBuffer.new + contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank? + contents << content_tag(:p, body_message) unless body_message.blank? + contents << content_tag(:ul, error_messages) + content_tag(:div, contents, html_options) end end @@ -251,24 +249,12 @@ module Padrino # # @api public def error_message_on(object, field, options={}) - object = object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object - error = object.errors[field] rescue nil - error = if defined?(Ohm::Model) && object.is_a?(Ohm::Model) - I18n.t("ohm.errors.messages.#{error[0]}", :default => error[0].to_s) - else - # Array(error).first is necessary because some ORMs - # give us an array others directly a value. - Array(error)[0] - end - - if error = Array(error)[0] - options.reverse_merge!(:tag => :span, :class => :error) - tag = options.delete(:tag) - error = [options.delete(:prepend), error, options.delete(:append)].compact.join(" ") - content_tag(tag, error, options) - else - '' - end + error = Array(resolve_object(object).errors[field]).first + return ''.html_safe unless error + options = options.reverse_merge(:tag => :span, :class => :error) + tag = options.delete(:tag) + error = [options.delete(:prepend), error, options.delete(:append)].compact.join(" ") + content_tag(tag, error, options) end ## @@ -290,14 +276,15 @@ module Padrino # label_tag :username, :class => 'long-label' do ... end # def label_tag(name, options={}, &block) - options.reverse_merge!(:caption => "#{name.to_s.humanize}: ", :for => name) - caption_text = options.delete(:caption).html_safe + options = options.reverse_merge(:caption => "#{name.to_s.humanize}: ", :for => name) + caption_text = ''.html_safe + caption_text.concat options.delete(:caption) caption_text.safe_concat "* " if options.delete(:required) - if block_given? # label with inner content + if block_given? label_content = caption_text.concat capture_html(&block) concat_content(content_tag(:label, label_content, options)) - else # regular label + else content_tag(:label, caption_text, options) end end @@ -360,7 +347,7 @@ module Padrino # # => # def text_field_tag(name, options={}) - input_tag(:text, options.reverse_merge!(:name => name)) + input_tag(:text, options.reverse_merge(:name => name)) end ## @@ -510,8 +497,7 @@ module Padrino # hidden_field_tag :session_key, :value => "__secret__" # def hidden_field_tag(name, options={}) - options.reverse_merge!(:name => name) - input_tag(:hidden, options) + input_tag(:hidden, options.reverse_merge(:name => name)) end ## @@ -521,7 +507,7 @@ module Padrino # text_area_tag :username, :class => 'long', :value => "Demo?" # def text_area_tag(name, options={}) - options.reverse_merge!(:name => name, :rows => "", :cols => "") + options = options.reverse_merge(:name => name, :rows => "", :cols => "") content_tag(:textarea, options.delete(:value).to_s, options) end @@ -533,8 +519,7 @@ module Padrino # # @api public def password_field_tag(name, options={}) - options.reverse_merge!(:name => name) - input_tag(:password, options) + input_tag(:password, options.reverse_merge(:name => name)) end ## @@ -544,8 +529,7 @@ module Padrino # check_box_tag :remember_me, :value => 'Yes' # def check_box_tag(name, options={}) - options.reverse_merge!(:name => name, :value => '1') - input_tag(:checkbox, options) + input_tag(:checkbox, options.reverse_merge(:name => name, :value => '1')) end ## @@ -555,8 +539,7 @@ module Padrino # radio_button_tag :remember_me, :value => 'true' # def radio_button_tag(name, options={}) - options.reverse_merge!(:name => name) - input_tag(:radio, options) + input_tag(:radio, options.reverse_merge(:name => name)) end ## @@ -568,8 +551,7 @@ module Padrino # @api public def file_field_tag(name, options={}) name = "#{name}[]" if options[:multiple] - options.reverse_merge!(:name => name) - input_tag(:file, options) + input_tag(:file, options.reverse_merge(:name => name)) end ## @@ -613,18 +595,12 @@ module Padrino # @return [String] The HTML input field based on the +options+ specified. # def select_tag(name, options={}) - options.reverse_merge!(:name => name) + options = options.reverse_merge(:name => name) + options[:name] = "#{options[:name]}[]" if options[:multiple] collection, fields = options.delete(:collection), options.delete(:fields) options[:options] = options_from_collection(collection, fields) if collection - prompt = options.delete(:include_blank) - select_options_html = if options[:options] - options_for_select(options.delete(:options), options.delete(:selected)) - elsif options[:grouped_options] - grouped_options_for_select(options.delete(:grouped_options), options.delete(:selected), prompt) - end - select_options_html = select_options_html.unshift(blank_option(prompt)) if select_options_html.is_a?(Array) - options.merge!(:name => "#{options[:name]}[]") if options[:multiple] - safe_content_tag(:select, select_options_html, options) + options_tags = extract_option_tags!(options) + content_tag(:select, options_tags, options) end ## @@ -641,8 +617,7 @@ module Padrino # button_tag "Cancel", :class => 'clear' # def button_tag(caption, options = {}) - options.reverse_merge!(:value => caption) - input_tag(:button, options) + input_tag(:button, options.reverse_merge(:value => caption)) end ## @@ -660,10 +635,9 @@ module Padrino # submit_tag :class => 'btn' # def submit_tag(*args) - options = args[-1].is_a?(Hash) ? args.pop : {} - caption = args.length >= 1 ? args.shift : "Submit" - options.reverse_merge!(:value => caption) - input_tag(:submit, options) + options = args.extract_options! + caption = args.length >= 1 ? args.first : "Submit" + input_tag(:submit, options.reverse_merge(:value => caption)) end ## @@ -677,11 +651,10 @@ module Padrino # @return [String] The html image button based on the +options+ specified. # # @example - # submit_tag "Create", :class => 'success' + # image_submit_tag 'form/submit.png' # def image_submit_tag(source, options={}) - options.reverse_merge!(:src => image_path(source)) - input_tag(:image, options) + input_tag(:image, options.reverse_merge(:src => image_path(source))) end ## @@ -747,14 +720,14 @@ module Padrino # # # def button_to(*args, &block) + options = args.extract_options!.dup name, url = args[0], args[1] - options = args.extract_options! options['data-remote'] = 'true' if options.delete(:remote) submit_options = options.delete(:submit_options) || {} if block_given? - form_tag(url, options, &block) + form_tag(url || name, options, &block) else - form_tag(url, options.merge!(:not_concat => true)) do + form_tag(url, options) do submit_tag(name, submit_options) end end @@ -780,7 +753,7 @@ module Padrino # @return [String] The html range field # def range_field_tag(name, options = {}) - options.reverse_merge!(:name => name) + options = options.reverse_merge(:name => name) if range = options.delete(:range) options[:min], options[:max] = range.min, range.max end @@ -802,39 +775,27 @@ module Padrino ## # Returns the options tags for a select based on the given option items. # - def options_for_select(option_items, selected_value=nil) + def options_for_select(option_items, state = {}) return [] if option_items.blank? - option_items.map do |caption, value, disabled| - value ||= caption - disabled ||= false - content_tag(:option, caption, :value => value, :selected => option_is_selected?(value, caption, selected_value), :disabled => disabled) + option_items.map do |caption, value, attributes| + html_attributes = { :value => value || caption }.merge(attributes||{}) + html_attributes[:selected] ||= option_is_selected?(value, caption, state[:selected]) + html_attributes[:disabled] ||= option_is_selected?(value, caption, state[:disabled]) + content_tag(:option, caption, html_attributes) end end ## # Returns the optgroups with options tags for a select based on the given :grouped_options items. # - def grouped_options_for_select(collection, selected=nil, prompt=false) - if collection.is_a?(Hash) - collection.map do |key, value| - # Hash format: - # {:first => [1,2,3], :second => [4,5,6]} - # or: - # {:first => [[1,2,3], {:disabled => true}], :second => [4,5,6]} - attributes_hash = value.last.is_a?(Hash) ? value.pop : nil - disabled ||= attributes_hash && attributes_hash.include?(:disabled) ? attributes_hash[:disabled] : false - content_tag :optgroup, options_for_select(value, selected), :label => key, :disabled => disabled - end - elsif collection.is_a?(Array) - # Array format: - # ["Option Label", [:option1, :option2, ...]] - # or: - # ["Option Label", [:option1, :option2, ...], true] - # the last item tells if it is disabled or not. This is keeps it backwards compatible. - collection.map do |optgroup| - disabled ||= optgroup.count > 2 ? optgroup.pop : false - content_tag :optgroup, options_for_select(optgroup.last, selected), :label => optgroup.first, :disabled => disabled - end + def grouped_options_for_select(collection, state = {}) + collection.map do |item| + caption = item.shift + attributes = item.last.kind_of?(Hash) ? item.pop : {} + value = item.flatten(1) + attributes = value.pop if value.last.kind_of?(Hash) + html_attributes = { :label => caption }.merge(attributes||{}) + content_tag(:optgroup, options_for_select(value, state), html_attributes) end end @@ -842,11 +803,15 @@ module Padrino # Returns the blank option serving as a prompt if passed. # def blank_option(prompt) - return unless prompt case prompt - when String then content_tag(:option, prompt, :value => '') - when Array then content_tag(:option, prompt.first, :value => prompt.last) - else content_tag(:option, '', :value => '') + when nil, false + nil + when String + content_tag(:option, prompt, :value => '') + when Array + content_tag(:option, prompt.first, :value => prompt.last) + else + content_tag(:option, '', :value => '') end end @@ -877,6 +842,7 @@ module Padrino end private + ## # Returns the FormBuilder class to use based on all available setting sources # If explicitly defined, returns that, otherwise returns defaults. @@ -914,6 +880,32 @@ module Padrino [value.to_s, caption.to_s].include?(selected.to_s) end end + + def extract_option_state!(options) + { + :selected => Array(options.delete(:selected))|Array(options.delete(:selected_options)), + :disabled => Array(options.delete(:disabled_options)) + } + end + + def extract_option_tags!(options) + state = extract_option_state!(options) + option_tags = case + when options[:options] + options_for_select(options.delete(:options), state) + when options[:grouped_options] + grouped_options_for_select(options.delete(:grouped_options), state) + else + [] + end + prompt = options.delete(:include_blank) + option_tags.unshift(blank_option(prompt)) if prompt + option_tags + end + + def resolve_object(object) + object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object + end end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/format_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/format_helpers.rb similarity index 99% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/format_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/format_helpers.rb index 534b9117..a1d3d186 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/format_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/format_helpers.rb @@ -78,7 +78,7 @@ module Padrino def simple_format(text, options={}) t = options.delete(:tag) || :p start_tag = tag(t, options, true) - text = escape_html(text.to_s.dup) + text = escape_html(text.to_s.dup) unless text.html_safe? text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n text.gsub!(/\n\n+/, "\n\n#{start_tag}") # 2+ newline -> paragraph text.gsub!(/([^\n]\n)(?=[^\n])/, '\1
') # 1 newline -> br diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/cs.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/cs.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/cs.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/cs.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/da.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/da.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/da.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/da.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/de.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/de.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/de.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/de.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/en.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/en.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/en.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/en.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/es.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/es.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/es.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/es.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/fr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/fr.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/fr.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/fr.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/hu.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/hu.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/hu.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/hu.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/it.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/it.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/it.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/it.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ja.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ja.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ja.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ja.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/lv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/lv.yml similarity index 99% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/lv.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/lv.yml index 199af0ef..9773b32d 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/lv.yml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/lv.yml @@ -15,7 +15,7 @@ lv: format: # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00). format: "%u %n" - unit: "LVL" + unit: '€' # These three are to override number.format and are optional. separator: "," delimiter: "." diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/nl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/nl.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/nl.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/nl.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/no.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/no.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/no.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/no.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/pl.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pl.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/pl.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pt_br.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/pt_br.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pt_br.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/pt_br.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ro.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ro.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ro.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ro.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ru.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ru.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ru.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/ru.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/sv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/sv.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/sv.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/sv.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/tr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/tr.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/tr.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/tr.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/uk.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/uk.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/uk.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/uk.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_cn.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/zh_cn.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_cn.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/zh_cn.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_tw.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/zh_tw.yml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_tw.yml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/locale/zh_tw.yml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/number_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/number_helpers.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/number_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/number_helpers.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers.rb similarity index 87% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers.rb index 69e8e945..91f7af5e 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers.rb @@ -8,6 +8,20 @@ module Padrino base.send(:include, SinatraCurrentEngine) unless base.method_defined?(:current_engine) end + ## + # Returns the list of all available template handlers. + # + def self.handlers + @_template_handlers ||= {} + end + + ## + # Registers a new handler as available to the output helpers. + # + def self.register(engine, handler) + handlers[engine] = handler + end + ## # Module used to detect the current engine in vanilla Sinatra apps. # @@ -45,14 +59,11 @@ module Padrino # # => "" # def capture_html(*args, &block) - handler = find_proper_handler - captured_block, captured_html = nil, "" - if handler && handler.is_type? && handler.block_is_type?(block) - captured_html, captured_block = handler.capture_from_template(*args, &block) + if handler = find_proper_handler + handler.capture_from_template(*args, &block) + else + block.call(*args) end - # invoking the block directly if there was no template - captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank? - captured_html end alias :capture :capture_html @@ -68,10 +79,9 @@ module Padrino # concat_content("This will be output to the template buffer") # def concat_content(text="") - handler = find_proper_handler - if handler && handler.is_type? + if handler = find_proper_handler handler.concat_to_template(text) - else # theres no template to concat, return the text directly + else text end end @@ -105,7 +115,7 @@ module Padrino # def block_is_template?(block) handler = find_proper_handler - block && handler && handler.block_is_type?(block) + block && handler && handler.engine_matches?(block) end ## @@ -124,7 +134,9 @@ module Padrino # content_for(:name) { |name| ...content... } # content_for(:name, "I'm Jeff") # - def content_for(key, content = nil, &block) + def content_for(key, content = nil, options = {}, &block) + options = content if content.is_a?(Hash) + content_blocks[key.to_sym].clear if options[:flush] content_blocks[key.to_sym] << (block_given? ? block : Proc.new { content }) end @@ -185,7 +197,8 @@ module Padrino # find_proper_handler => # def find_proper_handler - OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(current_engine) && h.is_type? } + handler_class = OutputHelpers.handlers[current_engine] + handler_class && handler_class.new(self) end ## diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/abstract_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/abstract_handler.rb new file mode 100644 index 00000000..e54c226d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/abstract_handler.rb @@ -0,0 +1,61 @@ +module Padrino + module Helpers + module OutputHelpers + class AbstractHandler + attr_reader :template, :output_buffer + + def initialize(template) + @template = template + @output_buffer = template.instance_variable_get(:@_out_buf) + end + + ## + # Returns true if the block given is of the handler's template type; false otherwise. + # + # @example + # @handler.engine_matches?(block) => true + # + def engine_matches?(block) + end + + ## + # Captures the html from a block of template code for this handler. + # + # This method is called to capture content of a block-loving helpers in templates. + # Haml has a special method to do this, for Erb and Slim we save original buffer, + # call the block and then restore the buffer. + # + # @example + # @handler.capture_from_template(&block) => "...html..." + # + def capture_from_template(*args, &block) + self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer + raw = block.call(*args) + captured = template.instance_variable_get(:@_out_buf) + self.output_buffer = _buf_was + engine_matches?(block) ? captured : raw + end + + ## + # Outputs the given text to the template. + # + # This method is called when template uses block-aware helpers. For Slim and Haml such + # helpers just return output to use with `=`. For Erb this method is implemented in + # ErbHandler by concatenating given text to output buffer. + # + # @example + # @handler.concat_to_template("This will be output to the template buffer") + # + def concat_to_template(text="") + text + end + + protected + + def output_buffer=(val) + template.instance_variable_set(:@_out_buf, val) + end + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb new file mode 100644 index 00000000..f394783c --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb @@ -0,0 +1,27 @@ +module Padrino + module Helpers + module OutputHelpers + ## + # Handler for Erb template. + # + class ErbHandler < AbstractHandler + ## + # Outputs the given text to the templates buffer directly. + # + def concat_to_template(text="") + output_buffer << text + nil + end + + ## + # Returns true if the block is Erb. + # + def engine_matches?(block) + block.binding.eval('defined? __in_erb_template') + end + end + OutputHelpers.register(:erb, ErbHandler) + OutputHelpers.register(:erubis, ErbHandler) + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/haml_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/haml_handler.rb new file mode 100644 index 00000000..0b37c29d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/haml_handler.rb @@ -0,0 +1,25 @@ +module Padrino + module Helpers + module OutputHelpers + ## + # Handler for Haml templates. + # + class HamlHandler < AbstractHandler + ## + # Returns true if the block is for Haml + # + def engine_matches?(block) + template.block_is_haml?(block) + end + + ## + # Captures the html from a block of template code for this handler. + # + def capture_from_template(*args, &block) + engine_matches?(block) ? template.capture_haml(*args, &block) : block.call(*args) + end + end + OutputHelpers.register(:haml, HamlHandler) + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/slim_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/slim_handler.rb new file mode 100644 index 00000000..65735cc0 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/slim_handler.rb @@ -0,0 +1,18 @@ +module Padrino + module Helpers + module OutputHelpers + ## + # Handler for Slim templates. + # + class SlimHandler < AbstractHandler + ## + # Returns true if the block is for Slim. + # + def engine_matches?(block) + block.binding.eval('defined? __in_slim_template') + end + end + OutputHelpers.register(:slim, SlimHandler) + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/render_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/render_helpers.rb similarity index 57% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/render_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/render_helpers.rb index 79ec87c4..a7ac1705 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/render_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/render_helpers.rb @@ -30,27 +30,30 @@ module Padrino # # @note If using this from Sinatra, pass explicit +:engine+ option # - def partial(template, options={}) - options.reverse_merge!(:locals => {}, :layout => false) - path = template.to_s.split(File::SEPARATOR) - object_name = path[-1].to_sym - path[-1] = "_#{path[-1]}" + def partial(template, options={}, &block) + options = options.reverse_merge(:locals => {}, :layout => false) explicit_engine = options.delete(:engine) - template_path = File.join(path).to_sym - raise 'Partial collection specified but is nil' if options.has_key?(:collection) && options[:collection].nil? - if collection = options.delete(:collection) - options.delete(:object) - counter = 0 - collection.map { |member| - counter += 1 - options[:locals].merge!(object_name => member, "#{object_name}_counter".to_sym => counter) - render(explicit_engine, template_path, options.dup) - }.join("\n").html_safe + + path,_,name = template.to_s.rpartition(File::SEPARATOR) + template_path = File.join(path,"_#{name}").to_sym + object_name = name.to_sym + + objects, counter = if options[:collection].respond_to?(:inject) + [options.delete(:collection), 0] else - if member = options.delete(:object) - options[:locals].merge!(object_name => member) + [[options.delete(:object)], nil] + end + + locals = options[:locals] + objects.inject(''.html_safe) do |html,object| + locals[object_name] = object if object + locals["#{object_name}_counter".to_sym] = counter += 1 if counter + if block_given? + output = render(explicit_engine, template_path, options){ capture_html(&block) }.html_safe + html << (block_is_template?(block) ? concat_content(output) : output) + else + html << render(explicit_engine, template_path, options).html_safe end - render(explicit_engine, template_path, options.dup).html_safe end end alias :render_partial :partial diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/tag_helpers.rb similarity index 99% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/tag_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/tag_helpers.rb index a39e1a5f..f097e87b 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/tag_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/tag_helpers.rb @@ -129,7 +129,7 @@ module Padrino if content.respond_to?(:each) && !content.is_a?(String) content.each { |c| output.concat c; output.safe_concat NEWLINE } else - output.concat content + output.concat content.to_s end output.safe_concat "" diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/translation_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/translation_helpers.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/translation_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers/translation_helpers.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/padrino-helpers.gemspec b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/padrino-helpers.gemspec similarity index 93% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/padrino-helpers.gemspec rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/padrino-helpers.gemspec index 01d1d61c..8cd0e5ad 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/padrino-helpers.gemspec +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/padrino-helpers.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.version = Padrino.version s.date = Time.now.strftime("%Y-%m-%d") + s.license = "MIT" s.extra_rdoc_files = Dir["*.rdoc"] s.files = `git ls-files`.split("\n") @@ -23,5 +24,5 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.add_dependency("padrino-core", Padrino.version) - s.add_dependency("i18n", "~> 0.6") + s.add_dependency("i18n", "~> 0.6", ">= 0.6.7") end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/app.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/app.rb similarity index 80% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/app.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/app.rb index 88c18aed..c0b1d078 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/app.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/app.rb @@ -1,22 +1,14 @@ -require 'sinatra/base' -require 'haml' -require 'erubis' -require 'slim' -require 'padrino-core/application/rendering/extensions/erubis' -require 'padrino-core/application/rendering/extensions/haml' -require 'padrino-core/application/rendering/extensions/slim' +require 'padrino-core' class MarkupDemo < Sinatra::Base register Padrino::Helpers + register Padrino::Rendering configure do set :logging, false set :padrino_logging, false set :environment, :test set :root, File.dirname(__FILE__) - set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate - set :haml, :escape_html => true - set :slim, :generator => Temple::Generators::RailsOutputBuffer, :buffer => "out_buf" set :sessions, true set :protect_from_csrf, true end @@ -50,6 +42,18 @@ class MarkupDemo < Sinatra::Base content_tag(:span, "This not a template block") end end + + def content_tag_with_block + one = content_tag(:p) do + "one" + end + two = content_tag(:p) do + "two" + end + one << two + rescue + "

failed

".html_safe + end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.haml similarity index 59% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.haml index fa189844..570db5a0 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.haml @@ -1,5 +1,5 @@ -- button_to 'Foo button', '/foo', :class => 'foo-form' do - - field_set_tag do += button_to 'Foo button', '/foo', :class => 'foo-form' do + = field_set_tag do = label_tag :username = content_tag(:p, 'button_to test', :id => 'test-point') = button_to 'Bar button', '/bar' diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/button_to.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.haml similarity index 56% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.haml index 527c0115..37e0f3dd 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.haml @@ -3,10 +3,10 @@ %span Captured Line 2 = @content -- concat_in_p('Concat Line 3') += concat_in_p('Concat Line 3') -- concat_if_block_is_template('haml') do += concat_if_block_is_template('haml') do %span This is haml %span This is haml -- concat_ruby_not_template_block += concat_ruby_not_template_block diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.slim similarity index 55% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.slim index 04186e7b..4a72b2ac 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.slim +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/capture_concat.slim @@ -3,10 +3,10 @@ span Captured Line 2 = @content -- concat_in_p('Concat Line 3') += concat_in_p('Concat Line 3') -- concat_if_block_is_template('slim') do += concat_if_block_is_template('slim') do span This is slim span This is slim -- concat_ruby_not_template_block \ No newline at end of file += concat_ruby_not_template_block diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.erb similarity index 59% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.erb index bede704d..acd3da7a 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.erb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.erb @@ -11,4 +11,13 @@
<%= yield_content :demo2, "Johnny", "Smith" %>
<%= content_for?(:demo).to_s %> -
<%= content_for?(:fake).to_s %> \ No newline at end of file +
<%= content_for?(:fake).to_s %> + +<% content_for :demo3 do %> +

One

+<% end %> +<% content_for :demo3, :flush => true do %> +

Two

+<% end %> + +
<%= yield_content :demo3 %>
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.haml similarity index 54% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.haml index 80055aa8..d3dd07c4 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.haml @@ -1,12 +1,19 @@ -- content_for :demo do += content_for :demo do %h1 This is content yielded from a content_for .demo= yield_content :demo -- content_for :demo2 do |fname, lname| += content_for :demo2 do |fname, lname| %h1 This is content yielded with name #{fname + " " + lname} .demo2= yield_content :demo2, "Johnny", "Smith" .demo_has_content= content_for?(:demo) .fake_has_content= content_for?(:fake) + += content_for :demo3 do + %p{:class => "duplication"} One += content_for :demo3, :flush => true do + %p{:class => "duplication"} Two + +.demo3= yield_content :demo3 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.slim similarity index 62% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.slim index be66c854..d7f87691 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.slim +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_for.slim @@ -9,4 +9,11 @@ .demo2= yield_content :demo2, "Johnny", "Smith" .demo_has_content= content_for?(:demo) -.fake_has_content= content_for?(:fake) \ No newline at end of file +.fake_has_content= content_for?(:fake) + +- content_for :demo3 do + p.duplication One +- content_for :demo3, :flush => true do + p.duplication Two + +.demo3= yield_content :demo3 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.erb similarity index 88% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.erb index 2771f33a..d1f1f010 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.erb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.erb @@ -9,3 +9,5 @@ <% content_tag(:p) do %> Test 4 <% end %> + +<%= content_tag_with_block %> diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.haml similarity index 54% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.haml index 780a2332..55812685 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.haml @@ -2,8 +2,10 @@ = content_tag :p, "Test 2" -- content_tag(:p, :class => 'test', :id => 'test3') do += content_tag(:p, :class => 'test', :id => 'test3') do %span Test 3 -- content_tag(:p) do += content_tag(:p) do %span Test 4 + += content_tag_with_block diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.slim similarity index 81% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.slim index 5ba06188..237e99c4 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.slim +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/content_tag.slim @@ -6,4 +6,6 @@ span Test 3 =content_tag(:p) do - span Test 4 \ No newline at end of file + span Test 4 + += content_tag_with_block diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/current_engine.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.slim similarity index 66% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.slim index 6a67d79b..9046b11c 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/fields_for.slim @@ -1,13 +1,13 @@ - @user = MarkupUser.new -- form_for @user , '/demo1', :id => 'demo-fields-for' do |f| += form_for @user , '/demo1', :id => 'demo-fields-for' do |f| = f.text_field :gender - - fields_for @user.permission do |permission| + = fields_for @user.permission do |permission| = permission.check_box :can_edit = permission.check_box :can_delete - - f.fields_for :telephone do |child_form| + = f.fields_for :telephone do |child_form| = child_form.label :number = child_form.text_field :number - - f.fields_for :addresses do |child_form| + = f.fields_for :addresses do |child_form| = child_form.label :name = child_form.text_field :name - unless child_form.object.new_record? diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.haml similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.haml index dfc71a00..59e9573c 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.haml @@ -1,4 +1,4 @@ -- form_for MarkupUser.new, '/demo', :id => 'demo' do |f| += form_for MarkupUser.new, '/demo', :id => 'demo' do |f| = f.error_messages(:header_message => "custom MarkupUser cannot be saved!") = f.hidden_field :session_id %p @@ -43,7 +43,7 @@ %p = f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button' -- form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f| += form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f| = f.error_messages :header_message => "custom MarkupUser cannot be saved!" = f.hidden_field :session_id = f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' } @@ -55,5 +55,5 @@ = f.submit_block "Create", { :class => 'button' } = f.image_submit_block "buttons/ok.png", { :class => 'image' } -- form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f| += form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f| = f.text_field_block :username diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_for.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.haml similarity index 90% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.haml index 4cf41167..b39a3131 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.haml @@ -1,6 +1,6 @@ -- form_tag '/simple', :class => 'simple-form' do += form_tag '/simple', :class => 'simple-form' do = error_messages_for nil - - field_set_tag do + = field_set_tag do = hidden_field_tag :session_id, :value => "__secret__" = label_tag :username = text_field_tag :username @@ -26,10 +26,10 @@ = check_box_tag :remember_me = submit_tag -- form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do += form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do = error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!" = hidden_field_tag :session_id, :value => "__secret__" - - field_set_tag "Advanced", :class => 'advanced-field-set' do + = field_set_tag "Advanced", :class => 'advanced-field-set' do %p = label_tag :username, :class => 'first', :caption => "Nickname" = text_field_tag :username, :value => params[:username], :id => 'the_username' @@ -69,10 +69,10 @@ %p = range_field_tag('ranger_with_min_max', :min => 1, :max => 50) = range_field_tag('ranger_with_range', :range => 1..5) - - field_set_tag(:class => 'buttons') do + = field_set_tag(:class => 'buttons') do = submit_tag "Login" = button_tag "Cancel" = image_submit_tag "buttons/submit.png" -- form_tag '/dontprotect', :class => 'no-protection', :protect_from_csrf => false do += form_tag '/dontprotect', :class => 'no-protection', :protect_from_csrf => false do = submit_tag "Login" diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/form_tag.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.haml similarity index 63% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.haml index b53277d4..ee317470 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.haml +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.haml @@ -1,4 +1,4 @@ = link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1' -- link_to("/test2", :class => 'test', :id => 'test2') do += link_to("/test2", :class => 'test', :id => 'test2') do %span Test 2 With Block diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/link_to.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/mail_to.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/meta_tag.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_erb.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_erb.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_erb.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_haml.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_haml.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_haml.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_slim.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_slim.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/partials/_slim.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.slim new file mode 100644 index 00000000..698d9a0e --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/markup_app/views/simple_partial.slim @@ -0,0 +1 @@ +p.slim= partial 'partials/slim', :engine => "slim" diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/app.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/app.rb similarity index 78% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/app.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/app.rb index bf4bc057..7dfadb45 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/app.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/app.rb @@ -1,8 +1,7 @@ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT -PADRINO_ENV = 'test' unless defined? PADRINO_ENV +RACK_ENV = 'test' unless defined? RACK_ENV require 'padrino-core' -require 'slim' class RenderUser attr_accessor :name @@ -17,9 +16,6 @@ class RenderDemo < Padrino::Application set :logging, false set :padrino_logging, false set :environment, :test - set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate - set :haml, :escape_html => true - set :slim, :generator => Temple::Generators::RailsOutputBuffer end # get current engines from partials @@ -36,6 +32,10 @@ class RenderDemo < Padrino::Application render "double_capture_#{params[:ext]}" end + get '/wrong_capture_:ext' do + render "wrong_capture_#{params[:ext]}" + end + # partial with object get '/partial/object' do partial 'template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" } @@ -55,4 +55,16 @@ class RenderDemo < Padrino::Application get '/partial/foward_slash' do partial '/template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" } end + + get '/render_block_:ext' do + render "render_block_#{params[:ext]}" do + content_tag :div, 'go block!' + end + end + + get '/partial_block_:ext' do + partial "partial_block_#{params[:ext]}" do + content_tag :div, 'go block!' + end + end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.erb new file mode 100644 index 00000000..d33d1c34 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.erb @@ -0,0 +1,3 @@ +
+<%= yield %> +
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.haml new file mode 100644 index 00000000..24303b3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.haml @@ -0,0 +1,2 @@ +.deep + = yield diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.slim new file mode 100644 index 00000000..24303b3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_deep.slim @@ -0,0 +1,2 @@ +.deep + = yield diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_erb.erb new file mode 100644 index 00000000..b155dfd4 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_erb.erb @@ -0,0 +1,10 @@ +

prefix

+
+<%= yield %> +
+
+<% partial 'deep.erb' do %> +Done +<% end %> +
+

postfix

diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_haml.haml new file mode 100644 index 00000000..49e44a1c --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_haml.haml @@ -0,0 +1,7 @@ +%h1 prefix +.haml-block + = yield +.go-deep + = partial 'deep.haml' do + Done +%h3 postfix diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_slim.slim new file mode 100644 index 00000000..34d0b50c --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/_partial_block_slim.slim @@ -0,0 +1,7 @@ +h1 prefix +.slim-block + = yield +.go-deep + = partial 'deep.slim' do + | Done +h3 postfix diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engine.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engine.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engine.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_erb.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_erb.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_erb.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_haml.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_haml.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_haml.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_slim.slim similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_slim.slim rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/current_engines/_slim.slim diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_erb.erb new file mode 100644 index 00000000..aae2849a --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_erb.erb @@ -0,0 +1,3 @@ +<% form_for( :object, '/' ) do |f| %> + <%= $number_of_captures += 1 %> +<% end %> diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_haml.haml new file mode 100644 index 00000000..28951e3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_haml.haml @@ -0,0 +1,2 @@ += form_for :object, '/' do |f| + = $number_of_captures += 1 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_slim.slim new file mode 100644 index 00000000..28951e3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/double_capture_slim.slim @@ -0,0 +1,2 @@ += form_for :object, '/' do |f| + = $number_of_captures += 1 diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/erb/test.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/erb/test.erb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/erb/test.erb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/erb/test.erb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/explicit_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/explicit_engine.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/explicit_engine.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/explicit_engine.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/haml/test.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/haml/test.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/haml/test.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/haml/test.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_erb.erb new file mode 100644 index 00000000..1417078c --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_erb.erb @@ -0,0 +1,5 @@ +

prefix

+
+<%= yield %> +
+

postfix

diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_haml.haml new file mode 100644 index 00000000..5e270fc2 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_haml.haml @@ -0,0 +1,4 @@ +%h1 prefix +.haml-block + = yield +%h3 postfix diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_slim.slim new file mode 100644 index 00000000..93509351 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/render_block_slim.slim @@ -0,0 +1,4 @@ +h1 prefix +.slim-block + = yield +h3 postfix diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/_user.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/_user.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/_user.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/_user.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/haml_template.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/haml_template.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/haml_template.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/haml_template.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/some_template.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/some_template.haml similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/some_template.haml rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/template/some_template.haml diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_erb.erb new file mode 100644 index 00000000..edcd6db3 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_erb.erb @@ -0,0 +1,3 @@ +<%= form_for( :object, '/' ) do |f| %> + <%= content_tag(:p, 'this is wrong') %> +<% end %> diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_haml.haml new file mode 100644 index 00000000..f40514d8 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_haml.haml @@ -0,0 +1,2 @@ +- form_for :object, '/' do |f| + = content_tag(:p, 'this is wrong') diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_slim.slim new file mode 100644 index 00000000..f40514d8 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/fixtures/render_app/views/wrong_capture_slim.slim @@ -0,0 +1,2 @@ +- form_for :object, '/' do |f| + = content_tag(:p, 'this is wrong') diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/helper.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/helper.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/helper.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/helper.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_asset_tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_asset_tag_helpers.rb similarity index 92% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_asset_tag_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_asset_tag_helpers.rb index afa5d678..a510a708 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_asset_tag_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_asset_tag_helpers.rb @@ -98,6 +98,16 @@ describe "AssetTagHelpers" do assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1' assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2' end + + should "not double-escape" do + actual_link = link_to('test escape', '?a=1&b=2') + assert_has_tag('a', :href => '?a=1&b=2') { actual_link } + end + + should "escape scary things" do + actual_link = link_to('test escape', '?a=1&b=') + assert_no_match(' "/js/application.js?#{time.to_i}", :type => "text/javascript") { actual_html } + end + should "display javascript item for long relative path" do time = stop_time_for_test actual_html = javascript_include_tag('example/demo/application') @@ -356,4 +374,20 @@ describe "AssetTagHelpers" do assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" } end end + + context 'for #asset_path method' do + should 'generate proper paths for js and css' do + assert_match /\/javascripts\/app.js\?\d+/, asset_path(:js, 'app') + assert_match /\/stylesheets\/app.css\?\d+/, asset_path(:css, 'app') + end + + should 'generate proper paths for images and other files' do + assert_match /\/images\/app.png\?\d+/, asset_path(:images, 'app.png') + assert_match /\/documents\/app.pdf\?\d+/, asset_path(:documents, 'app.pdf') + end + + should 'generate proper paths for public folder' do + assert_match /\/files\/file.ext\?\d+/, asset_path('files/file.ext') + end + end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_breadcrumb_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_breadcrumb_helpers.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_breadcrumb_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_breadcrumb_helpers.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_builder.rb similarity index 97% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_builder.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_builder.rb index 8a64b7f3..0f86d7ee 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_builder.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_builder.rb @@ -70,6 +70,16 @@ describe "FormBuilder" do assert_has_tag(:input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name') { actual_html } end + should "display correct form html with :as option" do + actual_html = form_for(@user, '/update', :as => :customer) do |f| + f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) } + end + + assert_has_no_tag(:form, :as => 'customer') { actual_html } + assert_has_tag(:input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name') { actual_html } + assert_has_tag(:input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name') { actual_html } + end + should "display correct form html with remote option and method put" do actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" } assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html } @@ -917,6 +927,23 @@ describe "FormBuilder" do assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html } end + should "display fields for nested forms with custom indices" do + actual_html = standard_builder.fields_for :addresses do |child_form| + html = ''.html_safe + child_form.object.businesses.each_with_index do |business, i| + html += child_form.fields_for(:businesses, business, :index => ('a'..'z').to_a[i]) do |second_child_form| + second_child_form.label(:name) + + second_child_form.text_field(:name) + + second_child_form.check_box('_destroy') + end + end + html + end + + assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_a_name', :content => 'Name') { actual_html } + assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]') { actual_html } + end + should "display nested children fields in erb" do visit '/erb/fields_for' # Telephone diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_helpers.rb similarity index 97% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_helpers.rb index c9052c61..034bc945 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_form_helpers.rb @@ -646,9 +646,9 @@ describe "FormHelpers" do should "take a range as a collection for options" do actual_html = select_tag(:favorite_color, :options => (1..3)) assert_has_tag(:select) { actual_html } - assert_has_tag('select option', :value => '1') { actual_html } - assert_has_tag('select option', :value => '2') { actual_html } - assert_has_tag('select option', :value => '3') { actual_html } + assert_has_tag('select option', :content => '1', :value => '1') { actual_html } + assert_has_tag('select option', :content => '2', :value => '2') { actual_html } + assert_has_tag('select option', :content => '3', :value => '3') { actual_html } end should "include blank for grouped options" do @@ -675,7 +675,7 @@ describe "FormHelpers" do should "display select tag with grouped options for a nested array and accept disabled groups" do opts = [ ["Friends",["Yoda",["Obiwan",2]]], - ["Enemies", ["Palpatine",['Darth Vader',3]], true] + ["Enemies", ["Palpatine",['Darth Vader',3]], {:disabled => true}] ] actual_html = select_tag( 'name', :grouped_options => opts ) assert_has_tag(:select, :name => "name") { actual_html } @@ -686,8 +686,8 @@ describe "FormHelpers" do should "display select tag with grouped options for a nested array and accept disabled groups and/or with disabled options" do opts = [ - ["Friends",["Yoda",["Obiwan",2, true]]], - ["Enemies", [["Palpatine", "Palpatine", true],['Darth Vader',3]], true] + ["Friends",["Yoda",["Obiwan",2, {:disabled => true}]]], + ["Enemies", [["Palpatine", "Palpatine", {:disabled => true}],['Darth Vader',3]], {:disabled => true}] ] actual_html = select_tag( 'name', :grouped_options => opts ) assert_has_tag(:select, :name => "name") { actual_html } @@ -713,22 +713,10 @@ describe "FormHelpers" do assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html } end - should "display select tag with grouped options for a hash and accept disabled groups" do - opts = { - "Friends" => ["Yoda",["Obiwan",2]], - "Enemies" => ["Palpatine",['Darth Vader',3], {:disabled => true}] - } - actual_html = select_tag( 'name', :grouped_options => opts ) - assert_has_tag(:select, :name => "name") { actual_html } - assert_has_tag(:option, :disabled => 'disabled', :count => 0) { actual_html } - assert_has_tag(:optgroup, :disabled => 'disabled', :count => 1) { actual_html } - assert_has_tag(:optgroup, :label => "Enemies", :disabled => 'disabled') { actual_html } - end - should "display select tag with grouped options for a hash and accept disabled groups and/or with disabled options" do opts = { - "Friends" => ["Yoda",["Obiwan",2,true]], - "Enemies" => [["Palpatine","Palpatine",true],["Darth Vader",3], {:disabled => true}] + "Friends" => ["Yoda",["Obiwan",2,{:disabled => true}]], + "Enemies" => [["Palpatine","Palpatine",{:disabled => true}],["Darth Vader",3], {:disabled => true}] } actual_html = select_tag( 'name', :grouped_options => opts ) assert_has_tag(:select, :name => "name") { actual_html } @@ -739,6 +727,18 @@ describe "FormHelpers" do assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled') { actual_html } end + should "display select tag with grouped options for a rails-style attribute hash" do + opts = { + "Friends" => ["Yoda",["Obiwan",2,{:magister=>'no'}],{:lame=>'yes'}], + "Enemies" => [["Palpatine","Palpatine",{:scary=>'yes',:old=>'yes'}],["Darth Vader",3,{:disabled=>true}]] + } + actual_html = select_tag( 'name', :grouped_options => opts, :disabled_options => [2], :selected => ['Yoda'] ) + assert_has_tag(:optgroup, :label => "Friends", :lame => 'yes') { actual_html } + assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :scary => 'yes', :old => 'yes') { actual_html } + assert_has_tag(:option, :content => "Darth Vader", :disabled => 'disabled') { actual_html } + assert_has_tag(:option, :content => "Obiwan", :disabled => 'disabled') { actual_html } + assert_has_tag(:option, :content => "Yoda", :selected => 'selected') { actual_html } + end should "display select tag in ruby with multiple attribute" do actual_html = select_tag(:favorite_color, :multiple => true, :options => ['only', 'option']) @@ -756,7 +756,7 @@ describe "FormHelpers" do end should "display options with values and accept disabled options" do - options = [['Green', 'green1', true], ['Blue', 'blue1'], ['Black', "black1"]] + options = [['Green', 'green1', {:disabled => true}], ['Blue', 'blue1'], ['Black', "black1"]] actual_html = select_tag(:favorite_color, :options => options) assert_has_tag(:select, :name => 'favorite_color') { actual_html } assert_has_tag('select option', :disabled => 'disabled', :count => 1) { actual_html } diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_format_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_format_helpers.rb similarity index 96% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_format_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_format_helpers.rb index 52108099..85982c3e 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_format_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_format_helpers.rb @@ -29,6 +29,16 @@ describe "FormatHelpers" do assert_equal "

Look me! A class!

", actual_text end + should "escape html tags" do + actual_text = simple_format("Will you escape that?") + assert_equal "

Will you escape <b>that</b>?

", actual_text + end + + should "support already sanitized text" do + actual_text = simple_format("Don't try to escape me!".html_safe) + assert_equal "

Don't try to escape me!

", actual_text + end + context 'wrapped in a custom tag' do should "format simple text into html format" do actual_text = simple_format("Here is some basic text...\n...with a line break.", :tag => :div) diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_locale.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_locale.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_locale.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_locale.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_number_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_number_helpers.rb similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_number_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_number_helpers.rb diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_output_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_output_helpers.rb similarity index 77% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_output_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_output_helpers.rb index 2140bec2..d8bcaf4c 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_output_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_output_helpers.rb @@ -9,20 +9,26 @@ describe "OutputHelpers" do context 'for #content_for method' do should 'work for erb templates' do visit '/erb/content_for' - assert_have_selector '.demo h1', :content => "This is content yielded from a content_for" - assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith" + assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1 + assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1 + assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication" + assert_have_selector '.demo3 p', :content => "Two", :class => "duplication" end should "work for haml templates" do visit '/haml/content_for' - assert_have_selector '.demo h1', :content => "This is content yielded from a content_for" - assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith" + assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1 + assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1 + assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication" + assert_have_selector '.demo3 p', :content => "Two", :class => "duplication" end should "work for slim templates" do visit '/slim/content_for' - assert_have_selector '.demo h1', :content => "This is content yielded from a content_for" - assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith" + assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1 + assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1 + assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication" + assert_have_selector '.demo3 p', :content => "Two", :class => "duplication" end end # content_for @@ -49,20 +55,20 @@ describe "OutputHelpers" do context 'for #capture_html method' do should "work for erb templates" do visit '/erb/capture_concat' - assert_have_selector 'p span', :content => "Captured Line 1" - assert_have_selector 'p span', :content => "Captured Line 2" + assert_have_selector 'p span', :content => "Captured Line 1", :count => 1 + assert_have_selector 'p span', :content => "Captured Line 2", :count => 1 end should "work for haml templates" do visit '/haml/capture_concat' - assert_have_selector 'p span', :content => "Captured Line 1" - assert_have_selector 'p span', :content => "Captured Line 2" + assert_have_selector 'p span', :content => "Captured Line 1", :count => 1 + assert_have_selector 'p span', :content => "Captured Line 2", :count => 1 end should "work for slim templates" do visit '/slim/capture_concat' - assert_have_selector 'p span', :content => "Captured Line 1" - assert_have_selector 'p span', :content => "Captured Line 2" + assert_have_selector 'p span', :content => "Captured Line 1", :count => 1 + assert_have_selector 'p span', :content => "Captured Line 2", :count => 1 end end @@ -79,30 +85,27 @@ describe "OutputHelpers" do should "work for slim templates" do visit '/slim/capture_concat' - # TODO Get Slim concat working - # assert_have_selector 'p', :content => "Concat Line 3", :count => 1 + assert_have_selector 'p', :content => "Concat Line 3", :count => 1 end end context 'for #block_is_template?' do should "work for erb templates" do visit '/erb/capture_concat' - assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template' - # TODO Get ERB template detection working (fix block_is_erb? method) - # assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template' + assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1 + assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1 end should "work for haml templates" do visit '/haml/capture_concat' - assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template' - assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template' + assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1 + assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1 end should "work for slim templates" do visit '/slim/capture_concat' - # TODO Get Slim template detection working - # assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template' - assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template' + assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1 + assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1 end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_render_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_render_helpers.rb similarity index 58% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_render_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_render_helpers.rb index c4dffb5a..b03e7d4f 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_render_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_render_helpers.rb @@ -54,6 +54,57 @@ describe "RenderHelpers" do end end + context 'render with block' do + should 'render slim with block' do + visit '/render_block_slim' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.slim-block' + assert_have_selector 'div', :content => 'go block!' + end + should 'render erb with block' do + visit '/render_block_erb' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.erb-block' + assert_have_selector 'div', :content => 'go block!' + end + should 'render haml with block' do + visit '/render_block_haml' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.haml-block' + assert_have_selector 'div', :content => 'go block!' + end + end + + context 'partial with block' do + should 'show partial slim with block' do + visit '/partial_block_slim' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.slim-block' + assert_have_selector 'div', :content => 'go block!' + assert_have_selector 'div.deep', :content => 'Done' + end + should 'show partial erb with block' do + visit '/partial_block_erb' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.erb-block' + assert_have_selector 'div', :content => 'go block!' + assert_have_selector 'div.deep', :content => 'Done' + end + should 'show partial haml with block' do + visit '/partial_block_haml' + assert_have_selector 'h1', :content => 'prefix' + assert_have_selector 'h3', :content => 'postfix' + assert_have_selector '.haml-block' + assert_have_selector 'div', :content => 'go block!' + assert_have_selector 'div.deep', :content => 'Done' + end + end + context 'for #current_engine method' do should 'detect correctly current engine for a padrino application' do visit '/current_engine' @@ -90,5 +141,21 @@ describe "RenderHelpers" do visit '/double_capture_erb' assert_equal 1,$number_of_captures end + + should "fail on wrong erb usage" do + assert_raises(SyntaxError) do + visit '/wrong_capture_erb' + end + end + + should "ignore wrong haml usage" do + visit '/wrong_capture_haml' + assert_have_no_selector 'p', :content => 'this is wrong' + end + + should "ignore wrong slim usage" do + visit '/wrong_capture_slim' + assert_have_no_selector 'p', :content => 'this is wrong' + end end end diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_tag_helpers.rb similarity index 87% rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_tag_helpers.rb rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_tag_helpers.rb index 1bec5fb0..6f3f8a48 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_tag_helpers.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.12.0/test/test_tag_helpers.rb @@ -64,12 +64,20 @@ describe "TagHelpers" do assert_has_tag('p.large#star', :content => "<>") { actual_html } end + should "convert to a string if the content is not a string" do + actual_html = content_tag(:p, 97) + assert_has_tag('p', :content => "97") { actual_html } + end + should "support tags with erb" do visit '/erb/content_tag' assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1' assert_have_selector :p, :content => "Test 2" assert_have_selector :p, :content => "Test 3" assert_have_selector :p, :content => "Test 4" + assert_have_selector :p, :content => "one" + assert_have_selector :p, :content => "two" + assert_have_no_selector :p, :content => "failed" end should "support tags with haml" do @@ -78,6 +86,9 @@ describe "TagHelpers" do assert_have_selector :p, :content => "Test 2" assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3' assert_have_selector :p, :content => "Test 4" + assert_have_selector :p, :content => "one" + assert_have_selector :p, :content => "two" + assert_have_no_selector :p, :content => "failed" end should "support tags with slim" do @@ -86,6 +97,9 @@ describe "TagHelpers" do assert_have_selector :p, :content => "Test 2" assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3' assert_have_selector :p, :content => "Test 4" + assert_have_selector :p, :content => "one" + assert_have_selector :p, :content => "two" + assert_have_no_selector :p, :content => "failed" end end diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 1d98baa6..2729e790 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |s| s.add_dependency("bundler", ["~> 1.1"]) s.add_dependency("rack", [">= 1.4.5"]) s.add_dependency("tilt", ["~> 1.4.1"]) + s.add_dependency("erubis") s.add_dependency("hooks", ["~> 0.3"]) # Builder From ca50f21fac11da871dc7fda2ee9ffc4c184afa62 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Wed, 19 Feb 2014 23:13:59 -0800 Subject: [PATCH 11/12] "middleman init" will create a project in the current directory. Fixes #1181. --- middleman-core/features/cli_init.feature | 26 +++++++++++++------ middleman-core/lib/middleman-core/cli/init.rb | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/middleman-core/features/cli_init.feature b/middleman-core/features/cli_init.feature index fc84cc08..d6d5b4b4 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-core/features/cli_init.feature @@ -15,19 +15,29 @@ Feature: Middleman CLI | source/javascripts/all.js | | source/stylesheets/all.css | | source/stylesheets/normalize.css | - + + Scenario: Create a new project in the current directory + Given a directory named "MY_PROJECT" + When I cd to "MY_PROJECT" + And I run `middleman init` + Then the exit status should be 0 + And the following files should exist: + | Gemfile | + | config.rb | + | source/index.html.erb | + Scenario: Create a new project (alias i) When I run `middleman i MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project (alias new) When I run `middleman new MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project (alias n) When I run `middleman n MY_PROJECT` Then a directory named "MY_PROJECT" should exist - + Scenario: Create a new project with Rack When I run `middleman init MY_PROJECT --rack` Then a directory named "MY_PROJECT" should exist @@ -36,7 +46,7 @@ Feature: Middleman CLI | config.rb | | config.ru | | Gemfile | - + Scenario: Create a new HTML5 project When I run `middleman init MY_PROJECT --template=html5` Then a directory named "MY_PROJECT" should exist @@ -54,7 +64,7 @@ Feature: Middleman CLI | layouts/layout.erb | | humans.txt | | js/main.js | - + Scenario: Create a new HTML5 project with Rack When I run `middleman init MY_PROJECT --rack --template=html5` Then a directory named "MY_PROJECT" should exist @@ -63,7 +73,7 @@ Feature: Middleman CLI | config.rb | | config.ru | | Gemfile | - + Scenario: Create a new Mobile HTML5 project When I run `middleman init MY_PROJECT --template=mobile` Then a directory named "MY_PROJECT" should exist @@ -79,7 +89,7 @@ Feature: Middleman CLI | index.html | | humans.txt | | js/libs/respond.min.js | - + Scenario: Create a new Mobile HTML5 project with Rack When I run `middleman init MY_PROJECT --rack --template=mobile` Then a directory named "MY_PROJECT" should exist diff --git a/middleman-core/lib/middleman-core/cli/init.rb b/middleman-core/lib/middleman-core/cli/init.rb index 6f61a080..c96e29b4 100644 --- a/middleman-core/lib/middleman-core/cli/init.rb +++ b/middleman-core/lib/middleman-core/cli/init.rb @@ -43,7 +43,7 @@ module Middleman::Cli :desc => 'Skip Git ignores and keeps' # The init task # @param [String] name - def init(name) + def init(name = '.') key = options[:template].to_sym unless ::Middleman::Templates.registered.has_key?(key) raise Thor::Error.new "Unknown project template '#{key}'" From 477f87e98a6b19775697c0a25090795a74e591ff Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 20 Feb 2014 00:32:38 -0800 Subject: [PATCH 12/12] Prefer loading layouts from `layouts_dir` over layouts with the same name in the source root. This also includes a bunch of refactoring/cleanup of rendering.rb. Fixes #1176. --- middleman-core/features/layouts_dir.feature | 8 ++ .../layouts-dir-app/source/ambiguous.html.erb | 5 + .../layouts-dir-app/source/layouts/other.erb | 3 + .../fixtures/layouts-dir-app/source/other.erb | 3 + .../core_extensions/rendering.rb | 106 +++++++----------- 5 files changed, 59 insertions(+), 66 deletions(-) create mode 100644 middleman-core/fixtures/layouts-dir-app/source/ambiguous.html.erb create mode 100644 middleman-core/fixtures/layouts-dir-app/source/layouts/other.erb create mode 100644 middleman-core/fixtures/layouts-dir-app/source/other.erb diff --git a/middleman-core/features/layouts_dir.feature b/middleman-core/features/layouts_dir.feature index 5d31d4f5..3a5b6b00 100644 --- a/middleman-core/features/layouts_dir.feature +++ b/middleman-core/features/layouts_dir.feature @@ -28,3 +28,11 @@ Feature: Layouts dir When I go to "/index.html" Then I should see "contents of the layout" + Scenario: Prefer a layout in the layouts_dir to one with the same name in the root + Given a fixture app "layouts-dir-app" + And a file named "config.rb" with: + """ + """ + And the Server is running + When I go to "/ambiguous.html" + Then I should see "contents of the layout in layouts_dir" diff --git a/middleman-core/fixtures/layouts-dir-app/source/ambiguous.html.erb b/middleman-core/fixtures/layouts-dir-app/source/ambiguous.html.erb new file mode 100644 index 00000000..77a651ff --- /dev/null +++ b/middleman-core/fixtures/layouts-dir-app/source/ambiguous.html.erb @@ -0,0 +1,5 @@ +--- +layout: other +--- + +Hello diff --git a/middleman-core/fixtures/layouts-dir-app/source/layouts/other.erb b/middleman-core/fixtures/layouts-dir-app/source/layouts/other.erb new file mode 100644 index 00000000..f8471491 --- /dev/null +++ b/middleman-core/fixtures/layouts-dir-app/source/layouts/other.erb @@ -0,0 +1,3 @@ +contents of the layout in layouts_dir + +<%= yield %> \ No newline at end of file diff --git a/middleman-core/fixtures/layouts-dir-app/source/other.erb b/middleman-core/fixtures/layouts-dir-app/source/other.erb new file mode 100644 index 00000000..6a74c4a8 --- /dev/null +++ b/middleman-core/fixtures/layouts-dir-app/source/other.erb @@ -0,0 +1,3 @@ +contents of the layout in the root + +<%= yield %> \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index e326d2e1..4698ee2b 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -157,7 +157,7 @@ module Middleman content = render_individual_file(path, locs, opts, context) path = File.basename(path, File.extname(path)) rescue LocalJumpError - raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{layout_dir}." + raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{config[:layouts_dir]}." end end @@ -190,42 +190,29 @@ module Middleman locals = options[:locals] found_partial = false - engine = nil + resolve_opts = { try_without_underscore: true } # If the path is known to the sitemap if resource = sitemap.find_resource_by_path(current_path) current_dir = File.dirname(resource.source_file) - engine = File.extname(resource.source_file)[1..-1].to_sym + resolve_opts[:preferred_engine] = File.extname(resource.source_file)[1..-1].to_sym # Look for partials relative to the current path relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data) - # Try to use the current engine first - found_partial, found_engine = resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true) - - # Fall back to any engine available - if !found_partial - found_partial, found_engine = resolve_template(relative_dir, :try_without_underscore => true) - end + found_partial = resolve_template(relative_dir, resolve_opts) end # Look in the partials_dir for the partial with the current engine - partials_path = File.join(config[:partials_dir], data) - if !found_partial && !engine.nil? - found_partial, found_engine = resolve_template(partials_path, :preferred_engine => engine, :try_without_underscore => true) + if !found_partial + partials_path = File.join(config[:partials_dir], data) + found_partial = resolve_template(partials_path, resolve_opts) end - # Look in the root with any engine - if !found_partial - found_partial, found_engine = resolve_template(partials_path, :try_without_underscore => true) - end + raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate partial: #{data}" unless found_partial # Render the partial if found, otherwide throw exception - if found_partial - render_individual_file(found_partial, locals, options, self, &block) - else - raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate partial: #{data}" - end + render_individual_file(found_partial, locals, options, self, &block) end # Render an on-disk file. Used for everything, including layouts. @@ -370,26 +357,14 @@ module Middleman # Whether we've found the layout layout_path = false - # If we prefer a specific engine - if !preferred_engine.nil? - # Check root - layout_path, layout_engine = resolve_template(name, :preferred_engine => preferred_engine) + resolve_opts = {} + resolve_opts[:preferred_engine] = preferred_engine if !preferred_engine.nil? - # Check layouts folder - if !layout_path - layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s), :preferred_engine => preferred_engine) - end - end + # Check layouts folder + layout_path = resolve_template(File.join(config[:layouts_dir], name.to_s), resolve_opts) - # Check root, no preference - if !layout_path - layout_path, layout_engine = resolve_template(name) - end - - # Check layouts folder, no preference - if !layout_path - layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s)) - end + # If we didn't find it, check root + layout_path = resolve_template(name, resolve_opts) unless layout_path # Return the path layout_path @@ -440,7 +415,8 @@ module Middleman # Find a template on disk given a output path # @param [String] request_path - # @param [Hash] options + # @option options [Boolean] :preferred_engine If set, try this engine first, then fall back to any engine. + # @option options [Boolean] :try_without_underscore # @return [Array, Boolean] def resolve_template(request_path, options={}) # Find the path by searching or using the cache @@ -450,48 +426,46 @@ module Middleman on_disk_path = File.expand_path(relative_path, self.source_dir) # By default, any engine will do - preferred_engine = '*' + preferred_engines = ['*'] - # Unless we're specifically looking for a preferred engine + # If we're specifically looking for a preferred engine if options.has_key?(:preferred_engine) extension_class = ::Tilt[options[:preferred_engine]] matched_exts = [] # Get a list of extensions for a preferred engine - # TODO: Cache this - ::Tilt.mappings.each do |ext, engines| - next unless engines.include? extension_class - matched_exts << ext - end + matched_exts = ::Tilt.mappings.select do |ext, engines| + engines.include? extension_class + end.keys - # Change the glob to only look for the matched extensions - if matched_exts.length > 0 - preferred_engine = '{' + matched_exts.join(',') + '}' - else - return false + # Prefer to look for the matched extensions + unless matched_exts.empty? + preferred_engines.unshift('{' + matched_exts.join(',') + '}') end end - # Look for files that match - path_with_ext = on_disk_path + '.' + preferred_engine - - found_path = Dir[path_with_ext].find do |path| - ::Tilt[path] + search_paths = preferred_engines.flat_map do |preferred_engine| + path_with_ext = on_disk_path + '.' + preferred_engine + paths = [path_with_ext] + if options[:try_without_underscore] + paths << path_with_ext.sub(relative_path, relative_path.sub(/^_/, '').sub(/\/_/, '/')) + end + paths end - if !found_path && options[:try_without_underscore] && - path_no_underscore = path_with_ext. - sub(relative_path, relative_path.sub(/^_/, ''). - sub(/\/_/, '/')) - found_path = Dir[path_no_underscore].find do |path| + found_path = nil + search_paths.each do |path_with_ext| + found_path = Dir[path_with_ext].find do |path| ::Tilt[path] end + break if found_path end # If we found one, return it and the found engine - if found_path || files.exists?(on_disk_path) - engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil - [ found_path || on_disk_path, engine ] + if found_path + found_path + elsif File.exists?(on_disk_path) + on_disk_path else false end