diff options
Diffstat (limited to 'app')
23 files changed, 134 insertions, 117 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index eec684b0a..9f94b41b2 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -308,7 +308,7 @@ class AdminRequestController < AdminController post_redirect.save! url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true)) - 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." + 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) end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d8206fe76..2a2b29bfe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -560,7 +560,7 @@ class ApplicationController < ActionController::Base end def set_popup_banner - @popup_banner = render_to_string(:partial => "general/popup_banner").strip + @popup_banner = render_to_string(:partial => "general/popup_banner").strip.html_safe end # URL generating functions are needed by all controllers (for redirects), # views (for links) and mailers (for use in emails), so include them into diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index ecf865543..34870bd42 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -110,7 +110,6 @@ class GeneralController < ApplicationController # XXX Why is this so complicated with arrays and stuff? Look at the route # in config/routes.rb for comments. combined = params[:combined].split("/") - p params[:combined] @sortby = nil @bodies = @requests = @users = true if combined.size > 0 && (['advanced'].include?(combined[-1])) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index d13b2655f..573abac63 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -19,7 +19,6 @@ class HelpController < ApplicationController def contact @contact_email = Configuration::contact_email - @contact_email = @contact_email.gsub(/@/, "@") # if they clicked remove for link to request/body, remove it if params[:remove] diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 179c04e4e..162060d9b 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -333,7 +333,7 @@ class RequestController < ApplicationController message += _("<p>Your request contains a <strong>postcode</strong>. Unless it directly relates to the subject of your request, please remove any address as it will <strong>appear publicly on the Internet</strong>.</p>"); end if not message.empty? - flash.now[:error] = message + flash.now[:error] = message.html_safe end render :action => 'preview' return diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b9ba712a4..42f9d30f1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,15 +54,12 @@ module ApplicationHelper # Highlight words, also escapes HTML (other than spans that we add) def highlight_words(t, words, html = true) if html - t = h(t) - end - if html - t = highlight(t, words, '<span class="highlight">\1</span>') + highlight(h(t), words, '<span class="highlight">\1</span>').html_safe else - t = highlight(t, words, '*\1*') + highlight(t, words, '*\1*') end - return t end + def highlight_and_excerpt(t, words, excount, html = true) newt = excerpt(t, words[0], excount) if not newt diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb index 5e04c2761..8ee505ac8 100644 --- a/app/models/about_me_validator.rb +++ b/app/models/about_me_validator.rb @@ -17,10 +17,14 @@ class AboutMeValidator < ActiveRecord::BaseWithoutTable column :about_me, :text, "I...", false - def validate + # TODO: Switch to built in validations + validate :length_of_about_me + + private + + def length_of_about_me if !self.about_me.blank? && self.about_me.size > 500 errors.add(:about_me, _("Please keep it shorter than 500 characters")) end end - end diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 5e954e624..37eb3c176 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -28,12 +28,15 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable validates_presence_of :old_email, :message => N_("Please enter your old email address") validates_presence_of :new_email, :message => N_("Please enter your new email address") validates_presence_of :password, :message => N_("Please enter your password"), :unless => :changing_email + validate :password_and_format_of_email def changing_email() self.user_circumstance == 'change_email' end - def validate + private + + def password_and_format_of_email if !self.old_email.blank? && !MySociety::Validate.is_valid_email(self.old_email) errors.add(:old_email, _("Old email doesn't look like a valid address")) end diff --git a/app/models/comment.rb b/app/models/comment.rb index bcd1efca8..70f3ba00d 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -24,13 +24,13 @@ class Comment < ActiveRecord::Base strip_attributes! belongs_to :user - #validates_presence_of :user # breaks during construction of new ones :( - - validates_inclusion_of :comment_type, :in => [ 'request' ] belongs_to :info_request - has_many :info_request_events # in practice only ever has one + #validates_presence_of :user # breaks during construction of new ones :( + validates_inclusion_of :comment_type, :in => [ 'request' ] + validate :body_of_comment + def body ret = read_attribute(:body) if ret.nil? @@ -40,6 +40,7 @@ class Comment < ActiveRecord::Base ret = ret.gsub(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out ret end + def raw_body read_attribute(:body) end @@ -52,16 +53,6 @@ class Comment < ActiveRecord::Base end end - # Check have edited comment - def validate - if self.body.empty? || self.body =~ /^\s+$/ - errors.add(:body, _("Please enter your annotation")) - end - if !MySociety::Validate.uses_mixed_capitals(self.body) - errors.add(:body, _('Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')) - end - end - # Return body for display as HTML def get_body_for_html_display text = self.body.strip @@ -82,9 +73,21 @@ class Comment < ActiveRecord::Base return Comment.find(:first, :conditions => [ "info_request_id = ? and body = ?", info_request_id, body ]) end end - def for_admin_column - self.class.content_columns.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + + def for_admin_column + self.class.content_columns.each do |column| + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) + end + end + + private + + def body_of_comment + if self.body.empty? || self.body =~ /^\s+$/ + errors.add(:body, _("Please enter your annotation")) + end + if !MySociety::Validate.uses_mixed_capitals(self.body) + errors.add(:body, _('Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')) + end end - end end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index f70b8c0cb..229d3bf24 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -535,7 +535,7 @@ class IncomingMessage < ActiveRecord::Base text = Iconv.conv('utf-8//IGNORE', source_charset, text) + _("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]", :site_name => Configuration::site_name) - rescue Iconv::InvalidEncoding, Iconv::IllegalSequence + rescue Iconv::InvalidEncoding, Iconv::IllegalSequence, Iconv::InvalidCharacter if source_charset != "utf-8" source_charset = "utf-8" retry diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 23b5c904b..0c358a7c8 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -30,6 +30,7 @@ class OutgoingMessage < ActiveRecord::Base validates_inclusion_of :status, :in => ['ready', 'sent', 'failed'] validates_inclusion_of :message_type, :in => ['initial_request', 'followup' ] #, 'complaint'] + validate :format_of_body belongs_to :incoming_message_followup, :foreign_key => 'incoming_message_followup_id', :class_name => 'IncomingMessage' @@ -131,32 +132,6 @@ class OutgoingMessage < ActiveRecord::Base MySociety::Validate.contains_postcode?(self.body) end - # Check have edited letter - def validate - if self.body.empty? || self.body =~ /\A#{get_salutation}\s+#{get_signoff}/ || self.body =~ /#{get_internal_review_insert_here_note}/ - if self.message_type == 'followup' - if self.what_doing == 'internal_review' - errors.add(:body, _("Please give details explaining why you want a review")) - else - errors.add(:body, _("Please enter your follow up message")) - end - elsif - errors.add(:body, _("Please enter your letter requesting information")) - else - raise "Message id #{self.id} has type '#{self.message_type}' which validate can't handle" - end - end - if self.body =~ /#{get_signoff}\s*\Z/m - errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff })) - end - if !MySociety::Validate.uses_mixed_capitals(self.body) - errors.add(:body, _('Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.')) - end - if self.what_doing.nil? || !['new_information', 'internal_review', 'normal_sort'].include?(self.what_doing) - errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.')) - end - end - # Deliver outgoing message # Note: You can test this from script/console with, say: # InfoRequest.find(1).outgoing_messages[0].send_message @@ -278,6 +253,31 @@ class OutgoingMessage < ActiveRecord::Base self.body = get_default_message end end + + def format_of_body + if self.body.empty? || self.body =~ /\A#{get_salutation}\s+#{get_signoff}/ || self.body =~ /#{get_internal_review_insert_here_note}/ + if self.message_type == 'followup' + if self.what_doing == 'internal_review' + errors.add(:body, _("Please give details explaining why you want a review")) + else + errors.add(:body, _("Please enter your follow up message")) + end + elsif + errors.add(:body, _("Please enter your letter requesting information")) + else + raise "Message id #{self.id} has type '#{self.message_type}' which validate can't handle" + end + end + if self.body =~ /#{get_signoff}\s*\Z/m + errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff })) + end + if !MySociety::Validate.uses_mixed_capitals(self.body) + errors.add(:body, _('Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.')) + end + if self.what_doing.nil? || !['new_information', 'internal_review', 'normal_sort'].include?(self.what_doing) + errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.')) + end + end end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 1b254afcc..a06e0d253 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -35,7 +35,7 @@ class PublicBody < ActiveRecord::Base validates_uniqueness_of :short_name, :message => N_("Short name is already taken"), :if => Proc.new { |pb| pb.short_name != "" } validates_uniqueness_of :name, :message => N_("Name is already taken") - validate :validate_request_email_if_requestable + validate :request_email_if_requestable has_many :info_requests, :order => 'created_at desc' has_many :track_things, :order => 'created_at desc' @@ -634,7 +634,7 @@ class PublicBody < ActiveRecord::Base private - def validate_request_email_if_requestable + def request_email_if_requestable # Request_email can be blank, meaning we don't have details if self.is_requestable? unless MySociety::Validate.is_valid_email(self.request_email) diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 81800f0ae..dfe92b7fe 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -199,7 +199,8 @@ class TrackThing < ActiveRecord::Base if self.track_type == 'request_updates' @params = { # Website - :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_request}}', a request", + :link_to_request => ("<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this request"), :verb_on_page_already => _("You are already following this request"), # Email @@ -250,7 +251,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'public_body_updates' @params = { # Website - :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => ("<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)), :verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)), # Email @@ -266,7 +267,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'user_updates' @params = { # Website - :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_user}}', a person", :link_to_user => ("<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this person"), :verb_on_page_already => _("You are already following this person"), # Email @@ -282,7 +283,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'search_query' @params = { # Website - :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => ("<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + CGI.escapeHTML(self.track_query_description) + "</a>").html_safe, # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow things matching this search"), :verb_on_page_already => _("You are already following things matching this search"), # Email diff --git a/app/models/user.rb b/app/models/user.rb index bc04b5449..d16a9452a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -341,12 +341,13 @@ class User < ActiveRecord::Base end # Return about me text for display as HTML + # TODO: Move this to a view helper def get_about_me_for_html_display text = self.about_me.strip text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text, :contract => 1) text = text.gsub(/\n/, '<br>') - return text + return text.html_safe end def json_for_api diff --git a/app/views/admin_request/show_raw_email.rhtml b/app/views/admin_request/show_raw_email.rhtml index fa1470e77..ea0d6017e 100644 --- a/app/views/admin_request/show_raw_email.rhtml +++ b/app/views/admin_request/show_raw_email.rhtml @@ -33,5 +33,5 @@ <p><%= link_to "Download", "../download_raw_email/" + @raw_email.id.to_s %></p> -<pre><%=h(@raw_email.data).gsub(/\n/, '<br>') %></pre> +<pre><%= h(@raw_email.data).gsub(/\n/, '<br>').html_safe %></pre> diff --git a/app/views/general/_localised_datepicker.rhtml b/app/views/general/_localised_datepicker.rhtml index 5fdd63644..ec6593ea0 100644 --- a/app/views/general/_localised_datepicker.rhtml +++ b/app/views/general/_localised_datepicker.rhtml @@ -5,11 +5,11 @@ prevText: '<%= _("Prev") %>', nextText: '<%= _("Next") %>', currentText: '<%= _("Today") %>', - monthNames: <%= I18n.translate('date.month_names')[1..-1].to_json %>, - monthNamesShort: <%= I18n.translate('date.abbr_month_names')[1..-1].to_json %>, - dayNames: <%= I18n.translate('date.day_names').to_json %>, - dayNamesShort: <%= I18n.translate('date.abbr_day_names').to_json %>, - dayNamesMin: <%= I18n.translate('date.abbr_day_names').collect{|x| x[0..0]}.to_json %>, + monthNames: <%= raw I18n.translate('date.month_names')[1..-1].to_json %>, + monthNamesShort: <%= raw I18n.translate('date.abbr_month_names')[1..-1].to_json %>, + dayNames: <%= raw I18n.translate('date.day_names').to_json %>, + dayNamesShort: <%= raw I18n.translate('date.abbr_day_names').to_json %>, + dayNamesMin: <%= raw I18n.translate('date.abbr_day_names').collect{|x| x[0..0]}.to_json %>, weekHeader: '<%= _("Wk") %>', dateFormat: '<%= I18n.translate('date.formats.default').sub("%Y", "yy").sub("%m", "mm").sub("%d", "dd").gsub("-", "/") %>'} ); diff --git a/app/views/public_body/view_email.rhtml b/app/views/public_body/view_email.rhtml index 50601069f..79d7f7f4c 100644 --- a/app/views/public_body/view_email.rhtml +++ b/app/views/public_body/view_email.rhtml @@ -25,9 +25,9 @@ <p> <% if @public_body.is_requestable? || @public_body.not_requestable_reason != 'bad_contact' %> - <%= _('If the address is wrong, or you know a better address, please <a href="%s">contact us</a>.')% [help_contact_path]%> + <%= raw _('If the address is wrong, or you know a better address, please <a href="%s">contact us</a>.')% [help_contact_path]%> <% else %> - <%= _(' If you know the address to use, then please <a href="%s">send it to us</a>. + <%= raw _(' If you know the address to use, then please <a href="%s">send it to us</a>. You may be able to find the address on their website, or by phoning them up and asking.')% [help_contact_path] %> <% end %> </p> diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml index 451932b8d..045bcd9ba 100644 --- a/app/views/request/_followup.rhtml +++ b/app/views/request/_followup.rhtml @@ -1,5 +1,10 @@ <div id="followup"> <% if (incoming_message.nil? || !incoming_message.valid_to_reply_to?) + # TRANSLATORS: This phrase completes the following sentences: + # Request an internal review from... + # Send a public follow up message to... + # Send a public reply to... + # Don't want to address your message to... ? name_for_followup = _("the main FOI contact at {{public_body}}", :public_body => h(OutgoingMailer.name_for_followup(@info_request, nil))) else name_for_followup = h(OutgoingMailer.name_for_followup(@info_request, incoming_message)) @@ -8,16 +13,16 @@ <h1><%= _('Request an internal review from {{person_or_body}}', :person_or_body => name_for_followup) %> </h1> <% elsif incoming_message.nil? || !incoming_message.valid_to_reply_to? %> - <h2><%= _('Send a public follow up message to {{person_or_body}}', :person_or_body => name_for_followup) %> + <h2><%= _('Send a public follow up message to {{person_or_body}}', :person_or_body => name_for_followup) %> </h2> <% else %> - <h2><%= _('Send a public reply to {{person_or_body}}', :person_or_body => name_for_followup) %> + <h2><%= _('Send a public reply to {{person_or_body}}', :person_or_body => name_for_followup) %> </h2> <% end %> <% if @info_request.who_can_followup_to(incoming_message).count > 0 %> <div id="other_recipients"> - <%= _("Don't want to address your message to {{person_or_body}}? You can also write to:", :person_or_body => name_for_followup) %> - <ul> + <%= _("Don't want to address your message to {{person_or_body}}? You can also write to:", :person_or_body => name_for_followup) %> + <ul> <% @info_request.who_can_followup_to(incoming_message).each do |name, email, id| %> <% if id.nil? && !incoming_message.nil? && incoming_message.valid_to_reply_to? %> <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> @@ -51,7 +56,7 @@ <% end %> <p> - <%= _('Please <strong>only</strong> write messages directly relating to your request {{request_link}}. If you would like to ask for information that was not in your original request, then <a href="{{new_request_link}}">file a new request</a>.', :request_link=>request_link(@info_request), :new_request_link => new_request_to_body_url(:url_name => @info_request.public_body.url_name)) %> + <%= _('Please <strong>only</strong> write messages directly relating to your request {{request_link}}. If you would like to ask for information that was not in your original request, then <a href="{{new_request_link}}">file a new request</a>.', :request_link=>request_link(@info_request), :new_request_link => new_request_to_body_url(:url_name => @info_request.public_body.url_name)) %> </p> <% status = @info_request.calculate_status %> @@ -60,11 +65,11 @@ by law, the authority should normally have responded <strong>promptly</strong> and') %> <% if @info_request.public_body.is_school? %> - <%= _('in term time') %> + <%= _('in term time') %> <% end %> <%= _('by <strong>{{date}}</strong>',:date=>simple_date(@info_request.date_response_required_by)) %> (<%= raw(_('<a href="%s">details</a>') % ["#{help_requesting_path}#quickly_response"]) %>). - + </p> <% elsif status == 'waiting_response_very_overdue' %> <p> @@ -97,8 +102,8 @@ --> <div> <%= radio_button "outgoing_message", "what_doing", "internal_review", :id => "internal_review" %> - <label for="internal_review"><%= _('I am requesting an <strong>internal review</strong>') %> - <%= raw(_('<a href="%s">what\'s that?</a>') % ["/help/unhappy"]) %> + <label for="internal_review"><%= _('I am requesting an <strong>internal review</strong>') %> + <%= raw(_('<a href="%s">what\'s that?</a>') % ["/help/unhappy"]) %> </label> </div> <div> 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/_wall_listing.rhtml b/app/views/request/_wall_listing.rhtml index 9cde234c0..26d34e1a1 100644 --- a/app/views/request/_wall_listing.rhtml +++ b/app/views/request/_wall_listing.rhtml @@ -6,13 +6,13 @@ end %> <div class="request_left"> <div class="requester"> <% if event.event_type == 'sent' %> - <%= _('A new request, <em><a href="{{request_url}}">{{request_title}}</a></em>, was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:date=>simple_date(event.created_at),:request_url=>request_url(info_request),:request_title=>info_request.title) %> + <%= _('A new request, <em><a href="{{request_url}}">{{request_title}}</a></em>, was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>request_url(info_request),:request_title=>info_request.title) %> <% elsif event.event_type == 'followup_sent' %> - <%= _('A <a href="{{request_url}}">follow up</a> to <em>{{request_title}}</em> was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:date=>simple_date(event.created_at),:request_url=>outgoing_message_url(event.outgoing_message),:request_title=>info_request.title) %> + <%= _('A <a href="{{request_url}}">follow up</a> to <em>{{request_title}}</em> was sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>outgoing_message_url(event.outgoing_message),:request_title=>info_request.title) %> <% elsif event.event_type == 'response' %> - <%= _('A <a href="{{request_url}}">response</a> to <em>{{request_title}}</em> was sent by {{public_body_name}} to {{info_request_user}} on {{date}}. The request status is: {{request_status}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:date=>simple_date(event.created_at),:request_url=>incoming_message_url(event.incoming_message_selective_columns("incoming_messages.id")),:request_title=>info_request.title,:request_status=>info_request.display_status) %> + <%= _('A <a href="{{request_url}}">response</a> to <em>{{request_title}}</em> was sent by {{public_body_name}} to {{info_request_user}} on {{date}}. The request status is: {{request_status}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at),:request_url=>incoming_message_url(event.incoming_message_selective_columns("incoming_messages.id")),:request_title=>info_request.title,:request_status=>info_request.display_status) %> <% elsif event.event_type == 'comment' %> - <%= _('An <a href="{{request_url}}">annotation</a> to <em>{{request_title}}</em> was made by {{event_comment_user}} on {{date}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at),:request_url=>comment_url(event.comment),:request_title=>info_request.title) %> + <%= _('An <a href="{{request_url}}">annotation</a> to <em>{{request_title}}</em> was made by {{event_comment_user}} on {{date}}',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at),:request_url=>comment_url(event.comment),:request_title=>info_request.title) %> <% else %> <%# Events of other types will not be indexed: see InfoRequestEvent#indexed_by_search? However, it can happen that we see other types of event transiently here in the period @@ -22,7 +22,7 @@ end %> </div> </div> <div class="request_right"> - <span class="desc"> + <span class="desc"> <%= highlight_and_excerpt(event.search_text_main(true), @highlight_words, 150) %> </span> </div> diff --git a/app/views/request/upload_response.rhtml b/app/views/request/upload_response.rhtml index bc129426d..675951595 100644 --- a/app/views/request/upload_response.rhtml +++ b/app/views/request/upload_response.rhtml @@ -12,7 +12,7 @@ <h1><%= _('Respond to the FOI request')%> '<%=request_link(@info_request)%>'<% _(' made by ')%><%=user_link(@info_request.user) %></h1> <p> - <%= _('Your response will <strong>appear on the Internet</strong>, <a href="%s">read why</a> and answers to other questions.')% [help_officers_path] %> + <%= raw(_('Your response will <strong>appear on the Internet</strong>, <a href="%s">read why</a> and answers to other questions.') % [help_officers_path]) %> </p> <h2><%= _('Respond by email')%></h2> @@ -27,8 +27,8 @@ <h2><%= _('Respond using the web')%></h2> - <p><%= _('Enter your response below. You may attach one file (use email, or - <a href="%s">contact us</a> if you need more).')% [help_contact_path] %></p> + <p><%= raw(_('Enter your response below. You may attach one file (use email, or + <a href="%s">contact us</a> if you need more).')% [help_contact_path]) %></p> <% form_tag '', :id => 'upload_response_form', :multipart => true do %> <p> diff --git a/app/views/track/atom_feed.atom.builder b/app/views/track/atom_feed.atom.builder deleted file mode 100644 index d1e9310b8..000000000 --- a/app/views/track/atom_feed.atom.builder +++ /dev/null @@ -1,25 +0,0 @@ -atom_feed do |feed| - feed.title(@track_thing.params[:title_in_rss]) - @highlight_words = @xapian_object.words_to_highlight - - for result in @xapian_object.results - feed.entry(result[:model]) do |entry| - # Get the HTML content from the same partial template as website search does - content = '' - if result[:model].class.to_s == 'InfoRequestEvent' - content += render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } - else - content = "<p><strong>Unknown search result type " + result[:model].class.to_s + "</strong></p>" - end - # Pull out the heading as separate item, from the partial template - content.match(/(<span class="head">\s+<a href="[^>]*">(.*)<\/a>\s+<\/span>)/) - heading = $1 - heading_text = $2 - content.sub!(heading, "") - # Render the atom - entry.title(heading_text, :type => 'html') - entry.content(content, :type => 'html') - end - end -end - diff --git a/app/views/track/atom_feed.atom.erb b/app/views/track/atom_feed.atom.erb new file mode 100644 index 000000000..23c932308 --- /dev/null +++ b/app/views/track/atom_feed.atom.erb @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom"> + <id>tag:<%= request.host %>,2005:<%= request.fullpath.split(".")[0] %></id> + <link type="text/html" rel="alternate" href="<%= request.protocol + request.host_with_port %>"/> + <link type="application/atom+xml" rel="self" href="<%= request.url %>"/> + <title><%= @track_thing.params[:title_in_rss] %></title> + <% @xapian_object.results.each do |result| %> + <% + # Get the HTML content from the same partial template as website search does + content = '' + if result[:model].class.to_s == 'InfoRequestEvent' + content += render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } + else + content = "<p><strong>Unknown search result type " + result[:model].class.to_s + "</strong></p>" + end + # Pull out the heading as separate item, from the partial template + content.match(/(<span class="head">\s+<a href="[^>]*">(.*)<\/a>\s+<\/span>)/) + heading = $1 + heading_text = $2 + content.sub!(heading, "") + %> + <entry> + <id>tag:<%= request.host %>,2005:<%= result[:model].class %>/<%= result[:model].id %></id> + <published><%= result[:model].created_at.xmlschema %></published> + <link type="text/html" rel="alternate" href="<%= polymorphic_url(result[:model]) %>"/> + <title type="html"><%= heading_text %></title> + <content type="html"><%= content %></content> + </entry> + <% end %> +</feed> |