Skip to content
Browse files

added maximum mtime to generated URL

  • Loading branch information...
1 parent 3fce79e commit 617a7d366e0c57dc22a30136aad26d6b4e4260fa @pgte committed
View
3 lib/styled_objects/actionview.rb
@@ -42,6 +42,9 @@ def styled_objects_partial_css_paths
(partials_collector.stylesheets if partials_collector) || []
end
+ def styled_objects_max_mtime
+ partials_collector.max_mtime if partials_collector
+ end
private
View
2 lib/styled_objects/helpers/stylesheet_link_tag.rb
@@ -8,7 +8,7 @@ def self.included(base)
module InstanceMethods
def so_stylesheet_link_tag
- return "<link href=\"#{styledobject_path styled_objects_partial_css_paths.collect {|path| URI.encode(path.gsub(/:|\.css/, ''))}.join(':')}#{"?#{ENV['RAILS_ASSET_ID']}" if ENV['RAILS_ASSET_ID'] }\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
+ return "<link href=\"#{styledobject_path styled_objects_partial_css_paths.collect {|path| URI.encode(path.gsub(/:|\.css/, ''))}.join(':')}?#{styled_objects_max_mtime}\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
end
end
View
22 lib/styled_objects/partials_collector.rb
@@ -5,29 +5,31 @@ def initialize(view_paths)
@stylesheets = {}
@visited_partials = {}
@view_paths = view_paths
+ @max_mtime = 0
end
- def partial_visited(partial)
-# unless @visited_partials[partial]
-# @visited_partials[partial] = true
- style_file = _find_style_file(partial)
+ def << (partial)
+ unless @visited_partials[partial]
+ @visited_partials[partial] = true
+ style_file, mtime = _find_style_file(partial)
if style_file
@stylesheets[style_file] = true
+ @max_mtime = mtime if mtime > @max_mtime
else
nil
end
-# end
+ end
end
- def << (partial)
- partial_visited(partial)
- end
-
def stylesheets
@stylesheets.keys
end
+ def max_mtime
+ @max_mtime
+ end
+
private
def _find_style_file(partial)
@@ -35,7 +37,7 @@ def _find_style_file(partial)
#RAILS_DEFAULT_LOGGER.debug("Looking for #{style_file}")
@view_paths.each do |view_path|
try_path = File.join view_path, style_file
- return style_file if File.file? try_path
+ return [style_file, File.mtime(try_path).to_i] if File.file? try_path
end
#raise "SO: did not find style file for #{partial}"
nil

0 comments on commit 617a7d3

Please sign in to comment.
Something went wrong with that request. Please try again.