From 955bb4eeffd56b4f8e5d220a4b60ce79847aa5df Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 20 Mar 2008 07:20:11 +0000 Subject: [PATCH] =?utf8?q?Hauptmen=C3=BC=20fertig,=20Statuszeile=20fertig?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/FrBr/Books.pm | 13 ++++++-- lib/FrBr/Books/Controller/Books.pm | 8 ++++- lib/FrBr/Books/Controller/Login.pm | 52 ++++++++++++++++++++++++++++++ lib/FrBr/Books/Controller/Root.pm | 19 +++++++++-- root/lib/site/statusbar.tt2 | 25 +++++++++++++- root/lib/site/styles.css | 43 ++++++++++++++++++++++++ root/src/books/index.tt2 | 45 ++++++++++++++++++++++++++ root/src/index.tt2 | 27 ++++++++++++++++ t/controller_Login.t | 10 ++++++ 9 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 lib/FrBr/Books/Controller/Login.pm create mode 100644 root/src/books/index.tt2 create mode 100644 root/src/index.tt2 create mode 100644 t/controller_Login.t diff --git a/lib/FrBr/Books.pm b/lib/FrBr/Books.pm index 550fe50..c1a16aa 100644 --- a/lib/FrBr/Books.pm +++ b/lib/FrBr/Books.pm @@ -76,6 +76,14 @@ sub auto : Private { my $storage = $c->model('Schema')->storage; $c->stash->{'storage'} = $storage; + $c->stash->{'site_title'} = "Franks Büchersammlung"; + + $c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'}; + push @{ $c->stash->{'menu_path'} }, { + 'path' => $c->uri_for("/"), + 'name' => "Startseite" + }; + $c->config->{'debug_level'} = 0 unless defined $c->config->{'debug_level'}; $c->log->debug( get_output_string( $K, "Aktuelle Konfiguration: ", $c->config ) ) if $c->config->{'debug_level'} >= 3; @@ -107,9 +115,6 @@ sub auto : Private { $c->session->{'cur_path'} = $req_path; } - $c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'}; - push @{ $c->stash->{'menu_path'} }, { 'path' => $c->uri_for("/"), 'name' => "Home" }; - # Request-URI in Sitzung einpflegen $c->session->{'request'} = {}; $c->session->{'request'}{'uri'} = $c->req->uri(); @@ -134,6 +139,8 @@ sub auto : Private { #$c->stash->{'lang_to_use'} = $lang; #$c->log->debug( $K . "Neue Sprache: '" . $lang . "' (" . $LangsToUseInDates{$lang} . ")." ) if $c->stash->{'debug_level'} >= 2; + $c->stash->{'login_action'} = 'login'; + 1; } ## end sub auto : diff --git a/lib/FrBr/Books/Controller/Books.pm b/lib/FrBr/Books/Controller/Books.pm index 1aa08a5..7f952ac 100644 --- a/lib/FrBr/Books/Controller/Books.pm +++ b/lib/FrBr/Books/Controller/Books.pm @@ -58,7 +58,8 @@ sub auto : Private { sub index : Private { my ( $self, $c ) = @_; - $c->response->body('Matched FrBr::Books::Controller::Books in Books.'); + $c->stash->{'template'} = 'books/index.tt2'; + } #------------------------------------------------------- @@ -96,6 +97,11 @@ sub list : Local { my $K = __PACKAGE__ . "::list(): "; $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2; + push @{ $c->stash->{'menu_path'} }, { + 'path' => $c->uri_for("/books/list"), + 'name' => "Liste" + }; + my $buchliste = get_booklist( $c ); $c->log->debug( get_output_string( $K, "Erhaltene Buchliste: ", $buchliste ) ) if $c->stash->{'debug_level'} >= 2; $c->stash->{'books'} = $buchliste; diff --git a/lib/FrBr/Books/Controller/Login.pm b/lib/FrBr/Books/Controller/Login.pm new file mode 100644 index 0000000..eaa72aa --- /dev/null +++ b/lib/FrBr/Books/Controller/Login.pm @@ -0,0 +1,52 @@ +package FrBr::Books::Controller::Login; + +# $Id$ +# $URL$ + +use strict; +use warnings; +use base 'Catalyst::Controller'; +use FrBr::Common; + +=head1 NAME + +FrBr::Books::Controller::Login - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +sub index : Private { + my ( $self, $c ) = @_; + + $c->stash->{'template'} = 'not_implemented.tt2'; + + push @{ $c->stash->{'menu_path'} }, { + 'path' => $c->uri_for("/login"), + 'name' => "Anmeldung" + }; + +} + + +=head1 AUTHOR + +Frank Brehm + +=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/lib/FrBr/Books/Controller/Root.pm b/lib/FrBr/Books/Controller/Root.pm index 9ae0e9f..0caeb5d 100644 --- a/lib/FrBr/Books/Controller/Root.pm +++ b/lib/FrBr/Books/Controller/Root.pm @@ -6,6 +6,7 @@ package FrBr::Books::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; +use FrBr::Common; # # Sets the actions in this controller to be registered with no prefix @@ -25,6 +26,8 @@ FrBr::Books::Controller::Root - Root Controller for FrBr::Books =cut +#--------------------------------------------------------------------------- + =head2 default =cut @@ -34,21 +37,31 @@ sub default : Private { my ( $self, $c ) = @_; #$c->stash->{'site_title'} = sprintf( $c->localize( "%s's Cookbook" ) , 'Frank Brehm' ); - $c->stash->{'site_title'} = "Franks Bucharchiv"; + $c->stash->{'site_title'} = "Willkommen in Franks Büchersammlung"; $c->stash->{'message'} = 'Willkommen!'; - $c->stash->{'template'} = 'welcome.tt2'; + $c->stash->{'template'} = 'index.tt2'; # Hello World #$c->response->body( $c->welcome_message ); } +#--------------------------------------------------------------------------- + =head2 end Attempt to render a view, if needed. =cut -sub end : ActionClass('RenderView') {} +sub end : ActionClass('RenderView') { + + my ( $self, $c ) = @_; + my $K = __PACKAGE__ . "::end(): "; + + pop @{ $c->stash->{'menu_path'} }; + $c->log->debug( get_output_string( $K, "Menue-Pfad: ", $c->stash->{'menu_path'} ) ) if $c->stash->{'debug_level'}; + +} =head1 AUTHOR diff --git a/root/lib/site/statusbar.tt2 b/root/lib/site/statusbar.tt2 index 4c326b9..50fcf30 100644 --- a/root/lib/site/statusbar.tt2 +++ b/root/lib/site/statusbar.tt2 @@ -6,4 +6,27 @@ $URL$ -%] -  + + + + + +
+[%- IF login_action == 'none' -%] +   +[%- ELSE -%] + [% tt_menu = [ ]; tt_menu.push( "${item.name}" ) FOREACH item IN menu_path %][% tt_menu.join(' » ') %] +[%- END -%] + +[%- IF login_action == 'none' -%] +   +[%- ELSE -%] + [%- IF login_action == 'login' -%] + + [%- ELSE -%] + Angemeldet als: + [%- END -%] +[%- END -%] +
+ diff --git a/root/lib/site/styles.css b/root/lib/site/styles.css index 86a5401..4773c67 100644 --- a/root/lib/site/styles.css +++ b/root/lib/site/styles.css @@ -166,6 +166,49 @@ DIV#copyright { color: [% site.col.error %]; } +TABLE.menu { + font-size: 14pt; + margin-left: auto; + margin-right: auto; + margin-top: 20px; + margin-bottom: 20px; + border-spacing: 0; + padding: 2px; +} + +TABLE.menu TH { + background-color: [% site.col.head %]; + border: 1px solid [% site.col.line %]; + margin: 0; + padding: 5px; +} + +TABLE.menu TD { + text-align: left; +} + +TABLE.menu TD.empty { + margin: 0; + padding: 0; + font-size: 6pt; +} + +TABLE.menu TD.button { + background-color: [% site.col.head %]; + border: 1px solid [% site.col.line %]; + margin: 0; + padding: 5px; +} + + +TABLE.menu TD.item { + background-color: [% site.col.statusbarbg %]; + border: 1px solid [% site.col.line %]; + margin: 0; + padding: 5px; +} + + [%- FOREACH cssfile IN cssfiles %] /* --- [% cssfile %] ----------------- */ [% PROCESS $cssfile -%] diff --git a/root/src/books/index.tt2 b/root/src/books/index.tt2 new file mode 100644 index 0000000..0d58760 --- /dev/null +++ b/root/src/books/index.tt2 @@ -0,0 +1,45 @@ +[%# + + message.tt2 - Universal-Template + + #$Id$ + #$URL$ + +-%] +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/root/src/index.tt2 b/root/src/index.tt2 new file mode 100644 index 0000000..dea2373 --- /dev/null +++ b/root/src/index.tt2 @@ -0,0 +1,27 @@ +[%# + + message.tt2 - Universal-Template + + #$Id$ + #$URL$ + +-%] +[%- META title = 'Willkommen in Franks Büchersammlung' -%] + +
+ + + + + + + + + + + + +
diff --git a/t/controller_Login.t b/t/controller_Login.t new file mode 100644 index 0000000..a083eb3 --- /dev/null +++ b/t/controller_Login.t @@ -0,0 +1,10 @@ +use strict; +use warnings; +use Test::More tests => 3; + +BEGIN { use_ok 'Catalyst::Test', 'FrBr::Books' } +BEGIN { use_ok 'FrBr::Books::Controller::Login' } + +ok( request('/login')->is_success, 'Request should succeed' ); + + -- 2.39.5