mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
tinysrc feature (unfinished)
This commit is contained in:
parent
ab16d6f2e6
commit
16ffd59ef9
5 changed files with 28 additions and 0 deletions
|
@ -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
12
features/tiny_src.feature
Normal 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"
|
1
fixtures/test-app/views/tiny_src.html.haml
Normal file
1
fixtures/test-app/views/tiny_src.html.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= image_tag "http://test.com/image.jpg"
|
|
@ -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"
|
||||||
|
|
11
lib/middleman/features/tiny_src.rb
Normal file
11
lib/middleman/features/tiny_src.rb
Normal 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
|
Loading…
Reference in a new issue