Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

beginnings of working around an issue with caching translated pages

  • Loading branch information...
commit d6ff02a4fca05c02b71e541b552a254ba0dc5d47 1 parent 058757a
@peburrows authored
Showing with 30 additions and 0 deletions.
  1. +29 −0 app/models/translate_response_cache.rb
  2. +1 −0  translator_extension.rb
View
29 app/models/translate_response_cache.rb
@@ -0,0 +1,29 @@
+class TranslateResponseCache
+
+ ResponseCache.class_eval{
+ private
+ def page_cache_path(path)
+ logger.error("\n\n-------------------\n i was called? \n---------------------\n\n")
+
+ # set up '/' as '/index' so we don't have to worry about having cache files in the wrong directory
+ path = page_cache_file(path)
+ path = translator_path(path)
+ root_dir = File.expand_path(page_cache_directory)
+ cache_path = File.expand_path(File.join(root_dir,path), root_dir)
+ if(cache_path.index(root_dir) == 0)
+ logger.error(cache_path)
+ cache_path
+ end
+ end
+
+ # def page_cache_file(path)
+ # name = ((path.empty? || path == "/") ? "/index" : URI.unescape(path))
+ # end
+
+ def translator_path(path)
+ path = path + '_en' unless path.match(/[\.css|\.js]$/)
+ path
+ end
+ }
+
+end
View
1  translator_extension.rb
@@ -13,6 +13,7 @@ class TranslatorExtension < Radiant::Extension
def activate
Page.send :include, TranslatorTags
SiteController.class_eval{session :disabled => false}
+ TranslateResponseCache
end
def deactivate
Please sign in to comment.
Something went wrong with that request. Please try again.