Skip to content

Commit

Permalink
Fixed asset caching PLEASE FIX YOUR VHOST FILES: rake zena:create_vho…
Browse files Browse the repository at this point in the history
…st -s host='xxxxx'.
  • Loading branch information
gaspard committed Dec 14, 2011
1 parent 26bb208 commit 8455c7f
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 42 deletions.
3 changes: 3 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

* Major changes
* Added 'remove_from_db' method to remove a site from the database.
* Fixed asset caching PLEASE FIX YOUR VHOST FILES: rake zena:create_vhost -s host='xxxxx'.
* Fixed deadlock_retry (a bug in the error message aborted the retry).

* Minor changes
* Enabled Acl during document upload.
* Fixed a bug when using [edit] in a list with [add].
* Fixed 'unknown this' bug in [calendar] when rendering in a [block].
* Enabled 'alt_class' to work on multiple elements ([each]).

== 1.1.3 2011-11-09

Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
Users have access rights defined by the groups they belong to. They also have a 'status' indicating the kind of
things they can/cannot do :
+:user+:: (60): can read/write/publish
+:admin+:: (60): can read/write/publish in any group, can create users/groups
+:user+:: (50): can read/write/publish
+:commentator+:: (40): can write comments
+:moderated+:: (30): can write moderated comments
+:reader+:: (20): can only read
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/db_helper/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def transaction_with_deadlock_retry(*args, &block)
if error.message =~ DEADLOCK_REGEX
retry_count += 1
if retry_count < DEADLOCK_MAX_RETRY
Node.logger.warn "#{Time.now.strftim('%Y-%m-%d %H:%M:%S')} [#{current_site.host}] Retry (#{retry_count}) #{error.message}"
Node.logger.warn "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} [#{current_site.host}] Retry (#{retry_count}) #{error.message}"
retry
else
raise
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/deploy/awstats.conf.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ HostAliases="localhost 127.0.0.1 <%= config[:host] %> stats.<%= config[:host] %>
# 2 - DNS Lookup is made only from static DNS cache file (if it exists)
# Default: 2
#
DNSLookup=2
DNSLookup=1


# When AWStats updates its statistics, it stores results of its analysis in
Expand Down
18 changes: 16 additions & 2 deletions lib/zena/deploy/vhost.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,22 @@
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}%{QUERY_STRING} !-f
# 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).
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -f
RewriteRule ^/(.*)$ %{REQUEST_FILENAME} [L]

# else
# Request with query string (if some page is cached, the same page with a query should not be served as static)
RewriteCond %{QUERY_STRING} ^.+$ [OR]
# All non-static
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://<%= config[:balancer] %>%{REQUEST_URI} [P,QSA,L]
<% elsif config[:app_type] == :passenger %>
PassengerAppRoot <%= config[:app_root] %>
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def form_hidden_fields(opts)
# r_form params
:klass, :done, :on, :update,
# r_each params (make_form)
:join].include?(key)
:join, :alt_class].include?(key)
code = ::RubyLess.translate(self, value)
if code.literal.kind_of?(String) || code.literal.kind_of?(Number)
hidden_fields[key.to_s] = "#{code.literal}"
Expand Down
11 changes: 5 additions & 6 deletions lib/zena/use/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,11 @@ def page_cache_file(url = nil)
ext = params[:format].blank? ? 'html' : params[:format]
path << ".#{ext}" unless path =~ /\.#{ext}(\?\d+|)$/
#
# QUERY_STRING in cached page ?
#
# Do not cache filename with query or apache will not see it !
# if cachestamp_format?(params['format'])
# path << "?" << make_cachestamp(@node, params['mode'])
# end
# 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
path
end

Expand Down
24 changes: 0 additions & 24 deletions test/integration/zafu_compiler/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,6 @@ each_traductions_only_list:
src: "<r:traductions only='en,ru'><ul><li do='each'><r:show attr='title'/></li></ul></r:traductions>"
res: "<ul><li>status title</li></ul>"

each_alternate_class:
context:
node: 'cleanWater'
src: "<ol do='pages'><li do='each' alt_class='blue' do='title'/></ol>"
res: "<ol><li class=''>crocodiles</li><li class='blue'>status title</li><li class=''>Kill the bugs</li></ol>"

each_alternate_class_reverse:
context:
node: 'cleanWater'
src: "<ol do='pages' limit='2'><li do='each' alt_class='blue' alt_reverse='true' do='title'/></ol>"
res: "<ol><li class='blue'>crocodiles</li><li class=''>status title</li></ol>"

each_alternate_class_two:
context:
node: 'collections'
src: "<ol do='pages'><li class='post' do='each' alt_class='stripe' do='title'/></ol>"
res: "<ol><li class='post '>art</li><li class='post stripe'>menu</li><li class='post '>news</li><li class='post stripe'>wikiSkin</li></ol>"

