aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-09-16 02:04:06 +0100
committerFrancis Irving <francis@mysociety.org>2010-09-16 02:04:06 +0100
commiteb14e07eaee3f30b3bbadd06b9e99c0e11ba88bb (patch)
tree7663a320f3489901008bbcc151e0cbd9ad97cb4b
parenta690d47e205b30f641e89f6a7f7c613a02c1b6af (diff)
Serve CSS from secure URL for admin
-rw-r--r--app/helpers/link_to_helper.rb6
-rw-r--r--config/environment.rb8
-rw-r--r--config/general-example5
3 files changed, 11 insertions, 8 deletions
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index aa63ef65d..2ba4649ba 100644
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -179,12 +179,6 @@ module LinkToHelper
end
- # Where stylesheets used by admin page sit under
- def admin_public_url(relative_path)
- admin_url_prefix = MySociety::Config.get("ADMIN_PUBLIC_URL", "/")
- return admin_url_prefix + relative_path.sub(/^\//, "") # stylesheet relative paths start with /
- end
-
def main_url(relative_path)
url_prefix = "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000')
return url_prefix + relative_path
diff --git a/config/environment.rb b/config/environment.rb
index 5b632471e..e02a11e49 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -96,7 +96,13 @@ ActionMailer::Base.default_url_options[:host] = MySociety::Config.get("DOMAIN",
# So that javascript assets use full URL, so proxied admin URLs read javascript OK
if (MySociety::Config.get("DOMAIN", "") != "")
- ActionController::Base.asset_host = MySociety::Config.get("DOMAIN", 'localhost:3000')
+ ActionController::Base.asset_host = Proc.new { |source, request|
+ if request.ssl? # for mySociety proxying
+ MySociety::Config.get("ADMIN_PUBLIC_URL", "/")
+ else
+ MySociety::Config.get("DOMAIN", 'localhost:3000')
+ end
+ }
end
# Load monkey patches from lib/
diff --git a/config/general-example b/config/general-example
index bc8e03f65..8b36ef9c8 100644
--- a/config/general-example
+++ b/config/general-example
@@ -38,7 +38,10 @@ define('OPTION_BLACKHOLE_PREFIX', 'do-not-reply-to-this-address'); // used as en
// Administration
define('OPTION_CONTACT_EMAIL', 'admin@localhost');
define('OPTION_ADMIN_BASE_URL', '/admin/');
-define('OPTION_ADMIN_PUBLIC_URL', '/'); // where /stylesheets sits under for admin pages
+// Where /stylesheets sits under for pages served over SSL, see asset_host in
+// config/environment.rb. This is to serve the stylesheets from SSL as well in
+// mySociety's proxied admin system.
+define('OPTION_ADMIN_PUBLIC_URL', '/');
// Secret key for signing cookie_store sessions
define('OPTION_COOKIE_STORE_SESSION_SECRET', 'your secret key here, make it long and random');