diff options
-rw-r--r-- | app/controllers/request_controller.rb | 2 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 5 | ||||
-rw-r--r-- | app/models/info_request.rb | 2 | ||||
-rw-r--r-- | app/views/general/_frontpage_intro_sentence.rhtml | 3 | ||||
-rw-r--r-- | app/views/general/blog.rhtml | 7 | ||||
-rw-r--r-- | app/views/general/frontpage.rhtml | 4 | ||||
-rw-r--r-- | app/views/help/_why_they_should_reply_by_email.rhtml | 3 | ||||
-rw-r--r-- | app/views/request/_view_html_prefix.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/show_response.rhtml | 4 | ||||
-rw-r--r-- | app/views/user/set_profile_about_me.rhtml | 2 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 2 | ||||
-rw-r--r-- | config/general.yml-example | 3 | ||||
-rwxr-xr-x | script/compact-xapian-database | 29 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 14 |
15 files changed, 57 insertions, 27 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index dff03983b..42d54a403 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -393,7 +393,7 @@ class RequestController < ApplicationController flash[:notice] = _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(@info_request.date_response_required_by)) redirect_to request_url(@info_request) elsif @info_request.calculate_status == 'waiting_response_very_overdue' - flash[:notice] = _("<p>Thank you! Your request is long overdue, by more than 40 working days. Most requests should be answered within 20 working days. You might like to complain about this, see below.</p>") + flash[:notice] = _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40), :late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20)) redirect_to unhappy_url(@info_request) elsif @info_request.calculate_status == 'not_held' flash[:notice] = _("<p>Thank you! Here are some ideas on what to do next:</p> diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index ae7d1201e..b0b02fdda 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -569,7 +569,8 @@ class IncomingMessage < ActiveRecord::Base text.gsub!(/(Complaints and Corporate Affairs Officer)\s+Westminster Primary Care Trust.+/ms, "\\1") # Remove WhatDoTheyKnow signup links - text.gsub!(/http:\/\/www.whatdotheyknow.com\/c\/[^\s]+/, "[WDTK login link]") + domain = MySociety::Config.get('DOMAIN') + text.gsub!(/http:\/\/#{domain}\/c\/[^\s]+/, "[WDTK login link]") # Remove Home Office survey links # e.g. http://www.whatdotheyknow.com/request/serious_crime_act_2007_section_7#incoming-12650 @@ -1134,7 +1135,7 @@ class IncomingMessage < ActiveRecord::Base elsif content_type == 'text/html' # lynx wordwraps links in its output, which then don't get formatted properly # by Alaveteli. We use elinks instead, which doesn't do that. - external_command("/usr/bin/elinks", "-dump-charset", "utf-8", "-force-html", "-dump", + external_command("/usr/bin/elinks", "-eval", "'set document.codepage.assume = \"utf-8\"'", "-dump-charset", "utf-8", "-force-html", "-dump", tempfile.path, :append_to => text) elsif content_type == 'application/vnd.ms-excel' # Bit crazy using /usr/bin/strings - but xls2csv, xlhtml and diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 419546c99..c667e1499 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -651,6 +651,8 @@ public # days is a very long time. def date_very_overdue_after last_sent = last_event_forming_initial_request + very_late_days_later = MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40) + school_very_late_days_later = MySociety::Config.get('SPECIAL_REPLY_VERY_LATE_AFTER_DAYS', 60) if self.public_body.is_school? # schools have 60 working days maximum (even over a long holiday) return Holiday.due_date_from(self.date_initial_request_last_sent_at, 60) diff --git a/app/views/general/_frontpage_intro_sentence.rhtml b/app/views/general/_frontpage_intro_sentence.rhtml new file mode 100644 index 000000000..2c3bcaf83 --- /dev/null +++ b/app/views/general/_frontpage_intro_sentence.rhtml @@ -0,0 +1,3 @@ +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_url %>">why?</a>). diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.rhtml index cbd37240e..c9387c24f 100644 --- a/app/views/general/blog.rhtml +++ b/app/views/general/blog.rhtml @@ -1,8 +1,8 @@ <% @title = "#{site_name} blog and tweets" %> <h1><%=@title %></h1> - <img src="/images/twitter.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/whatdotheyknow">Follow us on twitter</a> - <img src="/images/rss.png" alt="RSS icon" valign="middle"> <a href="http://www.mysociety.org/category/projects/whatdotheyknow/feed/">Subscribe to blog</a> + <img src="/images/twitter.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">Follow us on twitter</a> + <img src="/images/rss.png" alt="RSS icon" valign="middle"> <a href="<%= MySociety::Config.get('BLOG_FEED') %>">Subscribe to blog</a> <% if !@twitter_user.empty? %> <div id="twitter"> <script src="http://widgets.twimg.com/j/2/widget.js"></script> @@ -52,8 +52,5 @@ new TWTR.Widget({ </p> </div> <% end %> - <p> - <a href="http://www.mysociety.org/category/projects/whatdotheyknow/">All blog posts</a> - </p> </div> diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index e8e5d8634..abed0294e 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -5,9 +5,7 @@ <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %> <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="%s">why?</a>).') % help_about_url %> + <%= render :partial => 'frontpage_intro_sentence' %> <br> <br> diff --git a/app/views/help/_why_they_should_reply_by_email.rhtml b/app/views/help/_why_they_should_reply_by_email.rhtml new file mode 100644 index 000000000..faaa2b2e2 --- /dev/null +++ b/app/views/help/_why_they_should_reply_by_email.rhtml @@ -0,0 +1,3 @@ +The law, the Ministry of Justice and the Information Commissioner all say that an email is sufficient (<a href="<%= help_page_url %>#full_address">more details</a>). + +At the bottom of this page, write a reply to the authority explaining this to them. diff --git a/app/views/request/_view_html_prefix.rhtml b/app/views/request/_view_html_prefix.rhtml index 6d352ea91..b29830ac7 100644 --- a/app/views/request/_view_html_prefix.rhtml +++ b/app/views/request/_view_html_prefix.rhtml @@ -1,6 +1,6 @@ <div class="view_html_prefix"> <div class="view_html_logo"> - <a href="/"><img src="/images/navimg/logo-trans-small.png" alt="<%= site_name %> logo"></a> + <a href="/"><img src="/images/navimg/logo-trans-small.png" alt="<%= site_name %>"></a> </div> <div class="view_html_download_link"> <%=link_to _("Download original attachment"), @attachment_url %> diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.rhtml index 40c3b3d5b..d8647d1ec 100644 --- a/app/views/request/show_response.rhtml +++ b/app/views/request/show_response.rhtml @@ -19,9 +19,7 @@ address</strong>, not just an email, for it to be a valid FOI request') %> </dt> <dd> - <%= _('The law, the Ministry of Justice and the Information Commissioner - all say that an email is sufficient (<a href="%s">more details</a>). - At the bottom of this page, write a reply to the authority explaining this to them.') % [help_privacy_path + '#full_address'] %> + <%= render :partial => 'help/why_they_should_reply_by_email', :locals => {:help_page_url => help_privacy_path } %> </dd> <dt> diff --git a/app/views/user/set_profile_about_me.rhtml b/app/views/user/set_profile_about_me.rhtml index af6433e89..6c1edc254 100644 --- a/app/views/user/set_profile_about_me.rhtml +++ b/app/views/user/set_profile_about_me.rhtml @@ -26,7 +26,7 @@ <%= _(' Include relevant links, such as to a campaign page, your blog or a twitter account. They will be made clickable. e.g.')%> - <a href="http://www.twitter.com/whatdotheyknow">http://www.twitter.com/whatdotheyknow</a> + <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %></a> </p> </div> diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 5e2c29d84..c3a99311a 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -110,7 +110,7 @@ <% if not @is_you %> <p id="user_not_logged_in"> - <%= link_to _('Sign in'), signin_url(:r => request.request_uri) %><%= _('to change password, + <%= link_to _('Sign in'), signin_url(:r => request.request_uri) %> <%= _('to change password, subscriptions and more')%> (<%=h @display_user.name %> <%= _('only')%>) </p> <% end %> diff --git a/config/general.yml-example b/config/general.yml-example index c832111c7..3537cd792 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -23,6 +23,9 @@ USE_DEFAULT_BROWSER_LANGUAGE: true # How many days should have passed before an answer to a request is officially late? REPLY_LATE_AFTER_DAYS: 20 +REPLY_VERY_LATE_AFTER_DAYS: 40 +# We give some types of authority like schools a bit longer than everyone else +SPECIAL_REPLY_VERY_LATE_AFTER_DAYS: 60 # example searches for the home page, semicolon delimited. FRONTPAGE_SEARCH_EXAMPLES: 'Geraldine Quango; Department for Humpadinking' diff --git a/script/compact-xapian-database b/script/compact-xapian-database index 5c12b5dae..f1a6058b0 100755 --- a/script/compact-xapian-database +++ b/script/compact-xapian-database @@ -1,16 +1,25 @@ #!/bin/bash -RAILS_ENV=$1 +export RAILS_ENV=$1 set -e + if [ -x /usr/bin/xapian-compact ]; then - XAPIAN_DB_DIR="$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs" - OWNER=`stat -c %U $XAPIAN_DB_DIR/$RAILS_ENV` - su -c "xapian-compact $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.new" $OWNER - mv $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.tmp - mv $XAPIAN_DB_DIR/$RAILS_ENV.new $XAPIAN_DB_DIR/$RAILS_ENV - rm -rf $XAPIAN_DB_DIR/$RAILS_ENV.tmp - /etc/init.d/apache2 restart + XAPIAN_DB_DIR=$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs + if [ -e "$XAPIAN_DB_DIR/$RAILS_ENV.new" ]; then + echo >&2 "Didn't compact Xapian database because there was an existing database at $XAPIAN_DB_DIR/$RAILS_ENV.new" + exit 1 + else + OWNER=$(stat -c %U "$XAPIAN_DB_DIR/$RAILS_ENV") + export XAPIAN_DB_DIR RAILS_ENV + su "$OWNER" <<SU + xapian-compact "\$XAPIAN_DB_DIR/\$RAILS_ENV" "\$XAPIAN_DB_DIR/\$RAILS_ENV.new" +SU + mv "$XAPIAN_DB_DIR/$RAILS_ENV" "$XAPIAN_DB_DIR/$RAILS_ENV.tmp" + mv "$XAPIAN_DB_DIR/$RAILS_ENV.new" "$XAPIAN_DB_DIR/$RAILS_ENV" + rm -rf "$XAPIAN_DB_DIR/$RAILS_ENV.tmp" + /etc/init.d/apache2 restart + fi else - echo "Could not find xapian-compact script; have you installed xapian-tools?" + echo >&2 "Could not find xapian-compact script; have you installed xapian-tools?" exit 1 -fi
\ No newline at end of file +fi diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 4afc8f876..dcd33d279 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -778,6 +778,8 @@ describe RequestController, "when classifying an information request" do @dog_request.stub!(:date_very_overdue_after).and_return(Time.now.to_date-1) expect_redirect('waiting_response', unhappy_url) flash[:notice].should match(/is long overdue/) + flash[:notice].should match(/by more than 40 working days/) + flash[:notice].should match(/within 20 working days/) end it 'should redirect to the "request url" when status is updated to "not held"' do diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 5fcc534ca..183a258af 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -19,6 +19,13 @@ describe IncomingMessage, " when dealing with incoming mail" do end +describe IncomingMessage, "when parsing HTML mail" do + it "should display UTF-8 characters in the plain text version correctly" do + html = "<html><b>foo</b> është" + plain_text = IncomingMessage._get_attachment_text_internal_one_file('text/html', html) + plain_text.should match(/është/) + end +end describe IncomingMessage, "when getting the attachment text" do @@ -201,6 +208,13 @@ describe IncomingMessage, " when censoring data" do data.should == "There was a mouse called Jarlsberg, he wished that he was yellow." end + it "should apply hard-coded privacy rules to HTML files" do + domain = MySociety::Config.get('DOMAIN') + data = "http://#{domain}/c/cheese" + @im.html_mask_stuff!(data) + data.should == "[WDTK login link]" + end + it "should apply censor rules to From: addresses" do mock_mail = mock('Email object') mock_mail.stub!(:from_name_if_present).and_return("Stilton Mouse") |