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