Cleaned up routes/template names
This commit is contained in:
parent
4576163015
commit
5fa2e9e938
12
PostText.pl
12
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();
|
||||
};
|
||||
};
|
||||
|
||||
|
|
32
templates/post.html.ep
Normal file
32
templates/post.html.ep
Normal file
|
@ -0,0 +1,32 @@
|
|||
% 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 %>
|
||||
<% if (my $error = validation->error('name')) { =%>
|
||||
<p class="field-with-error">Invalid name: 1 to 63 characters please.</p>
|
||||
<% } =%>
|
||||
</div>
|
||||
<div class="title field">
|
||||
<%= label_for title => 'Title' %>
|
||||
<%= text_field 'title', maxlength => 127, minlength => 1 %>
|
||||
<% if (my $error = validation->error('title')) { =%>
|
||||
<p class="field-with-error">Invalid title: 1 to 127 characters please.</p>
|
||||
<% } =%>
|
||||
</div>
|
||||
<div class="text field">
|
||||
<%= label_for post => 'Text' %>
|
||||
<%= text_area 'post', (
|
||||
maxlength => 4000,
|
||||
minlength => 2,
|
||||
required => 'true',
|
||||
rows => 6
|
||||
) %>
|
||||
<% if (my $error = validation->error('post')) { =%>
|
||||
<p class="field-with-error">Invalid post: Up to 4,000 characters only.</p>
|
||||
<% } =%>
|
||||
</div>
|
||||
<%= submit_button 'Post', class => 'post button' %>
|
||||
</form>
|
33
templates/remark_page.html.ep
Normal file
33
templates/remark_page.html.ep
Normal file
|
@ -0,0 +1,33 @@
|
|||
% layout 'main';
|
||||
% title "View Thread - #$thread->{'id'}";
|
||||
<h2><%= title %></h2>
|
||||
<div class="threads">
|
||||
<article class="thread">
|
||||
<h3 class="title"><%= %$thread{'title'} %></h3>
|
||||
<h4 class="date"><%= %$thread{'date'} %></h4>
|
||||
<h5 class="author"><%= %$thread{'author'} %></h5>
|
||||
<p class="body"><%= %$thread{'body'} %></p>
|
||||
</article>
|
||||
</div>
|
||||
<nav>
|
||||
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
||||
</nav>
|
||||
<% if (my $first_remark = @$remarks[0]) { =%>
|
||||
<div class="remarks">
|
||||
<h3>Remarks</h3>
|
||||
<% for my $remark (@$remarks) { =%>
|
||||
<article class="remark">
|
||||
<span class="id">#<%= %$remark{'id'} %></span>
|
||||
<h4 class="date"><%= %$remark{'date'} %></h4>
|
||||
<h5 class="author"><%= %$remark{'author'} %></h5>
|
||||
<p class="body"><%= %$remark{'body'} %></p>
|
||||
</article>
|
||||
<% } =%>
|
||||
</div>
|
||||
<nav>
|
||||
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
||||
<% if ($last_page && $last_page != 1) { =%>
|
||||
<%= pagination $this_page, $last_page, ($base_path . '/{page}') %>
|
||||
<% } %>
|
||||
</nav>
|
||||
<% } =%>
|
|
@ -1,33 +1,34 @@
|
|||
% layout 'main';
|
||||
% title "View Thread - #$thread->{'id'}";
|
||||
% title 'New Remark';
|
||||
<h2><%= title %></h2>
|
||||
<div class="threads">
|
||||
<article class="thread">
|
||||
<span class="id">#<%= %$thread{'id'} %></span>
|
||||
<h3 class="title"><%= %$thread{'title'} %></h3>
|
||||
<h4 class="date"><%= %$thread{'date'} %></h4>
|
||||
<h5 class="author"><%= %$thread{'author'} %></h5>
|
||||
<p class="body"><%= %$thread{'body'} %></p>
|
||||
</article>
|
||||
</div>
|
||||
<nav>
|
||||
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
||||
</nav>
|
||||
<% if (my $first_remark = @$remarks[0]) { =%>
|
||||
<div class="remarks">
|
||||
<h3>Remarks</h3>
|
||||
<% for my $remark (@$remarks) { =%>
|
||||
<article class="remark">
|
||||
<span class="id">#<%= %$remark{'id'} %></span>
|
||||
<h4 class="date"><%= %$remark{'date'} %></h4>
|
||||
<h5 class="author"><%= %$remark{'author'} %></h5>
|
||||
<p class="body"><%= %$remark{'body'} %></p>
|
||||
</article>
|
||||
<% } =%>
|
||||
</div>
|
||||
<nav>
|
||||
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
||||
<% if ($last_page && $last_page != 1) { =%>
|
||||
<%= pagination $this_page, $last_page, ($base_path . '/{page}') %>
|
||||
<% } %>
|
||||
</nav>
|
||||
<% } =%>
|
||||
<form method="post">
|
||||
<div class="name field">
|
||||
<%= label_for name => 'Author' %>
|
||||
<%= text_field name =>'Anonymous', maxlength => 63, minlength => 1 %>
|
||||
<% if (my $error = validation->error('name')) { =%>
|
||||
<p class="field-with-error">Invalid name: 1 to 63 characters please.</p>
|
||||
<% } =%>
|
||||
</div>
|
||||
<div class="text field">
|
||||
<%= label_for post => 'Text' %>
|
||||
<%= text_area 'post', (
|
||||
maxlength => 4000,
|
||||
minlength => 2,
|
||||
required => 'true',
|
||||
rows => 6
|
||||
) %>
|
||||
<% if (my $error = validation->error('post')) { =%>
|
||||
<p class="field-with-error">Invalid post: Up to 4,000 characters only.</p>
|
||||
<% } =%>
|
||||
</div>
|
||||
<%= submit_button 'Post', class => 'post button' %>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue