Cache bookmarklet code in public/assets/bookmarklet.js

tmp/cache is not something you would include in a packaging situation.
This commit is contained in:
Jonne Haß 2015-11-03 18:06:55 +01:00
parent 65e466f1e2
commit c815ed4d7c

View file

@ -2,7 +2,7 @@
class BookmarkletRenderer class BookmarkletRenderer
class << self class << self
def cached_name def cached_name
@cached ||= File.join(Rails.application.config.paths["tmp"].first, "cache", "bookmarklet.cached") @cached ||= Rails.root.join("public", "assets", "bookmarklet.js")
end end
def source_name def source_name
@ -21,6 +21,7 @@ class BookmarkletRenderer
def compile def compile
src = File.read(source_name) src = File.read(source_name)
@body = Uglifier.compile(src) @body = Uglifier.compile(src)
FileUtils.mkdir_p cached_name.dirname
File.open(cached_name, "w") {|f| f.write(@body) } File.open(cached_name, "w") {|f| f.write(@body) }
end end
end end