From e67094090978c89852f1dbca51e4b34f1128c344 Mon Sep 17 00:00:00 2001 From: tdreyno Date: Tue, 4 Aug 2009 16:32:01 -0700 Subject: [PATCH] asset helpers --- .gitmodules | 5 +---- lib/middleman.rb | 7 ------- lib/middleman/helpers.rb | 18 ++++++++++++++++-- vendor/sinatra-helpers | 1 - 4 files changed, 17 insertions(+), 14 deletions(-) delete mode 160000 vendor/sinatra-helpers diff --git a/.gitmodules b/.gitmodules index cb12acf6..5e00a346 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,4 @@ url = git://github.com/brynary/rack-test.git [submodule "vendor/sinatra-content-for"] path = vendor/sinatra-content-for - url = git://github.com/foca/sinatra-content-for.git -[submodule "vendor/sinatra-helpers"] - path = vendor/sinatra-helpers - url = git://github.com/sbfaulkner/sinatra-helpers.git + url = git://github.com/foca/sinatra-content-for.git \ No newline at end of file diff --git a/lib/middleman.rb b/lib/middleman.rb index cb510537..de95d478 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -12,9 +12,6 @@ require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib # Include content_for support require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-content-for', 'lib', 'sinatra', 'content_for') -# Include common haml/html helper support -require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-helpers', 'lib', 'sinatra-helpers', 'haml') - class Middleman < Sinatra::Base set :app_file, __FILE__ set :static, true @@ -24,9 +21,6 @@ class Middleman < Sinatra::Base helpers Sinatra::Markaby helpers Sinatra::Maruku helpers Sinatra::ContentFor - helpers Sinatra::Helpers::Haml::Forms - helpers Sinatra::Helpers::Haml::Links - helpers Sinatra::Helpers::Haml::Partials def self.run!(options={}, &block) set options @@ -51,7 +45,6 @@ class Middleman < Sinatra::Base end configure do - puts "config yo" Compass.configuration do |config| config.project_path = Dir.pwd config.sass_dir = File.join(File.basename(self.views), "stylesheets") diff --git a/lib/middleman/helpers.rb b/lib/middleman/helpers.rb index 630c4ebc..34da8875 100644 --- a/lib/middleman/helpers.rb +++ b/lib/middleman/helpers.rb @@ -15,7 +15,21 @@ Middleman.helpers do classes.join(' ') end - def asset_url(path, tld_length = 1) - "/#{path}" + def asset_url(path) + path.include?("://") ? path : "/#{path}" + end + + def image_tag(path, options={}) + options[:alt] ||= "" + capture_haml do + haml_tag :img, options.merge(:src => asset_url(path)) + end + end + + def stylesheet_link_tag(path, options={}) + options[:rel] ||= "stylesheet" + capture_haml do + haml_tag :link, options.merge(:href => asset_url(path), :type => "text/css") + end end end diff --git a/vendor/sinatra-helpers b/vendor/sinatra-helpers deleted file mode 160000 index 65d5060a..00000000 --- a/vendor/sinatra-helpers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 65d5060ad8cdff6b12631878d97486114d195376