From 6d0804a199f1cae7be898b771829c0dfbf2de7f1 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Wed, 12 Oct 2011 21:49:19 -0600 Subject: [PATCH] adding a basic template to build off of --- lib/Chatty/Controller/Root.pm | 13 ++++------ lib/Chatty/View/HTML.pm | 42 ++++++++++++++++++++++++++++++ root/static/css/common.css | 49 +++++++++++++++++++++++++++++++++++ root/tt/index.tt | 1 + root/tt/wrapper.tt | 18 +++++++++++++ t/view_HTML.t | 8 ++++++ 6 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 lib/Chatty/View/HTML.pm create mode 100644 root/static/css/common.css create mode 100644 root/tt/index.tt create mode 100644 root/tt/wrapper.tt create mode 100644 t/view_HTML.t diff --git a/lib/Chatty/Controller/Root.pm b/lib/Chatty/Controller/Root.pm index 4d4c979..644a861 100644 --- a/lib/Chatty/Controller/Root.pm +++ b/lib/Chatty/Controller/Root.pm @@ -16,7 +16,7 @@ Chatty::Controller::Root - Root Controller for Chatty =head1 DESCRIPTION -[enter your description here] +Implements all actions for this simple chat application. =head1 METHODS @@ -27,10 +27,7 @@ The root page (/) =cut sub index :Path :Args(0) { - my ( $self, $c ) = @_; - - # Hello World - $c->response->body( $c->welcome_message ); + my ( $self, $c ) = @_; } =head2 default @@ -40,9 +37,9 @@ Standard 404 error page =cut sub default :Path { - my ( $self, $c ) = @_; - $c->response->body( 'Page not found' ); - $c->response->status(404); + my ( $self, $c ) = @_; + $c->response->body( 'Page not found' ); + $c->response->status(404); } =head2 end diff --git a/lib/Chatty/View/HTML.pm b/lib/Chatty/View/HTML.pm new file mode 100644 index 0000000..02877fb --- /dev/null +++ b/lib/Chatty/View/HTML.pm @@ -0,0 +1,42 @@ +package Chatty::View::HTML; + +use strict; +use warnings; + +use base 'Catalyst::View::TT'; + +__PACKAGE__->config( + TEMPLATE_EXTENSION => '.tt', + INCLUDE_PATH => [ + Chatty->path_to('root', 'tt'), + ], + WRAPPER => 'wrapper.tt', + render_die => 1, + COMPILE_DIR => '/tmp/tt_cache', +); + + +=head1 NAME + +Chatty::View::HTML - TT View for Chatty + +=head1 DESCRIPTION + +TT View for Chatty. + +=head1 SEE ALSO + +L + +=head1 AUTHOR + +Charles McGarvey + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +1; diff --git a/root/static/css/common.css b/root/static/css/common.css new file mode 100644 index 0000000..2e378b5 --- /dev/null +++ b/root/static/css/common.css @@ -0,0 +1,49 @@ + +body { + font: 100 14px Verdana, Helvetica, Arial; + margin: 10px; + background: #ccf; +} + +img { + border: 0; +} + +a { + text-decoration: none; +} + +a:hover { + border-bottom: 1px dotted blue; +} + + +.left { + float: left; + margin: 0 5px 5px 0; +} + +.right { + float: right; + margin: 0 0 5px 5px; +} + + +#outer { + margin: 0 auto 0 auto; + width: 640px; + border: 2px solid black; + background: #99c; +} + +#inner { + margin: 5px; + padding: 10px; + border: 2px solid black; + background: white; +} + +#inner h1 { + font-size: 1.3em; +} + diff --git a/root/tt/index.tt b/root/tt/index.tt new file mode 100644 index 0000000..51e8ea5 --- /dev/null +++ b/root/tt/index.tt @@ -0,0 +1 @@ +

Chatty - Toy chat app written in Perl/Catalyst

diff --git a/root/tt/wrapper.tt b/root/tt/wrapper.tt new file mode 100644 index 0000000..cfcaf5b --- /dev/null +++ b/root/tt/wrapper.tt @@ -0,0 +1,18 @@ + + + + + + + + Chatty - [% template.title or 'Toy chat application written in Perl/Catalyst' %] + + +
+
+[% content %] +
+
+ + + diff --git a/t/view_HTML.t b/t/view_HTML.t new file mode 100644 index 0000000..0b1a753 --- /dev/null +++ b/t/view_HTML.t @@ -0,0 +1,8 @@ +use strict; +use warnings; +use Test::More; + + +BEGIN { use_ok 'Chatty::View::HTML' } + +done_testing(); -- 2.43.0