Skip to content

Commit

Permalink
Fixed "text/javascript" TextDocument and cache settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Sep 20, 2012
1 parent c412d90 commit 3d23f6b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/text_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextDocument < Document
class << self
# Return true if a new text document can be created with the content_type. Used by the superclass Document to choose the corret subclass when creating a new object.
def accept_content_type?(content_type)
(content_type =~ /(^text|^image\/svg\+xml|x-javascript)/) &&
(content_type =~ /(^text|^image\/svg\+xml|javascript)/) &&
(Zena::TYPE_TO_EXT[content_type.chomp] != ['rtf'])
end

Expand Down
1 change: 1 addition & 0 deletions lib/zena.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def init
[ "jpe" , "image/jpeg" ],
[ "jpeg" , "image/jpeg" ],
[ "js" , "application/x-javascript" ],
[ "js" , "text/javascript" ],
[ "kar" , "audio/midi" ],
[ "latex" , "application/x-latex" ],
[ "lha" , "application/octet-stream" ],
Expand Down
11 changes: 4 additions & 7 deletions lib/zena/deploy/httpd.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ PassengerDefaultUser www-data
<% end %>

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault A0
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
<FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>
</IfModule>
2 changes: 2 additions & 0 deletions lib/zena/use/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ def page_cache_file(url = nil)
if cachestamp_format?(params['format'])
# We have to use a '.' because apache cannot serve static files with '?'.
path << "." << make_cachestamp(@node, params['mode'])
# Set expire
response.headers['Expires'] = 1.year.from_now.httpdate
end
path
end
Expand Down
4 changes: 3 additions & 1 deletion lib/zena/use/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ module Urls
ALLOWED_REGEXP = /\A(([a-zA-Z]+)([0-9]+)|([#{String::ALLOWED_CHARS_IN_URL}\-%]+))(_[a-zA-Z]+|)(\..+|)\Z/

module Common
CACHESTAMP_FORMATS = ['jpg', 'png', 'gif', 'css', 'js']
# This is directly related to the FileMatch clause in httpd.rhtml (mod_expires for apaches)
CACHESTAMP_FORMATS = %w{ico pdf flv jpg jpeg png gif js css swf}

def prefix
if visitor.is_anon?
visitor.lang
Expand Down

0 comments on commit 3d23f6b

Please sign in to comment.