diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | bin/generate_council_location | 26 | ||||
-rwxr-xr-x | bin/send-reports | 2 | ||||
-rw-r--r-- | notes/cobranding.txt | 44 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Reading.pm | 81 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/Bing.pm | 1 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 10 | ||||
-rw-r--r-- | templates/web/reading/footer.html | 40 | ||||
-rw-r--r-- | templates/web/reading/header.html | 43 | ||||
-rw-r--r-- | web/cobrands/reading/css/css.scss | 86 | ||||
-rw-r--r-- | web/cobrands/reading/css/print3rdParty.css | 33 | ||||
-rw-r--r-- | web/cobrands/reading/css/reading.css | 176 | ||||
-rwxr-xr-x | web/cobrands/reading/images/favicon.ico | bin | 0 -> 3262 bytes | |||
-rw-r--r-- | web/cobrands/reading/images/reading-borough-council-logo.gif | bin | 0 -> 4575 bytes |
17 files changed, 556 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore index c8eebb0b2..4f3cb067d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ lib tags /web/cobrands/fiksgatami/css.css /web/cobrands/southampton/css.css +/web/cobrands/reading/css/css.css /web/css/core.css /web/css/main.css diff --git a/bin/generate_council_location b/bin/generate_council_location new file mode 100644 index 000000000..36bf14d04 --- /dev/null +++ b/bin/generate_council_location @@ -0,0 +1,26 @@ +use strict; +use JSON; +use LWP::Simple; + +my $id = shift; + +my $url = sprintf( 'http://mapit.mysociety.org/area/%s/geometry', $id); + +my $json = get( $url ); +my $geo = decode_json( $json ); + +my $max_lat = $geo->{max_lat}; +my $min_lat = $geo->{min_lat}; +my $max_lon = $geo->{max_lon}; +my $min_lon = $geo->{min_lon}; +my $c_lat = $geo->{centre_lat}; +my $c_lon = $geo->{centre_lon}; + +my $spn_lat = $max_lat - $min_lat; +my $spn_lon = $max_lon - $min_lon; + +print <<"EOT"; + centre => '$c_lat,$c_lon', + span => '$spn_lat,$spn_lon', + bounds => [ '$min_lat,$min_lon','$max_lat,$max_lon' ], +EOT diff --git a/bin/send-reports b/bin/send-reports index a43432312..b2820b750 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -460,7 +460,7 @@ sub post_london_report { # Nearest things sub london_lookup { - my $org = shift; + my $org = shift || ''; my $str = "Unknown ($org)"; open(FP, "$FindBin::Bin/../data/dft.csv"); while (<FP>) { diff --git a/notes/cobranding.txt b/notes/cobranding.txt new file mode 100644 index 000000000..1db3b8188 --- /dev/null +++ b/notes/cobranding.txt @@ -0,0 +1,44 @@ +Notes on adding a co brand +-------------------------- + +Basic steps + +Assumes cobrand is for ExampleCom + +NB: this is moderately specific to producing cobrands for UK councils + +1: copy an exiting perllib/FixMyStreet/Cobrand/ file to perllib/FixMyStreet/Cobrand/ExampleCom.pm + * Change package name at top of file + * Change following functions accordingly: + site_title + site_restriction + problems_clause + enter_postcode_text + council_check + base_url + all_councils_report should return 0 + disambiguate_location - see below for details on this + +2: create a web/cobrands/examplecom folder and put custom css/images/js in here + +3: create templates/web/examplecom/ and put a header.html and footer.html with relevant html + +4: edit conf/general and add examplecom to allowed cobrands + +5: restart server + +6: on dev server you can append ?_override_cobrand_moniker=examplecom +to display the cobrand. ?_override_clear_all=1 will remove this + +disambiguate_location + +The results of this are used to provide a bounding box for reverse +geolocation. + +There's a script in bin - generate_council_location that takes the +mapit area code for the council as a argument and generates the +contents of the disambiguate_location hash. + +You can also add a town key to the hashref which will be appended +on to the end of geolocation queries in order to narrow down results +for popular road names, e.g High St diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 551e9b719..0714db6eb 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -932,6 +932,16 @@ sub save_user_and_report : Private { # Save or update the user if appropriate if ( !$report->user->in_storage ) { + # User does not exist. + # Store changes in token for when token is validated. + $c->stash->{token_data} = { + name => $report->user->name, + phone => $report->user->phone, + password => $report->user->password, + }; + $report->user->name( undef ); + $report->user->phone( undef ); + $report->user->password( '', 1 ); $report->user->insert(); } elsif ( $c->user && $report->user->id == $c->user->id ) { diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index add9d1371..c67ca4d1f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -255,6 +255,14 @@ sub save_update : Private { my $update = $c->stash->{update}; if ( !$update->user->in_storage ) { + # User does not exist. + # Store changes in token for when token is validated. + $c->stash->{token_data} = { + name => $update->user->name, + password => $update->user->password, + }; + $update->user->name( undef ); + $update->user->password( '', 1 ); $update->user->insert; } elsif ( $c->user && $c->user->id == $update->user->id ) { diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 10f994d9f..b974f94e6 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -69,6 +69,7 @@ sub confirm_problem : Path('/P') { # log the problem creation user in to the site if ( ref($data) && ( $data->{name} || $data->{password} ) ) { $problem->user->name( $data->{name} ) if $data->{name}; + $problem->user->phone( $data->{phone} ) if $data->{phone}; $problem->user->password( $data->{password}, 1 ) if $data->{password}; $problem->user->update; } diff --git a/perllib/FixMyStreet/Cobrand/Reading.pm b/perllib/FixMyStreet/Cobrand/Reading.pm new file mode 100644 index 000000000..f4fd0dc7a --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/Reading.pm @@ -0,0 +1,81 @@ +package FixMyStreet::Cobrand::Reading; +use base 'FixMyStreet::Cobrand::Default'; + +use strict; +use warnings; + +use Carp; +use URI::Escape; +use mySociety::VotingArea; + +sub site_restriction { + return ( "and council='2596'", 'reading', { council => '2596' } ); +} + +sub problems_clause { + return { council => '2596' }; +} + +sub problems { + my $self = shift; + return $self->{c}->model('DB::Problem')->search( $self->problems_clause ); +} + +sub base_url { + my $base_url = mySociety::Config::get('BASE_URL'); + if ($base_url !~ /reading/) { + $base_url =~ s{http://(?!www\.)}{http://reading.}g; + $base_url =~ s{http://www\.}{http://reading.}g; + } + return $base_url; +} + +sub site_title { + my ( $self ) = @_; + return 'Reading City Council FixMyStreet'; +} + +sub enter_postcode_text { + my ( $self ) = @_; + return 'Enter a Reading postcode, or street name and area'; +} + +sub council_check { + my ( $self, $params, $context ) = @_; + + my $councils = $params->{all_councils}; + my $council_match = defined $councils->{2596}; + if ($council_match) { + return 1; + } + my $url = 'http://www.fixmystreet.com/'; + $url .= 'alert' if $context eq 'alert'; + $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{c}->req->param('pc')) + if $self->{c}->req->param('pc'); + my $error_msg = "That location is not covered by Reading. +Please visit <a href=\"$url\">the main FixMyStreet site</a>."; + return ( 0, $error_msg ); +} + +# All reports page only has the one council. +sub all_councils_report { + return 0; +} + +sub disambiguate_location { + return { + town => 'Reading', + centre => '51.452983169803964,-0.98382678731985973', + span => '0.0833543573028663,0.124500468843446', + bounds => [ '51.409779668156361,-1.0529948144525243', '51.493134025459227,-0.92849434560907829' ], + }; +} + +sub recent_photos { + my ($self, $num, $lat, $lon, $dist) = @_; + $num = 2 if $num == 3; + return $self->problems->recent_photos( $num, $lat, $lon, $dist ); +} + +1; + diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm index b804102c9..856d7061e 100644 --- a/perllib/FixMyStreet/Geocode/Bing.pm +++ b/perllib/FixMyStreet/Geocode/Bing.pm @@ -22,6 +22,7 @@ use Digest::MD5 qw(md5_hex); # may be used to disambiguate the location in cobranded versions of the site. sub string { my ( $s, $c, $params ) = @_; + $s .= '+' . $params->{town} if $params->{town} and $s !~ /$params->{town}/i; my $url = "http://dev.virtualearth.net/REST/v1/Locations?q=$s&c=en-GB"; # FIXME nb-NO for Norway $url .= '&mapView=' . $params->{bounds}[0] . ',' . $params->{bounds}[1] if $params->{bounds}; diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index a071d3fda..9ec8fa4a8 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -375,9 +375,11 @@ foreach my $test ( FixMyStreet::App->model('DB::User')->find( { email => $test_email } ); ok $user, "user found"; if ($test->{user}) { + is $user->name, 'Old Name', 'name unchanged'; ok $user->check_password('old_password'), 'password unchanged'; } else { - ok $user->check_password('secret'), 'password set correctly'; + is $user->name, undef, 'name not yet set'; + is $user->password, '', 'password not yet set for new user'; } # find the report @@ -406,10 +408,8 @@ foreach my $test ( $mech->get_ok( '/report/' . $report->id ); - if ($test->{user}) { - is $report->name, 'Joe Bloggs', 'name updated correctly'; - ok $report->user->check_password('secret'), 'password updated correctly'; - } + is $report->name, 'Joe Bloggs', 'name updated correctly'; + ok $report->user->check_password('secret'), 'password updated correctly'; # check that the reporter has an alert my $alert = FixMyStreet::App->model('DB::Alert')->find( { diff --git a/templates/web/reading/footer.html b/templates/web/reading/footer.html new file mode 100644 index 000000000..be410bbfc --- /dev/null +++ b/templates/web/reading/footer.html @@ -0,0 +1,40 @@ +</div> +</div> + +<h2 class="v">[% loc('Navigation') %]</h2> +<ul id="navigation"> +<li><a href="/">[% loc("Report a problem") %]</a></li> +<li id="nav_new"><a href="/my">[% loc("Your reports") %]</a></li> +<li><a href="/reports/Reading">[% loc("All reports") %]</a></li> +<li><a href="/alert[% pc ? '/list?pc=' : '' %][% pc | uri %]">[% loc("Local alerts") %]</a></li> +<li><a href="/faq">[% loc("Help") %]</a></li> +</ul> + +<div id="footer"> + <p>[% loc('Built by <a href="http://www.mysociety.org/">mySociety</a>') %] + | <a href="/contact">[% loc("Contact FixMyStreet") | replace(' ', ' ') %]</a></p> +[% loc('<a href="http://www.mysociety.org/"><img id="logo" width="133" height="26" src="/i/mysociety-dark.png" alt="View mySociety.org"><span id="logoie"></span></a>') %] +</div> + <!-- start of footer --> + <div style="clear:both"></div> + </div> + <div style="clear:both"></div> + </div> + <div class="footer"> + <div class="contact"> + <p class="title">Contact</p> + <address> + Reading Borough Council<br /> + Civic Centre<br /> + Reading<br /> + RG1 7AE + </address> + <div class="phone"> + <p>Phone: 0118 937 3737<br />Text: 81722</p> + </div> + </div> + <div class="clear"></div> + </div> + </div> +</body> +</html> diff --git a/templates/web/reading/header.html b/templates/web/reading/header.html new file mode 100644 index 000000000..d32bd545e --- /dev/null +++ b/templates/web/reading/header.html @@ -0,0 +1,43 @@ +<!doctype html> +<!--[if lt IE 7]><html class="no-js ie6 oldie" lang="[% lang_code %]"><![endif]--> +<!--[if IE 7]> <html class="no-js ie7 oldie" lang="[% lang_code %]"><![endif]--> +<!--[if IE 8]> <html class="no-js ie8 oldie" lang="[% lang_code %]"><![endif]--> +<!--[if gt IE 8]><!--><html class="no-js" lang="[% lang_code %]"><!--<![endif]--> + +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head id="ctl00_pageHead"> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <title>Reading Borough Council | FixMyStreet</title> + <link rel="shortcut icon" href="[% version('/cobrands/reading/images/favicon.ico') %]"> + <link rel="stylesheet" type="text/css" href="[% version('/css/core.css') %]"> + <link rel="stylesheet" type="text/css" href="[% version('/cobrands/reading/css/reading.css') %]" /> + <link rel="stylesheet" type="text/css" href="[% version('/cobrands/reading/css/print3rdParty.css') %]" media="print"/> + <link rel="stylesheet" type="text/css" href="[% version('/cobrands/reading/css/css.css') %]" /> + + [% INCLUDE 'common_header_tags.html' %] + +</head> +<body> + <div class="wrapper"> + <div class="header"> + <p id="reading-logo" class="thirdParty"><img src="/cobrands/reading/images/reading-borough-council-logo.gif" width="176" height="38" alt="reading borough council logo" class="printMe" /><a href="http://www.reading.gov.uk/" title="Click to return to home page">Reading Borough Council</a></p> + </div> + + <div id="content"> + <div class="thirdParty"> + <!-- end of header --> + + [% IF NOT title AND NOT c.req.path %]<h1 id="header">[% ELSE %]<div id="header"><a href="/">[% END %] + [%- loc('Fix<span id="my">My</span>Street') %] + [%- IF NOT title AND NOT c.req.path %]</h1>[% ELSE %]</a></div>[% END %] + + <ul id="meta"> + [% IF c.user_exists %] + <li>[% tprintf(loc('Signed in as %s'), c.user.name || c.user.email) %] + <li><a href="/auth/sign_out">[% loc('Sign out') %]</a></li> + [% ELSE %] + <li> </li> + [% END %] + </ul> + + <div id="wrapper"><div id="mysociety"> diff --git a/web/cobrands/reading/css/css.scss b/web/cobrands/reading/css/css.scss new file mode 100644 index 000000000..d9f3083ee --- /dev/null +++ b/web/cobrands/reading/css/css.scss @@ -0,0 +1,86 @@ +// Generics + +$header_back: #ecf5fd; +$header_back_lighter: #ecf5fd; +$header_colour: #000; +$header_darker: #000; + +$map_width: 420px; + +@import "../../../css/_main.scss"; + + #navigation { + margin-top: 125px; + } + + h1#header { + font-size: 200%; + margin-bottom: 0em; + } + + #logo { + top: 12.5em; + } + + a { + color: #9C2161; + } + + body { + font-family: Helvetica, Arial, sans-serif; + font-size: 13.5px; + color: black; + } + +#mysociety { + + #map_box { + width: $map_width + 2; + } + + #map { + width: $map_width; + height: $map_width; + } + + dd { + margin-left: 40px; + } + + div { + padding-top: 0.2em; + padding-bottom: 0.2em; + } + + h3 { + font-size: 1.17em; + font-weight: bold; + margin: 1em 0em 1em 0em; + } + + h2 { + font-weight: bold; + margin: 1em 0em 1em 0em; + } + + ul, ol { + padding-left: 2em; + } + + label { + width: 6em; + } + + .fieldset div.checkbox, #problem_submit { + padding-left: 6.5em; + } + + table { + border-collapse: separate; + border-spacing: 1px; + } + + td { + padding: 3px; + } +} diff --git a/web/cobrands/reading/css/print3rdParty.css b/web/cobrands/reading/css/print3rdParty.css new file mode 100644 index 000000000..f5b7ebc83 --- /dev/null +++ b/web/cobrands/reading/css/print3rdParty.css @@ -0,0 +1,33 @@ +body { + background: white; + font-size: 12pt; + color:#000; + } +#access, +.header .social, .nav, .footer { + display: none; +} +.wrapper, #content { + width: auto; + margin: 0 2%; + padding: 0; + border: 0; + float: none !important; + color: black; + background: transparent none; +} +p#logo img.printMe { display:block; vertical-align: bottom; } +div#content { + margin-left: 5%; + padding-top: 1em; + border-top: 1px solid #9c2161; +} +p#logo { + margin-bottom: -8px; +} +a:link, a:visited { + color: #9c2161; + background: transparent; + font-weight: bold; + text-decoration: underline; +}
\ No newline at end of file diff --git a/web/cobrands/reading/css/reading.css b/web/cobrands/reading/css/reading.css new file mode 100644 index 000000000..4daef13c9 --- /dev/null +++ b/web/cobrands/reading/css/reading.css @@ -0,0 +1,176 @@ +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +blockquote, q { quotes: none; } +blockquote:before, blockquote:after, +q:before, q:after { content: ''; content: none; } +ins { background-color: #ff9; color: #000; text-decoration: none; } +mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; } +del { text-decoration: line-through; } +abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; } +table { border-collapse: collapse; border-spacing: 0; } +hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } +input, select { vertical-align: middle; } +body { font:13px/1.231 sans-serif; *font-size:small; } +select, input, textarea, button { font:99% sans-serif; } +pre, code, kbd, samp { font-family: monospace, sans-serif; } +html { overflow-y: scroll; } +a:hover, a:active { outline: none; } +ul, ol { margin-left: 0; } +ol { list-style-type: decimal; } +nav ul, nav li, +.nav ul, .nav li{ margin: 0; list-style:none; list-style-image: none; } +small { font-size: 85%; } +strong, th { font-weight: bold; } +td { vertical-align: top; } +sub, sup { font-size: 75%; line-height: 0; position: relative; } +sup { top: -0.5em; } +sub { bottom: -0.25em; } +pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 15px; } +textarea { overflow: auto; } +.ie6 legend, .ie7 legend { margin-left: -7px; } +input[type="radio"] { vertical-align: text-bottom; } +input[type="checkbox"] { vertical-align: bottom; } +.ie7 input[type="checkbox"] { vertical-align: baseline; } +.ie6 input { vertical-align: text-bottom; } +label, input[type="button"], input[type="submit"], input[type="image"], button { cursor: pointer; } +button, input, select, textarea { margin: 0; } +input:valid, textarea:valid { } +input:invalid, textarea:invalid { border-radius: 1px; -moz-box-shadow: 0px 0px 5px red; -webkit-box-shadow: 0px 0px 5px red; box-shadow: 0px 0px 5px red; } +.no-boxshadow input:invalid, .no-boxshadow textarea:invalid { background-color: #f0dddd; } +button { width: auto; overflow: visible; } +img { -ms-interpolation-mode: bicubic; } +body { + margin:0; + padding:0; + font:normal 14px Helvetica, Arial, serif; +} + + + +/*Main Structure*/ +.wrapper { + max-width: 1376px; + margin-bottom:20px; +} +header, nav, footer, +.header, .nav, .footer, +#content{ + margin:0 20px; +} + + +.header {} + +p#reading-logo{ + text-indent:-9999px; + background:url("/cobrands/reading/images/reading-borough-council-logo.gif") top left no-repeat; + width:176px; + padding-bottom:20px; +} +p.thirdParty#reading-logo { margin-top:35px;} +p#reading-logo img.printMe { display:none;} +p#reading-logo a{ + display:block; + height:38px; +} + +#content{ + margin-top:30px; +} +#content h1 { + font-weight: bold; + font-size:1.6em; + margin-bottom:1em; +} +.thirdParty { } +.thirdParty p { margin-bottom:1em;} + .footer .contact { + width:44%!important; + } + .footer .links { + width:55%!important; + margin-right:0!important; + } + .footer .links ul li { + display:inline; + font-size:12px; + margin-right:3px; + border-right:1px solid #999; + padding-right:4px; + } + .footer .links ul li.last { + margin-right:0; + border:none; + paddin-right:0; + } + .footer .partners { + width:100%!important; + } +footer, +.footer{ + margin-top:15px; +} +footer h3, +.footer h3{ + border-bottom:1px solid #b4b4b4; + padding-bottom:3px; + margin-bottom:10px; +} +footer p.title, +.footer p.title{ + border-bottom:1px solid #b4b4b4; + padding-bottom:3px; + margin-bottom:10px; +} +footer .contact, +.footer .contact { + width:38.9%; + margin-top:15px; +} +footer .links, +.footer .links { + width:15%; + margin-top:15px; +} +footer .partners, +.footer .partners { + width:44%; + margin-top:15px; +} +footer h4, +.footer h4 {display:inline;} +footer .contact, +footer .links, +.footer .contact, +.footer .links { + margin-right:1%; +} +footer .contact address, footer .contact .phone, +.footer .contact address, .footer .contact .phone{ + width:49%; +} +footer .contact,footer .links,footer .contact address,footer .contact .phone,footer .partners, +.footer .contact,.footer .links,.footer .contact address,.footer .contact .phone,.footer .partners{ + float:left; + font-style:normal +} +.clear { clear:both;} + diff --git a/web/cobrands/reading/images/favicon.ico b/web/cobrands/reading/images/favicon.ico Binary files differnew file mode 100755 index 000000000..2619d70e9 --- /dev/null +++ b/web/cobrands/reading/images/favicon.ico diff --git a/web/cobrands/reading/images/reading-borough-council-logo.gif b/web/cobrands/reading/images/reading-borough-council-logo.gif Binary files differnew file mode 100644 index 000000000..8532e63ea --- /dev/null +++ b/web/cobrands/reading/images/reading-borough-council-logo.gif |