diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 30 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 3 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 8 | ||||
-rw-r--r-- | app/views/admin_general/debug.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_frontpage_search_box.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_locale_switcher.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/exception_caught.rhtml | 4 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 2 | ||||
-rw-r--r-- | app/views/public_body/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/_sidebar.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/select_authority.rhtml | 2 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 2 |
15 files changed, 28 insertions, 45 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ed1523f75..f3deeb64a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -456,11 +456,7 @@ class ApplicationController < ActionController::Base end end - def param_exists(item) - return params[item] && !params[item].empty? - end - - def get_request_variety_from_params + def get_request_variety_from_params(params) query = "" sortby = "newest" varieties = [] @@ -482,7 +478,7 @@ class ApplicationController < ActionController::Base return query end - def get_status_from_params + def get_status_from_params(params) query = "" if params[:latest_status] statuses = [] @@ -517,24 +513,24 @@ class ApplicationController < ActionController::Base return query end - def get_date_range_from_params + def get_date_range_from_params(params) query = "" - if param_exists(:request_date_after) && !param_exists(:request_date_before) + if params.has_key?(:request_date_after) && !params.has_key?(:request_date_before) params[:request_date_before] = Time.now.strftime("%d/%m/%Y") query += " #{params[:request_date_after]}..#{params[:request_date_before]}" - elsif !param_exists(:request_date_after) && param_exists(:request_date_before) + elsif !params.has_key?(:request_date_after) && params.has_key?(:request_date_before) params[:request_date_after] = "01/01/2001" end - if param_exists(:request_date_after) + if params.has_key?(:request_date_after) query = " #{params[:request_date_after]}..#{params[:request_date_before]}" end return query end - def get_tags_from_params + def get_tags_from_params(params) query = "" tags = [] - if param_exists(:tags) + if params.has_key?(:tags) params[:tags].split().each do |tag| tags << "tag:#{tag}" end @@ -545,12 +541,12 @@ class ApplicationController < ActionController::Base return query end - def make_query_from_params + def make_query_from_params(params) query = params[:query] || "" if query.nil? - query += get_date_range_from_params - query += get_request_variety_from_params - query += get_status_from_params - query += get_tags_from_params + query += get_date_range_from_params(params) + query += get_request_variety_from_params(params) + query += get_status_from_params(params) + query += get_tags_from_params(params) return query end diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 875e39494..a8bbc22ff 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -151,10 +151,10 @@ class GeneralController < ApplicationController params[:query] = @query end if @variety_postfix != "all" && @requests - @query, _ = make_query_from_params + @query, _ = make_query_from_params(params) end @inputted_sortby = @sortby - @common_query = get_tags_from_params + @common_query = get_tags_from_params(params) if @sortby.nil? # Parse query, so can work out if it has prefix terms only - if so then it is a # structured query which should show newest first, rather than a free text search diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 8a4a65820..1bcc0145c 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -25,7 +25,7 @@ class PublicBodyController < ApplicationController end # If found by historic name, or alternate locale name, redirect to new name if @public_body.url_name != params[:url_name] - redirect_to show_public_body_url(:url_name => @public_body.url_name) + redirect_to :url_name => @public_body.url_name return end @@ -38,9 +38,7 @@ class PublicBodyController < ApplicationController @searched_to_send_request = true end @view = params[:view] - params[:latest_status] = @view - - query = make_query_from_params + query = make_query_from_params(params.merge(:latest_status => @view)) query += " requested_from:#{@public_body.url_name}" # Use search query for this so can collapse and paginate easily # XXX really should just use SQL query here rather than Xapian. diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index dfa3a4834..6b8444f90 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -174,8 +174,7 @@ class RequestController < ApplicationController raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.") end - params[:latest_status] = @view - query = make_query_from_params + query = make_query_from_params(params.merge(:latest_status => @view)) @title = _("View and search requests") sortby = "newest" xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 030fab20b..42c1e0549 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -269,13 +269,5 @@ module LinkToHelper def year_from_date(date) return date.strftime("%Y").strip end - - #I18n locale switcher - - def locale_switcher(locale, params) - params['locale'] = locale - return url_for(params) - end - end diff --git a/app/views/admin_general/debug.rhtml b/app/views/admin_general/debug.rhtml index 99488ba0c..b0749bedb 100644 --- a/app/views/admin_general/debug.rhtml +++ b/app/views/admin_general/debug.rhtml @@ -20,8 +20,6 @@ Rails::VERSION::STRING <%=h Rails::VERSION::STRING%> TMail::VERSION::STRING <%=h TMail::VERSION::STRING%> <br> Xapian::version_string <%=h Xapian::version_string%> -<br> -Spec::VERSION::STRING <%=h Spec::VERSION::STRING%> </p> <h2>Configuration</h2> diff --git a/app/views/general/_frontpage_search_box.rhtml b/app/views/general/_frontpage_search_box.rhtml index d2718b3a3..890602416 100644 --- a/app/views/general/_frontpage_search_box.rhtml +++ b/app/views/general/_frontpage_search_box.rhtml @@ -6,7 +6,7 @@ </h2> <form id="search_form" method="post" action="<%= search_redirect_path %>"> <div> - <input id="query" type="text" size="30" name="query"> + <input id="query" type="text" size="30" name="query" title="type your search term here" > <input type="submit" value="<%= _('Search') %>"> </div> </form> diff --git a/app/views/general/_locale_switcher.rhtml b/app/views/general/_locale_switcher.rhtml index 2521b5eb5..d0040bb0d 100644 --- a/app/views/general/_locale_switcher.rhtml +++ b/app/views/general/_locale_switcher.rhtml @@ -5,7 +5,7 @@ <% if possible_locale == I18n.locale.to_s %> <a href="#" class="btn disabled"><%= locale_name(possible_locale) %></a> <% else %> - <a href="<%= locale_switcher(possible_locale, params) %>" class="btn"><%= locale_name(possible_locale) %></a> + <a href="<%= url_for params.merge(:locale => possible_locale) %>" class="btn"><%= locale_name(possible_locale) %></a> <% end %> <% end %> </div> diff --git a/app/views/general/exception_caught.rhtml b/app/views/general/exception_caught.rhtml index 5f0dfe13d..f8fe4343b 100644 --- a/app/views/general/exception_caught.rhtml +++ b/app/views/general/exception_caught.rhtml @@ -7,8 +7,8 @@ <ul> <li><%= _("Check for mistakes if you typed or copied the address.")%></li> <li><%= _("Search the site to find what you were looking for.")%> - <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form"}) do %> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> + <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form" }) do %> + <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %> <%= submit_tag _("Search") %> <% end %> </li> diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index 6df12d980..7d402b9b9 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -37,7 +37,7 @@ <% else %> <% form_tag(request.url, {:method => "get", :id => "search_form"}) do %> <p> - <%= text_field_tag 'query', params[:query], { :size => 40 } %> + <%= text_field_tag 'query', params[:query], { :size => 40, :title => "type your search term here" } %> <%= hidden_field_tag 'sortby', @inputted_sortby %> <% if @bodies %> <%= hidden_field_tag 'bodies', 1 %> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 6ac7064a7..9eb967578 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -102,7 +102,7 @@ <div id="navigation_search"> <form id="navigation_search_form" method="post" action="<%= search_redirect_path %>"> <p> - <%= text_field_tag 'query', params[:query], { :size => 40, :id => "navigation_search_query" } %> + <%= text_field_tag 'query', params[:query], { :size => 40, :id => "navigation_search_query", :title => "type your search term here" } %> <input id="navigation_search_button" type="submit" value="search"> </p> </form> diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml index 94fbb759c..dd97b99fd 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.rhtml @@ -34,7 +34,7 @@ <% form_tag(list_public_bodies_default_url, :method => "get", :id=>"search_form") do %> <div> - <%= text_field_tag(:public_body_query, params[:public_body_query]) %> + <%= text_field_tag(:public_body_query, params[:public_body_query], { :title => "type your search term here" } ) %> <%= submit_tag(_("Search")) %> </div> <% end %> diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml index 5e0c6fd2d..884d4b2b1 100644 --- a/app/views/request/_sidebar.rhtml +++ b/app/views/request/_sidebar.rhtml @@ -4,7 +4,7 @@ <% follower_count = TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 %> <p><%= n_("There is %d person following this request", "There are %d people following this request", follower_count) % follower_count %></p> - <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user == @user, :location => 'sidebar' } %> + <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user && @info_request.user == @user, :location => 'sidebar' } %> </div> <% if @info_request.described_state != "attention_requested" %> <h2><%= _('Offensive? Unsuitable?') %></h2> diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml index 652c24da9..df0498d6a 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.rhtml @@ -37,7 +37,7 @@ like information from. <strong>By law, they have to respond</strong> (<a href="%s#%s">why?</a>).') % [help_about_url, "whybother_them"]) %> </p> - <%= text_field_tag 'query', params[:query], { :size => 30 } %> + <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %> <%= hidden_field_tag 'bodies', 1 %> <%= submit_tag _('Search') %> </div> diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 31ea2a70b..9d8bf6f2f 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -109,7 +109,7 @@ <div id="user_profile_search"> <% form_tag(show_user_url, :method => "get", :id=>"search_form") do %> <div> - <%= text_field_tag(:user_query, params[:user_query]) %> + <%= text_field_tag(:user_query, params[:user_query], {:title => "type your search term here" }) %> <% if @is_you %> <%= submit_tag(_("Search your contributions")) %> <% else %> |