From 8250eb360c341a4eeaa76e5e3fc0f57cf0014a60 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 12 Jun 2008 23:41:11 +0200 Subject: [PATCH] Added model and renamed submodule --- .gitmodules | 4 ++-- ND => lib/ND | 0 lib/NDWeb/Controller/Root.pm | 15 ++++++++++++--- lib/NDWeb/Model/Model.pm | 11 +++++++++++ root/lib/config/main.tt2 | 2 ++ root/lib/site/html.tt2 | 2 +- root/lib/site/leftbar.tt2 | 2 +- root/src/index.tt2 | 9 +++------ t/model_Model.t | 6 ++++++ 9 files changed, 38 insertions(+), 13 deletions(-) rename ND => lib/ND (100%) create mode 100644 lib/NDWeb/Model/Model.pm create mode 100644 t/model_Model.t diff --git a/.gitmodules b/.gitmodules index 9fcfba2..b1886ab 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "ND"] - path = ND +[submodule "lib/ND"] + path = lib/ND url = whale@ruin.nu:git/ND.git diff --git a/ND b/lib/ND similarity index 100% rename from ND rename to lib/ND diff --git a/lib/NDWeb/Controller/Root.pm b/lib/NDWeb/Controller/Root.pm index 4657f7a..0a41059 100644 --- a/lib/NDWeb/Controller/Root.pm +++ b/lib/NDWeb/Controller/Root.pm @@ -29,17 +29,26 @@ NDWeb::Controller::Root - Root Controller for NDWeb sub index : Local Path Args(0) { my ( $self, $c ) = @_; - # Hello World - #$c->response->body( $c->welcome_message ); + $c->stash(abc => $c->req->base); } sub default : Path { my ( $self, $c ) = @_; - $c->response->body( 'Page not found' ); + $c->res->body( 'Page not found' ); $c->response->status(404); } +sub auto : Private { + my ($self, $c) = @_; + + my $dbh = $c ->model; + $c->stash(dbh => $dbh); + + $c->stash->{game}->{tick} = $dbh->selectrow_array('SELECT tick()',undef); + +} + =head2 end Attempt to render a view, if needed. diff --git a/lib/NDWeb/Model/Model.pm b/lib/NDWeb/Model/Model.pm new file mode 100644 index 0000000..c696778 --- /dev/null +++ b/lib/NDWeb/Model/Model.pm @@ -0,0 +1,11 @@ +package NDWeb::Model::Model; +use strict; +use warnings; +use base 'Catalyst::Model::Factory::PerRequest'; + +__PACKAGE__->config( + class => 'ND::DB', + constructor => 'DB', +); + +1; diff --git a/root/lib/config/main.tt2 b/root/lib/config/main.tt2 index fe70a5e..2e9bcfd 100644 --- a/root/lib/config/main.tt2 +++ b/root/lib/config/main.tt2 @@ -16,6 +16,8 @@ copyright => '2008 harv', }; + USE DBI ( dbh = dbh); + # load up any other configuration items PROCESS config/url.tt2; diff --git a/root/lib/site/html.tt2 b/root/lib/site/html.tt2 index f7236e7..8cccb3f 100644 --- a/root/lib/site/html.tt2 +++ b/root/lib/site/html.tt2 @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - [% template.title or site.title %] + [% site.title %]: [% template.title %] diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index a5bfb75..3714285 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -1,5 +1,5 @@