diff --git a/PostText.pl b/PostText.pl index 9b1fa12..f92637a 100755 --- a/PostText.pl +++ b/PostText.pl @@ -63,9 +63,7 @@ group { # Post group { - under '/post'; - - any [qw{GET POST}], '/', sub ($c) { + any [qw{GET POST}], '/post', sub ($c) { my $v; $v = $c->validation() if $c->req->method eq 'POST'; @@ -93,9 +91,11 @@ group { } } - return $c->render(template => 'post_thread'); + return $c->render(); }; + under '/post'; + any [qw{GET POST}], '/:thread_id', [thread_id => qr/[0-9]+/], sub ($c) { my ($thread_id, $v) = ($c->param('thread_id'), undef); @@ -131,7 +131,7 @@ group { $c->stash(thread => $thread); - return $c->render(template => 'post_remark'); + return $c->render(); }; }; @@ -166,7 +166,7 @@ group { ) } - $c->render(template => 'thread_id'); + $c->render(); }; }; diff --git a/templates/post.html.ep b/templates/post.html.ep new file mode 100644 index 0000000..aef4b41 --- /dev/null +++ b/templates/post.html.ep @@ -0,0 +1,32 @@ +% layout 'main'; +% title 'New Thread'; +

<%= title %>

+
+
+ <%= label_for name => 'Author' %> + <%= text_field name =>'Anonymous', maxlength => 63, minlength => 1 %> + <% if (my $error = validation->error('name')) { =%> +

Invalid name: 1 to 63 characters please.

+ <% } =%> +
+
+ <%= label_for title => 'Title' %> + <%= text_field 'title', maxlength => 127, minlength => 1 %> + <% if (my $error = validation->error('title')) { =%> +

Invalid title: 1 to 127 characters please.

+ <% } =%> +
+
+ <%= label_for post => 'Text' %> + <%= text_area 'post', ( + maxlength => 4000, + minlength => 2, + required => 'true', + rows => 6 + ) %> + <% if (my $error = validation->error('post')) { =%> +

Invalid post: Up to 4,000 characters only.

+ <% } =%> +
+ <%= submit_button 'Post', class => 'post button' %> +
diff --git a/templates/remark_page.html.ep b/templates/remark_page.html.ep new file mode 100644 index 0000000..175afa0 --- /dev/null +++ b/templates/remark_page.html.ep @@ -0,0 +1,33 @@ +% layout 'main'; +% title "View Thread - #$thread->{'id'}"; +

<%= title %>

+
+
+

<%= %$thread{'title'} %>

+

<%= %$thread{'date'} %>

+
<%= %$thread{'author'} %>
+

<%= %$thread{'body'} %>

+
+
+ +<% if (my $first_remark = @$remarks[0]) { =%> +
+

Remarks

+ <% for my $remark (@$remarks) { =%> +
+ #<%= %$remark{'id'} %> +

<%= %$remark{'date'} %>

+
<%= %$remark{'author'} %>
+

<%= %$remark{'body'} %>

+
+ <% } =%> +
+ +<% } =%> diff --git a/templates/thread_id.html.ep b/templates/thread_id.html.ep index 175afa0..ff5a8ed 100644 --- a/templates/thread_id.html.ep +++ b/templates/thread_id.html.ep @@ -1,33 +1,34 @@ % layout 'main'; -% title "View Thread - #$thread->{'id'}"; +% title 'New Remark';

<%= title %>

+ #<%= %$thread{'id'} %>

<%= %$thread{'title'} %>

<%= %$thread{'date'} %>

<%= %$thread{'author'} %>

<%= %$thread{'body'} %>

- -<% if (my $first_remark = @$remarks[0]) { =%> -
-

Remarks

- <% for my $remark (@$remarks) { =%> -
- #<%= %$remark{'id'} %> -

<%= %$remark{'date'} %>

-
<%= %$remark{'author'} %>
-

<%= %$remark{'body'} %>

-
- <% } =%> -
- -<% } =%> +
+
+ <%= label_for name => 'Author' %> + <%= text_field name =>'Anonymous', maxlength => 63, minlength => 1 %> + <% if (my $error = validation->error('name')) { =%> +

Invalid name: 1 to 63 characters please.

+ <% } =%> +
+
+ <%= label_for post => 'Text' %> + <%= text_area 'post', ( + maxlength => 4000, + minlength => 2, + required => 'true', + rows => 6 + ) %> + <% if (my $error = validation->error('post')) { =%> +

Invalid post: Up to 4,000 characters only.

+ <% } =%> +
+ <%= submit_button 'Post', class => 'post button' %> +