From 3421afdb9eb79effa562ded447923b529ef8b714 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 28 Nov 2012 15:57:58 +0000 Subject: Give the implicit default locale in a URL without locale precedence over the session in the case where the default locale is not being included in URLs. This allows the user to return to the default locale. --- app/controllers/application_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f9649c868..320d0cc50 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -54,10 +54,15 @@ class ApplicationController < ActionController::Base end def set_gettext_locale + if Configuration::include_default_locale_in_urls == false + params_locale = params[:locale] ? params[:locale] : I18n.default_locale + else + params_locale = params[:locale] + end if Configuration::use_default_browser_language - requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale + requested_locale = params_locale || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale else - requested_locale = params[:locale] || session[:locale] || cookies[:locale] || I18n.default_locale + requested_locale = params_locale || session[:locale] || cookies[:locale] || I18n.default_locale end requested_locale = FastGettext.best_locale_in(requested_locale) session[:locale] = FastGettext.set_locale(requested_locale) -- cgit v1.2.3 From 611411fc7907a97e3aa8c2339bc9f5b70a5d1a01 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 13 Dec 2012 19:11:48 +0000 Subject: Use helper method for download path, and use Rails.root instead of file location. --- app/controllers/application_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3f3c169ae..239d49a6c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -229,6 +229,10 @@ class ApplicationController < ActionController::Base end end + def download_zip_dir() + File.join(Rails.root, '/cache/zips/') + end + # get the local locale def locale_from_params(*args) if params[:show_locale] -- cgit v1.2.3 From d2dc193066222b279faa52a66a22760e739dd87e Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 13 Dec 2012 20:15:54 +0000 Subject: Put download zips in a predictable location - sharded folders based on request ID, rather than distributing them across the download directories by the generated SHA. Preserve the uniqueness of the subdirectory. --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 239d49a6c..d8f7f9ea7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -229,6 +229,11 @@ class ApplicationController < ActionController::Base end end + def request_dirs(info_request) + first_three_digits = info_request.id.to_s()[0..2] + File.join(first_three_digits.to_s, info_request.id.to_s) + end + def download_zip_dir() File.join(Rails.root, '/cache/zips/') end -- cgit v1.2.3 From a5744b206cf1ca811f913d68cafc0178079be2f7 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 13 Dec 2012 20:23:23 +0000 Subject: Remove any download zip files when a request's cached files are expired. --- app/controllers/application_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d8f7f9ea7..b707ae878 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -234,6 +234,10 @@ class ApplicationController < ActionController::Base File.join(first_three_digits.to_s, info_request.id.to_s) end + def request_download_zip_dir(info_request) + File.join(download_zip_dir, "download", request_dirs(info_request)) + end + def download_zip_dir() File.join(Rails.root, '/cache/zips/') end -- cgit v1.2.3