Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added basic display pages for users and lists.

  • Loading branch information...
commit 9436dbcddba27de83e6202fb7f801ea6f60fc147 1 parent 34872cb
@davorg authored
View
37 lib/Lystyng.pm
@@ -22,6 +22,43 @@ get '/' => sub {
template 'index';
};
+get '/user' => sub {
+ template 'users', {
+ users => resultset('User')->all,
+ };
+};
+
+get '/user/:username' => sub {
+ if (my $user = resultset('User')->find({
+ username => params->{username},
+ })) {
+ template 'user', {
+ user => $user,
+ };
+ } else {
+ send_error 'User not found', 404;
+ }
+};
+
+get '/user/:username/list/:list' => sub {
+ my $user;
+ unless ($user = resultset('User')->find({
+ username => params->{username},
+ })) {
+ send_error 'User not found', 404;
+ };
+
+ if (my $list = $user->lists->find({
+ slug => params->{list},
+ })) {
+ template 'list', {
+ list => $list,
+ };
+ } else {
+ send_error 'List not found', 404;
+ };
+};
+
get '/register' => sub {
template 'register';
};
View
12 views/list.tt
@@ -0,0 +1,12 @@
+<h2>[% list.title %]</h2>
+<p>By <a href="">[% list.user.username %]</a></p>
+<p>[% list.description %]</p>
+[% IF list.list_items.size -%]
+<ul>
+[% FOREACH item IN list.list_items -%]
+<li><h3>[% item.title %]</h3>
+<p>[% item.description %]</p></li>
+[% END -%]
+[% ELSE -%]
+<p>List has no items</p>
+[% END -%]
View
2  views/register.tt
@@ -9,7 +9,7 @@
</ul>
</div>
[% END -%]
- <form role="form" class="form-horizontal">
+ <form role="form" class="form-horizontal" method="post" action="/register">
<div class="form-group">
<label class="col-md-2 control-label" for="username">Username</label>
<div class="col-md-6">
View
10 views/user.tt
@@ -0,0 +1,10 @@
+<h2>[% user.username %]</h2>
+[% IF user.lists.size -%]
+<ul>
+[% FOREACH list IN user.lists -%]
+<li><a href="/user/[% user.username %]/list/[% list.slug %]">[% list.title %]</a>
+<br>[% list.description %]</li>
+[% END -%]
+[% ELSE -%]
+<p>User has no lists</p>
+[% END -%]
View
9 views/users.tt
@@ -0,0 +1,9 @@
+[% IF users.size -%]
+<ul>
+[% FOREACH user IN users -%]
+ <li><a href="/user/[% user.username %]">[% user.username %]</a></li>
+[% END -%]
+</ul>
+[% ELSE -%]
+ <p>No users found</p>
+[% END -%]
Please sign in to comment.
Something went wrong with that request. Please try again.