Skip to content

Commit

Permalink
Fixed cachestamp in cached file (thanks Christian).
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Sep 5, 2012
1 parent a68ffb4 commit 78ec11e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions bricks/acls/zena/test/integration/acl_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AclIntegrationTest < Zena::Integration::TestCase
should 'find nodes' do
get "http://erebus.host/oo/project#{nodes_zip(:over_zeus)}.html"
assert_response :success
assert_match %r{there is "A plan to overrule Zeus"}, response.body
assert_match %r{there is &quote;A plan to overrule Zeus&quote;}, response.body
end
end # with normal access

Expand Down Expand Up @@ -48,7 +48,7 @@ class AclIntegrationTest < Zena::Integration::TestCase

should 'render with forced skin' do
get "http://erebus.host/oo/project#{nodes_zip(:queen)}.html"
assert_match %r{you can see \"My Queen\"}, response.body
assert_match %r{you can see &quote;My Queen&quote;}, response.body
end

should 'find items in view with exec_group' do
Expand Down
8 changes: 1 addition & 7 deletions lib/zena/deploy/vhost.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Serve static (cached) assets
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.%{QUERY_STRING} -f
# We have to use '.'. If we use '?' apache won't find the file.
RewriteRule ^/(.*)$ %{REQUEST_FILENAME}.%{QUERY_STRING} [L]

# Rails assets (static CSS, JS).
# Cached/static assets
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f
RewriteRule ^/(.*)$ %{REQUEST_FILENAME} [L]
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module ViewMethods
include ImageTags
include RubyLess
safe_method [:sprintf, String, Number] => {:class => String, :method => 'sprintf'}
safe_method [:search_box, {:ajax => String, :type => String}] => String
safe_method [:search_box, {:ajax => String, :type => String}] => {:class => String, :method => 'search_box', :html_safe => true}
safe_context [:admin_links, {:list => String}] => [String]

# Return sprintf formated entry. Return '' for values eq to zero.
Expand Down
8 changes: 4 additions & 4 deletions lib/zena/use/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ def page_cache_file(url = nil)
path << ".#{ext}" unless path =~ /\.#{ext}(\?\d+|)$/
#
# FULL QUERY_STRING in cached page ?
if cachestamp_format?(params['format'])
# We have to use a '.' because apache cannot serve static files with '?'.
path << "." << make_cachestamp(@node, params['mode'])
end
# if cachestamp_format?(params['format'])
# # We have to use a '.' because apache cannot serve static files with '?'.
# path << "." << make_cachestamp(@node, params['mode'])
# end
path
end

Expand Down
10 changes: 3 additions & 7 deletions test/functional/nodes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def test_should_cache_document_data_without_cachestamp
# cache info ok
get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => node.updated_at.to_i
assert_response :success
assert File.exist?(make_cache_path("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.jpg", node))
assert File.exist?("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.jpg")
end
end
end
Expand Down Expand Up @@ -778,10 +778,6 @@ def test_ics_format_not_anon
end
end

def make_cache_path(file, node)
"#{file}.#{node.updated_at.to_i}"
end

def test_cache_css_auto_publish
test_site('zena')
Site.connection.execute "UPDATE sites set auto_publish = #{Zena::Db::TRUE}, redit_time = 7200 WHERE id = #{sites_id(:zena)}"
Expand All @@ -795,7 +791,7 @@ def test_cache_css_auto_publish
assert !File.exist?(filename)
get 'show', :prefix => 'en', :path => [name], :cachestamp => node.updated_at.to_i
assert_response :success
cache1 = make_cache_path(filename, node)
cache1 = filename
assert File.exist?(cache1) # cached page created
assert_match %r[body \{ background: #eee; color:#444;], File.read(cache1)
put 'save_text', :id => nodes_zip(:style_css), :node => {'text' => '/* empty */'}
Expand All @@ -806,7 +802,7 @@ def test_cache_css_auto_publish
assert !File.exist?(cache1) # old cached page removed
get 'show', :prefix => 'en', :path => [name], :cachestamp => node.updated_at.to_i
assert_response :success
cache2 = make_cache_path(filename, node)
cache2 = filename
assert File.exist?(cache2) # cached page created again
assert_match %r[/\* empty \*/], File.read(cache2)
end
Expand Down
4 changes: 4 additions & 0 deletions test/integration/zafu_compiler/display.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ stylesheets:
src: "<r:stylesheets list='zena,code,search'/>"
tem: "/link href.*/stylesheets/zena.css.*text/css.*code.css.*text/css.*search.css.*stylesheet/"

search_box:
src: "<div id='search' do='search_box' type='search'/>"
res: "/<div id='search'><div class=\"search\">/"

icon:
context:
node: wiki
Expand Down

0 comments on commit 78ec11e

Please sign in to comment.