each_alternate_class_ajax:
context:
node: 'cleanWater'
src: "<ol do='pages' limit='2'><li do='each' alt_class='blue' do='title'/><li do='add'/></ol>"
res: "/<li>crocodiles<\/li><li class=\"blue\">status/"

each_else:
context:
node: 'opening'
Expand Down
6 changes: 5 additions & 1 deletion test/integration/zafu_compiler/dates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,8 @@ test_date:

format_date_empty_string:
tem: "<%= format_date('') %>"
res: ""
res: ""

date_empty_value:
src: "<r:input name='date' value=''/>"
tem: "x"
40 changes: 39 additions & 1 deletion test/integration/zafu_compiler/display.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,42 @@ array_literal:

style_tag:
src: "<r:style>.foo <r:title/></r:style>"
res: "<style>.foo status title</style>"
res: "<style>.foo status title</style>"

each_alternate_class:
context:
node: 'cleanWater'
src: "<ol do='pages'><li do='each' alt_class='blue' do='title'/></ol>"
res: "<ol><li class=''>crocodiles</li><li class='blue'>status title</li></ol>"

each_alternate_class_reverse:
context:
node: 'cleanWater'
src: "<ol do='pages' limit='2'><li do='each' alt_class='blue' alt_reverse='true' do='title'/></ol>"
res: "<ol><li class='blue'>crocodiles</li><li class=''>status title</li></ol>"

each_alternate_class_two:
context:
node: 'collections'
src: "<ol do='pages'><li class='post' do='each' alt_class='stripe' do='title'/></ol>"
res: "<ol><li class='post '>Art</li><li class='post stripe'>News list</li><li class='post '>Top menu</li><li class='post stripe'>wiki skin</li></ol>"

each_alternate_class_ajax:
context:
node: 'cleanWater'
src: "<ol do='pages' limit='2'><li do='each' alt_class='blue' do='title'/><li do='add'/></ol>"
res: "/<li class='' id='list1_26'>crocodiles<\/li><li class='blue' id='list1_22'>status title<\/li>/"

each_alternate_class_with_conditional:
context:
node: 'cleanWater'
src: "<ol do='pages'><li do='each' alt_class='blue' on_if='title' do='title'/></ol>"
res: "<ol><li class=' on'>crocodiles</li><li class='blue on'>status title</li></ol>"

each_alternate_by_hand:
context:
node: 'cleanWater'
# This is useful when we need to have more then one table row per item for example.
src: "<ol do='pages'><r:each alt_class='blue'><li class='#{alt_class}' do='title'/></r:each></ol>"
tem: "/class='<%= _zaltclass %>'/"
res: "<ol><li class=''>crocodiles</li><li class='blue'>status title</li></ol>"
8 changes: 4 additions & 4 deletions zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
s.date = %q{2011-11-16}
s.date = %q{2011-11-30}
s.default_executable = %q{zena}
s.description = %q{zena is a Ruby on Rails CMS (content managment system) with a focus on usability, ease of customization and web 2.0 goodness (application like behaviour).}
s.email = %q{gaspard@teti.ch}
Expand Down Expand Up @@ -2166,7 +2166,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<syntax>, ["= 1.0.0"])
s.add_runtime_dependency(%q<gem_plugin>, [">= 0"])
s.add_runtime_dependency(%q<yamltest>, ["= 0.7.0"])
s.add_runtime_dependency(%q<json>, ["= 1.5.1"])
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_runtime_dependency(%q<will_paginate>, ["~> 2.3.12"])
s.add_runtime_dependency(%q<gettext>, ["= 2.1.0"])
s.add_runtime_dependency(%q<versions>, ["= 0.3.1"])
Expand All @@ -2192,7 +2192,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<syntax>, ["= 1.0.0"])
s.add_dependency(%q<gem_plugin>, [">= 0"])
s.add_dependency(%q<yamltest>, ["= 0.7.0"])
s.add_dependency(%q<json>, ["= 1.5.1"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<will_paginate>, ["~> 2.3.12"])
s.add_dependency(%q<gettext>, ["= 2.1.0"])
s.add_dependency(%q<versions>, ["= 0.3.1"])
Expand All @@ -2219,7 +2219,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<syntax>, ["= 1.0.0"])
s.add_dependency(%q<gem_plugin>, [">= 0"])
s.add_dependency(%q<yamltest>, ["= 0.7.0"])
s.add_dependency(%q<json>, ["= 1.5.1"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<will_paginate>, ["~> 2.3.12"])
s.add_dependency(%q<gettext>, ["= 2.1.0"])
s.add_dependency(%q<versions>, ["= 0.3.1"])
Expand Down

0 comments on commit 8455c7f

Please sign in to comment.