Merge remote branch 'upstream/master'

This commit is contained in:
Matthias Döring 2011-06-24 20:56:11 +02:00
commit 5a467d4258
15 changed files with 98 additions and 27 deletions

3
.gitignore vendored
View file

@ -8,4 +8,5 @@ pkg
Gemfile.lock
docs
.rvmrc
fixtures/test-app/build
fixtures/test-app/build
.*.swp

View file

@ -0,0 +1,27 @@
Feature: Built-in auto_javascript_include_tag view helper
In order to simplify including javascript files
Scenario: Viewing the root path
Given the Server is running
When I go to "/auto-js.html"
Then I should see "javascripts/auto-js.js"
Scenario: Viewing a tier-1 path
Given the Server is running
When I go to "/auto-js/auto-js.html"
Then I should see "javascripts/auto-js/auto-js.js"
Scenario: Viewing the index file of a tier-1 path, without filename
Given the Server is running
When I go to "/auto-js"
Then I should see "javascripts/auto-js/index.js"
Scenario: Viewing the index file of a tier-1 path, without filename, with a trailing slash
Given the Server is running
When I go to "/auto-js/"
Then I should see "javascripts/auto-js/index.js"
Scenario: Viewing a tier-2 path
Given the Server is running
When I go to "/auto-js/sub/auto-js.html"
Then I should see "javascripts/auto-js/sub/auto-js.js"

View file

@ -8,10 +8,20 @@ Feature: Built-in auto_stylesheet_link_tag view helper
Scenario: Viewing a tier-1 path
Given the Server is running
When I go to "/sub1/auto-css.html"
Then I should see "stylesheets/sub1/auto-css.css"
When I go to "/auto-css/auto-css.html"
Then I should see "stylesheets/auto-css/auto-css.css"
Scenario: Viewing the index file of a tier-1 path, without filename
Given the Server is running
When I go to "/auto-css"
Then I should see "stylesheets/auto-css/index.css"
Scenario: Viewing the index file of a tier-1 path, without filename, with a trailing slash
Given the Server is running
When I go to "/auto-css/"
Then I should see "stylesheets/auto-css/index.css"
Scenario: Viewing a tier-2 path
Given the Server is running
When I go to "/sub1/sub2/auto-css.html"
Then I should see "stylesheets/sub1/sub2/auto-css.css"
When I go to "/auto-css/sub/auto-css.html"
Then I should see "stylesheets/auto-css/sub/auto-css.css"

View file

@ -17,14 +17,27 @@ get "/sub1/sub2/page-class.html" do
haml :"page-classes.html", :layout => false
end
get "/auto-css.html" do
haml :"auto-css.html", :layout => false
%w{
/auto-css.html
/auto-css
/auto-css/
/auto-css/auto-css.html
/auto-css/sub/auto-css.html
}.each do |path|
get path do
haml :"auto-css.html", :layout => false
end
end
get "/sub1/auto-css.html" do
haml :"auto-css.html", :layout => false
%w{
/auto-js.html
/auto-js
/auto-js/
/auto-js/auto-js.html
/auto-js/sub/auto-js.html
}.each do |path|
get path do
haml :"auto-js.html", :layout => false
end
end
get "/sub1/sub2/auto-css.html" do
haml :"auto-css.html", :layout => false
end

View file

@ -0,0 +1 @@
= auto_javascript_include_tag

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -8,22 +8,36 @@ module Middleman::Features::DefaultHelpers
module Helpers
def auto_stylesheet_link_tag(separator="/")
path = request.path_info.dup
path << self.class.index_file if path.match(%r{/$})
path = path.gsub(%r{^/}, '')
path = path.gsub(File.extname(path), '')
path = path.gsub("/", separator)
css_file = File.join(self.class.views, self.class.css_dir, "#{path}.css")
sass_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.sass")
scss_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.scss")
less_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.less")
if File.exists?(css_file) || File.exists?(sass_file) || File.exists?(scss_file) || File.exists?(less_file)
stylesheet_link_tag "#{path}.css"
auto_tag(:css, separator) do |path|
stylesheet_link_tag path
end
end
def auto_javascript_include_tag(separator="/")
auto_tag(:js, separator) do |path|
javascript_include_tag path
end
end
def auto_tag(asset_ext, separator="/", asset_dir=nil)
if asset_dir.nil?
asset_dir = case asset_ext
when :js then self.class.js_dir
when :css then self.class.css_dir
end
end
path = request.path_info.dup
# If the basename of the request as no extension, assume we are serving a
# directory and join index_file to the path.
path = File.join(path, self.class.index_file) if File.extname(path).empty?
path = path.gsub(%r{^/}, '')
path = path.gsub(File.extname(path), ".#{asset_ext}")
path = path.gsub("/", separator)
view = File.join(self.class.views, asset_dir, path)
yield path if File.exists?(view) or Dir["#{view}.*"].any?
end
def page_classes
path = request.path_info.dup
path << settings.index_file if path.match(%r{/$})
@ -58,4 +72,4 @@ module Middleman::Features::DefaultHelpers
"#{result_path}#{timestamp}"
end
end
end
end

View file

@ -1,3 +1,3 @@
module Middleman
VERSION = "2.0.0.beta3"
VERSION = "2.0.0.beta4"
end

View file

@ -36,6 +36,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("coffee-script", ["~> 2.2.0"])
s.add_runtime_dependency("httparty", ["~> 0.7.0"])
s.add_development_dependency("cucumber", ["~> 0.10.0"])
s.add_development_dependency("rake", ["0.8.7"])
s.add_development_dependency("rspec", [">= 0"])
s.add_development_dependency("rocco", [">= 0"]) unless defined?(JRUBY_VERSION)
end