diff options
-rw-r--r-- | app/controllers/application_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 17 | ||||
-rw-r--r-- | app/views/general/frontpage.rhtml | 21 |
3 files changed, 21 insertions, 25 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4252d4212..1628d2f31 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,9 +13,17 @@ class ApplicationController < ActionController::Base # Standard headers, footers and navigation for whole site layout "default" before_filter :set_gettext_locale + # scrub sensitive parameters from the logs filter_parameter_logging :password + helper_method :site_name + def site_name + # XXX should come from database: + site_name = "WhatDoTheyKnow" + return site_name + end + # Help work out which request causes RAM spike. # http://www.codeweblog.com/rails-to-monitor-the-process-of-memory-leaks-skills/ # This shows the memory use increase of the Ruby process due to the request. diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 21e715424..df46c4ae8 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -22,22 +22,7 @@ class GeneralController < ApplicationController def frontpage behavior_cache do # This is too slow - #@popular_bodies = PublicBody.find(:all, :select => "*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", :order => "c desc", :limit => 32) - - # Just hardcode some popular authorities for now - # ('tgq', 'atbra' is for debugging on Francis's development environment) - @popular_bodies = PublicBody.find(:all, :conditions => ["url_name in ( - 'bbc', - 'dwp', - 'dh', - 'snh', - 'royal_mail_group', - 'mod', - 'kent_county_council', - 'wirral_borough_council' - /* , 'tgq', 'atbra' */ - )"]).sort_by { |pb| pb.url_name }.reverse # just an order that looks better - + @popular_bodies = PublicBody.find(:all, :select => "*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", :order => "c desc", :limit => 32) # Get some successful requests # begin query = 'variety:response (status:successful OR status:partially_successful)' diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index e5f9a14f8..276ac70a7 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -7,19 +7,22 @@ <p> <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d <br>like information from. <strong>By law, they have to respond</strong> - (<a href="/help/about">why?</a>).') %> + (<a href="%s">why?</a>).') % help_about_url %> <br> <br> <%= text_field_tag 'query', params[:query], { :size => 30 } %> <%= hidden_field_tag 'bodies', 1 %> - <%= submit_tag "Search" %> + <%= submit_tag _('Search') %> <br> - e.g. <%=link_to 'Liverpool', search_url('liverpool', 'bodies')%>, <%=link_to 'MRSA', search_url('mrsa', 'bodies')%>, <%=link_to 'Treasury', search_url('treasury', 'bodies')%> + <%= _('e.g.') %> + <% @popular_bodies.each_with_index do |body, i| %> + <%=link_to body.name, search_url(body.name, 'bodies')%><% if i < 2 %>, <% else %>. <% break %><% end %> + <% end %> <br> <br> - OR, <strong>search</strong> for information others have requested using WhatDoTheyKnow.com + <%= _('OR, <strong>search</strong> for information others have requested using {{site_name}}', :site_name => site_name) %> </p> <% end %> </div> @@ -27,15 +30,15 @@ <div id="frontpage_examples"> <% if @popular_bodies.size > 0 %> <div id="examples_0"> - <ul> + <ul> <% for popular_body in @popular_bodies %> <li><%=public_body_link(popular_body)%> - <%=h popular_body.info_requests.count%> requests + <%= n_('%d request', '%d requests', popular_body.info_requests.count) % popular_body.info_requests.count %> </li> <% end%> </ul> <p><strong> - <%= link_to "More authorities...", list_public_bodies_default %> + <%= link_to _('More authorities...'), list_public_bodies_default %> </strong></p> </div> <% end %> @@ -45,11 +48,11 @@ <ul> <% for event in @successful_request_events %> <li><%=link_to h(excerpt(event.info_request.title, "", 30)), request_url(event.info_request)%> - <%=h time_ago_in_words(event.described_at).gsub("about ", "") %> ago + <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> </li> <% end %> </ul> - <p><strong><a href="/list/successful">More successful requests...</a></strong></p> + <p><strong><%=link_to _('More successful requests...'), request_list_successful_url %></strong></p> </div> <% end %> </div> |