diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/admin_user_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/api_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 2 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 29 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 12 | ||||
-rw-r--r-- | app/models/track_mailer.rb | 2 | ||||
-rw-r--r-- | app/views/admin_general/index.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_general/stats.rhtml | 4 | ||||
-rw-r--r-- | app/views/admin_general/timeline.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_public_body/_tags.rhtml | 4 | ||||
-rw-r--r-- | app/views/admin_public_body/show.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_user/show.rhtml | 6 | ||||
-rw-r--r-- | app/views/api/request_events.atom.builder | 4 | ||||
-rw-r--r-- | app/views/contact_mailer/to_admin_message.rhtml | 6 | ||||
-rw-r--r-- | app/views/help/unhappy.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/admin.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 2 | ||||
-rw-r--r-- | app/views/track_mailer/event_digest.rhtml | 8 |
21 files changed, 45 insertions, 62 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index c631c88f9..49f40b098 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -297,12 +297,12 @@ class AdminRequestController < AdminController end # Bejeeps, look, sometimes a URL is something that belongs in a controller, jesus. - # XXX hammer this square peg into the round MVC hole - should be calling main_url(upload_response_url()) + # XXX hammer this square peg into the round MVC hole post_redirect = PostRedirect.new( - :uri => main_url(upload_response_url(:url_title => info_request.url_title, :only_path => true)), + :uri => upload_response_url(:url_title => info_request.url_title), :user_id => user.id) post_redirect.save! - url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true)) + url = confirm_url(:email_token => post_redirect.email_token) flash[:notice] = 'Send "' + name + '" <<a href="mailto:' + email + '">' + email + '</a>> this URL: <a href="' + url + '">' + url + "</a> - it will log them in and let them upload a response to this request.".html_safe redirect_to request_admin_url(info_request) diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb index 52f7f330c..1478cb21f 100644 --- a/app/controllers/admin_user_controller.rb +++ b/app/controllers/admin_user_controller.rb @@ -72,9 +72,9 @@ class AdminUserController < AdminController def login_as @admin_user = User.find(params[:id]) # check user does exist - post_redirect = PostRedirect.new( :uri => main_url(user_path(@admin_user)), :user_id => @admin_user.id, :circumstance => "login_as" ) + post_redirect = PostRedirect.new( :uri => user_url(@admin_user), :user_id => @admin_user.id, :circumstance => "login_as" ) post_redirect.save! - url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true)) + url = confirm_url(:email_token => post_redirect.email_token) redirect_to url end diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index aa1ea632f..5d8ceb888 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -220,7 +220,7 @@ class ApiController < ApplicationController :event_id => event.id, :created_at => event.created_at.iso8601, :event_type => event.event_type, - :request_url => main_url(request_path(request)), + :request_url => request_url(request), :request_email => request.incoming_email, :title => request.title, :body => event.outgoing_message.body, @@ -228,7 +228,7 @@ class ApiController < ApplicationController :user_name => request.user_name, } if request.user - this_event[:user_url] = main_url(user_path(request.user)) + this_event[:user_url] = user_url(request.user) end @event_data.push(this_event) diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 8a4a65820..e304f0776 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -31,7 +31,7 @@ class PublicBodyController < ApplicationController set_last_body(@public_body) - top_url = main_url("/") + top_url = frontpage_url @searched_to_send_request = false referrer = request.env['HTTP_REFERER'] if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$}) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 22d5571ae..fc8b6e014 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -422,7 +422,7 @@ class UserController < ApplicationController ContactMailer.deliver_user_message( @user, @recipient_user, - main_url(user_path(@user)), + user_url(@user), params[:contact][:subject], params[:contact][:message] ) diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 7d0dd7766..6e0a6f355 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -31,7 +31,7 @@ module LinkToHelper end def request_both_links(info_request) - link_to(h(info_request.title), main_url(request_path(info_request))) + " (" + link_to("admin", request_admin_url(info_request)) + ")" + link_to(h(info_request.title), request_url(info_request)) + " (" + link_to("admin", request_admin_url(info_request)) + ")" end def request_similar_url(info_request) @@ -60,7 +60,7 @@ module LinkToHelper end def comment_url(comment, options = {}) - return request_path(comment.info_request, options.merge(:anchor => "comment-#{comment.id}")) + request_url(comment.info_request, options.merge(:anchor => "comment-#{comment.id}")) end def comment_path(comment) @@ -99,7 +99,7 @@ module LinkToHelper end def public_body_link_absolute(public_body) # e.g. for in RSS - link_to h(public_body.name), main_url(public_body_path(public_body)) + link_to h(public_body.name), public_body_url(public_body) end def public_body_admin_url(public_body) @@ -107,7 +107,7 @@ module LinkToHelper end def public_body_both_links(public_body) - link_to(h(public_body.name), main_url(public_body_path(public_body))) + " (" + link_to("admin", public_body_admin_url(public_body)) + ")" + link_to(h(public_body.name), public_body_url(public_body)) + " (" + link_to("admin", public_body_admin_url(public_body)) + ")" end # Users @@ -146,7 +146,7 @@ module LinkToHelper end def user_link_absolute(user) - link_to h(user.name), main_url(user_path(user)) + link_to h(user.name), user_url(user) end def user_link(user) @@ -198,7 +198,7 @@ module LinkToHelper end def user_both_links(user) - link_to(h(user.name), main_url(user_path(user))) + " (" + link_to("admin", user_admin_url(user)) + ")" + link_to(h(user.name), user_url(user)) + " (" + link_to("admin", user_admin_url(user)) + ")" end # Tracks. feed can be 'track' or 'feed' @@ -279,23 +279,6 @@ module LinkToHelper end end - - def main_url(relative_path, append = nil) - url_prefix = "http://" + Configuration::domain - url = url_prefix + relative_path - if !append.nil? - begin - env = Rack::MockRequest.env_for(url) - req = Rack::Request.new(env) - req.path_info += append - url = req.url - rescue URI::InvalidURIError - # don't append to it - end - end - return url - end - # Basic date format def simple_date(date) date = date.in_time_zone.to_date unless date.is_a? Date diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index f42c3b0c7..3be68ba24 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -67,7 +67,7 @@ class RequestMailer < ApplicationMailer @from = user.name_and_email @recipients = contact_from_name_and_email @subject = _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title) - url = main_url(request_path(info_request)) + url = request_url(info_request) admin_url = request_admin_url(info_request) @body = {:reported_by => user, :info_request => info_request, :url => url, :admin_url => admin_url } end @@ -76,7 +76,7 @@ class RequestMailer < ApplicationMailer def new_response(info_request, incoming_message) # Don't use login link here, just send actual URL. This is # because people tend to forward these emails amongst themselves. - url = main_url(incoming_message_url(incoming_message)) + url = incoming_message_url(incoming_message) @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken @@ -131,7 +131,7 @@ class RequestMailer < ApplicationMailer # Make a link going to the form to describe state, and which logs the # user in. post_redirect = PostRedirect.new( - :uri => main_url(request_path(info_request)) + "#describe_state_form_1", + :uri => request_url(info_request) + "#describe_state_form_1", :user_id => info_request.user.id) post_redirect.save! url = confirm_url(:email_token => post_redirect.email_token) @@ -153,7 +153,7 @@ class RequestMailer < ApplicationMailer 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = _("Someone has updated the status of your request") - url = main_url(request_path(info_request)) + url = request_url(info_request) @body = {:info_request => info_request, :url => url} end @@ -185,7 +185,7 @@ class RequestMailer < ApplicationMailer 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = _("Somebody added a note to your FOI request - ") + info_request.title - @body = { :comment => comment, :info_request => info_request, :url => main_url(comment_url(comment)) } + @body = { :comment => comment, :info_request => info_request, :url => comment_url(comment) } end def comment_on_alert_plural(info_request, count, earliest_unalerted_comment) @from = contact_from_name_and_email @@ -194,7 +194,7 @@ class RequestMailer < ApplicationMailer 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = _("Some notes have been added to your FOI request - ") + info_request.title - @body = { :count => count, :info_request => info_request, :url => main_url(comment_url(earliest_unalerted_comment)) } + @body = { :count => count, :info_request => info_request, :url => comment_url(earliest_unalerted_comment) } end # Class function, called by script/mailin with all incoming responses. diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index fe01f1c52..51440e4d7 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -7,7 +7,7 @@ class TrackMailer < ApplicationMailer def event_digest(user, email_about_things) post_redirect = PostRedirect.new( - :uri => main_url(user_path(user)) + "#email_subscriptions", + :uri => user_url(user) + "#email_subscriptions", :user_id => user.id) post_redirect.save! unsubscribe_url = confirm_url(:email_token => post_redirect.email_token) diff --git a/app/views/admin_general/index.rhtml b/app/views/admin_general/index.rhtml index eddd216d7..a7dfba90f 100644 --- a/app/views/admin_general/index.rhtml +++ b/app/views/admin_general/index.rhtml @@ -98,7 +98,7 @@ </ul> <p>(<%= link_to "Full list", admin_url("unclassified") %>, or play public - <%= link_to "Categorisation game", main_url(categorise_play_url(:only_path => true)) %>) + <%= link_to "Categorisation game", categorise_play_url(:only_path => true) %>) </p> <% end %> diff --git a/app/views/admin_general/stats.rhtml b/app/views/admin_general/stats.rhtml index b22adb581..27a52a74b 100644 --- a/app/views/admin_general/stats.rhtml +++ b/app/views/admin_general/stats.rhtml @@ -5,7 +5,7 @@ <h2>Chart of requests (excluding backpaged)</h2> <p> - <img src="<%= main_url("/foi-live-creation.png")%>"> + <img src="/foi-live-creation.png"> </p> <h2>State of requests (includes backpaged)</h2> @@ -19,7 +19,7 @@ <h2>Chart of users</h2> <p> - <img src="<%= main_url("/foi-user-use.png")%>"> + <img src="/foi-user-use.png"> </p> <h2>Tracks by type</h2> diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.rhtml index e84539970..57ded629a 100644 --- a/app/views/admin_general/timeline.rhtml +++ b/app/views/admin_general/timeline.rhtml @@ -72,7 +72,7 @@ <% elsif event.event_type == 'response' %> <% incoming_message = event.incoming_message %> received - <%= link_to 'a response', main_url(incoming_message_url(incoming_message)) %> + <%= link_to 'a response', incoming_message_url(incoming_message) %> from <%=h event.info_request.public_body.name %>. <% elsif event.event_type == 'sent' %> was initially sent to <%=h event.params[:email]%> at <%=h event.info_request.public_body.name %>. diff --git a/app/views/admin_public_body/_tags.rhtml b/app/views/admin_public_body/_tags.rhtml index 85dc942fd..6172e0864 100644 --- a/app/views/admin_public_body/_tags.rhtml +++ b/app/views/admin_public_body/_tags.rhtml @@ -1,8 +1,8 @@ <% for t in body.tags %> <% if t.value %> - <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %>:<%= link_to(h(t.value), main_url(list_public_bodies_url(:tag => t.name_and_value, :only_path => true))) %> + <%= link_to(h(t.name), list_public_bodies_url(:tag => t.name)) %>:<%= link_to(h(t.value), list_public_bodies_url(:tag => t.name_and_value)) %> <% else %> - <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %> + <%= link_to(h(t.name), list_public_bodies_url(:tag => t.name)) %> <% end %> (<a href="<%= admin_url('body/list') %>?query=<%= h(t.name)%>">admin</a>) <% end %> diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml index 61ac668dd..712ab083c 100644 --- a/app/views/admin_public_body/show.rhtml +++ b/app/views/admin_public_body/show.rhtml @@ -35,7 +35,7 @@ <%= # url_name can be missing if the name hasn't been set for this locale if !@public_body.url_name.nil? - link_to 'Public page', main_url(public_body_path(@public_body)) + link_to 'Public page', public_body_url(@public_body) else 'Public page not available' end diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 825c0e6f7..f9d6bdac8 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -54,7 +54,7 @@ <% end %> <p> - <%= link_to 'Public page', main_url(request_path(@info_request)) %> + <%= link_to 'Public page', request_url(@info_request) %> | <%= link_to 'Edit', '../edit/' + @info_request.id.to_s %> | <%= link_to 'FOI officer upload URL', '../generate_upload_url/' + @info_request.id.to_s %> (see also links on incoming messages below) </p> diff --git a/app/views/admin_user/show.rhtml b/app/views/admin_user/show.rhtml index f6f2a0ae0..7dd849df5 100644 --- a/app/views/admin_user/show.rhtml +++ b/app/views/admin_user/show.rhtml @@ -5,7 +5,7 @@ <% if @admin_user.profile_photo %> <div class="user_photo_on_admin"> <% form_tag '../clear_profile_photo/' + @admin_user.id.to_s, :multipart => true do %> - <img src="<%= main_url(get_profile_photo_url(:url_name => @admin_user.url_name, :only_path => true)) %>"> + <img src="<%= get_profile_photo_url(:url_name => @admin_user.url_name) %>"> <br> <%= submit_tag "Clear photo" %> <% end %> @@ -34,7 +34,7 @@ </div> <p> - <%= link_to 'Public page', main_url(user_path(@admin_user)) %> + <%= link_to 'Public page', user_url(@admin_user) %> | <%= link_to 'Edit', '../edit/' + @admin_user.id.to_s %> | <%= link_to 'Log in as this user', '../login_as/' + @admin_user.id.to_s %> (also confirms their email) </p> @@ -57,7 +57,7 @@ <td><%=h post_redirect.id %></td> <% for column in PostRedirect.content_columns.map { |c| c.name } %> <% if column == 'email_token' %> - <td><%=link_to post_redirect.send(column), main_url(confirm_url(:email_token => post_redirect.send(column), :only_path => true)) %></td> + <td><%=link_to post_redirect.send(column), confirm_url(:email_token => post_redirect.send(column)) %></td> <% else %> <td><%=h post_redirect.send(column) %></td> <% end %> diff --git a/app/views/api/request_events.atom.builder b/app/views/api/request_events.atom.builder index 3d46e5376..648a81e5c 100644 --- a/app/views/api/request_events.atom.builder +++ b/app/views/api/request_events.atom.builder @@ -8,7 +8,7 @@ atom_feed("xmlns:alaveteli" => "http://www.alaveteli.org/API/v2/RequestEvents/At entry.updated(event.created_at.utc.iso8601) entry.tag!("alaveteli:event_type", event.event_type) - entry.tag!("alaveteli:request_url", main_url(request_path(request))) + entry.tag!("alaveteli:request_url", request_url(request)) entry.title(request.title) entry.content(event.outgoing_message.body, :type => 'text') @@ -16,7 +16,7 @@ atom_feed("xmlns:alaveteli" => "http://www.alaveteli.org/API/v2/RequestEvents/At entry.author do |author| author.name(request.user_name) if !request.user.nil? - author.uri(main_url(user_path(request.user))) + author.uri(user_url(request.user)) end author.email(request.incoming_email) end diff --git a/app/views/contact_mailer/to_admin_message.rhtml b/app/views/contact_mailer/to_admin_message.rhtml index d5aa6ac7c..4c0e5a800 100644 --- a/app/views/contact_mailer/to_admin_message.rhtml +++ b/app/views/contact_mailer/to_admin_message.rhtml @@ -2,10 +2,10 @@ --------------------------------------------------------------------- <%= _('Message sent using {{site_name}} contact form, ', :site_name=>site_name)%> -<%=(@logged_in_user ? ("logged in as user " + main_url(user_path(@logged_in_user))) : "not logged in")%><% if !@last_request.nil? %> +<%=(@logged_in_user ? ("logged in as user " + user_url(@logged_in_user)) : "not logged in")%><% if !@last_request.nil? %> -<%= _('Last request viewed: ')%><%= main_url(request_path(@last_request)) %> +<%= _('Last request viewed: ')%><%= request_url(@last_request) %> <% end %> <% if !@last_body.nil? %> -<%= _('Last authority viewed: ')%><%= main_url(public_body_path(@last_body)) %> +<%= _('Last authority viewed: ')%><%= public_body_url(@last_body) %> <% end %>--------------------------------------------------------------------- diff --git a/app/views/help/unhappy.rhtml b/app/views/help/unhappy.rhtml index 80a4ce779..79e3f8273 100644 --- a/app/views/help/unhappy.rhtml +++ b/app/views/help/unhappy.rhtml @@ -62,7 +62,7 @@ to the Scottish Information Commissioner</a>. Information Commissioner, either <% if !@info_request.nil? %> include a link to your request - <strong><%=h main_url(request_path(@info_request)) %></strong> + <strong><%=h request_url(@info_request) %></strong> <% else %> include a link to your request on <%= site_name %> <% end %> diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index d85eecbf2..a9bc0556b 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -12,7 +12,7 @@ <body class="admin"> <p> - <strong><%= link_to 'Alaveteli', main_url('/') %> admin:</strong> + <strong><%= link_to 'Alaveteli', frontpage_url %> admin:</strong> <%= link_to 'Summary', admin_url("") %> | <%= link_to 'Timeline', admin_url("timeline") %> | <%= link_to 'Stats', admin_url("stats") %> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 216e50e7a..fffb3d061 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -32,7 +32,7 @@ <% end %> <% end %> <% if @has_json %> - <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h main_url(request.request_uri, '.json') %>"> + <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.query_parameters.merge(:format => 'json')) %>"> <% end %> <% if @no_crawl %> diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml index dc8132b99..8dbc7fe06 100644 --- a/app/views/track_mailer/event_digest.rhtml +++ b/app/views/track_mailer/event_digest.rhtml @@ -17,17 +17,17 @@ # e.g. Julian Burgess sent a request to Royal Mail Group (15 May 2008) if event.event_type == 'response' - url = main_url(incoming_message_url(event.incoming_message)) + url = incoming_message_url(event.incoming_message) main_text += _("{{public_body}} sent a response to {{user_name}}", :public_body => event.info_request.public_body.name, :user_name => event.info_request.user_name) elsif event.event_type == 'followup_sent' - url = main_url(outgoing_message_url(event.outgoing_message)) + url = outgoing_message_url(event.outgoing_message) main_text += _("{{user_name}} sent a follow up message to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'sent' # this is unlikely to happen in real life, but happens in the test code - url = main_url(outgoing_message_url(event.outgoing_message)) + url = outgoing_message_url(event.outgoing_message) main_text += _("{{user_name}} sent a request to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'comment' - url = main_url(comment_url(event.comment)) + url = comment_url(event.comment) main_text += _("{{user_name}} added an annotation", :user_name => event.comment.user.name) else raise "unknown type in event_digest " + event.event_type |