From 617f73c8dbdf75373dc64700b601e8a161dd6f11 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 4 Mar 2012 17:20:57 -0800 Subject: [PATCH 1/2] Fix Padrino helpers that require an i18n locale to be present --- .../features/former_padrino_helpers.feature | 8 +++++--- .../source/former_padrino_test.html.erb | 3 ++- .../core_extensions/default_helpers.rb | 18 +++++------------- .../lib/padrino-helpers.rb | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/middleman-core/features/former_padrino_helpers.feature b/middleman-core/features/former_padrino_helpers.feature index 66f790b0..6665331b 100644 --- a/middleman-core/features/former_padrino_helpers.feature +++ b/middleman-core/features/former_padrino_helpers.feature @@ -1,10 +1,12 @@ Feature: Built-in macro view helpers In order to simplify generating HTML - Scenario: Using the link_to helper + Scenario: Using the padrino helpers Given the Server is running at "padrino-helpers-app" When I go to "/former_padrino_test.html" And I should see 'href="test2.com"' And I should see 'src="/images/test2.png"' - Then I should see 'src="/javascripts/test1.js"' - Then I should see 'href="/stylesheets/test1.css"' \ No newline at end of file + And I should see 'src="/javascripts/test1.js"' + And I should see 'href="/stylesheets/test1.css"' + And I should see '1 KB' + \ No newline at end of file diff --git a/middleman-core/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb b/middleman-core/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb index f83a33bb..63f069a6 100644 --- a/middleman-core/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb +++ b/middleman-core/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb @@ -1,4 +1,5 @@ <%= stylesheet_link_tag "test1" %> <%= javascript_include_tag "test1" %> <%= image_tag "test2.png", :alt => "alt" %> -<%= link_to "Has param", "test2.com", :class => "test" %> \ No newline at end of file +<%= link_to "Has param", "test2.com", :class => "test" %> +<%= number_to_human_size(1024) %> diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index 2a7df53a..f6982ca5 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -1,13 +1,4 @@ -require "middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite" -# require 'i18n' -require 'enumerator' -# require 'active_support/core_ext/string/conversions' # to_date -require 'active_support/core_ext/float/rounding' # round -require 'active_support/option_merger' # with_options -require 'active_support/core_ext/object/with_options' # with_options -# require 'active_support/inflector' # humanize - -FileSet.glob_require('../vendor/padrino-helpers-0.10.5/lib/padrino-helpers/**/*.rb', __FILE__) +require 'middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers' # Built-in helpers module Middleman::CoreExtensions::DefaultHelpers @@ -27,9 +18,10 @@ module Middleman::CoreExtensions::DefaultHelpers app.helpers Helpers - # app.ready do - # ::I18n.load_path = Dir["#{File.join(root, 'locales', '*.yml')}"] - # end + app.ready do + ::I18n.load_path += Dir["#{File.join(root, 'locales','*.yml')}"] + ::I18n.load_path += Dir["#{File.dirname(__FILE__)}/../vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/*.yml"] + end end alias :included :registered end diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb index 751230ef..f8c1a358 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb @@ -1,4 +1,4 @@ -require 'padrino-core/support_lite' unless defined?(SupportLite) +require 'middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite' unless defined?(SupportLite) require 'cgi' # require 'i18n' require 'enumerator' From e7df250c4d2313e8a31544ae5165f7324fbfcb45 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 8 Mar 2012 23:05:59 -0800 Subject: [PATCH 2/2] Include "i18n" gem in middleman-core gemspec --- middleman-core/middleman-core.gemspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 3e06280d..dae237f7 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -36,5 +36,8 @@ Gem::Specification.new do |s| # Web Server s.add_dependency("thin", ["~> 1.3.1"]) + + # i18n, needed for Padrino helpers + s.add_dependency("i18n", ["~> 0.6.0"]) end