New Thread form, more tests, more TODOs
This commit is contained in:
parent
4738ce9d27
commit
55e6089fdd
10
PostText.pl
10
PostText.pl
|
@ -25,15 +25,23 @@ under sub ($c) {
|
||||||
1;
|
1;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Root redirect
|
# Root
|
||||||
get '/', sub ($c) { $c->redirect_to('view') };
|
get '/', sub ($c) { $c->redirect_to('view') };
|
||||||
|
|
||||||
|
# View
|
||||||
get '/view', sub ($c) {
|
get '/view', sub ($c) {
|
||||||
$c->render()
|
$c->render()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Post
|
||||||
|
any [qw{GET POST}], '/post', sub ($c) {
|
||||||
|
$c->render()
|
||||||
|
};
|
||||||
|
|
||||||
|
# Configure things
|
||||||
app->secrets(app->config->{'secrets'}) || die $@;
|
app->secrets(app->config->{'secrets'}) || die $@;
|
||||||
|
|
||||||
app->pg->migrations->from_dir('migrations')->migrate();
|
app->pg->migrations->from_dir('migrations')->migrate();
|
||||||
|
|
||||||
|
# Send it
|
||||||
app->start();
|
app->start();
|
||||||
|
|
|
@ -25,4 +25,5 @@ Run the tests locally (against development environment)
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Moar tests...
|
1. Moar tests...
|
||||||
1. Route for creating threads
|
1. Page navigation
|
||||||
|
1. Do something with submitted form data
|
||||||
|
|
16
t/post.t
Normal file
16
t/post.t
Normal file
|
@ -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();
|
14
t/view.t
Normal file
14
t/view.t
Normal file
|
@ -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();
|
22
templates/post.html.ep
Normal file
22
templates/post.html.ep
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
% layout 'main';
|
||||||
|
% title 'New Thread';
|
||||||
|
<h2><%= title %></h2>
|
||||||
|
<form method="post">
|
||||||
|
<div class="name field">
|
||||||
|
<%= label_for name => 'Author' %>
|
||||||
|
<%= text_field name =>'Anonymous', maxlength => 63, minlength => 1 %>
|
||||||
|
</div>
|
||||||
|
<div class="title field">
|
||||||
|
<%= label_for title => 'Title' %>
|
||||||
|
<%= text_field 'title', maxlength => 255, minlength => 1 %>
|
||||||
|
</div>
|
||||||
|
<div class="text field">
|
||||||
|
<%= label_for post => 'Text' %>
|
||||||
|
<%= text_area 'post',
|
||||||
|
maxlength => 4000,
|
||||||
|
minlength => 2,
|
||||||
|
required => 'true',
|
||||||
|
rows => 6 %>
|
||||||
|
</div>
|
||||||
|
<%= submit_button 'Post', class => 'post button' %>
|
||||||
|
</form>
|
Loading…
Reference in New Issue
Block a user