diff options
author | Mark Longair <mhl@pobox.com> | 2013-08-21 14:26:49 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-08-21 14:26:49 +0100 |
commit | 8dea412e69d62d336a079dc0f27eacd0566c6242 (patch) | |
tree | 807b08ed7cf957a69e85166fa6bbd86d12269ae1 | |
parent | 4dc5bfce6f8a34aa9f01e9232190fa2c169727a9 (diff) |
Serve admin.js as a static file
admin.js was being generated from a view so that the config variable
ADMIN_PUBLIC_URL could be used to direct AJAX requests in the admin
interface correctly. ADMIN_PUBLIC_URL was necessary for
WhatDoTheyKnow when the admin interface was proxied over SSL, while
the rest of the site was non-SSL. Now that the whole site is served
over SSL, however, the proxy for the admin interface is not longer
used and ADMIN_PUBLIC_URL / ADMIN_BASE_URL have been removed.
As a result, admin.js is now being generated from a Rails view
unnecessarily, and at some performance cost. This commit moves
admin.coffee and admin.js to the public directory, so they will
be served more efficiently.
In addition, this commit removes admin.coffee / admin.js from
public/javascripts/ where there was a second (and different) version
that now appears to be unused.
-rw-r--r-- | app/controllers/admin_general_controller.rb | 5 | ||||
-rw-r--r-- | app/views/admin_general/admin_js.erb | 34 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | doc/ADMIN.md | 10 | ||||
-rw-r--r-- | public/admin/javascripts/admin.coffee (renamed from app/views/admin_general/admin.coffee) | 0 | ||||
-rw-r--r-- | public/admin/javascripts/admin.js (renamed from app/views/admin_general/admin.js) | 0 | ||||
-rw-r--r-- | public/javascripts/admin.coffee | 10 | ||||
-rw-r--r-- | public/javascripts/admin.js | 14 |
8 files changed, 4 insertions, 70 deletions
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb index ec5f95eda..196616ed6 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -5,7 +5,6 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class AdminGeneralController < AdminController - skip_before_filter :authenticate, :only => :admin_js def index # ensure we have a trailing slash @@ -142,9 +141,5 @@ class AdminGeneralController < AdminController @request_env = request.env end - # TODO: Remove this when support for proxy admin interface is removed - def admin_js - render :layout => false, :content_type => "application/javascript" - end end diff --git a/app/views/admin_general/admin_js.erb b/app/views/admin_general/admin_js.erb deleted file mode 100644 index c8788a452..000000000 --- a/app/views/admin_general/admin_js.erb +++ /dev/null @@ -1,34 +0,0 @@ -(function() { - - jQuery(function() { - $('.locales a:first').tab('show'); - $('.accordion-body').on('hidden', function() { - return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-right'); - }); - $('.accordion-body').on('shown', function() { - return $(this).prev().find('i').first().removeClass().addClass('icon-chevron-down'); - }); - $('.toggle-hidden').live('click', function() { - $(this).parents('td').find('div:hidden').show(); - return false; - }); - return $('#request_hidden_user_explanation_reasons input').live('click', function() { - var info_request_id, reason; - $('#request_hidden_user_subject, #request_hidden_user_explanation, #request_hide_button').show(); - info_request_id = $('#hide_request_form').attr('data-info-request-id'); - reason = $(this).val(); - $('#request_hidden_user_explanation_field').attr("value", "[loading default text...]"); - return $.ajax("/hidden_user_explanation?reason=" + reason + "&info_request_id=" + info_request_id, { - type: "GET", - dataType: "text", - error: function(data, textStatus, jqXHR) { - return $('#request_hidden_user_explanation_field').attr("value", "Error: " + textStatus); - }, - success: function(data, textStatus, jqXHR) { - return $('#request_hidden_user_explanation_field').attr("value", data); - } - }); - }); - }); - -}).call(this); diff --git a/config/routes.rb b/config/routes.rb index 5af94768c..646334f5c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -176,7 +176,6 @@ Alaveteli::Application.routes.draw do match '/admin/timeline' => 'admin_general#timeline', :as => :admin_timeline match '/admin/debug' => 'admin_general#debug', :as => :admin_debug match '/admin/stats' => 'admin_general#stats', :as => :admin_stats - match '/admin/javascripts/admin.js' => 'admin_general#admin_js', :as => :admin_js #### #### AdminRequest controller diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 07fe9398d..6248e6cfc 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -11,11 +11,9 @@ If you want to work on the CSS, you'll want to use $ gem install compass $ compass compile --config .compass/config.rb -The javascript is included in a funky way -[for reasons explained in this commit](https://github.com/sebbacon/adminbootstraptheme/commit/45a73d53fc9e8f0b728933ff58764bd8d0612dab). -To change it, edit the coffeescript at -`lib/view/general/admin.coffee`, and then do something like: +To change the JavaScript, edit `public/admin/javascripts/admin.coffee` +and then run: - $ coffee -o /tmp/ -c app/views/admin_general/admin.coffee - $ mv /tmp/admin.js app/views/admin_general/admin_js.erb + $ coffee -c public/admin/javascripts/admin.coffee +That will update `public/admin/javascripts/admin.js`.
\ No newline at end of file diff --git a/app/views/admin_general/admin.coffee b/public/admin/javascripts/admin.coffee index 3d39369a4..3d39369a4 100644 --- a/app/views/admin_general/admin.coffee +++ b/public/admin/javascripts/admin.coffee diff --git a/app/views/admin_general/admin.js b/public/admin/javascripts/admin.js index 9daa51459..9daa51459 100644 --- a/app/views/admin_general/admin.js +++ b/public/admin/javascripts/admin.js diff --git a/public/javascripts/admin.coffee b/public/javascripts/admin.coffee deleted file mode 100644 index 59c5c0a6f..000000000 --- a/public/javascripts/admin.coffee +++ /dev/null @@ -1,10 +0,0 @@ -(($) -> - $(document).ready(-> - $('.locales a:first').tab('show') - ) - $('.toggle-hidden').live('click', -> - $(@).parents('td').find('div:hidden').show() - false - ) -)(jQuery) - diff --git a/public/javascripts/admin.js b/public/javascripts/admin.js deleted file mode 100644 index 21725ded4..000000000 --- a/public/javascripts/admin.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by CoffeeScript 1.3.1 -(function() { - - (function($) { - $(document).ready(function() { - return $('.locales a:first').tab('show'); - }); - return $('.toggle-hidden').live('click', function() { - $(this).parents('td').find('div:hidden').show(); - return false; - }); - })(jQuery); - -}).call(this); |