lib/nitro/caching/output.rb in nitro-0.21.2 vs lib/nitro/caching/output.rb in nitro-0.22.0
- old
+ new
@@ -22,31 +22,31 @@
def do_cache_output(path, content)
filepath = output_cache_path(path)
FileUtils.makedirs(File.dirname(filepath))
File.open(filepath, 'w+') { |f| f.write(content) }
- Logger.debug "Cached page: #{filepath}" if $DBG
+ Logger.debug "Cached page '#{filepath}'" if $DBG
end
# Enable output caching for the given actions.
def cache_output(*actions)
return unless caching_enabled?
str = actions.collect { |a| ":#{a}" }.join(', ')
module_eval %{
- post "do_cache_output", :only => [ #{str} ]
+ after "do_cache_output", :on => [ #{str} ]
}
end
private
def output_cache_path(path)
- filename = ((path.empty? || path == '/') ? '/index' : path.dup)
+ filename = ((path.empty? || path == '/') ? 'index.html' : path.dup)
# filename.gsub!(/\/$/, '')
- filename << 'index.html' unless (name.split('/').last || name).include? '.'
+ filename << 'index.html' unless (filename.split('/').last || filename).include? '.'
return output_cache_root + '/' + filename
end
end
@@ -58,10 +58,11 @@
end
end
def expire_output(name)
begin
- FileUtils.rm("#{context.dispatcher.public_root}/#{name}/index.html")
+ Logger.debug "Expirinig cache file '#{context.dispatcher.public_root}/#{name}'" if $DBG
+ FileUtils.rm_rf("#{context.dispatcher.public_root}/#{name}")
rescue Object
# gmosx: is this the right thing to do?
end
end