diff options
Diffstat (limited to 'app')
58 files changed, 595 insertions, 170 deletions
diff --git a/app/assets/images/icon_application_octet-stream_large.png b/app/assets/images/icon_application_octet-stream_large.png Binary files differindex a239862e1..a23916e9c 100644 --- a/app/assets/images/icon_application_octet-stream_large.png +++ b/app/assets/images/icon_application_octet-stream_large.png diff --git a/app/assets/images/icon_application_pdf_large.png b/app/assets/images/icon_application_pdf_large.png Binary files differindex 9a38ca33c..990b96c0a 100644 --- a/app/assets/images/icon_application_pdf_large.png +++ b/app/assets/images/icon_application_pdf_large.png diff --git a/app/assets/images/icon_application_rtf_large.png b/app/assets/images/icon_application_rtf_large.png Binary files differindex 2ad990608..977972124 100644 --- a/app/assets/images/icon_application_rtf_large.png +++ b/app/assets/images/icon_application_rtf_large.png diff --git a/app/assets/images/icon_application_vnd.ms-excel_large.png b/app/assets/images/icon_application_vnd.ms-excel_large.png Binary files differindex 3f346f5ef..acca5d92c 100644 --- a/app/assets/images/icon_application_vnd.ms-excel_large.png +++ b/app/assets/images/icon_application_vnd.ms-excel_large.png diff --git a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png Binary files differindex 82c225059..9a1582930 100644 --- a/app/assets/images/icon_application_vnd.ms-powerpoint_large.png +++ b/app/assets/images/icon_application_vnd.ms-powerpoint_large.png diff --git a/app/assets/images/icon_application_vnd.ms-word_large.png b/app/assets/images/icon_application_vnd.ms-word_large.png Binary files differindex 91a696ab5..2f3cb8efa 100644 --- a/app/assets/images/icon_application_vnd.ms-word_large.png +++ b/app/assets/images/icon_application_vnd.ms-word_large.png diff --git a/app/assets/images/icon_application_zip_large.png b/app/assets/images/icon_application_zip_large.png Binary files differindex 0a14e978e..c52d6d5aa 100644 --- a/app/assets/images/icon_application_zip_large.png +++ b/app/assets/images/icon_application_zip_large.png diff --git a/app/assets/images/icon_image_bmp_large.png b/app/assets/images/icon_image_bmp_large.png Binary files differindex f6e8dbaed..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_bmp_large.png +++ b/app/assets/images/icon_image_bmp_large.png diff --git a/app/assets/images/icon_image_gif_large.png b/app/assets/images/icon_image_gif_large.png Binary files differindex 424d1e0fd..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_gif_large.png +++ b/app/assets/images/icon_image_gif_large.png diff --git a/app/assets/images/icon_image_img_large.png b/app/assets/images/icon_image_img_large.png Binary files differnew file mode 100644 index 000000000..e19e7553c --- /dev/null +++ b/app/assets/images/icon_image_img_large.png diff --git a/app/assets/images/icon_image_jpeg_large.png b/app/assets/images/icon_image_jpeg_large.png Binary files differindex fd50a889d..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_jpeg_large.png +++ b/app/assets/images/icon_image_jpeg_large.png diff --git a/app/assets/images/icon_image_png_large.png b/app/assets/images/icon_image_png_large.png Binary files differindex f16edb08e..347bdaaf1 100644..120000 --- a/app/assets/images/icon_image_png_large.png +++ b/app/assets/images/icon_image_png_large.png diff --git a/app/assets/images/icon_image_tiff_large.png b/app/assets/images/icon_image_tiff_large.png Binary files differindex 356f63478..000bd0318 100644 --- a/app/assets/images/icon_image_tiff_large.png +++ b/app/assets/images/icon_image_tiff_large.png diff --git a/app/assets/images/icon_message_delivery-status_large.png b/app/assets/images/icon_message_delivery-status_large.png Binary files differindex a239862e1..dccdbbccd 100644 --- a/app/assets/images/icon_message_delivery-status_large.png +++ b/app/assets/images/icon_message_delivery-status_large.png diff --git a/app/assets/images/icon_text_html_large.png b/app/assets/images/icon_text_html_large.png Binary files differindex 914502cf4..3813d2582 100644 --- a/app/assets/images/icon_text_html_large.png +++ b/app/assets/images/icon_text_html_large.png diff --git a/app/assets/images/icon_text_plain_large.png b/app/assets/images/icon_text_plain_large.png Binary files differindex f74a997ba..f15b0dbdc 100644 --- a/app/assets/images/icon_text_plain_large.png +++ b/app/assets/images/icon_text_plain_large.png diff --git a/app/assets/images/icon_text_x-vcard_large.png b/app/assets/images/icon_text_x-vcard_large.png Binary files differindex cc44d3edc..804066af8 100644 --- a/app/assets/images/icon_text_x-vcard_large.png +++ b/app/assets/images/icon_text_x-vcard_large.png diff --git a/app/assets/images/icon_unknown.png b/app/assets/images/icon_unknown.png Binary files differindex 992c646c0..9a06d9baa 100644 --- a/app/assets/images/icon_unknown.png +++ b/app/assets/images/icon_unknown.png diff --git a/app/assets/images/widget-base.png b/app/assets/images/widget-base.png Binary files differnew file mode 100644 index 000000000..872244543 --- /dev/null +++ b/app/assets/images/widget-base.png diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js index 002eef760..639a6917b 100644 --- a/app/assets/javascripts/general.js +++ b/app/assets/javascripts/general.js @@ -34,12 +34,12 @@ $(document).ready(function() {      box.width(location.length + " em");      box.find('input').val(location).attr('size', location.length + " em");      box.show(); -    box.find('input').select();      box.position({        my: "right center",        at: "left bottom",        of:  this,        collision: "fit" }); +    box.find('input').select();      return false;    }); @@ -57,4 +57,12 @@ $(document).ready(function() {       $('#everypage').hide();     } +  // "Create widget" page +  $("#widgetbox").select() +  // Chrome workaround +  $("widgetbox").mouseup(function() { +    // Prevent further mouseup intervention +    $this.unbind("mouseup"); +    return false; +  });  }) diff --git a/app/assets/stylesheets/responsive/_global_layout.scss b/app/assets/stylesheets/responsive/_global_layout.scss index d7b24df41..b34a6af74 100644 --- a/app/assets/stylesheets/responsive/_global_layout.scss +++ b/app/assets/stylesheets/responsive/_global_layout.scss @@ -98,3 +98,10 @@ textarea{      padding-right: 0.9375em;    }  } +.box { +  padding: 1em; + +  @include respond-min( $main_menu-mobile_menu_cutoff ){ +    padding: 1.2em; +  } +} diff --git a/app/assets/stylesheets/responsive/_global_style.scss b/app/assets/stylesheets/responsive/_global_style.scss index 24cddc0d9..27d238962 100644 --- a/app/assets/stylesheets/responsive/_global_style.scss +++ b/app/assets/stylesheets/responsive/_global_style.scss @@ -84,9 +84,6 @@ dd {  dt + dd {    margin-top: 0.5em; -  > p { -    margin-top: 0; -  }  } diff --git a/app/assets/stylesheets/responsive/_header_layout.scss b/app/assets/stylesheets/responsive/_header_layout.scss index b3103e3a9..7c7bdfe97 100644 --- a/app/assets/stylesheets/responsive/_header_layout.scss +++ b/app/assets/stylesheets/responsive/_header_layout.scss @@ -131,25 +131,25 @@    }    form{          @include grid-row; -        padding-right: 1em; +        padding: 1em 1em 0;          @include lte-ie7 {             display: inline;          } +        @include respond-min( $main_menu-mobile_menu_cutoff ){ +          padding-top: 0; +        }      }      input{ -        @include grid-column($columns:9); -        margin:0; +        @include grid-column($columns:10); +        margin-right:0;          @include lte-ie7 {            width: 10.063em;          }      } -    label{ +    button[type="submit"]{          @include prefix-postfix-base; -        @include grid-column($columns:3,$float:left); +        @include grid-column($columns:2,$float:right);          border:none; -        img{ -            max-width: 100%; -        }          @include lte-ie7 {             width: 2.125em;          } diff --git a/app/assets/stylesheets/responsive/_header_style.scss b/app/assets/stylesheets/responsive/_header_style.scss index 9008a73a7..ec1e8ea5c 100644 --- a/app/assets/stylesheets/responsive/_header_style.scss +++ b/app/assets/stylesheets/responsive/_header_style.scss @@ -2,3 +2,9 @@  #navigation {      border-bottom: 1px solid #e9e9e9;  } + +#navigation_search { +  button[type="submit"] { +    background:image-url('/assets/search.png') transparent no-repeat center center; +  } +} diff --git a/app/assets/stylesheets/responsive/_request_style.scss b/app/assets/stylesheets/responsive/_request_style.scss index e6f36674a..44ca9a288 100644 --- a/app/assets/stylesheets/responsive/_request_style.scss +++ b/app/assets/stylesheets/responsive/_request_style.scss @@ -3,12 +3,9 @@  div.correspondence {    border: 1px solid #ccc;    margin: 0 0 1em; -  padding: 1em; -  @include respond-min( $main_menu-mobile_menu_cutoff ){ -    padding: 1.5em; -  }    h2 { +    margin-top: 0;      text-align:right;      font-size:1em;    } @@ -31,7 +28,6 @@ div.correspondence {  div.comment_in_request {    border: 1px dotted #ccc;    margin:0 0 1em 3em; -  padding:0 0.5em;    h2 {      font-size:1em; @@ -42,13 +38,9 @@ div.comment_in_request {  }  .event_actions { +  margin-bottom: 0;    text-align:right;    line-height: 1em; -  margin-bottom: 1em; -} - -.comment_in_request_text { -  margin:0 1.2em 0 0.9em;  }  .user_photo_on_request img { @@ -64,7 +56,6 @@ div.comment_in_request {    height:36px;    float:left;    vertical-align:middle; -  margin-top: 0.5em;    margin-right:0.5em;  } @@ -86,11 +77,9 @@ a img.attachment_image {  }  .describe_state_form,#other_recipients { -    border-radius:3px;    -moz-border-radius:3px;    margin:1em 0; -  padding:0.5em 1em;  }  .describe_state_form { diff --git a/app/assets/stylesheets/responsive/_utils.scss b/app/assets/stylesheets/responsive/_utils.scss index 68884fa7a..e19201475 100644 --- a/app/assets/stylesheets/responsive/_utils.scss +++ b/app/assets/stylesheets/responsive/_utils.scss @@ -33,3 +33,18 @@ $lte-ie7: false !default;          @content;      }  } + +// Hide content visually, but keep it available to screen readers +// source: http://a11yproject.com/posts/how-to-hide-content/ +.visually-hidden { +  // http://developer.yahoo.com/blogs/ydn/posts/2012/10/clip-your-hidden-content-for-better-accessibility/ +    position: absolute !important; +    clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ +    clip: rect(1px, 1px, 1px, 1px); +    padding:0 !important; +    border:0 !important; +    height: 1px !important; +    width: 1px !important; +    overflow: hidden; +} +body:hover .visually-hidden a, body:hover .visually-hidden input, body:hover .visually-hidden button { display: none !important; } diff --git a/app/assets/stylesheets/widget.scss b/app/assets/stylesheets/widget.scss new file mode 100644 index 000000000..a67e1f3f0 --- /dev/null +++ b/app/assets/stylesheets/widget.scss @@ -0,0 +1,109 @@ +/* CSS Mini Reset */ + +html, body, div, form, fieldset, legend, label +{ + margin: 0; + padding: 0; +} + +table +{ + border-collapse: collapse; + border-spacing: 0; +} + +th, td +{ + text-align: left; + vertical-align: top; +} + +h1, h2, h3, h4, h5, h6, th, td, caption { font-weight:normal; } + +img { border: 0; } + +body { +    background-color: #ffffff; +    color: #333333; +    padding: 0; +    margin: 0; +    font-family: "Helvetica Neue", Arial, Helvetica, Helmet, Freesans, sans-serif; +    font-weight: normal; +    font-style: normal; +    line-height: 1.5em; +    position: relative; +    cursor: default; +    font-size: 1em; +} + +a:hover, +a:focus, +a:active { +    color: #333; +} + +.alaveteli-widget { +    width: 318px; +    height: 213px; +    border: 1px solid #e9e9e9; +    background: #e9e9e9 url("widget-base.png") top left no-repeat; +    position: relative; +    border: 1px solid #eee; +} + +.alaveteli-widget__title { +    position: absolute; +    top: 1em; +    left: 16px; +    width: 160px; +    height: 75px; +    overflow: hidden; +} + +.alaveteli-widget__status { +    position: absolute; +    top: 97px; +    left: 16px; +    font-weight: bold; +    text-transform: uppercase; +} + +.alaveteli-widget__status__status-label { +    margin: 0; +    font-weight: normal; +    font-size: 0.875em; +    line-height: 1.1em; +    color: #555; +    text-transform: capitalize; +} + +.alaveteli-widget__left { +    position: absolute; +    width: 145px; +} + +.alaveteli-widget__people-count { +  position: absolute; +  left: 192px; +  top: 44px; +  width: 100px; +  text-align: center; +  line-height: 1.3em; +} +.alaveteli-widget__count { +    font-size: 55px; +    line-height: 55px; +    text-align: center; +} + +.alaveteli-widget__bottom a { +    text-decoration: none; +} + +.alaveteli-widget__button { +    position: absolute; +    top: 173px; +    left: 16px; +    text-align: center; +} + diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb index f2414eeab..4927f631b 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -7,29 +7,29 @@  class AdminGeneralController < AdminController      def index -        # Overview counts of things -        @public_body_count = PublicBody.count - -        @info_request_count = InfoRequest.count -        @outgoing_message_count = OutgoingMessage.count -        @incoming_message_count = IncomingMessage.count - -        @user_count = User.count -        @track_thing_count = TrackThing.count - -        @comment_count = Comment.count -          # Tasks to do          @requires_admin_requests = InfoRequest.find_in_state('requires_admin')          @error_message_requests = InfoRequest.find_in_state('error_message')          @attention_requests = InfoRequest.find_in_state('attention_requested') -        @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], -                                                :order => "updated_at") +        @blank_contacts = PublicBody. +                            includes(:tags, :translations). +                              where(:request_email => ""). +                                order(:updated_at). +                                  select { |pb| !pb.defunct? }          @old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,                                                                :conditions => ["prominence = 'normal'"]) -        @holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages -        @new_body_requests = PublicBodyChangeRequest.new_body_requests.open -        @body_update_requests = PublicBodyChangeRequest.body_update_requests.open +        @holding_pen_messages = InfoRequest. +                                  includes(:incoming_messages => :raw_email). +                                    holding_pen_request. +                                      incoming_messages +        @new_body_requests = PublicBodyChangeRequest. +                               includes(:public_body, :user). +                                 new_body_requests. +                                   open +        @body_update_requests = PublicBodyChangeRequest. +                                  includes(:public_body, :user). +                                    body_update_requests. +                                      open      end      def timeline diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 1e083f57e..db20e8dcc 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -114,21 +114,14 @@ class AdminRequestController < AdminController              end              redirect_to admin_request_url(info_request)          elsif params[:commit] == 'Move request to authority' && !params[:public_body_url_name].blank? -            old_public_body = info_request.public_body              destination_public_body = PublicBody.find_by_url_name(params[:public_body_url_name]) -            if destination_public_body.nil? -                flash[:error] = "Couldn't find public body '" + params[:public_body_url_name] + "'" -            else -                info_request.public_body = destination_public_body -                info_request.save! -                info_request.log_event("move_request", { -                        :editor => admin_current_user(), -                        :old_public_body_url_name => old_public_body.url_name, -                        :public_body_url_name => destination_public_body.url_name -                }) -                info_request.reindex_request_events -                flash[:notice] = "Request has been moved to new body" +            if info_request.move_to_public_body(destination_public_body, +                                                :editor => admin_current_user, +                                                :reindex => true) +              flash[:notice] = "Request has been moved to new body" +            else +              flash[:error] = "Couldn't find public body '#{ params[:public_body_url_name] }'"              end              redirect_to admin_request_url(info_request) diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 4b272797f..8b8055b55 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -214,6 +214,4 @@ class TrackController < ApplicationController          redirect_to URI.parse(params[:r]).path      end -  end - diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb new file mode 100644 index 000000000..0cc1008a1 --- /dev/null +++ b/app/controllers/widgets_controller.rb @@ -0,0 +1,63 @@ +# app/controllers/widget_controller.rb: +# Handle widgets, if enabled +# +# Copyright (c) 2014 UK Citizens Online Democracy. All rights reserved. +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ + +require 'securerandom' + +class WidgetsController < ApplicationController + +    before_filter :check_widget_config, :find_info_request, :check_prominence +    skip_before_filter :set_x_frame_options_header, :only => [:show] + +    def show +        medium_cache +        @track_thing = TrackThing.create_track_for_request(@info_request) +        @status = @info_request.calculate_status +        @count = @info_request.track_things.count + @info_request.widget_votes.count + 1 + +        if @user +            @existing_track = TrackThing.find_existing(@user, @track_thing) +        end +        unless @user || cookies[:widget_vote] +          cookies.permanent[:widget_vote] = SecureRandom.hex(10) +        end +        render :action => 'show', :layout => false +    end + +    def new +        long_cache +    end + +    # Track interest in a request from a non-logged in user +    def update +        if !@user && cookies[:widget_vote] +            @info_request.widget_votes. +                where(:cookie => cookies[:widget_vote]). +                    first_or_create +        end + +        track_thing = TrackThing.create_track_for_request(@info_request) +        redirect_to do_track_path(track_thing), status => :temporary_redirect +    end + +    private + +    def find_info_request +        @info_request = InfoRequest.find(params[:request_id]) +    end + +    def check_widget_config +        unless AlaveteliConfiguration::enable_widgets +            raise ActiveRecord::RecordNotFound.new("Page not enabled") +        end +    end + +    def check_prominence +        unless @info_request.prominence == 'normal' +            render :nothing => true, :status => :forbidden +        end +    end + +end diff --git a/app/helpers/health_checks_helper.rb b/app/helpers/health_checks_helper.rb index f5769a9ba..f9e4d42df 100644 --- a/app/helpers/health_checks_helper.rb +++ b/app/helpers/health_checks_helper.rb @@ -1,7 +1,7 @@  module HealthChecksHelper      def check_status(check) -        style = check.ok? ? {} : "color: red" +        style = check.ok? ? '' : 'color: red'          content_tag(:b, check.message, :style => style)      end diff --git a/app/helpers/widget_helper.rb b/app/helpers/widget_helper.rb new file mode 100644 index 000000000..e604954fe --- /dev/null +++ b/app/helpers/widget_helper.rb @@ -0,0 +1,46 @@ +module WidgetHelper +    def status_description(info_request, status) +        case status +        when 'waiting_classification' +            _('Awaiting classification') +        when 'waiting_response' +            _('Awaiting response') +        when 'waiting_response_overdue' +            _('Delayed') +        when 'waiting_response_very_overdue' +            _('Long overdue') +        when 'not_held' +            _('Not held') +        when 'rejected' +            _('Rejected') +        when 'successful' +            _('Successful') +        when 'partially_successful' +            _('Partial success') +        when 'waiting_clarification' +            _('Awaiting clarification') +        when 'gone_postal' +            _('Handled by post') +        when 'internal_review' +            _('Internal review') +        when 'error_message' +            _('Delivery error') +        when 'requires_admin' +            _('Unusual response') +        when 'user_withdrawn' +            _('Withdrawn') +        when 'attention_requested' +            _('Needs admin attention') +        when 'vexatious' +            _('Vexatious') +        when 'not_foi' +            _('Not an FOI request') +        else +            if info_request.respond_to?(:theme_display_status) +                info_request.theme_display_status(status) +            else +                _('Unknown') +            end +        end +    end +end
\ No newline at end of file diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index 252df861c..8f9f91a1c 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -64,7 +64,7 @@ class RequestMailer < ApplicationMailer          mail(:from => user.name_and_email,               :to => contact_from_name_and_email, -             :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title).html_safe) +             :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title.html_safe))      end      # Tell the requester that a new response has arrived @@ -80,7 +80,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => info_request.user.name_and_email, -             :subject => (_("New response to your FOI request - ") + info_request.title).html_safe, +             :subject => _("New response to your FOI request - ") + info_request.title.html_safe,               :charset => "UTF-8",               # not much we can do if the user's email is broken               :reply_to => contact_from_name_and_email) @@ -105,7 +105,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => user.name_and_email, -             :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe) +             :subject => _("Delayed response to your FOI request - ") + info_request.title.html_safe)      end      # Tell the requester that the public body is very late in replying @@ -125,7 +125,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => user.name_and_email, -             :subject => (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe) +             :subject => _("You're long overdue a response to your FOI request - ") + info_request.title.html_safe)      end      # Tell the requester that they need to say if the new response @@ -183,7 +183,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => info_request.user.name_and_email, -             :subject => (_("Clarify your FOI request - ") + info_request.title).html_safe) +             :subject => _("Clarify your FOI request - ") + info_request.title.html_safe)      end      # Tell requester that somebody add an annotation to their request @@ -197,7 +197,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => info_request.user.name_and_email, -             :subject => (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe) +             :subject => _("Somebody added a note to your FOI request - ") + info_request.title.html_safe)      end      def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)          @count, @info_request = count, info_request @@ -209,7 +209,7 @@ class RequestMailer < ApplicationMailer          mail(:from => contact_from_name_and_email,               :to => info_request.user.name_and_email, -             :subject => (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe) +             :subject => _("Some notes have been added to your FOI request - ") + info_request.title.html_safe)      end      # Class function, called by script/mailin with all incoming responses. diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index 3b5c2d805..58170f237 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -42,6 +42,11 @@ class CensorRule < ActiveRecord::Base                                        :user_id => nil,                                        :public_body_id => nil } } +    def apply_to_text(text_to_censor) +        return nil if text_to_censor.nil? +        text_to_censor.gsub(to_replace, replacement) +    end +      def apply_to_text!(text_to_censor)          return nil if text_to_censor.nil?          text_to_censor.gsub!(to_replace, replacement) diff --git a/app/models/info_request.rb b/app/models/info_request.rb index c203f75c3..02faffcfa 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -50,6 +50,7 @@ class InfoRequest < ActiveRecord::Base      has_many :info_request_events, :order => 'created_at'      has_many :user_info_request_sent_alerts      has_many :track_things, :order => 'created_at desc' +    has_many :widget_votes      has_many :comments, :order => 'created_at'      has_many :censor_rules, :order => 'created_at desc'      has_many :mail_server_logs, :order => 'mail_server_log_done_id' @@ -783,7 +784,14 @@ public      end      def public_response_events -        self.info_request_events.select{|e| e.response? && e.incoming_message.all_can_view? } +        condition = <<-SQL +        info_request_events.event_type = ? +        AND incoming_messages.prominence = ? +        SQL + +        info_request_events. +          joins(:incoming_message). +            where(condition, 'response', 'normal')      end      # The last public response is the default one people might want to reply to @@ -810,8 +818,9 @@ public      # Text from the the initial request, for use in summary display      def initial_request_text -        return '' if outgoing_messages.empty? # mainly for use with incomplete fixtures -        outgoing_messages.first.get_text_for_indexing +        return '' if outgoing_messages.empty? +        body_opts = { :censor_rules => applicable_censor_rules } +        outgoing_messages.first.try(:get_text_for_indexing, true, body_opts) or ''      end      # Returns index of last event which is described or nil if none described. @@ -908,21 +917,24 @@ public      # Completely delete this request and all objects depending on it      def fully_destroy -        self.track_things.each do |track_thing| +        track_things.each do |track_thing|              track_thing.track_things_sent_emails.each { |a| a.destroy }              track_thing.destroy          end -        self.user_info_request_sent_alerts.each { |a| a.destroy } -        self.info_request_events.each do |info_request_event| +        user_info_request_sent_alerts.each { |a| a.destroy } +        info_request_events.each do |info_request_event|              info_request_event.track_things_sent_emails.each { |a| a.destroy }              info_request_event.destroy          end -        self.mail_server_logs.each do |mail_server_log| +        mail_server_logs.each do |mail_server_log|              mail_server_log.destroy          end -        self.outgoing_messages.each { |a| a.destroy } -        self.incoming_messages.each { |a| a.destroy } -        self.destroy +        outgoing_messages.each { |a| a.destroy } +        incoming_messages.each { |a| a.destroy } +        comments.each { |comment| comment.destroy } +        censor_rules.each{ |censor_rule| censor_rule.destroy } + +        destroy      end      # Called by incoming_email - and used to be called to generate separate @@ -1362,6 +1374,39 @@ public                  order('last_event_time')      end +    def move_to_public_body(destination_public_body, opts = {}) +        old_body = public_body +        editor = opts.fetch(:editor) + +        attrs = { :public_body => destination_public_body } + +        if destination_public_body +          attrs.merge!({ +            :law_used => destination_public_body.law_only_short.downcase +          }) +        end + +        if update_attributes(attrs) +            log_event('move_request', +                      :editor => editor, +                      :public_body_url_name => public_body.url_name, +                      :old_public_body_url_name => old_body.url_name) + +            reindex_request_events + +            public_body +        end +    end + +    # The DateTime of the last InfoRequestEvent belonging to the InfoRequest +    # Only available if the last_event_time attribute has been set. This is +    # currentlt only set through .find_in_state +    # +    # Returns a DateTime +    def last_event_time +        attributes['last_event_time'].try(:to_datetime) +    end +      private      def set_defaults @@ -1373,8 +1418,9 @@ public              # this should only happen on Model.exists?() call. It can be safely ignored.              # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/          end +          # FOI or EIR? -        if !self.public_body.nil? && self.public_body.eir_only? +        if new_record? && public_body && public_body.eir_only?              self.law_used = 'eir'          end      end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 635ba8f58..0ee82d30c 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -278,9 +278,15 @@ class InfoRequestEvent < ActiveRecord::Base          end          self.params_yaml = params.to_yaml      end +      def params -        YAML.load(self.params_yaml) +        param_hash = YAML.load(params_yaml) +        param_hash.each do |key, value| +            param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) +        end +        param_hash      end +      def params_yaml_as_html          ret = ''          # split out parameters into old/new diffs, and other ones diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index c2c8ef4f2..4f6318b3d 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -140,22 +140,28 @@ class OutgoingMessage < ActiveRecord::Base          end      end -    def body -        ret = read_attribute(:body) -        if ret.nil? -            return ret +    # Public: The body text of the OutgoingMessage. The text is cleaned and +    # CensorRules are applied. +    # +    # options - Hash of options +    #           :censor_rules - Array of CensorRules to apply. Defaults to the +    #                           applicable_censor_rules of the associated +    #                           InfoRequest. (optional) +    # +    # Returns a String +    def body(options = {}) +        text = raw_body.dup +        return text if text.nil? + +        text = clean_text(text) + +        # Use the given censor_rules; otherwise fetch them from the associated +        # info_request +        censor_rules = options.fetch(:censor_rules) do +            info_request.try(:applicable_censor_rules) or []          end -        ret = ret.dup -        ret.strip! -        ret.gsub!(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out - -        # Remove things from censor rules -        unless info_request.nil? -            self.info_request.apply_censor_rules_to_text!(ret) -        end - -        ret +        censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) }      end      def raw_body @@ -227,8 +233,12 @@ class OutgoingMessage < ActiveRecord::Base      end      # Returns text for indexing / text display -    def get_text_for_indexing(strip_salutation = true) -        text = body.strip +    def get_text_for_indexing(strip_salutation = true, opts = {}) +        if opts.empty? +            text = body.strip +        else +            text = body(opts).strip +        end          # Remove salutation          text.sub!(/Dear .+,/, "") if strip_salutation @@ -332,6 +342,11 @@ class OutgoingMessage < ActiveRecord::Base              errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.'))          end      end + +    # remove excess linebreaks that unnecessarily space it out +    def clean_text(text) +        text.strip.gsub(/(?:\n\s*){2,}/, "\n\n") +    end  end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 8049349d0..59160381c 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -71,7 +71,11 @@ class PostRedirect < ActiveRecord::Base      end      def reason_params -        YAML.load(reason_params_yaml) +        param_hash = YAML.load(reason_params_yaml) +        param_hash.each do |key, value| +            param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) +        end +        param_hash      end      # Extract just local path part, without domain or # diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 232c0ffa1..dac77d4c5 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -339,19 +339,20 @@ class PublicBody < ActiveRecord::Base      # Are all requests to this body under the Environmental Information Regulations?      def eir_only? -        return self.has_tag?('eir_only') +        has_tag?('eir_only')      end +      def law_only_short -        if self.eir_only? -            return "EIR" -        else -            return "FOI" -        end +        eir_only? ? 'EIR' : 'FOI'      end      # Schools are allowed more time in holidays, so we change some wordings      def is_school? -        return self.has_tag?('school') +        has_tag?('school') +    end + +    def site_administration? +        has_tag?('site_administration')      end      # The "internal admin" is a special body for internal use. @@ -379,10 +380,6 @@ class PublicBody < ActiveRecord::Base          end      end -    def site_administration? -        has_tag?('site_administration') -    end -      class ImportCSVDryRun < StandardError      end @@ -577,17 +574,11 @@ class PublicBody < ActiveRecord::Base          return self.request_email_domain      end -    # Returns nil if configuration variable not set -    def override_request_email -        e = AlaveteliConfiguration::override_all_public_body_request_emails -        e if e != "" -    end -      def request_email -        if override_request_email -            override_request_email -        else +        if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank?              read_attribute(:request_email) +        else +            AlaveteliConfiguration::override_all_public_body_request_emails          end      end @@ -774,10 +765,7 @@ class PublicBody < ActiveRecord::Base      end      def empty_translation_in_params?(attributes) -        attrs_with_values = attributes.select do |key, value| -            value != '' and key.to_s != 'locale' -        end -        attrs_with_values.empty? +        attributes.select { |k, v| !v.blank? && k.to_s != 'locale' }.empty?      end      def request_email_if_requestable diff --git a/app/models/user.rb b/app/models/user.rb index 920c0da46..1fb5d9139 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,6 +38,7 @@ class User < ActiveRecord::Base      has_one :profile_photo      has_many :censor_rules, :order => 'created_at desc'      has_many :info_request_batches, :order => 'created_at desc' +    has_many :request_classifications      validates_presence_of :email, :message => _("Please enter your email address")      validates_presence_of :name, :message => _("Please enter your name") diff --git a/app/models/widget_vote.rb b/app/models/widget_vote.rb new file mode 100644 index 000000000..021c38b30 --- /dev/null +++ b/app/models/widget_vote.rb @@ -0,0 +1,19 @@ +# == Schema Information +# +# Table name: widget_votes +# +#  id              :integer          not null, primary key +#  cookie          :string(255) +#  info_request_id :integer          not null +#  created_at      :datetime         not null +#  updated_at      :datetime         not null +# + +class WidgetVote < ActiveRecord::Base +  belongs_to :info_request +  validates :info_request, :presence => true + +  attr_accessible :cookie +  validates :cookie, :length => { :is => 20 } +  validates_uniqueness_of :cookie, :scope => :info_request_id +end diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb index ba0563bb6..8840bce74 100644 --- a/app/views/admin_general/index.html.erb +++ b/app/views/admin_general/index.html.erb @@ -2,17 +2,10 @@  <div class="row">    <div class="span12"> -    <h1><%=@title%></h1> - -    <ul> -      <li><%=@public_body_count%> public authorities</li> -      <li> -        <%=@info_request_count%> requests, <%=@outgoing_message_count%> outgoing messages, -        <%=@incoming_message_count%> incoming messages -      </li> -      <li><%=@user_count%> users, <%=@track_thing_count%> tracked things</li> -      <li><%=@comment_count%> annotations</li> -    </ul> +    <h1><%= @title %></h1> +    <p> +      <%= link_to 'Summary stats have moved →', admin_stats_path %> +    </p>    </div>  </div> @@ -28,8 +21,14 @@    <% if @holding_pen_messages.size > 0 %>      <div class="accordion-group">        <div class="accordion-heading"> -        <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%=@holding_pen_messages.size%></span><%= chevron_right %> Put misdelivered responses with the right request</a> +        <a class="accordion-toggle" href="#holding-pen" data-toggle="collapse" data-parent="things-to-do"> +          <span class="label label-important"> +            <%= @holding_pen_messages.size %> +          </span> +          <%= chevron_right %> Put misdelivered responses with the right request +        </a>        </div> +        <div id="holding-pen" class="accordion-body collapse">          <table class="table table-striped table-condensed">            <tbody> @@ -39,11 +38,13 @@                    <% if message.get_body_for_quoting.strip.size == 0 %>                        <%= link_to "(no body)", admin_raw_email_path(message.raw_email_id) %>                    <% else %> -                      <%= link_to excerpt(message.get_body_for_quoting, "", :radius => 60), admin_raw_email_path(message.raw_email_id) %> +                      <%= link_to admin_raw_email_path(message.raw_email_id) do %> +                        <%= excerpt(message.get_body_for_quoting, "", :radius => 60) %> +                      <% end %>                    <% end %>                  </td>                  <td class="span2"> -                  <%=simple_date(message.sent_at)%> +                  <%= simple_date(message.sent_at) %>                  </td>                </tr>              <% end %> @@ -67,7 +68,7 @@                    <%= request_both_links(@request) %>                  </td>                  <td class="span2"> -                  <%=simple_date(@request.info_request_events.last.created_at)%> +                  <%= simple_date(@request.last_event_time) %>                  </td>                </tr>              <% end %> @@ -92,7 +93,7 @@                    <%= request_both_links(@request) %>                  </td>                  <td class="span2"> -                  <%=simple_date(@request.info_request_events.last.created_at)%> +                  <%= simple_date(@request.last_event_time) %>                  </td>                </tr>              <% end %> @@ -116,7 +117,7 @@                    <%= request_both_links(@request) %>                  </td>                  <td class="span2"> -                  <%=simple_date(@request.info_request_events.last.created_at)%> +                  <%= simple_date(@request.last_event_time) %>                  </td>                </tr>              <% end %> @@ -178,18 +179,33 @@    <% if @new_body_requests.size > 0 %>      <div class="accordion-group">        <div class="accordion-heading"> -        <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @new_body_requests.size %></span><%= chevron_right %> Add new authorities</a> +        <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"> +          <span class="label label-important"> +            <%= @new_body_requests.size %> +          </span> +          <%= chevron_right %> Add new authorities +        </a>        </div> +        <div id="new-authorities" class="accordion-body collapse"> -            <% for @change_request in @new_body_requests %> -              <%= render :partial => 'change_request_summary'%> -              <%= form_tag admin_change_request_path(@change_request), :method => 'put', :class => "form form-horizontal" do %> -                <%= submit_tag 'Close', :class => "btn btn-danger" %> -                <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %> -                <%= link_to("Add authority", new_admin_body_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %> -              <% end %> +        <% for @change_request in @new_body_requests %> +          <%= render :partial => 'change_request_summary'%> -            <% end %> +          <%= form_tag admin_change_request_path(@change_request), +                :method => 'put', +                :class => "form form-horizontal" do %> + +             <%= submit_tag 'Close', :class => "btn btn-danger" %> + +             <%= link_to "Close and respond", +                   edit_admin_change_request_path(@change_request), +                   :class => 'btn' %> + +             <%= link_to "Add authority", +                   new_admin_body_path(:change_request_id => @change_request.id), +                   :class => 'btn btn-primary' %> +          <% end %> +        <% end %>        </div>      </div>    <% end %> @@ -197,17 +213,34 @@    <% if @body_update_requests.size > 0 %>      <div class="accordion-group">        <div class="accordion-heading"> -        <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @body_update_requests.size %></span><%= chevron_right %> Update authorities</a> +        <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"> +          <span class="label label-important"> +            <%= @body_update_requests.size %> +          </span> +          <%= chevron_right %> Update authorities +        </a>        </div> +        <div id="update-authorities" class="accordion-body collapse">          <% for @change_request in @body_update_requests %> -            <%= render :partial => 'change_request_summary' %> -            <%= form_tag admin_change_request_path(@change_request), :class => "form form-horizontal", :method => 'put' do %> -              <%= submit_tag 'Close', :class => "btn btn-danger" %> -            <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %> -            <%= link_to("Make update", edit_admin_body_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %> -            <% end %> +          <%= render :partial => 'change_request_summary' %> + +          <%= form_tag admin_change_request_path(@change_request), +                :class => "form form-horizontal", +                :method => 'put' do %> + +            <%= submit_tag 'Close', :class => "btn btn-danger" %> + +            <%= link_to "Close and respond", +                  edit_admin_change_request_path(@change_request), +                  :class => 'btn' %> + +            <%= link_to "Make update", +                  edit_admin_body_path(@change_request.public_body, +                                       :change_request_id => @change_request.id), +                  :class => 'btn btn-primary' %>            <% end %> +        <% end %>        </div>      </div>    <% end %> diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb index dcafbd270..fc9c25e8f 100644 --- a/app/views/admin_public_body/edit.html.erb +++ b/app/views/admin_public_body/edit.html.erb @@ -13,7 +13,7 @@        <div class="row">          <div class="span8">            <div class="well"> -            <%= link_to 'Show', admin_bodies_path(@public_body), :class => "btn" %> +            <%= link_to 'Show', admin_body_path(@public_body), :class => "btn" %>              <%= link_to 'List all', admin_bodies_path, :class => "btn" %>            </div>          </div> diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb index 07017dabf..badc39d9a 100644 --- a/app/views/comment/_single_comment.html.erb +++ b/app/views/comment/_single_comment.html.erb @@ -1,4 +1,4 @@ -<div class="comment_in_request" id="comment-<%=comment.id.to_s%>"> +<div class="comment_in_request box" id="comment-<%=comment.id.to_s%>">      <% if comment.user && comment.user.profile_photo && !@render_to_file %>          <div class="user_photo_on_comment">              <img src="<%= get_profile_photo_url(:url_name => comment.user.url_name) %>" alt=""> diff --git a/app/views/general/_responsive_topnav.html.erb b/app/views/general/_responsive_topnav.html.erb index 0af6629c8..c99864cab 100644 --- a/app/views/general/_responsive_topnav.html.erb +++ b/app/views/general/_responsive_topnav.html.erb @@ -21,11 +21,16 @@          </li>          <li id="navigation_search"> -          <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>"> -            <label for="navigation_search_button"> -              <img src="/assets/search.png" alt="Search:"> +          <form id="navigation_search_form" method="get" action="<%= search_redirect_path %>" role="search"> +            <label class="visually-hidden" for="navigation_search_button"> +              <%= _("Search") %>              </label> -              <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :title => "type your search term here" } %> +              <%= text_field_tag 'query', params[:query], { :id => "navigation_search_button", :type => "search", :placeholder => _("Search"), :title => _("type your search term here") } %> +              <button type="submit"> +                <span class="visually-hidden"> +                  <%= _("Submit Search") %> +                </span> +              </button>            </form>          </li>      </ul> diff --git a/app/views/help/unhappy.html.erb b/app/views/help/unhappy.html.erb index 79e3f8273..c0444fb54 100644 --- a/app/views/help/unhappy.html.erb +++ b/app/views/help/unhappy.html.erb @@ -101,9 +101,8 @@ contact any registered user from their page. There may be an Internet  forum or group that they hang out in. If it is a local matter, use <a  href="http://www.groupsnearyou.com">GroupsNearYou</a> to find such a  forum.</li> -<li><strong>Start a pledge</strong> on <a href="http://www.pledgebank.com">PledgeBank</a> to get -others to act together with you. For example, you could arrange a meeting with -staff from the authority. Or you could form a small local campaigns group. +<li>You could form a small local campaign group and arrange a meeting +with staff from the authority.</li>  </ul> diff --git a/app/views/request/_act.html.erb b/app/views/request/_act.html.erb index 878cdf4ff..c7bbd287f 100644 --- a/app/views/request/_act.html.erb +++ b/app/views/request/_act.html.erb @@ -20,3 +20,8 @@      <% end %>      <%= link_to _("Start your own blog"), "http://wordpress.com/"%>  </div> +<% if AlaveteliConfiguration::enable_widgets %> +  <div class="act_link"> +     <%= link_to _("Create a widget for this request"), new_request_widget_path(@info_request) %> +  </div> +<% end %> diff --git a/app/views/request/_followup.html.erb b/app/views/request/_followup.html.erb index 2643b767f..24cede824 100644 --- a/app/views/request/_followup.html.erb +++ b/app/views/request/_followup.html.erb @@ -20,7 +20,7 @@          </h2>      <% end %>  <% if @info_request.who_can_followup_to(incoming_message).count > 0 %> -<div id="other_recipients"> +<div id="other_recipients" class="box">    <%= _("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|  %> diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb index 70bd25c7f..9d205204e 100644 --- a/app/views/request/_incoming_correspondence.html.erb +++ b/app/views/request/_incoming_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="incoming correspondence <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>"> +<div class="incoming correspondence box <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>">    <%- if not incoming_message.user_can_view?(@user) %>      <%= render :partial => 'request/hidden_correspondence', :locals => { :message => incoming_message }%>    <%- else %> diff --git a/app/views/request/_outgoing_correspondence.html.erb b/app/views/request/_outgoing_correspondence.html.erb index dced5c94c..3b85cae7f 100644 --- a/app/views/request/_outgoing_correspondence.html.erb +++ b/app/views/request/_outgoing_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>"> +<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>">    <%- if not outgoing_message.user_can_view?(@user) %>      <%= render :partial => 'request/hidden_correspondence', :locals => { :message => outgoing_message }%>    <%- else %> diff --git a/app/views/request/_resent_outgoing_correspondence.html.erb b/app/views/request/_resent_outgoing_correspondence.html.erb index 17b6b635b..287a5cac5 100644 --- a/app/views/request/_resent_outgoing_correspondence.html.erb +++ b/app/views/request/_resent_outgoing_correspondence.html.erb @@ -1,4 +1,4 @@ -<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>"> +<div class="outgoing correspondence box" id="outgoing-<%=outgoing_message.id.to_s%>">    <h2>      <%= simple_date(info_request_event.created_at) %>    </h2> diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 486a89d45..23f7ad76a 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -144,7 +144,7 @@            <% if @info_request.public_body.info_requests.size > 0 %>                <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %>            <% else %> -              <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> +              <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_successful_url) %>            <% end %>          </p>        <% end %> @@ -156,7 +156,7 @@            this website <a href="{{url}}">forever</a>', :url => (help_privacy_path+"#public_request").html_safe)) %>.          </p>          <p> -          <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>.', :url => (help_privacy_path+"#real_name").html_safe)) %> +          <%= raw(_('<a href="{{url}}">Thinking of using a pseudonym?</a>', :url => (help_privacy_path+"#real_name").html_safe)) %>          </p>        <% else %>          <p> diff --git a/app/views/request/new_bad_contact.html.erb b/app/views/request/new_bad_contact.html.erb index 56f3f4168..f9881b62b 100644 --- a/app/views/request/new_bad_contact.html.erb +++ b/app/views/request/new_bad_contact.html.erb @@ -5,6 +5,6 @@  <p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}}  address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find  one on their website, or by phoning them up and asking. If you manage -to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %> +to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => new_change_request_path(:body => @info_request.public_body.url_name)) %>  </p> diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb index 78e022aa9..5862413de 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -22,7 +22,7 @@  <% if ( @update_status || @info_request.awaiting_description ) && ! @info_request.is_external? %> -    <div class="describe_state_form" id="describe_state_form_1"> +    <div class="describe_state_form box" id="describe_state_form_1">      <%= render :partial => 'describe_state', :locals => { :id_suffix => "1" } %>      </div>  <% end %> @@ -146,7 +146,7 @@      <% end %>      <% if @info_request.awaiting_description && ! @info_request.is_external? %> -        <div class="describe_state_form" id="describe_state_form_2"> +        <div class="describe_state_form box" id="describe_state_form_2">          <%= render :partial => 'describe_state', :locals => { :id_suffix => "2" } %>          </div>      <% end %> diff --git a/app/views/request_game/play.html.erb b/app/views/request_game/play.html.erb index 471a0e09e..44fe641f9 100644 --- a/app/views/request_game/play.html.erb +++ b/app/views/request_game/play.html.erb @@ -2,7 +2,12 @@  <div id="game_sidebar">      <p style="text-align: center"> -        <img width=250 height=125 src="http://chart.apis.google.com/chart?chs=250x125&cht=gom&chd=t:<%=@percentage%>" alt="<%=@percentage%>% of requests have been categorised"> +        <%= +            image_tag "https://chart.googleapis.com/chart?chs=250x125&cht=gom&chd=t:#{@percentage}", +                      :size => "250x125", +                      :alt => "A chart showing #{@percentage}% of requests have been categorised", +                      :title => "#{@percentage}% of requests have been categorised" +        %>          <br><%=pluralize(@missing, 'request')%> left to categorise / <%=@total %> total      </p> diff --git a/app/views/widgets/new.html.erb b/app/views/widgets/new.html.erb new file mode 100644 index 000000000..c706155a5 --- /dev/null +++ b/app/views/widgets/new.html.erb @@ -0,0 +1,15 @@ +<h1>Add a widget</h1> + +<p> +To add a widget for <b><%= @info_request.title %></b>, copy and paste the +following code to your web page: +<textarea autofocus readonly rows='4' cols='60' id='widgetbox'> +<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe> +</textarea> +</p> + +<p> +The widget will look like this: +<br> +<iframe src='<%= request_widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'></iframe> +</p> diff --git a/app/views/widgets/show.html.erb b/app/views/widgets/show.html.erb new file mode 100644 index 000000000..07c7b1908 --- /dev/null +++ b/app/views/widgets/show.html.erb @@ -0,0 +1,48 @@ +<head> +  <%= stylesheet_link_tag "widget" %> +</head> +<body> +  <div class="alaveteli-widget"> +    <div class="alaveteli-widget__top"> +      <div class="alaveteli-widget__left"> +        <div class="alaveteli-widget__title"> +          <%= link_to @info_request.title, request_path(@info_request), :target => "_top" %> +        </div> +        <div class="alaveteli-widget__status <%= @status %>"> +          <p class="alaveteli-widget__status__status-label">Status</p> +          <%= status_description(@info_request, @status) %> +        </div> +      </div> +      <div class="alaveteli-widget__people-count"> +         <%= n_('<div class="alaveteli-widget__count">{{count}}</div> person wants to know', '<div class="alaveteli-widget__count">{{count}}</div> people want to know', @count, :count => @count) %> +      </div> +    </div> + + +    <div class="alaveteli-widget__bottom"> +      <% if @info_request.user && @info_request.user == @user %> +        <div class="alaveteli-widget__button alaveteli-widget__button--down"> +          <%= _('This is your request') %> +        </div> +      <% elsif @existing_track %> +        <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath %>"> +          <div class="alaveteli-widget__button--down"> +            <%= _('You are tracking this request') %> +          </div> +        </a> +      <% else %> +        <% if @user %> +          <a href="<%= url_for do_track_path(@track_thing) %>" target="_blank"> +            <div class="alaveteli-widget__button"> +              <%= _('I also want to know!') %> +            </div> +          </a> +        <% else %> +          <%= form_tag request_widget_url(@info_request), :method => 'put', :target => '_blank' do %> +            <%= submit_tag _('I also want to know!'), :class => 'alaveteli-widget__button' %> +          <% end %> +        <% end %> +      <% end %> +    </div> +  </div> +</body>  | 
