diff --git a/Literature/lib/Literature.pm b/Literature/lib/Literature.pm
index a2bea24..83a8135 100644
--- a/Literature/lib/Literature.pm
+++ b/Literature/lib/Literature.pm
@@ -8,16 +8,31 @@ my $cfg = dancer_app->config;
$cfg->{plugins}{DBIC}{default}{user} = $ENV{LIT_USER};
$cfg->{plugins}{DBIC}{default}{pass} = $ENV{LIT_PASS};
+my %resources = qw[
+ actors Actor
+ authors Author
+ productions Production
+ works Work
+ fictional_characters FictionalCharacter
+];
+
+my $route_re = '/(' . join('|', keys %resources) . ')/';
+my $id_re = $route_re . '(\d+)';
+
get '/' => sub {
template 'index';
};
-get '/authors/' => sub {
- template 'authors', { authors => resultset('Author') };
+get qr{^$route_re$} => sub {
+ my ($resource) = splat;
+ template $resource,
+ { $resource => resultset($resources{$resource}) };
};
-get '/authors/:id' => sub {
- template 'author', { author => resultset('Author')->find(param('id')) };
+get qr{$id_re} => sub {
+ my ($resource, $id) = splat;
+ template substr($resource, 0, -1),
+ { lc $resources{$resource} => resultset($resources{$resource})->find($id) };
};
true;
diff --git a/Literature/views/actor.tt b/Literature/views/actor.tt
new file mode 100644
index 0000000..e95d5a2
--- /dev/null
+++ b/Literature/views/actor.tt
@@ -0,0 +1,19 @@
+[% META title = 'Actor' %]
+
+
[% actor.name %]
+[% IF actor.born OR actor.died %]
+[% IF actor.born %]Born: [% actor.born.strftime('%m %B %Y'); END -%]
+[% IF actor.born AND actor.died %], [% END %]
+[% IF actor.died %]Died: [% actor.died.strftime('%m %B %Y'); END %]
+[% END %]
+[% actor.name %] on IMDB
+[% IF actor.actor_roles.size %]
+
+[% ELSE %]
+No roles found.
+[% END %]
diff --git a/Literature/views/actors.tt b/Literature/views/actors.tt
new file mode 100644
index 0000000..bd1c40f
--- /dev/null
+++ b/Literature/views/actors.tt
@@ -0,0 +1,8 @@
+[% # Provide a title -%]
+[% META title = 'List of Actors' -%]
+
+
+[% FOREACH a IN actors.all.sort('name')-%]
+- [% a.name %]
+[% END -%]
+
diff --git a/Literature/views/authors.tt b/Literature/views/authors.tt
index fe05d29..37ce22c 100644
--- a/Literature/views/authors.tt
+++ b/Literature/views/authors.tt
@@ -1,5 +1,5 @@
-[% FOREACH author IN authors.all -%]
+[% FOREACH author IN authors.all.sort('name') -%]
- [% author.name %]
[% END -%]
diff --git a/Literature/views/fictional_character.tt b/Literature/views/fictional_character.tt
new file mode 100644
index 0000000..e1473dd
--- /dev/null
+++ b/Literature/views/fictional_character.tt
@@ -0,0 +1,31 @@
+[% META title = 'Character' %]
+
+[% fictionalcharacter.name %]
+[% IF fictionalcharacter.imdb %][% fictionalcharacter.name %] on IMDB
[% END %]
+Appearances
+[% IF fictionalcharacter.fictional_character_appearances.size %]
+
+[% FOR a IN fictionalcharacter.fictional_character_appearances %]
+- [% a.work.title %]
+by
+[% FOR au IN a.work.authors %]
+[% au.name %]
+[% END %]
+
+[% END %]
+
+[% ELSE %]
+No appearances found.
+[% END %]
+
+Played By
+[% IF fictionalcharacter.actor_roles.size %]
+
+[% FOR r IN fictionalcharacter.actor_roles %]
+- [% r.actor.name %] in
+[% r.production.title %] ([% r.production.made_by %]
+- [% r.production.year %])
+[% END %]
+[% ELSE %]
+No-one
+[% END %]
diff --git a/Literature/views/fictional_characters.tt b/Literature/views/fictional_characters.tt
new file mode 100644
index 0000000..295b3b8
--- /dev/null
+++ b/Literature/views/fictional_characters.tt
@@ -0,0 +1,8 @@
+[% # Provide a title -%]
+[% META title = 'List of Characters' -%]
+
+
+[% FOREACH ch IN fictional_characters.all.sort('name')-%]
+- [% ch.name %]
+[% END -%]
+
diff --git a/Literature/views/index.tt b/Literature/views/index.tt
index 75a6606..f3fbd38 100644
--- a/Literature/views/index.tt
+++ b/Literature/views/index.tt
@@ -4,7 +4,7 @@
diff --git a/Literature/views/production.tt b/Literature/views/production.tt
new file mode 100644
index 0000000..a254a07
--- /dev/null
+++ b/Literature/views/production.tt
@@ -0,0 +1,28 @@
+[% META title = 'Production' %]
+
+[% production.title %]
+[% production.made_by %] [% production.year %]
+
Based on
+[% production.work.title %] by
+[% FOR a IN production.work.authors %]
+[% a.name %]
+[% END %]
+
+[% production.title %] on IMDB
+
+Cast
+[% IF production.actor_roles.size %]
+
+[% ELSE %]
+No cast found.
+[% END %]
+Buy the DVD/BluRay
+[% FOR p IN production.production_products %]
+
+[% END %]
+
diff --git a/Literature/views/productions.tt b/Literature/views/productions.tt
new file mode 100644
index 0000000..17b88f0
--- /dev/null
+++ b/Literature/views/productions.tt
@@ -0,0 +1,8 @@
+[% # Provide a title -%]
+[% META title = 'List of Productions' -%]
+
+[% FOREACH p IN productions.all.sort('title')-%]
+- [% p.title %]
+ ([% p.made_by %] - [% p.year %])
+[% END -%]
+
diff --git a/Literature/views/work.tt b/Literature/views/work.tt
new file mode 100644
index 0000000..a49d905
--- /dev/null
+++ b/Literature/views/work.tt
@@ -0,0 +1,28 @@
+[% META title = 'Work' %]
+
+[% work.title %]
+By [% FOR a IN work.authors; ''; a.name; ' '; END %]
+Characters
+[% IF work.fictional_character_appearances.size %]
+
+[% ELSE %]
+No characters found.
+[% END %]
+Productions
+[% IF work.productions.size %]
+
+[% ELSE %]
+No productions found
+[% END %]
+Buy the Book
+[% FOR p IN work.work_products %]
+
+[% END %]
diff --git a/Literature/views/works.tt b/Literature/views/works.tt
new file mode 100644
index 0000000..36e1dab
--- /dev/null
+++ b/Literature/views/works.tt
@@ -0,0 +1,13 @@
+[% # Provide a title -%]
+[% META title = 'List of Works' -%]
+
+
+Title | Author(s) |
+[% # Display each book in a table row %]
+[% FOREACH work IN works.all.sort('title')-%]
+
+ [% work.title %] |
+ [% FOREACH a IN work.authors; a.name; ' '; END %] |
+
+[% END -%]
+