adding timestamp from file in full url
This commit is contained in:
parent
473eff9363
commit
06979f6fae
@ -14,7 +14,7 @@ module Sinatra
|
||||
# The default value of +closed+ option is +false+.
|
||||
#
|
||||
def image_tag(source, options = {})
|
||||
options[:src] = url_for(source)
|
||||
options[:src] = source_url(source)
|
||||
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 => url_for(source) }.merge(options))
|
||||
:href => source_url(source) }.merge(options))
|
||||
end
|
||||
|
||||
def javascript_tag(source, options = {})
|
||||
tag("script", { :type => "text/javascript", :charset => "utf-8",
|
||||
:src => url_for(source) }.merge(options)) do
|
||||
:src => source_url(source) }.merge(options)) do
|
||||
end
|
||||
end
|
||||
|
||||
@ -73,6 +73,19 @@ module Sinatra
|
||||
[a, opts]
|
||||
end
|
||||
|
||||
def source_url(source)
|
||||
source_url_timestamp url_for(source)
|
||||
end
|
||||
|
||||
def source_url_timestamp(url)
|
||||
full_url = "#{Sinatra::Application.root}/public#{url}"
|
||||
if File.exists? full_url
|
||||
timestamp = File.mtime(full_url).to_i
|
||||
"#{url}?#{timestamp}"
|
||||
else
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.registered(app)
|
||||
|
@ -4,7 +4,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{sinatra-static-assets}
|
||||
s.name = %q{r7-sinatra-static-assets}
|
||||
s.version = "0.5.2"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
@ -69,7 +69,7 @@ Gem::Specification.new do |s|
|
||||
s.homepage = %q{http://github.com/wbzyl/sinatra-static-assets}
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.require_paths = ["lib"]
|
||||
s.rubyforge_project = %q{sinatra-static-assets}
|
||||
s.rubyforge_project = %q{r7-sinatra-static-assets}
|
||||
s.rubygems_version = %q{1.3.6}
|
||||
s.summary = %q{Sinatra extension providing helper methods to output tags for static assetgemspec.}
|
||||
s.test_files = [
|
||||
|
Loading…
Reference in New Issue
Block a user