diff --git a/features/step_definitions/middleman_steps.rb b/features/step_definitions/middleman_steps.rb index 0fcc9096..cb793bef 100644 --- a/features/step_definitions/middleman_steps.rb +++ b/features/step_definitions/middleman_steps.rb @@ -16,6 +16,7 @@ end Then /^I should see "([^\"]*)"$/ do |expected| @browser.last_response.body.should include(expected) end + Then /^I should see '([^\']*)'$/ do |expected| @browser.last_response.body.should include(expected) end diff --git a/features/tiny_src.feature b/features/tiny_src.feature new file mode 100644 index 00000000..f6babc98 --- /dev/null +++ b/features/tiny_src.feature @@ -0,0 +1,12 @@ +Feature: Tiny Src + In order automatically scale images for mobile devices + + Scenario: Rendering html with the feature disabled + Given "tiny_src" feature is "disabled" + When I go to "/tiny_src.html" + Then I should see "http://test.com/image.jpg" + + Scenario: Rendering html with the feature enabled + Given "tiny_src" feature is "enabled" + When I go to "/tiny_src.html" + Then I should see "http://i.tinysrc.mobi/http://test.com/image.jpg" \ No newline at end of file diff --git a/fixtures/test-app/views/tiny_src.html.haml b/fixtures/test-app/views/tiny_src.html.haml new file mode 100644 index 00000000..94a61171 --- /dev/null +++ b/fixtures/test-app/views/tiny_src.html.haml @@ -0,0 +1 @@ += image_tag "http://test.com/image.jpg" \ No newline at end of file diff --git a/lib/middleman/features.rb b/lib/middleman/features.rb index 10c0d05b..23a3d42f 100644 --- a/lib/middleman/features.rb +++ b/lib/middleman/features.rb @@ -71,6 +71,9 @@ module Middleman::Features # to dynamic requests. autoload :Data, "middleman/features/data" + # Automatically resize images for mobile devises + # autoload :TinySrc, "middleman/features/tiny_src" + # LiveReload will auto-reload browsers with the live reload extension installed after changes # Currently disabled and untested. #autoload :LiveReload, "middleman/features/live_reload" diff --git a/lib/middleman/features/tiny_src.rb b/lib/middleman/features/tiny_src.rb new file mode 100644 index 00000000..6665f506 --- /dev/null +++ b/lib/middleman/features/tiny_src.rb @@ -0,0 +1,11 @@ +module Middleman::Features::TinySrc + class << self + def registered(app) + Middleman::Assets.register :tiny_src do |path, prefix, request| + original_output = Middleman::Assets.before(:tiny_src, path, prefix, request) + "http://i.tinysrc.mobi/#{original_output}" + end + end + alias :included :registered + end +end \ No newline at end of file