diff options
-rw-r--r-- | conf/httpd.conf | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Root.pm | 2 | ||||
-rw-r--r-- | t/app/controller/index.t | 39 | ||||
-rw-r--r-- | templates/web/default/index.html | 98 | ||||
-rwxr-xr-x | web/index.cgi | 200 |
5 files changed, 238 insertions, 103 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf index d0cb89ebb..1508c96af 100644 --- a/conf/httpd.conf +++ b/conf/httpd.conf @@ -111,8 +111,6 @@ RewriteRule ^/confirm(.*) /confirm.cgi$1 [L] RewriteRule ^/contact(.*) /contact.cgi$1 [L] RewriteRule ^/flickr(.*) /flickr.cgi$1 [L] RewriteRule ^/fun(.*) /fun.cgi$1 [L] -RewriteRule ^/$ /index.cgi [L] -RewriteRule ^/index(.*) /index.cgi$1 [L] RewriteRule ^/json(.*) /json.cgi$1 [L] RewriteRule ^/photo(.*) /photo.cgi$1 [L] RewriteRule ^/questionnaire(.*) /questionnaire.cgi$1 [L] diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 2a25d4040..461105b68 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -37,7 +37,7 @@ sub auto : Private { sub index : Path : Args(0) { my ( $self, $c ) = @_; - $c->res->body('index'); + } =head2 default diff --git a/t/app/controller/index.t b/t/app/controller/index.t new file mode 100644 index 000000000..1d0bff33c --- /dev/null +++ b/t/app/controller/index.t @@ -0,0 +1,39 @@ +use strict; +use warnings; +use Test::More; + +use FixMyStreet::TestMech; +my $mech = FixMyStreet::TestMech->new; + +# check that the homepage loads +$mech->get_ok('/'); + +subtest "check that the form goes to /around" => sub { + $mech->get_ok('/'); + + # submit form + $mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } ); + + # check that we are at /around + is $mech->res->uri->path, '/around', "Got to /around"; + is $mech->res->uri->query_form, { pc => 'SW1A 1AA' }, "query passed along"; +}; + +subtest "check that requests with pc, x,y or lat,lon go to /around" => sub { + foreach my $test ( + { pc => 'SW1A 1AA', }, + { x => 3281, y => 1113, }, + { lat => 51.50100, lon => -0.14158, }, + ) + { + my $uri = URI->new('http://localhost/'); + $uri->query_form($test); + $mech->get_ok($uri); + + # check that we are at /around + is $mech->res->uri->path, '/around', "Got to /around"; + is $mech->res->uri->query_form, $test, "query passed along"; + } +}; + +done_testing(); diff --git a/templates/web/default/index.html b/templates/web/default/index.html new file mode 100644 index 000000000..b895390ed --- /dev/null +++ b/templates/web/default/index.html @@ -0,0 +1,98 @@ +[% INCLUDE 'header.html', title => '' %] + +<p id="expl"> + [% + subhead + = c.cobrand.moniker == 'southampton' + ? '(like graffiti, fly tipping, or broken paving slabs)' + : loc('(like graffiti, fly tipping, broken paving slabs, or street lighting)'); + %] + + <strong>[% loc('Report, view, or discuss local problems') %]</strong> + + [% IF subhead != ' ' %] + <br><small>[% subhead %]</small> + [% END %] +</p> + + +[% # --- insert iPhone details, not converted from old cgi script yet + # + # if (my $url = mySociety::Config::get('IPHONE_URL')) { + # my $getiphone = _("Get FixMyStreet on your iPhone"); + # my $new = _("New!"); + # if ($q->{site} eq 'fixmystreet') { + # $out .= <<EOF + # <p align="center" style="margin-bottom:0"> + # <img width="23" height="12" alt="$new" src="/i/new.png" border="0"> + # <a href="$url">$getiphone</a> + # </p> + # EOF + # } +%] + + +[% IF error %] + <p class="error">[% error %]</p> +[% END %] + + +[% + question + = c.cobrand.enter_postcode_text() + || loc("Enter a nearby GB postcode, or street name and area"); +%] + +<form action="[% c.cobrand.url('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> + <label for="pc">[% question %]:</label> + <input type="text" name="pc" value="" id="pc" size="10" maxlength="200"> + <input type="submit" value="[% loc('Go') %]" id="submit"> + [% c.cobrand.form_elements('postcodeForm') %] +</form> + + +<div id="front_intro"> + + <h2>[% loc('How to report a problem') %]</h2> + + <ol> + <li>[% question %]</li> + <li>[% loc('Locate the problem on a map of the area') %]</li> + <li>[% loc('Enter details of the problem') %]</li> + <li>[% loc('We send it to the council on your behalf') %]</li> + </ol> + + <p>FIXME - front stats go here</p> + [%# c.cobrand.front_stats() %] + +</div> + +[% + recent_photos = c.cobrand.recent_photos(3); + probs = c.cobrand.recent(); +%] + + +[% IF probs.size || recent_photos %] +<div id="front_recent"> + [% IF recent_photos %] + <h2>[% loc('Photos of recent reports') %]</h2> + [% recent_photos %] + [% END %] + + [% IF probs.size %] + + <h2>[% loc('Recently reported problems') %]</h2> + + <ul> + [% FOREACH p IN probs %] + <li> + <a href="/report/[% p.id %]">[% p.title | html %]</a> + </li> + [% END %] + </ul> + [% END %] +</div> +[% END %] + +[% INCLUDE 'footer.html' %]
\ No newline at end of file diff --git a/web/index.cgi b/web/index.cgi index d92d420cb..01181805c 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -107,106 +107,106 @@ sub main { } Page::do_fastcgi(\&main); -# Display front page -sub front_page { - my ($q, $error, $status_code) = @_; - my $pc_h = ent($q->param('pc') || ''); - - # Look up various cobrand things - my $cobrand = Page::get_cobrand($q); - my $cobrand_form_elements = Cobrand::form_elements($cobrand, 'postcodeForm', $q); - my $form_action = Cobrand::url($cobrand, '/', $q); - my $question = Cobrand::enter_postcode_text($cobrand, $q); - $question = _("Enter a nearby GB postcode, or street name and area") - unless $question; - my %params = ('context' => 'front-page'); - $params{status_code} = $status_code if $status_code; - my %vars = ( - error => $error || '', - pc_h => $pc_h, - cobrand_form_elements => $cobrand_form_elements, - form_action => $form_action, - question => "$question:", - ); - my $cobrand_front_page = Page::template_include('front-page', $q, Page::template_root($q), %vars); - return ($cobrand_front_page, %params) if $cobrand_front_page; - - my $out = '<p id="expl"><strong>' . _('Report, view, or discuss local problems') . '</strong>'; - my $subhead = _('(like graffiti, fly tipping, broken paving slabs, or street lighting)'); - $subhead = '(like graffiti, fly tipping, or broken paving slabs)' - if $q->{site} eq 'southampton'; - $out .= '<br><small>' . $subhead . '</small>' if $subhead ne ' '; - $out .= '</p>'; - #if (my $url = mySociety::Config::get('IPHONE_URL')) { - # my $getiphone = _("Get FixMyStreet on your iPhone"); - # my $new = _("New!"); - # if ($q->{site} eq 'fixmystreet') { - # $out .= <<EOF -#<p align="center" style="margin-bottom:0"> -#<img width="23" height="12" alt="$new" src="/i/new.png" border="0"> -#<a href="$url">$getiphone</a> -#</p> -#EOF - # } - #} - $out .= '<p class="error">' . $error . '</p>' if ($error); - - # Add pretty commas for display - $out .= '<form action="' . $form_action . '" method="get" name="postcodeForm" id="postcodeForm">'; - if (my $token = $q->param('partial')) { - my $id = mySociety::AuthToken::retrieve('partial', $token); - if ($id) { - my $thanks = _("Thanks for uploading your photo. We now need to locate your problem, so please enter a nearby street name or postcode in the box below :"); - $out .= <<EOF; -<p style="margin-top: 0; color: #cc0000;"><img align="right" src="/photo?id=$id" hspace="5">$thanks</p> - -<input type="hidden" name="partial_token" value="$token"> -EOF - } - } - my $activate = _("Go"); - $out .= <<EOF; -<label for="pc">$question:</label> - <input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="200"> - <input type="submit" value="$activate" id="submit"> -$cobrand_form_elements -</form> - -<div id="front_intro"> -EOF - $out .= $q->h2(_('How to report a problem')); - $out .= $q->ol( - $q->li($question), - $q->li(_('Locate the problem on a map of the area')), - $q->li(_('Enter details of the problem')), - $q->li(_('We send it to the council on your behalf')) - ); - - - $out .= Cobrand::front_stats(Page::get_cobrand($q), $q); - - $out .= <<EOF; -</div> - -EOF - - my $recent_photos = Cobrand::recent_photos(Page::get_cobrand($q), 3); - my $probs = Cobrand::recent(Page::get_cobrand($q)); - if (@$probs || $recent_photos){ - $out .= '<div id="front_recent">'; - $out .= $q->h2(_('Photos of recent reports')) . $recent_photos if $recent_photos; - - $out .= $q->h2(_('Recently reported problems')) . ' <ul>' if @$probs; - foreach (@$probs) { - $out .= '<li><a href="/report/' . $_->{id} . '">'. ent($_->{title}); - $out .= '</a></li>'; - } - $out .= '</ul>' if @$probs; - $out .= '</div>'; - } - - return ($out, %params); -} +# # Display front page +# sub front_page { +# my ($q, $error, $status_code) = @_; +# my $pc_h = ent($q->param('pc') || ''); +# +# # Look up various cobrand things +# my $cobrand = Page::get_cobrand($q); +# my $cobrand_form_elements = Cobrand::form_elements($cobrand, 'postcodeForm', $q); +# my $form_action = Cobrand::url($cobrand, '/', $q); +# my $question = Cobrand::enter_postcode_text($cobrand, $q); +# $question = _("Enter a nearby GB postcode, or street name and area") +# unless $question; +# my %params = ('context' => 'front-page'); +# $params{status_code} = $status_code if $status_code; +# my %vars = ( +# error => $error || '', +# pc_h => $pc_h, +# cobrand_form_elements => $cobrand_form_elements, +# form_action => $form_action, +# question => "$question:", +# ); +# my $cobrand_front_page = Page::template_include('front-page', $q, Page::template_root($q), %vars); +# return ($cobrand_front_page, %params) if $cobrand_front_page; +# +# my $out = '<p id="expl"><strong>' . _('Report, view, or discuss local problems') . '</strong>'; +# my $subhead = _('(like graffiti, fly tipping, broken paving slabs, or street lighting)'); +# $subhead = '(like graffiti, fly tipping, or broken paving slabs)' +# if $q->{site} eq 'southampton'; +# $out .= '<br><small>' . $subhead . '</small>' if $subhead ne ' '; +# $out .= '</p>'; +# #if (my $url = mySociety::Config::get('IPHONE_URL')) { +# # my $getiphone = _("Get FixMyStreet on your iPhone"); +# # my $new = _("New!"); +# # if ($q->{site} eq 'fixmystreet') { +# # $out .= <<EOF +# #<p align="center" style="margin-bottom:0"> +# #<img width="23" height="12" alt="$new" src="/i/new.png" border="0"> +# #<a href="$url">$getiphone</a> +# #</p> +# #EOF +# # } +# #} +# $out .= '<p class="error">' . $error . '</p>' if ($error); +# +# # Add pretty commas for display +# $out .= '<form action="' . $form_action . '" method="get" name="postcodeForm" id="postcodeForm">'; +# if (my $token = $q->param('partial')) { +# my $id = mySociety::AuthToken::retrieve('partial', $token); +# if ($id) { +# my $thanks = _("Thanks for uploading your photo. We now need to locate your problem, so please enter a nearby street name or postcode in the box below :"); +# $out .= <<EOF; +# <p style="margin-top: 0; color: #cc0000;"><img align="right" src="/photo?id=$id" hspace="5">$thanks</p> +# +# <input type="hidden" name="partial_token" value="$token"> +# EOF +# } +# } +# my $activate = _("Go"); +# $out .= <<EOF; +# <label for="pc">$question:</label> +# <input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="200"> +# <input type="submit" value="$activate" id="submit"> +# $cobrand_form_elements +# </form> +# +# <div id="front_intro"> +# EOF +# $out .= $q->h2(_('How to report a problem')); +# $out .= $q->ol( +# $q->li($question), +# $q->li(_('Locate the problem on a map of the area')), +# $q->li(_('Enter details of the problem')), +# $q->li(_('We send it to the council on your behalf')) +# ); +# +# +# $out .= Cobrand::front_stats(Page::get_cobrand($q), $q); +# +# $out .= <<EOF; +# </div> +# +# EOF +# +# my $recent_photos = Cobrand::recent_photos(Page::get_cobrand($q), 3); +# my $probs = Cobrand::recent(Page::get_cobrand($q)); +# if (@$probs || $recent_photos){ +# $out .= '<div id="front_recent">'; +# $out .= $q->h2(_('Photos of recent reports')) . $recent_photos if $recent_photos; +# +# $out .= $q->h2(_('Recently reported problems')) . ' <ul>' if @$probs; +# foreach (@$probs) { +# $out .= '<li><a href="/report/' . $_->{id} . '">'. ent($_->{title}); +# $out .= '</a></li>'; +# } +# $out .= '</ul>' if @$probs; +# $out .= '</div>'; +# } +# +# return ($out, %params); +# } sub submit_update { my $q = shift; |