Skip to content

Commit

Permalink
Filling out some basic templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cross committed Oct 1, 2015
1 parent b89c848 commit f96685b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Literature/lib/Literature.pm
Expand Up @@ -16,4 +16,8 @@ get '/authors/' => sub {
template 'authors', { authors => resultset('Author') };
};

get '/authors/:id' => sub {
template 'author', { author => resultset('Author')->find(param('id')) };
};

true;
18 changes: 18 additions & 0 deletions Literature/views/author.tt
@@ -0,0 +1,18 @@
[% META title = 'Author' %]

<h2>[% author.name %]</h2>
[% IF author.born OR author.died %]
<p>[% IF author.born %]Born: [% author.born.strftime('%m %B %Y'); END -%]
[% IF author.born AND author.died %], [% END %]
[% IF author.died %]Died: [% author.died.strftime('%m %B %Y'); END %]</p>
[% END %]
<h3>Works</h3>
[% IF author.author_works.size %]
<ul>
[% FOR w IN author.author_works.sort('published') %]
<li><a href="/works/[% w.work.id %]">[% w.work.title %]</a></li>
[% END %]
</ul>
[% ELSE %]
<p>No works found.</p>
[% END %]
2 changes: 1 addition & 1 deletion Literature/views/authors.tt
@@ -1,5 +1,5 @@
<ul>
[% FOREACH author IN authors.all -%]
<li>[% author.name %]</li>
<li><a href="/authors/[% author.id %]">[% author.name %]</a></li>
[% END -%]
</ul>

0 comments on commit f96685b

Please sign in to comment.