diff --git a/PostText.pl b/PostText.pl index 1ff8125..a5da2c9 100755 --- a/PostText.pl +++ b/PostText.pl @@ -25,15 +25,23 @@ under sub ($c) { 1; }; -# Root redirect +# Root get '/', sub ($c) { $c->redirect_to('view') }; +# View get '/view', sub ($c) { $c->render() }; +# Post +any [qw{GET POST}], '/post', sub ($c) { + $c->render() +}; + +# Configure things app->secrets(app->config->{'secrets'}) || die $@; app->pg->migrations->from_dir('migrations')->migrate(); +# Send it app->start(); diff --git a/README.md b/README.md index 8996f27..01308b5 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,5 @@ Run the tests locally (against development environment) ## TODOs 1. Moar tests... -1. Route for creating threads +1. Page navigation +1. Do something with submitted form data diff --git a/t/post.t b/t/post.t new file mode 100644 index 0000000..0060ccd --- /dev/null +++ b/t/post.t @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use Mojo::File qw{curfile}; +use Test::Mojo; + +my $script = curfile->dirname->sibling('PostText.pl'); +my $t = Test::Mojo->new($script); + +$t->get_ok('/post')->status_is(200); + +$t->post_ok('/post')->status_is(200); + +done_testing(); diff --git a/t/view.t b/t/view.t new file mode 100644 index 0000000..0c7acb3 --- /dev/null +++ b/t/view.t @@ -0,0 +1,14 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use Mojo::File qw{curfile}; +use Test::Mojo; + +my $script = curfile->dirname->sibling('PostText.pl'); +my $t = Test::Mojo->new($script); + +$t->get_ok('/view')->status_is(200); + +done_testing(); diff --git a/templates/post.html.ep b/templates/post.html.ep new file mode 100644 index 0000000..2598213 --- /dev/null +++ b/templates/post.html.ep @@ -0,0 +1,22 @@ +% layout 'main'; +% title 'New Thread'; +