Commit 62419e2b7c1e021079eb41328039425654a95d4f

Authored by Antonio Terceiro
1 parent 783dcf1e

noosfero_caching: fix HTTP caching with Rails 3

config/application.rb
@@ -111,9 +111,7 @@ module Noosfero @@ -111,9 +111,7 @@ module Noosfero
111 # Make sure the secret is at least 30 characters and all random, 111 # Make sure the secret is at least 30 characters and all random,
112 # no regular words or you'll be exposed to dictionary attacks. 112 # no regular words or you'll be exposed to dictionary attacks.
113 config.secret_token = noosfero_session_secret 113 config.secret_token = noosfero_session_secret
114 - config.action_dispatch.session = {  
115 - :key => '_noosfero_session',  
116 - } 114 + config.session_store :cookie_store, :key => '_noosfero_session'
117 115
118 config.time_zone = File.read('/etc/timezone').split("\n").first 116 config.time_zone = File.read('/etc/timezone').split("\n").first
119 config.active_record.default_timezone = :local 117 config.active_record.default_timezone = :local
vendor/plugins/noosfero_caching/init.rb
@@ -49,11 +49,11 @@ module NoosferoHttpCaching @@ -49,11 +49,11 @@ module NoosferoHttpCaching
49 49
50 # filter off all cookies except for plugin-provided ones that are 50 # filter off all cookies except for plugin-provided ones that are
51 # path-specific (i.e path != "/"). 51 # path-specific (i.e path != "/").
52 - def remove_unwanted_cookies(cookie_list)  
53 - return nil if cookie_list.nil?  
54 - cookie_list.select do |c| 52 + def remove_unwanted_cookies(set_cookie)
  53 + return nil if set_cookie.nil?
  54 + set_cookie.split(/\s*,\s*/).select do |c|
55 c =~ /^_noosfero_plugin_\w+=/ && c =~ /path=\/\w+/ 55 c =~ /^_noosfero_plugin_\w+=/ && c =~ /path=\/\w+/
56 - end 56 + end.join(', ')
57 end 57 end
58 58
59 end 59 end
@@ -61,7 +61,7 @@ module NoosferoHttpCaching @@ -61,7 +61,7 @@ module NoosferoHttpCaching
61 end 61 end
62 62
63 unless Rails.env.development? 63 unless Rails.env.development?
64 - middleware = Rails.application.config.middleware 64 + middleware = Noosfero::Application.config.middleware
65 ActionController::Base.send(:include, NoosferoHttpCaching) 65 ActionController::Base.send(:include, NoosferoHttpCaching)
66 - middleware.use NoosferoHttpCaching::Middleware 66 + middleware.insert_before ::ActionDispatch::Cookies, NoosferoHttpCaching::Middleware
67 end 67 end