skip sources with '/'
This commit is contained in:
parent
9807102c3e
commit
6bdd6a5b20
@ -14,7 +14,7 @@ module Sinatra
|
||||
# The default value of +closed+ option is +false+.
|
||||
#
|
||||
def image_tag(source, options = {})
|
||||
options[:src] = source_url("/images/#{source}")
|
||||
options[:src] = source_url(source_path(source, {:folder => 'images'}))
|
||||
tag("img", options)
|
||||
end
|
||||
|
||||
@ -59,12 +59,12 @@ module Sinatra
|
||||
def stylesheet_tag(source, options = {})
|
||||
tag("link", { :type => "text/css",
|
||||
:charset => "utf-8", :media => "screen", :rel => "stylesheet",
|
||||
:href => source_url("/stylesheets/#{source}.css") }.merge(options))
|
||||
:href => source_url(source_path(source, {:folder => 'stylesheets', :extension => 'css'})) }.merge(options))
|
||||
end
|
||||
|
||||
def javascript_tag(source, options = {})
|
||||
tag("script", { :type => "text/javascript", :charset => "utf-8",
|
||||
:src => source_url("/javascripts/#{source}.js") }.merge(options)) do
|
||||
:src => source_url(source_path(source, {:folder => 'javascripts', :extension => 'js'})) }.merge(options)) do
|
||||
end
|
||||
end
|
||||
|
||||
@ -73,6 +73,13 @@ module Sinatra
|
||||
[a, opts]
|
||||
end
|
||||
|
||||
def source_path(source, options)
|
||||
return source if source =~ /^\//
|
||||
|
||||
extension = options[:extension] ? ".#{options[:extension]}" : ""
|
||||
"/#{options[:folder]}/#{source}.#{extension}"
|
||||
end
|
||||
|
||||
def source_url(source)
|
||||
url_with_timestamp = source_url_timestamp url_for(source)
|
||||
"#{ENV['asset_host']}#{url_with_timestamp}"
|
||||
|
Loading…
Reference in New Issue
Block a user