diff options
-rwxr-xr-x | bin/geocode | 79 | ||||
-rw-r--r-- | perllib/FixMyStreet.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 1 | ||||
-rw-r--r-- | templates/web/default/report/extra_analytics.html | 0 | ||||
-rw-r--r-- | templates/web/default/tokens/confirm_problem.html | 1 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/display.html | 1 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/extra_analytics.html | 8 |
8 files changed, 94 insertions, 1 deletions
diff --git a/bin/geocode b/bin/geocode new file mode 100755 index 000000000..254cf1578 --- /dev/null +++ b/bin/geocode @@ -0,0 +1,79 @@ +#!/usr/bin/perl + +=head1 NAME + +geocode - commandline tool to test geocoders + +=head1 SYNOPSIS + + $ eval `perl setenv.pl`, or call with bin/cron-wrapper + + $ bin/geocode --geocoder=Bing --cobrand=bromley "Glebe Rd" + + # ... if your conf/general.yml supplies GEOCODER: + $ bin/geocode --cobrand=bromley "Glebe Rd" + + # ... if you want to use config that you have in conf/general.bing.yml + $ bin/geocode --override-config=general.bing --cobrand=bromley "Glebe Rd" + + ## ... output from geocoder + +=cut + +use strict; +use warnings; +require 5.8.0; + +use Data::Dumper; +use Pod::Usage; +use feature 'say'; + +use Getopt::Long; + +my %options = ( help => sub { pod2usage(0) } ); + +GetOptions \%options, + 'geocoder=s', + 'help|h', + 'cobrand=s', + 'override-config=s'; + +my $s = join ' ', @ARGV + or pod2usage(0); + +pod2usage(0) unless $options{cobrand}; + +local $ENV{FMS_OVERRIDE_CONFIG} = $options{'override-config'} if $options{'override-config'}; + +eval 'use FixMyStreet'; +eval 'use FixMyStreet::App'; +eval 'use FixMyStreet::Cobrand'; +eval 'use FixMyStreet::Geocode'; + +mySociety::Locale::gettext_domain( 'FixMyStreet' ); + +my $geocoder_type = $options{geocoder} || do { + my $GEOCODER = FixMyStreet->config('GEOCODER'); + ref $GEOCODER ? $GEOCODER->{type} : $GEOCODER; +} or pod2usage(0); + +my $geocoder_name = "FixMyStreet::Geocode::${geocoder_type}"; +my $code_ref = $geocoder_name->can('string') + or die "$geocoder_name is not a valid geocoder?"; + +my @allowed_cobrands = FixMyStreet::Cobrand->get_allowed_cobrands(); + +my $cobrand_name = FixMyStreet::Cobrand->get_class_for_moniker($options{cobrand}); +my $cobrand = $cobrand_name->new(); + +say "USING COBRAND $cobrand_name"; +if ($cobrand->moniker ne lc($options{cobrand})) { + say "!!! asked for $options{cobrand}"; + say "!!! Check ALLOWED_COBRANDS setting in conf/general.yml (or supplied --override-config file)"; + say Dumper(\@allowed_cobrands); +} + +my $c = FixMyStreet::App->new(); +$c->stash->{cobrand} = $cobrand; + +say Dumper( $code_ref->( $s, $c ) ); diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm index cc5286bbb..de55e0070 100644 --- a/perllib/FixMyStreet.pm +++ b/perllib/FixMyStreet.pm @@ -12,8 +12,10 @@ use Sub::Override; use mySociety::Config; use mySociety::DBHandle; +my $CONF_FILE = $ENV{FMS_OVERRIDE_CONFIG} || 'general'; + # load the config file and store the contents in a readonly hash -mySociety::Config::set_file( __PACKAGE__->path_to("conf/general") ); +mySociety::Config::set_file( __PACKAGE__->path_to("conf/${CONF_FILE}") ); Readonly::Hash my %CONFIG, %{ mySociety::Config::get_list() }; =head1 NAME diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index bf9f171be..761215344 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -1155,6 +1155,7 @@ sub redirect_or_confirm_creation : Private { $report_uri = $c->cobrand->base_url_for_report( $report ) . $report->url; } $c->log->info($report->user->id . ' was logged in, redirecting to /report/' . $report->id); + $c->flash->{created_report} = 'loggedin'; $c->res->redirect($report_uri); $c->detach; } diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 5e536afa3..19130e25f 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -102,6 +102,7 @@ sub confirm_problem : Path('/P') { $c->res->redirect($report_uri); } + $c->flash->{created_report} = 'fromemail'; return 1; } diff --git a/templates/web/default/report/extra_analytics.html b/templates/web/default/report/extra_analytics.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/templates/web/default/report/extra_analytics.html diff --git a/templates/web/default/tokens/confirm_problem.html b/templates/web/default/tokens/confirm_problem.html index 723d515e1..51b459925 100644 --- a/templates/web/default/tokens/confirm_problem.html +++ b/templates/web/default/tokens/confirm_problem.html @@ -28,4 +28,5 @@ You can <a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %] [% display_crosssell_advert( problem.user.email, problem.name ) %] +[% INCLUDE 'report/extra_analytics.html' %] [% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html index b75ef92bc..2c65ca104 100644 --- a/templates/web/fixmystreet/report/display.html +++ b/templates/web/fixmystreet/report/display.html @@ -23,6 +23,7 @@ [% INCLUDE 'report/banner.html' %] [% INCLUDE 'report/_main.html' %] +[% INCLUDE 'report/extra_analytics.html' %] [% TRY %][% INCLUDE 'report/_message_manager.html' %][% CATCH file %][% END %] <div class="shadow-wrap"> diff --git a/templates/web/fixmystreet/report/extra_analytics.html b/templates/web/fixmystreet/report/extra_analytics.html new file mode 100644 index 000000000..4a993cc2d --- /dev/null +++ b/templates/web/fixmystreet/report/extra_analytics.html @@ -0,0 +1,8 @@ +[% IF c.flash.created_report %] +<script type="text/javascript"> + var cobrand = $('meta[name="cobrand"]').attr('content'); + if ( typeof ga !== 'undefined' && cobrand == 'fixmystreet' ) { + ga('send', 'event', 'report', 'completed', '[% c.flash.created_report %]' ); + } +</script> +[% END %] |