From 6d4dbdb7bfa1af7c1a34c57fe01198e861fb4b4a Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 22 Feb 2011 14:48:49 +0000 Subject: Created app using catalyst.pl --- perllib/FixMyStreet/App/Controller/Root.pm | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 perllib/FixMyStreet/App/Controller/Root.pm (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm new file mode 100644 index 000000000..8b34e66ca --- /dev/null +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -0,0 +1,69 @@ +package FixMyStreet::App::Controller::Root; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller' } + +# +# Sets the actions in this controller to be registered with no prefix +# so they function identically to actions created in MyApp.pm +# +__PACKAGE__->config(namespace => ''); + +=head1 NAME + +FixMyStreet::App::Controller::Root - Root Controller for FixMyStreet::App + +=head1 DESCRIPTION + +[enter your description here] + +=head1 METHODS + +=head2 index + +The root page (/) + +=cut + +sub index :Path :Args(0) { + my ( $self, $c ) = @_; + + # Hello World + $c->response->body( $c->welcome_message ); +} + +=head2 default + +Standard 404 error page + +=cut + +sub default :Path { + my ( $self, $c ) = @_; + $c->response->body( 'Page not found' ); + $c->response->status(404); +} + +=head2 end + +Attempt to render a view, if needed. + +=cut + +sub end : ActionClass('RenderView') {} + +=head1 AUTHOR + +Edmund von der Burg,,, + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; -- cgit v1.2.3 From 4aeed463059b4769135df9ed4b28a73d810b28d0 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 22 Feb 2011 16:28:51 +0000 Subject: make default handler state that code has fallen through to the Catalyst app --- perllib/FixMyStreet/App/Controller/Root.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 8b34e66ca..41bca4b7f 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -41,8 +41,11 @@ Standard 404 error page sub default :Path { my ( $self, $c ) = @_; - $c->response->body( 'Page not found' ); - $c->response->status(404); + + $c->response->body( "Fallen through to FixMyStreet::App default handler" ); + + # $c->response->body( 'Page not found' ); + # $c->response->status(404); } =head2 end -- cgit v1.2.3 From 0f515f88ef3ca7c5711c41f8066afb689e3f5b58 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 22 Feb 2011 18:13:40 +0000 Subject: Added templated 404 page as default --- perllib/FixMyStreet/App/Controller/Root.pm | 41 ++++++++++++++---------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 41bca4b7f..fc3932975 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -4,11 +4,7 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } -# -# Sets the actions in this controller to be registered with no prefix -# so they function identically to actions created in MyApp.pm -# -__PACKAGE__->config(namespace => ''); +__PACKAGE__->config( namespace => '' ); =head1 NAME @@ -26,7 +22,7 @@ The root page (/) =cut -sub index :Path :Args(0) { +sub index : Path : Args(0) { my ( $self, $c ) = @_; # Hello World @@ -35,38 +31,39 @@ sub index :Path :Args(0) { =head2 default -Standard 404 error page +Forward to the standard 404 error page =cut -sub default :Path { +sub default : Path { my ( $self, $c ) = @_; - - $c->response->body( "Fallen through to FixMyStreet::App default handler" ); - - # $c->response->body( 'Page not found' ); - # $c->response->status(404); + $c->detach('/page_not_found'); } -=head2 end +=head2 page_not_found -Attempt to render a view, if needed. + $c->detach('/page_not_found'); -=cut +Display a 404 page. -sub end : ActionClass('RenderView') {} +=cut -=head1 AUTHOR +sub page_not_found : Private { + my ( $self, $c ) = @_; -Edmund von der Burg,,, + $c->stash->{template} = 'errors/page_not_found.html'; + $c->response->status(404); +} -=head1 LICENSE +=head2 end -This library is free software. You can redistribute it and/or modify -it under the same terms as Perl itself. +Attempt to render a view, if needed. =cut +sub end : ActionClass('RenderView') { +} + __PACKAGE__->meta->make_immutable; 1; -- cgit v1.2.3 From 1498dfdec73becf769c3596bf41185f003c2a4cf Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 23 Feb 2011 13:58:27 +0000 Subject: Added About controller put 'loc' stub in place for i18n in templates server static files --- perllib/FixMyStreet/App/Controller/Root.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index fc3932975..b61650f79 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -16,6 +16,18 @@ FixMyStreet::App::Controller::Root - Root Controller for FixMyStreet::App =head1 METHODS +=head2 auto + +Set up general things for this instance + +=cut + +sub auto { + my ( $self, $c ) = @_; + + return; +} + =head2 index The root page (/) -- cgit v1.2.3 From 3ef36c3c9b5393c78c0af59b9f4e3f4528472357 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 23 Feb 2011 22:10:37 +0000 Subject: More work on the Cobrand and setting for request test to see welsh about us page --- perllib/FixMyStreet/App/Controller/Root.pm | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index b61650f79..debddef38 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -22,23 +22,13 @@ Set up general things for this instance =cut -sub auto { +sub auto : Private { my ( $self, $c ) = @_; - return; -} - -=head2 index - -The root page (/) - -=cut - -sub index : Path : Args(0) { - my ( $self, $c ) = @_; + # decide which cobrand this request should use + $c->setup_cobrand(); - # Hello World - $c->response->body( $c->welcome_message ); + return 1; } =head2 default -- cgit v1.2.3 From 49e2dec7a498e4375d2619befd6fa57aefa32f48 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 23 Feb 2011 22:13:39 +0000 Subject: Added back index page for the tests --- perllib/FixMyStreet/App/Controller/Root.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index debddef38..4b65dc4f7 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -31,6 +31,15 @@ sub auto : Private { return 1; } +=head2 index + +=cut + +sub index : Private { + my ( $self, $c ) = @_; + $c->res->body('index'); +} + =head2 default Forward to the standard 404 error page -- cgit v1.2.3 From 5cf138c1ace35dbc9cbce1279e1ddcb8a55fe513 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 23 Feb 2011 22:22:37 +0000 Subject: do the index page the proper way --- perllib/FixMyStreet/App/Controller/Root.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 4b65dc4f7..42ac856c6 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -35,7 +35,7 @@ sub auto : Private { =cut -sub index : Private { +sub index : Path : Args(0) { my ( $self, $c ) = @_; $c->res->body('index'); } -- cgit v1.2.3 From 72b67f1af5c4afac2205fe4bc08b02813d66050d Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 6 Apr 2011 10:42:29 +0100 Subject: Added overrides to staging servers to make testing/dev easier --- perllib/FixMyStreet/App/Controller/Root.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 42ac856c6..2a25d4040 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -26,7 +26,7 @@ sub auto : Private { my ( $self, $c ) = @_; # decide which cobrand this request should use - $c->setup_cobrand(); + $c->setup_request(); return 1; } -- cgit v1.2.3 From ca9b31f2e35f7ba962569e8b705a89b6dd139de3 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 12 Apr 2011 10:56:41 +0100 Subject: Start to move index.cgi into catalyst --- perllib/FixMyStreet/App/Controller/Root.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') 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 -- cgit v1.2.3 From a38d76783ee9a44b9e237a87d086549677d3282e Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 12 Apr 2011 12:32:58 +0100 Subject: Redirect locations queries from '/' to '/around' --- perllib/FixMyStreet/App/Controller/Root.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 461105b68..2dc770da5 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -33,11 +33,31 @@ sub auto : Private { =head2 index +Home page. + +If request includes certain parameters redirect to '/around' - this is to +preserve old behaviour. + =cut sub index : Path : Args(0) { my ( $self, $c ) = @_; + my @old_param_keys = ( 'pc', 'x', 'y', 'lat', 'lon' ); + my %old_params = (); + + foreach my $key (@old_param_keys) { + my $val = $c->req->param($key); + next unless $val; + $old_params{$key} = $val; + } + + if ( scalar keys %old_params ) { + my $around_uri = $c->uri_for( '/around', \%old_params ); + $c->res->redirect($around_uri); + return; + } + } =head2 default -- cgit v1.2.3 From 5bb7634143bd320b20601c3d92efc0b6987a0d8d Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 15 Apr 2011 11:25:42 +0100 Subject: Handle (e,n) requests to '/' --- perllib/FixMyStreet/App/Controller/Root.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 2dc770da5..3280d02b9 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -43,7 +43,7 @@ preserve old behaviour. sub index : Path : Args(0) { my ( $self, $c ) = @_; - my @old_param_keys = ( 'pc', 'x', 'y', 'lat', 'lon' ); + my @old_param_keys = ( 'pc', 'x', 'y', 'e', 'n', 'lat', 'lon' ); my %old_params = (); foreach my $key (@old_param_keys) { -- cgit v1.2.3 From 13b568cda0c03acdd0b660590b2d3055e8e66c0a Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 15 Apr 2011 17:34:54 +0100 Subject: Tidy up 404 template and add error message --- perllib/FixMyStreet/App/Controller/Root.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 3280d02b9..33f870986 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -73,16 +73,16 @@ sub default : Path { =head2 page_not_found - $c->detach('/page_not_found'); + $c->detach('/page_not_found', [ $error_msg ] ); -Display a 404 page. +Display a 404 page. Pass in an optional error message in an arrayref. =cut sub page_not_found : Private { - my ( $self, $c ) = @_; - - $c->stash->{template} = 'errors/page_not_found.html'; + my ( $self, $c, $error_msg ) = @_; + $c->stash->{template} = 'errors/page_not_found.html'; + $c->stash->{error_msg} = $error_msg; $c->response->status(404); } -- cgit v1.2.3 From 898d7c6f5f4c38ca2dd19df5c8a80ee222820130 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 15 Apr 2011 17:40:07 +0100 Subject: rename 404 error to be clearer --- perllib/FixMyStreet/App/Controller/Root.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 33f870986..830773542 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -68,20 +68,20 @@ Forward to the standard 404 error page sub default : Path { my ( $self, $c ) = @_; - $c->detach('/page_not_found'); + $c->detach('/page_error_404_not_found'); } -=head2 page_not_found +=head2 page_error_404_not_found - $c->detach('/page_not_found', [ $error_msg ] ); + $c->detach('/page_error_404_not_found', [ $error_msg ] ); Display a 404 page. Pass in an optional error message in an arrayref. =cut -sub page_not_found : Private { +sub page_error_404_not_found : Private { my ( $self, $c, $error_msg ) = @_; - $c->stash->{template} = 'errors/page_not_found.html'; + $c->stash->{template} = 'errors/page_error_404_not_found.html'; $c->stash->{error_msg} = $error_msg; $c->response->status(404); } -- cgit v1.2.3 From 49d6b2900ccc63b8c6c8022399b663b426fe9641 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 15 Apr 2011 17:49:04 +0100 Subject: Add 410 page --- perllib/FixMyStreet/App/Controller/Root.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Root.pm') diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 830773542..7e2acc03c 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -71,11 +71,12 @@ sub default : Path { $c->detach('/page_error_404_not_found'); } -=head2 page_error_404_not_found +=head2 page_error_404_not_found, page_error_410_gone - $c->detach('/page_error_404_not_found', [ $error_msg ] ); + $c->detach( '/page_error_404_not_found', [$error_msg] ); + $c->detach( '/page_error_410_gone', [$error_msg] ); -Display a 404 page. Pass in an optional error message in an arrayref. +Display a 404 (not found) or 410 (gone) page. Pass in an optional error message in an arrayref. =cut @@ -86,6 +87,13 @@ sub page_error_404_not_found : Private { $c->response->status(404); } +sub page_error_410_gone : Private { + my ( $self, $c, $error_msg ) = @_; + $c->stash->{template} = 'errors/page_error_410_gone.html'; + $c->stash->{error_msg} = $error_msg; + $c->response->status(410); +} + =head2 end Attempt to render a view, if needed. -- cgit v1.2.3