tinysrc feature (unfinished)

This commit is contained in:
Thomas Reynolds 2011-04-25 13:45:54 -07:00
parent ab16d6f2e6
commit 16ffd59ef9
5 changed files with 28 additions and 0 deletions

View file

@ -16,6 +16,7 @@ end
Then /^I should see "([^\"]*)"$/ do |expected| Then /^I should see "([^\"]*)"$/ do |expected|
@browser.last_response.body.should include(expected) @browser.last_response.body.should include(expected)
end end
Then /^I should see '([^\']*)'$/ do |expected| Then /^I should see '([^\']*)'$/ do |expected|
@browser.last_response.body.should include(expected) @browser.last_response.body.should include(expected)
end end

12
features/tiny_src.feature Normal file
View file

@ -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"

View file

@ -0,0 +1 @@
= image_tag "http://test.com/image.jpg"

View file

@ -71,6 +71,9 @@ module Middleman::Features
# to dynamic requests. # to dynamic requests.
autoload :Data, "middleman/features/data" 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 # LiveReload will auto-reload browsers with the live reload extension installed after changes
# Currently disabled and untested. # Currently disabled and untested.
#autoload :LiveReload, "middleman/features/live_reload" #autoload :LiveReload, "middleman/features/live_reload"

View file

@ -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