diff options
-rw-r--r-- | app/controllers/request_controller.rb | 3 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 62 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.rhtml | 7 | ||||
-rw-r--r-- | app/views/admin_public_body/edit.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/_bubble.rhtml | 4 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 10 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 67 | ||||
-rw-r--r-- | public/stylesheets/main.css | 41 | ||||
-rw-r--r-- | todo.txt | 14 |
9 files changed, 154 insertions, 56 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 6cce879e7..8c6b854e7 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.20 2007-11-23 12:01:19 francis Exp $ +# $Id: request_controller.rb,v 1.21 2007-12-22 02:23:35 francis Exp $ class RequestController < ApplicationController @@ -13,6 +13,7 @@ class RequestController < ApplicationController @correspondences = @info_request.outgoing_messages + @info_request.incoming_messages @correspondences.sort! { |a,b| a.sent_at <=> b.sent_at } @status = @info_request.calculate_status + @collapse_quotes = params[:unfold] ? false : true end def list diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index f1ae68410..be65a4b60 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.7 2007-12-17 19:35:13 francis Exp $ +# $Id: incoming_message.rb,v 1.8 2007-12-22 02:23:35 francis Exp $ class IncomingMessage < ActiveRecord::Base belongs_to :info_request @@ -45,18 +45,68 @@ class IncomingMessage < ActiveRecord::Base self.mail.date || self.created_at end - # Use this when displaying the body text - def sanitised_body - body = self.mail.body.dup + # Remove email addresses from text (mainly to reduce spam - particularly + # we want to stop spam to our own magic archiving request-* addresses, + # which would otherwise appear a lot in bounce messages and reply quotes etc.) + def self.email_filter(text) + text = text.dup # Remove any email addresses - we don't want bounce messages to leak out # either the requestor's email address or the request's response email # address out onto the internet rx = Regexp.new(MySociety::Validate.email_match_regexp) - body.gsub!(rx, "...@...") + text.gsub!(rx, "...@...") - return body + return text end + + # Remove quoted sections from emails (eventually the aim would be for this + # to do as good a job as GMail does) XXX bet it needs a proper parser + # XXX and this BEGIN_QUOTED / END_QUOTED stuff is a mess + def self.remove_email_quotage(text) + text = text.dup + + text.gsub!(/^(>.+\n)/, "BEGIN_QUOTED\\1END_QUOTED") + text.gsub!(/^(On .+ wrote:\n)/, "BEGIN_QUOTED\\1END_QUOTED") + + original_message = + '(' + '''------ This is a copy of the message, including all the headers. ------''' + + '|' + '''-----Original Message-----''' + + ')' + + text.gsub!(/^(#{original_message}\n.*)$/m, "BEGIN_QUOTED\\1END_QUOTED") + + return text + end + + # Returns body text with quotes flattened, and emails removed. + def get_body_for_display(collapse_quoted_sections = true) + parts = self.mail.parts + if parts.size > 0 + #return self.mail.parts[0].class.to_s + text = self.mail.body + else + text = self.mail.quoted_body + end + + text = IncomingMessage.email_filter(text) + text = IncomingMessage.remove_email_quotage(text) + text = CGI.escapeHTML(text) + if collapse_quoted_sections + #text = text.gsub(/BEGIN_QUOTED/, '<span class="quoted_email">') + #text = text.gsub(/END_QUOTED/, '</span>') + text = text.gsub(/(BEGIN_QUOTED(.+?)END_QUOTED)+/m, '<a href="?unfold=1">show quoted sections</a>') + else + if text.include?('BEGIN_QUOTED') + text = text.gsub(/BEGIN_QUOTED(.+?)END_QUOTED/m, '\1') + text = text + '<a href="?">hide quoted sections</a>' + end + end + text = text.gsub(/\n/, '<br>') + + return text + end + end diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index dda975d14..8b9eca34e 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -16,3 +16,10 @@ <%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p> <!--[eoform:public_body]--> +<p><strong>Privacy note:</strong> The email addresses are assumed public data, +so we can share the love around later. If somebody wants to give us a +super-secret address (say to bypass spam traps) then we'll have to rethink +this. +</p> + + diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml index 775c98a99..b38ff02b3 100644 --- a/app/views/admin_public_body/edit.rhtml +++ b/app/views/admin_public_body/edit.rhtml @@ -7,6 +7,8 @@ <%= submit_tag 'Save' %> <% end %> +<p> <%= link_to 'Show', '../show/' + @public_body.id.to_s %> | <%= link_to 'List all', '../list' %> +</p> diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.rhtml index 0af5d7b21..8480693e3 100644 --- a/app/views/request/_bubble.rhtml +++ b/app/views/request/_bubble.rhtml @@ -1,11 +1,11 @@ <blockquote class="xsnazzy"> <b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b><b class="xb5"></b><b class="xb6"></b><b class="xb7"></b> <div class="xboxcontent"> - <p><%= body.gsub(/\n/, '<br>') %></p> + <p><%= body %></p> </div> <b class="xb7"></b><b class="xb6"></b><b class="xb5"></b><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b> <em></em> - <span></span> + <span class="bubblebit"></span> </blockquote> diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index 7a85bb627..aa6b799fa 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -21,16 +21,18 @@ </p> <% elsif (correspondence.class.to_s == 'IncomingMessage') incoming_message = correspondence%> - <%= render :partial => 'bubble', :locals => { :body => incoming_message.sanitised_body } %> + <%= render :partial => 'bubble', :locals => { :body => incoming_message.get_body_for_display(@collapse_quotes) } %> <p class="xspeaker"> - <%= incoming_message.mail.friendly_from %> - of <%= public_body_link(@info_request.public_body) %> + <% if incoming_message.mail.from %> + <%= incoming_message.mail.friendly_from %> of + <% end %> + <%= public_body_link(@info_request.public_body) %> wrote a reply on <strong><%= simple_date(incoming_message.sent_at) %></strong> </p> <% else %> - <% raise "Unknown correspondence type" + correspondence.class.to_s %> + <% raise "Unknown correspondence type " + correspondence.class.to_s %> <% end %> </div> diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index 3b5a5c2bf..83e183c81 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -1,33 +1,46 @@ <% @title = h(@info_request.title) %> -<h1><%=@title%></h1> +<div id="request_main"> + <h1><%=@title%></h1> -<p class="subtitle">A Freedom of Information request to -<%= public_body_link(@info_request.public_body) %> -by -<%= user_link(@info_request.user) %> -</p> + <p class="subtitle">A Freedom of Information request to + <%= public_body_link(@info_request.public_body) %> + by + <%= user_link(@info_request.user) %> + </p> -<p class="xspeaker"> -<% if @status == 'awaiting' %> -Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %> -<% elsif @status == 'overdue' %> -Currently <strong>overdue a response</strong> from <%= -public_body_link(@info_request.public_body) %>. Under section blah of the -Freedom of Information Act 2000 responses must be made within 20 working days. -<% elsif @status == 'information' %> -The request was at least partly <strong>successful</strong>. -<% elsif @status == 'none' %> -The request is <strong>not (yet) successful</strong>. -<% elsif @status == 'unknown' %> -<strong>Response received</strong>, but <%= user_link(@info_request.user) %> has not yet reported if it was -successful or a rejection. -<% else %> -<% raise "unknown status " + $status %> -<% end %> -</p> + <p id="request_status"> + <% if @status == 'awaiting' %> + Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %> + <% elsif @status == 'overdue' %> + Currently <strong>overdue a response</strong> from <%= + public_body_link(@info_request.public_body) %>. Under section blah of the + Freedom of Information Act 2000 responses must be made within 20 working days. + <% elsif @status == 'information' %> + The request was at least partly <strong>successful</strong>. + <% elsif @status == 'none' %> + The request is <strong>not (yet) successful</strong>. + <% elsif @status == 'unknown' %> + <strong>Response received</strong>, but <%= user_link(@info_request.user) %> has not yet reported if it was + successful or a rejection. + <% else %> + <% raise "unknown status " + $status %> + <% end %> + </p> + + <% for correspondence in @correspondences %> + <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %> + <% end %> +</div> + +<div id="request_sidebar"> + <h2>Juicy stuff will be here</h2> + <p>For now it is just padding to make the messages on the left + narrower, so I can see what the formatting is like. + <!--<h2>Blog posts about this request</h2> + <p>... + <h2>Wikipedia articles</h2> + <p>...--> +</div> -<% for correspondence in @correspondences %> - <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %> -<% end %> diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 4c4d76ac0..301068d06 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -243,6 +243,22 @@ table#list_requests .odd { /* /request - viewing requests */ +#request_main { + float: left; + width: 70%; +} + +#request_sidebar { + float: right; + width: 25%; +} + +#request_status { +} + +.quoted_email { + display: none; +} /* /classify - classifying requests */ @@ -310,15 +326,15 @@ table#list_requests .odd { .xsnazzy h2 {font-size:2em; color:#234; border:0;} .xsnazzy p {padding-bottom:0.5em; color:#eee;} .xsnazzy h2 {padding-top:0.5em; padding-left:10px;} -.xsnazzy {background: transparent; margin:1em;} +.xsnazzy {background: transparent; margin:1em 0.5em 1em 0.5em;} .xsnazzy em {display:block; width:0; height:0; color:#d8d8ee; overflow:hidden; border-top:12px solid #fff; border-left:12px dotted transparent; border-right:12px dotted transparent; margin-left:50px;} /* hack for IE5.5 */ * html .xsnazzy em {width:24px; height:12px; w\idth:0; hei\ght:0;} -.xsnazzy span {display:block; width:0; height:0; color:#fff; overflow:hidden; border-top:10px solid #7f7f7f; border-left:10px dotted transparent; border-right:10px dotted transparent; margin-left:52px; margin-top:-15px;} -* html .xsnazzy span {width:20px; height:10px; w\idth:0; hei\ght:0;} +.xsnazzy span.bubblebit {display:block; width:0; height:0; color:#fff; overflow:hidden; border-top:10px solid #5f5f5f; border-left:10px dotted transparent; border-right:10px dotted transparent; margin-left:52px; margin-top:-15px;} +* html .xsnazzy span.bubblebit {width:20px; height:10px; w\idth:0; hei\ght:0;} .xb1, .xb2, .xb3, .xb4, .xb5, .xb6, .xb7 {display:block; overflow:hidden; font-size:0;} .xb1, .xb2, .xb3, .xb4, .xb5, .xb6 {height:1px;} @@ -326,12 +342,19 @@ table#list_requests .odd { .xb1 {margin:0 8px; background:#fff;} .xb2 {margin:0 6px; background:#fff;} .xb3 {margin:0 4px; background:#fff;} -.xb4 {margin:0 3px; background:#7f7f7f; border-width:0 5px;} -.xb5 {margin:0 2px; background:#7f7f7f; border-width:0 4px;} -.xb6 {margin:0 2px; background:#7f7f7f; border-width:0 3px;} -.xb7 {margin:0 1px; background:#7f7f7f; border-width:0 3px; height:2px;} +.xb4 {margin:0 3px; background:#5f5f5f; border-width:0 5px;} +.xb5 {margin:0 2px; background:#5f5f5f; border-width:0 4px;} +.xb6 {margin:0 2px; background:#5f5f5f; border-width:0 3px;} +.xb7 {margin:0 1px; background:#5f5f5f; border-width:0 3px; height:2px;} -.xboxcontent {display:block; background:#7f7f7f; border:3px solid #fff; border-width:0 3px;} +.xboxcontent {display:block; background:#5f5f5f; border:3px solid #fff; border-width:0 3px;} + +.xsnazzy a:link { + color: #ffffff; +} +.xsnazzy a:visited { + color: #999999; +} -.xspeaker { margin: -0.5em 52px; } +.xspeaker { margin: -0.5em 1.5em; } @@ -5,13 +5,6 @@ FOI requests to use to test it BAILII - relationship with law courts, robots.txt ? -Parliament - Corporate Business Plan 2007 - http://www.parliament.uk/documents/upload/CorporateBusinessPlan2007.pdf -on page 32, it says that PICT "undertook work to identify a future development -path for Parliament’s Enterprise Architecture". We would like a copy of the -resultant "agreed set of priorities and programme of work for the period up to -2009/10" - The Better Regulation Executive has issued step–by–step guidance for officials wishing to use the order–making powers to deliver regulatory reform. For this and contact details for the guidance, please visit the Better Regulation Unit @@ -27,6 +20,8 @@ Next ==== Track bounce messages via a separate address + - just record if they are bounce, and any DSN, for now + - and say in display "automatic message" Swap over the question as to if contains info to be on the left @@ -102,6 +97,11 @@ Say that we would like response by email (not postal address) in footer Later ===== +Show public body email address on their public page, with a link to say "this isn't right!" + +Email me updates on this request +Blog posts / Wikipedia articles about this request + About page Contact page |