From: Frank Brehm Date: Tue, 18 Mar 2008 10:04:24 +0000 (+0000) Subject: Grundstruktur importiert X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=b165a1a42da8614ffc583069e10b367cc786233b;p=books.git Grundstruktur importiert --- diff --git a/Changes b/Changes new file mode 100644 index 0000000..d4c8205 --- /dev/null +++ b/Changes @@ -0,0 +1,4 @@ +This file documents the revision history for Perl extension FrBr::Books. + +0.01 2008-03-17 17:36:11 + - initial revision, generated by Catalyst diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..86ef15a --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,16 @@ +use inc::Module::Install; + +name 'FrBr-Books'; +all_from 'lib/FrBr/Books.pm'; + +requires 'Catalyst::Runtime' => '5.7012'; +requires 'Catalyst::Plugin::ConfigLoader'; +requires 'Catalyst::Plugin::Static::Simple'; +requires 'Catalyst::Action::RenderView'; +requires 'YAML'; # This should reflect the config file format you've chosen + # See Catalyst::Plugin::ConfigLoader for supported formats +catalyst; + +install_script glob('script/*.pl'); +auto_install; +WriteAll; diff --git a/README b/README new file mode 100644 index 0000000..e8e8fb3 --- /dev/null +++ b/README @@ -0,0 +1 @@ +Run script/frbr_books_server.pl to test the application. diff --git a/frbr_books.yml b/frbr_books.yml new file mode 100644 index 0000000..ca5378f --- /dev/null +++ b/frbr_books.yml @@ -0,0 +1,30 @@ +--- +name: FrBr::Books +database: + host: localhost + port: 3306 + schema: books + user: books + # passwd: +authentication: + dbic: + # Note this first definition would be the same as setting + # __PACKAGE__->config->{authentication}->{dbic}->{user_class} = ’MyAppDB::User’ + # in lib/MyApp.pm (IOW, each hash key becomes a "name:" in the YAML file). + # + # This is the model object created by Catalyst::Model::DBIC from your + # schema (you created ’MyAppDB::User’ but as the Catalyst startup + # debug messages show, it was loaded as ’MyApp::Model::MyAppDB::User’). + # NOTE: Omit ’MyApp::Model’ to avoid a component lookup issue in Catalyst 5.66 + user_class: Schema::Users + # + # This is the name of the field in your ’users’ table that contains the user’s name + user_field: login + # + # This is the name of the field in your ’users’ table that contains the password + password_field: password + # + # Other options can go here for hashed passwords + password_type: salted_hash + password_salt_len: 4 + diff --git a/lib/FrBr/Books.pm b/lib/FrBr/Books.pm new file mode 100644 index 0000000..f423d9b --- /dev/null +++ b/lib/FrBr/Books.pm @@ -0,0 +1,120 @@ +package FrBr::Books; + +# $Id: CookBook.pm 15 2007-08-09 14:39:47Z frank $ +# $URL$ + +use strict; +use warnings; + +use Catalyst::Runtime '5.70'; + +use FrBr::Common; + +# Set flags and add plugins for the application +# +# -Debug: activates the debug mode for very useful log messages +# ConfigLoader: will load the configuration from a YAML file in the +# application's home directory +# Static::Simple: will serve static files from the application's root +# directory + +use Catalyst qw/ + + +FrBr::Books::Plugin::ConfigLoader + + Static::Simple + +/; + +our $VERSION = '0.01'; + +my %LangsToUse = ( + 'de' => 'deutsch', + 'en' => 'english', +); + +my %LangsToUseInDates = ( + 'de' => 'Deutsch', + 'en' => 'English', +); + +# Configure the application. +# +# Note that settings in frbr_books.yml (or other external +# configuration file that you set up manually) take precedence +# over this when using ConfigLoader. Thus configuration +# details given here can function as a default configuration, +# with a external configuration file acting as an override for +# local deployment. + +__PACKAGE__->config( name => 'FrBr::Books' ); + +# Start the application +__PACKAGE__->setup; + +#------------------------------------------------------- + +sub auto : Private { + + my ( $self, $c ) = @_; + my $K = __PACKAGE__ . "::auto(): "; + + $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; + + $c->stash->{'debug_level'} = to_int( $c->config->{'debug_level'} ) || 0; + my $env_debug_level = to_int( $ENV{'FRBR_BOOKS_DEBUG'} || $ENV{'CATALYST_DEBUG'} ); + $c->stash->{'debug_level'} = $env_debug_level if $env_debug_level and $env_debug_level > $c->stash->{'debug_level'}; + $c->log->debug( $K . "Aktuelles Debug-Level: " . $c->stash->{'debug_level'} ) if $c->stash->{'debug_level'}; + + + ######################## + # Sprachabhaengige Dinge + + my $lang = 'de'; + + # Neue Sprache festlegen: + if ( $c->req->param('new_lang_to_use') and $LangsToUse{ $c->req->param('new_lang_to_use') } ) { + $lang = $c->req->param('new_lang_to_use'); + #$c->session->{'lang_to_use'} = $lang; + } + else { + #$lang = $c->session->{'lang_to_use'} if $c->session->{'lang_to_use'}; + } + #$c->languages( [$lang] ); + #$c->stash->{'lang_to_use'} = $lang; + #$c->log->debug( $K . "Neue Sprache: '" . $lang . "' (" . $LangsToUseInDates{$lang} . ")." ) if $c->stash->{'debug_level'} >= 2; + + 1; + +} ## end sub auto : + + +=head1 NAME + +FrBr::Books - Catalyst based application + +=head1 SYNOPSIS + + script/frbr_books_server.pl + +=head1 DESCRIPTION + +[enter your description here] + +=head1 SEE ALSO + +L, L + +=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/Books.pm b/lib/FrBr/Books/Controller/Books.pm new file mode 100644 index 0000000..bd114fb --- /dev/null +++ b/lib/FrBr/Books/Controller/Books.pm @@ -0,0 +1,148 @@ +package FrBr::Books::Controller::Books; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; +use base 'Catalyst::Controller'; + +use FrBr::Common; + +=head1 NAME + +FrBr::Books::Controller::Books - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +sub index : Private { + my ( $self, $c ) = @_; + + $c->response->body('Matched FrBr::Books::Controller::Books in Books.'); +} + +=head2 list + +Fetch all book objects and pass to books/list.tt2 in stash to be displayed + +=cut + +sub list : Local { + + # Retrieve the usual perl OO '$self' for this object. $c is the Catalyst + # 'Context' that's used to 'glue together' the various components + # that make up the application + my ($self, $c) = @_; + my $K = __PACKAGE__ . "::list(): "; + $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2; + + $c->stash->{'cssfiles'} = [] unless $c->stash->{'cssfiles'}; + push @{$c->stash->{'cssfiles'}}, 'books/styles.css'; + + my $search_params = undef; + my $other_params = {}; + $other_params->{'order_by'} = [ 'title' ]; + $other_params->{'join'} = [ 'waehrung', 'verlag' ]; + $other_params->{'select'} = [ + 'me.id', + 'me.title', + 'me.title_original', + 'me.verlags_id', + 'me.isbn', + 'me.buch_nr', + 'me.ausgabejahr', + 'me.druckjahr', + 'me.preis', + 'me.waehrungs_id', + 'waehrung.waehrungs_kuerzel', + 'waehrung.waehrungs_name', + 'waehrung.umrechnung_in_euro', + 'verlag.name_short AS `verlagsname_short`', + 'verlag.name_long AS `verlagsname_long`', + ]; + $other_params->{'as'} = [ + 'id', + 'title', + 'title_original', + 'verlags_id', + 'isbn', + 'buch_nr', + 'ausgabejahr', + 'druckjahr', + 'preis', + 'waehrungs_id', + 'waehrungs_kuerzel', + 'waehrungs_name', + 'umrechnung_in_euro', + 'verlagsname_short', + 'verlagsname_long', + ]; + $c->stash->{'books'} = []; + for my $book ( $c->model('Schema::Buecher')->search( $search_params, $other_params )->all() ) { + my $buch = {}; + $buch->{'id'} = $book->id(); + $buch->{'title'} = $book->title(); + $buch->{'title_original'} = $book->title_original(); + $buch->{'verlags_id'} = $book->verlags_id(); + $buch->{'isbn'} = $book->isbn(); + $buch->{'buch_nr'} = $book->buch_nr(); + $buch->{'ausgabejahr'} = $book->ausgabejahr(); + $buch->{'druckjahr'} = $book->druckjahr(); + $buch->{'preis'} = $book->preis(); + $buch->{'waehrungs_id'} = $book->waehrungs_id(); + $buch->{'waehrungs_kuerzel'} = $book->get_column('waehrungs_kuerzel'); + $buch->{'waehrungs_name'} = $book->get_column('waehrungs_name'); + $buch->{'umrechnung_in_euro'} = $book->get_column('umrechnung_in_euro'); + $buch->{'verlagsname_short'} = $book->get_column('verlagsname_short'); + $buch->{'verlagsname_long'} = $book->get_column('verlagsname_long'); + push @{$c->stash->{'books'}}, $buch; + } + + $c->stash->{'autoren'} = {}; + for my $autor ( $c->model('Schema::Autoren')->all() ) { + my $au = {}; + my $id = $autor->id; + $au->{'id'} = $id; + $au->{'autor_name'} = $autor->autor_name; + $au->{'autor_descr'} = $autor->autor_descr; + $c->log->debug( $K . get_output_string( "Autor gefunden: ", $au ) ) if $c->stash->{'debug_level'} > 3; + $c->stash->{'autoren'}{$id} = $au; + } + $c->stash->{'buch2autor'} = {}; + for my $ref ( $c->model('Schema::Autor2buch')->search(undef, { 'order_by' => 'ord_num' } )->all() ) { + my $bid = $ref->buch_id; + my $aid = $ref->autor_id; + $c->stash->{'buch2autor'}{$bid} = [] unless $c->stash->{'buch2autor'}{$bid}; + push @{$c->stash->{'buch2autor'}{$bid}}, $c->stash->{'autoren'}{$aid}{'autor_name'}; + } + + # Set the TT template to use. You will almost always want to do this + # in your action methods (action methods respond to user input in + # your controllers). + $c->stash->{'template'} = 'books/list.tt2'; +} + + +=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 new file mode 100644 index 0000000..db62e57 --- /dev/null +++ b/lib/FrBr/Books/Controller/Root.pm @@ -0,0 +1,64 @@ +package FrBr::Books::Controller::Root; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; +use base 'Catalyst::Controller'; + +# +# Sets the actions in this controller to be registered with no prefix +# so they function identically to actions created in MyApp.pm +# +__PACKAGE__->config->{'namespace'} = ''; + +=head1 NAME + +FrBr::Books::Controller::Root - Root Controller for FrBr::Books + +=head1 DESCRIPTION + +[enter your description here] + +=head1 METHODS + +=cut + +=head2 default + +=cut + +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->{'message'} = 'Willkommen!'; + $c->stash->{'template'} = 'welcome.tt2'; + + # Hello World + #$c->response->body( $c->welcome_message ); +} + +=head2 end + +Attempt to render a view, if needed. + +=cut + +sub end : ActionClass('RenderView') {} + +=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/Db.pm b/lib/FrBr/Books/Db.pm new file mode 100644 index 0000000..f6c5101 --- /dev/null +++ b/lib/FrBr/Books/Db.pm @@ -0,0 +1,19 @@ +package FrBr::Books::Db; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class::Schema'; + +__PACKAGE__->load_classes; + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yMIjCo2VODRuy9VqS1AeQA + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Autor2buch.pm b/lib/FrBr/Books/Db/Autor2buch.pm new file mode 100644 index 0000000..84d83c4 --- /dev/null +++ b/lib/FrBr/Books/Db/Autor2buch.pm @@ -0,0 +1,28 @@ +package FrBr::Books::Db::Autor2buch; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("autor2buch"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "buch_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "autor_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "ord_num" => { data_type => "INT", default_value => 0, is_nullable => 0, size => 10 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("buch_id", ["buch_id", "autor_id"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ndVfBKXzEtRRzVPU1qAspg + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Autoren.pm b/lib/FrBr/Books/Db/Autoren.pm new file mode 100644 index 0000000..1c4cd1e --- /dev/null +++ b/lib/FrBr/Books/Db/Autoren.pm @@ -0,0 +1,27 @@ +package FrBr::Books::Db::Autoren; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("autoren"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "autor_name" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 250, }, + "autor_descr" => { data_type => "TEXT", default_value => undef, is_nullable => 0, size => 65535, }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("autor_name", ["autor_name"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QwPjYKNwUnR5b418xxulDg + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Buch2kategorie.pm b/lib/FrBr/Books/Db/Buch2kategorie.pm new file mode 100644 index 0000000..e61f62b --- /dev/null +++ b/lib/FrBr/Books/Db/Buch2kategorie.pm @@ -0,0 +1,27 @@ +package FrBr::Books::Db::Buch2kategorie; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("buch2kategorie"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "buch_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "kategorie_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("buch_id", ["buch_id", "kategorie_id"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rYT7qQgF4WvVJQgCDUurIw + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Buch2serie.pm b/lib/FrBr/Books/Db/Buch2serie.pm new file mode 100644 index 0000000..0220903 --- /dev/null +++ b/lib/FrBr/Books/Db/Buch2serie.pm @@ -0,0 +1,28 @@ +package FrBr::Books::Db::Buch2serie; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("buch2serie"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "buch_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "serien_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "ord_num" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("buch_id", ["buch_id", "serien_id"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0ZVowzPrhFa/hKjsW/G9RQ + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Buecher.pm b/lib/FrBr/Books/Db/Buecher.pm new file mode 100644 index 0000000..e0d16e5 --- /dev/null +++ b/lib/FrBr/Books/Db/Buecher.pm @@ -0,0 +1,36 @@ +package FrBr::Books::Db::Buecher; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("buecher"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "title" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 250, }, + "title_original" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 250, }, + "verlags_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "isbn" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 20, }, + "buch_nr" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 100, }, + "ausgabejahr" => { data_type => "MEDIUMINT", default_value => undef, is_nullable => 1, size => 8, }, + "druckjahr" => { data_type => "MEDIUMINT", default_value => undef, is_nullable => 1, size => 8, }, + "preis" => { data_type => "FLOAT", default_value => undef, is_nullable => 1, size => 32 }, + "waehrungs_id" => { data_type => "INT", default_value => undef, is_nullable => 1, size => 10 }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->might_have( 'waehrung' => 'FrBr::Books::Db::Waehrungen', { 'foreign.id' => 'self.waehrungs_id' } ); +__PACKAGE__->might_have( 'verlag' => 'FrBr::Books::Db::Verlage', { 'foreign.id' => 'self.verlags_id' } ); + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GjY80NXBYER1XlWgPukp+A + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Kategorien.pm b/lib/FrBr/Books/Db/Kategorien.pm new file mode 100644 index 0000000..142a4a6 --- /dev/null +++ b/lib/FrBr/Books/Db/Kategorien.pm @@ -0,0 +1,26 @@ +package FrBr::Books::Db::Kategorien; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("kategorien"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "kategorie_name" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("kategorie_name", ["kategorie_name"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZEMEahjPuJByMUE/OvebIg + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Serien.pm b/lib/FrBr/Books/Db/Serien.pm new file mode 100644 index 0000000..21b3b19 --- /dev/null +++ b/lib/FrBr/Books/Db/Serien.pm @@ -0,0 +1,27 @@ +package FrBr::Books::Db::Serien; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("serien"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "serien_name" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, }, + "descr" => { data_type => "TEXT", default_value => undef, is_nullable => 0, size => 65535, }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("serien_name", ["serien_name"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/IzPoWKb7jK+P2HCTO+bCQ + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Session.pm b/lib/FrBr/Books/Db/Session.pm new file mode 100644 index 0000000..04ff3a5 --- /dev/null +++ b/lib/FrBr/Books/Db/Session.pm @@ -0,0 +1,26 @@ +package FrBr::Books::Db::Session; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("session"); +__PACKAGE__->add_columns( + "id" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 72, }, + "session_data" => { data_type => "TEXT", default_value => undef, is_nullable => 0, size => 65535, }, + "expires" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, +); +__PACKAGE__->set_primary_key("id"); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iRa1VUPKms1GfHni1F3KoA + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Users.pm b/lib/FrBr/Books/Db/Users.pm new file mode 100644 index 0000000..d137f96 --- /dev/null +++ b/lib/FrBr/Books/Db/Users.pm @@ -0,0 +1,36 @@ +package FrBr::Books::Db::Users; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("users"); +__PACKAGE__->add_columns( + "user_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "login" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 50, }, + "vorname" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, }, + "nachname" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, }, + "password" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 250, }, + "date_created" => { data_type => "DATETIME", default_value => undef, is_nullable => 0, size => 19, }, + "date_changed" => { data_type => "DATETIME", default_value => undef, is_nullable => 0, size => 19, }, + "email" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 250, }, + "deleted" => { data_type => "ENUM", default_value => "n", is_nullable => 0, size => 1 }, + "enabled" => { data_type => "ENUM", default_value => "y", is_nullable => 0, size => 1 }, + "admin_status" => { data_type => "ENUM", default_value => "n", is_nullable => 0, size => 1 }, + "comments" => { data_type => "TEXT", default_value => undef, is_nullable => 0, size => 65535, }, +); +__PACKAGE__->set_primary_key("user_id"); +__PACKAGE__->add_unique_constraint("login", ["login"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dE3Et+cb9hDWcDvAu7CS+A + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Verlage.pm b/lib/FrBr/Books/Db/Verlage.pm new file mode 100644 index 0000000..f525289 --- /dev/null +++ b/lib/FrBr/Books/Db/Verlage.pm @@ -0,0 +1,27 @@ +package FrBr::Books::Db::Verlage; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("verlage"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "name_short" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 50, }, + "name_long" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 250, }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("name_short", ["name_short"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DAa/d3XMLm6o69u4vod7zA + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Db/Waehrungen.pm b/lib/FrBr/Books/Db/Waehrungen.pm new file mode 100644 index 0000000..61136d9 --- /dev/null +++ b/lib/FrBr/Books/Db/Waehrungen.pm @@ -0,0 +1,28 @@ +package FrBr::Books::Db::Waehrungen; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("waehrungen"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "waehrungs_kuerzel" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 10, }, + "waehrungs_name" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, }, + "umrechnung_in_euro" => { data_type => "FLOAT", default_value => undef, is_nullable => 1, size => 32 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("waehrungs_kuerzel", ["waehrungs_kuerzel"]); + + +# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WM0GK+E0U+7khRuX5LN3XA + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/lib/FrBr/Books/Model/Schema.pm b/lib/FrBr/Books/Model/Schema.pm new file mode 100644 index 0000000..da5fcbd --- /dev/null +++ b/lib/FrBr/Books/Model/Schema.pm @@ -0,0 +1,44 @@ +package FrBr::Books::Model::Schema; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use base 'Catalyst::Model::DBIC::Schema'; + +__PACKAGE__->config( + schema_class => 'FrBr::Books::Db', + 'connect_info' => [ + $ENV{'FRBR_BOOKS_DSN'} || 'dbi:mysql:database=books;host=localhost', + $ENV{'FRBR_BOOKS_USER'} || 'books', + $ENV{'FRBR_BOOKS_PWD'} || '', + { 'AutoCommit' => 1, + 'PrintError' => 0, + 'RaiseError' => 0, + } + ], +); + +=head1 NAME + +FrBr::Books::Model::Schema - Catalyst DBIC Schema Model +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +L Model using schema L + +=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/Plugin/ConfigLoader.pm b/lib/FrBr/Books/Plugin/ConfigLoader.pm new file mode 100644 index 0000000..faa6c0a --- /dev/null +++ b/lib/FrBr/Books/Plugin/ConfigLoader.pm @@ -0,0 +1,102 @@ +package FrBr::Books::Plugin::ConfigLoader; + +# $Id: ConfigLoader.pm 16 2007-08-09 14:47:12Z frank $ +# $URL$ + +use base "Catalyst::Plugin::ConfigLoader"; +use FrBr::Common; +use Catalyst::Log::Log4perl; + +my %LogLevels = ( + 'FATAL' => 1, + 'ERROR' => 1, + 'WARN' => 1, + 'INFO' => 1, + 'DEBUG' => 1, +); + +#--------------------------------------------------------------------------- + +=head2 finalize_config + +This method is called after the config file is loaded. It can be +used to implement tuning of config values that can only be done +at runtime. If you need to do this to properly configure any +plugins, it's important to load ConfigLoader before them. +ConfigLoader provides a default finalize_config method which +walks through the loaded config hash and replaces any strings +beginning containing C<__HOME__> with the full path to +app's home directory (i.e. C<$c-Epath_to('')> ). +You can also use C<__path_to(foo/bar)__> which translates to +C<$c-Epath_to('foo', 'bar')> + +=cut + +sub finalize_config { + + my $c = shift; + my $K = __PACKAGE__ . "::finalize_config(): "; + + #$c->log->debug( get_output_string( $K, "aufgerufen." ) ) if $c->config->{'debug_level'} >= 2; + + $c->SUPER::finalize_config(); + + $c->config->{'debug_level'} = to_int( $c->config->{'debug_level'} ) ? to_int( $c->config->{'debug_level'} ) : 0; + + # Vorgabe-View festlegen (kann mit $c->stash->{'current_view_instance'} oder $c->stash->{'current_view'} ueberschrieben werden.) + $c->config()->{'default_view'} = 'TtDefault' unless $c->config()->{'default_view'}; + + my $log4perlconf = ""; + my $log_level = uc( $c->config()->{'log_level'} || 'info' ); + $log_level = 'INFO' unless $LogLevels{$log_level}; + + if ( $ENV{'CATALYST_DEBUG'} or $ENV{'FRBR_BOOKS_DEBUG'} ) { + $log_level = 'DEBUG'; + } + else { + $log_level = 'INFO' if $log_level eq 'DEBUG'; + } + + $log4perlconf .= 'log4perl.rootLogger=' . $log_level . ", A1\n"; + if ( $c->config()->{'colored_log'} ) { + $log4perlconf .= "log4perl.appender.A1=Log::Log4perl::Appender::ScreenColoredLevels\n"; + } + else { + $log4perlconf .= "log4perl.appender.A1=Log::Log4perl::Appender::Screen\n"; + } + $log4perlconf .= "log4perl.appender.A1.layout=PatternLayout\n"; + $log4perlconf .= "log4perl.appender.A1.layout.ConversionPattern=[%d] [CookBook] [%p] %m%n\n"; + + $c->log->debug( $K . "Log4perl-Konfiguration:\n" . $log4perlconf ) if $c->config->{'debug_level'} >= 1; + $c->log( Catalyst::Log::Log4perl->new( \$log4perlconf ) ); + + my $dsn = 'dbi:mysql:host=%s;database=%s'; + + $dsn = sprintf( $dsn, ( $c->config()->{'database'}->{'host'} || 'localhost' ), + ( $c->config()->{'database'}->{'schema'} || 'books' ) ); + + my $port = 3306; + if ( $c->config()->{'database'}->{'port'} and to_int( $c->config()->{'database'}->{'port'} ) ) { + $port = $c->config()->{'database'}->{'port'}; + } + $port = $port == 3306 ? '' : ';port=' . $port; + $dsn .= $port; + + $c->config()->{'dsn'} = $dsn; + $c->config()->{'db_user'} = $c->config()->{'database'}->{'user'} || 'cookbook'; + $c->config()->{'db_passwd'} = $c->config()->{'database'}->{'passwd'} || ''; + + $ENV{'FRBR_BOOKS_DSN'} = $dsn; + $ENV{'FRBR_BOOKS_USER'} = $c->config()->{'db_user'}; + $ENV{'FRBR_BOOKS_PWD'} = $c->config()->{'db_passwd'}; + + $c->log->debug( get_output_string( $K, "Aktuelle Konfiguration: ", $c->config ) ) if $c->config->{'debug_level'} >= 3; + +} ## end sub finalize_config + +#--------------------------------------------------------------------------- + +1; + +#--------------------------------------------------------------------------- + diff --git a/lib/FrBr/Books/View/TtDefault.pm b/lib/FrBr/Books/View/TtDefault.pm new file mode 100644 index 0000000..b184a8e --- /dev/null +++ b/lib/FrBr/Books/View/TtDefault.pm @@ -0,0 +1,47 @@ +package FrBr::Books::View::TtDefault; + +# $Id: Absence.pm 305 2008-03-14 13:53:44Z fbrehm $ +# $URL$ + +use strict; +use base 'Catalyst::View::TT'; + +__PACKAGE__->config({ + CATALYST_VAR => 'Catalyst', + INCLUDE_PATH => [ + FrBr::Books->path_to( 'root', 'src' ), + FrBr::Books->path_to( 'root', 'lib' ) + ], + PRE_PROCESS => 'config/main.tt2', + WRAPPER => 'site/wrapper.tt2', + ERROR => 'error.tt2', + TIMER => 0, + PRE_CHOMP => 0, + POST_CHOMP => 0, + TEMPLATE_EXTENSION => '.tt2', +}); + +=head1 NAME + +FrBr::Books::View::TtDefault - TT View for FrBr::Books + +=head1 DESCRIPTION + +TT View for FrBr::Books. + +=head1 AUTHOR + +=head1 SEE ALSO + +L + +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/Common.pm b/lib/FrBr/Common.pm new file mode 100644 index 0000000..cc47329 --- /dev/null +++ b/lib/FrBr/Common.pm @@ -0,0 +1,432 @@ +package FrBr::Common; + +# $Id: Common.pm 5 2007-08-07 17:27:37Z frank $ +# $URL$ + +=head1 NAME + +FrBr::Common + +=head1 DESCRIPTION + +Modul fuer allgemeine Aufgaben, zum Beispiel Verbose-Level usw. + +Dieses Modul sollte von allen Scripten und Modulen verwendet werden. + +=cut + +#--------------------------------------------------------------------------- + +use strict; +use warnings; +use Exporter; +use Data::Dumper; +use Cwd; +use File::Spec; + +use Carp qw(:DEFAULT cluck); + +our @ISA = qw(Exporter); +our @EXPORT = qw( + &verbose + &canon_filename + &common_debug + &common_error + &common_notice + &get_output_string + &escape_html + &home_dir + &to_bool + &to_float + &to_int +); + +$Data::Dumper::Indent = 1; +$Data::Dumper::Sortkeys = 1; + +our $FRBR_VERSION = "1.1"; +our $AUTHOR = 'Frank Brehm '; + +our $env_home_name = 'FRBR_HOME'; + +my $Revis = <<'ENDE'; + $Revision$ +ENDE +$Revis =~ s/^.*:\s*(\S+)\s*\$.*/$1/s; +our $VERSION = $FRBR_VERSION . "." . $Revis; + +my $verbose = 0; +my $mark = 'CookBook'; + +$verbose = to_int( $ENV{'FRBR_BOOKS_DEBUG'} || $ENV{'CATALYST_DEBUG'} ) || 0; + +#------------------------------------------------------------------------------------------ + +=head1 Funktionen + +Alle hier definierten Funktionen werden exportiert. + +#------------------------------------------------------------------------------------------ + +=head2 verbose( $new_verbose_level ) + +Setzt bzw. gibt den Verbose-Level des aktuellen Scripts zurueck. + +Typische Werte: + +=over 4 + +=item I<0>: + +Keinerlei Ausgaben. + +=item I<1>: + +Ausgabe der wichtigsten Aktionen des aktuellen Scripts (sollte eigentlich Standard sein). + +. +. +. + +=item I<6>: + +Ausfuehrlichstes Geplapper bis zum Gehtnichtmehr. + +=back + +=cut + +sub verbose { + + my $new_verbose_level = shift; + + if ( defined $new_verbose_level and $new_verbose_level =~ /^\d+$/ ) { + $verbose = $new_verbose_level; + } + + return $verbose; + +} ## end sub verbose + +##------------------------------------------------------------------------------------------ + +=head2 mark( [$new_mark] ) + +Gibt den aktuellen Log-Marker zurueck bzw. setzt einen neuen, wenn er übergeben wurde. + +=cut + +sub mark { + + my $new_mark = shift; + + if ( $new_mark and $new_mark !~ /^\s*$/ ) { + $new_mark =~ s/^\s+//; + $new_mark =~ s/\s+$//s; + $mark = $new_mark; + } + + return $mark; + +} ## end sub mark + +#------------------------------------------------------------------------------------------ + +=head2 home_dir() + +Gibt den Namen des Verzeichnisses der Software-Installation zurueck, +die aus der Umgebungsvariablen C entnommen wird. + +Wenn die Umgebungsvariable nicht gesetzt ist bzw. auf ein nicht vorhandenes Verzeichnis +zeigt, wird undef zurueckgegeben. + +=cut + +sub home_dir { + + my $K = __PACKAGE__ . "::home_dir(): "; + + unless ( $ENV{$env_home_name} ) { + common_notice( $K . "Umgebungsvariable '" . $env_home_name . "' nicht gesetzt." ); + return undef; + } + + unless ( File::Spec->file_name_is_absolute( $ENV{$env_home_name} ) ) { + common_notice( $K . "Umgebungsvariable '" . $env_home_name . "' (" . $ENV{$env_home_name} . ") ist keine absolute Pfadangabe." ); + return undef; + } + + unless ( -d $ENV{$env_home_name} ) { + common_notice( + $K . "Umgebungsvariable '" . $env_home_name . "' zeigt auf nicht vorhandenes Verzeichnis '" . $ENV{$env_home_name} . "'." ); + return undef; + } + + return File::Spec->canonpath( $ENV{$env_home_name} ); + +} ## end sub home_dir + +#------------------------------------------------------------------------------------------ + +=head2 canon_filename( @directories, $filename ) + +Kettet die uebergebenen Verzeichnisnamen und Dateinamen aneinander. +Wenn der resultierende Pfad nicht absolut ist, wird home_dir() davorgehaengt. + +=cut + +sub canon_filename { + + my @path = @_; + my $K = __PACKAGE__ . "::canon_filename(): "; + + unless ( scalar(@path) ) { + common_notice( $K . "Keine Argumente uebergeben." ); + return undef; + } + + my $file = File::Spec->catfile(@path); + unless ( File::Spec->file_name_is_absolute($file) ) { + my $home = home_dir(); + return undef unless $home; + $file = File::Spec->catfile( $home, @path ); + } + + return $file; + +} ## end sub canon_filename + +#--------------------------------------------------------------------------- + +=head2 common_debug( $debug_level, @messages ) + +Allgemeine Debug-Funktion (wenn das Log-Objekt noch nicht existieren sollte) + +=cut + +sub common_debug { + + my $debug_level = shift; + + $debug_level = to_int($debug_level); + $debug_level = 1 unless defined $debug_level; + + return if $debug_level > $verbose; + + my $text = get_output_string(@_); + return if $text eq ''; + + print $mark . " (debug" . $debug_level . "): " . $text . "\n"; + + return; + +} ## end sub common_debug + +#--------------------------------------------------------------------------- + +sub get_output_string { + + my $text = ''; + for (@_) { + next unless defined $_; + my $t = ref($_) ? Dumper($_) : $_; + next if $t eq ''; + $text .= $t; + } + + $text =~ s/^\s+//; + $text =~ s/\s+$//s; + return $text; + +} ## end sub get_output_string + +#--------------------------------------------------------------------------- + +=head2 common_error( $error_level, @messages ) + +Allgemeine Error-Warn-Funktion (wenn das Log-Objekt noch nicht existieren sollte) + +=cut + +sub common_error { + + my $error_level = shift; + + $error_level ||= 'error'; + + my $text = get_output_string(@_); + + $text = "unbekannter Fehler" if $text eq ''; + + warn $mark . "(" . $error_level . "): " . $text . "\n"; + + return; + +} ## end sub common_error + +#--------------------------------------------------------------------------- + +=head2 common_notice( @messages ) + +Allgemeine Warnmeldung. + +=cut + +sub common_notice { + + my $text = get_output_string(@_); + $text = "unbekannter Fehler" if $text eq ''; + + warn $mark . ": " . $text . "\n"; + + return; + +} ## end sub common_notice + +#------------------------------------------------------------------------------------------ + +=head2 to_bool( $wert ) + +Wandelt den uebergebenen Scalar sicher in einen Wahrheitswert (0 oder 1) um. + +=cut + +sub to_bool { + + my $val = shift; + + return 0 unless defined $val; + return 0 if $val =~ /^\s*$/; + + if ( $val =~ /^\s*y(?:es?)?/i + or $val =~ /^\s*ja?/i + or $val =~ /^\s*[wt]\s*$/i + or $val =~ /^\s*on\s*$/i + or $val =~ /^\s*wahr|true/i ) + { + return 1; + } + + if ( $val =~ /^\s*no?/i + or $val =~ /^\s*ne(?:in?)?/i + or $val =~ /^\s*f\s*$/i + or $val =~ /^\s*off\s*$/i + or $val =~ /^\s*falsch|false/i ) + { + return 0; + } + + my $intval = to_int($val); + if ( defined $intval ) { + return $intval ? 1 : 0; + } + + return $val ? 1 : 0; + +} ## end sub to_bool + +#------------------------------------------------------------------------------------------ + +=head2 to_float( $wert ) + +Wandelt den uebergebenen Scalar sicher in eine Float-Zahl um. + +Falls der uebergebene Wert keine gueltige Zahl ist, wird undef zurueckgegeben. + +=cut + +sub to_float { + + my $val = shift; + + return undef unless defined($val) and $val =~ /\d/; + + my $ts = ","; + my $ds = "."; + + if ( ( $val =~ /\d,/ and $val !~ /\d\./ ) + or ( $val =~ /\d\.\d\d\d\./ ) + or ( $val =~ /\d\.\d\d\d,/ ) ) + { + $ds = ","; + $ts = "."; + } + + $val =~ s/\Q$ts\E//g; + $val =~ s/\Q$ds\E/\./g; + + return ( $val + 0 ); + +} ## end sub to_float + +#------------------------------------------------------------------------------------------ + +=head2 to_int( $wert, $signed ) + +Wandelt den uebergebenen Wert sicher in eine Integer-Zahl um. + +Dabei legt der optionale logische Parameter $signed fest, ob auch +vorzeichenbehaftete Werte zulaessig sind. + +Wenn keine gueltige Zahl uebergeben wird, wird undef zurueckgegeben. + +=cut + +sub to_int { + + my $val = shift; + my $signed = shift; + + return undef unless defined $val; + unless ( $val =~ /\d/ ) { + return undef; + } + + if ($signed) { + $val =~ /^[^\d-]*(?:(-)\s*)?(\d+)/; + $val = ( defined $1 ? $1 : '' ) . $2; + } + else { + $val =~ /^\D*(\d+)/; + $val = $1; + } + + return $val + 0; + +} ## end sub to_int + +#------------------------------------------------------------------------------------------ + +=head2 escape_html( $text ) + +Maskiert alle '&', '<', '>' und '"' im uebergebenen Text durch entsprechende +HTML-Entities. + +Entnommen dem Modul L. + +=cut + +sub escape_html { + + return unless defined( my $toencode = shift ); + + $toencode =~ s{&}{&}gso; + $toencode =~ s{<}{<}gso; + $toencode =~ s{>}{>}gso; + $toencode =~ s{\"}{"}gso; + + # Doesn't work. Can't work. forget it. + # $toencode =~ s{\x8b}{‹}gso; + # $toencode =~ s{\x9b}{›}gso; + + $toencode; + +} ## end sub escape_html + +#------------------------------------------------------------------------------------------ + +1; + +#------------------------------------------------------------------------------------------ + +__END__ diff --git a/root/lib/config/colors.tt2 b/root/lib/config/colors.tt2 new file mode 100644 index 0000000..0c16999 --- /dev/null +++ b/root/lib/config/colors.tt2 @@ -0,0 +1,84 @@ +[%# config/col + + alle Farbdefinitionen + + $Id: colors.tt2 1998 2008-03-06 11:34:59Z fbrehm $ + $URL$ + +-%] + +[%- + # Definition von Farbnamen + + site.rgb = { + black = '#000000' + white = '#ffffff' + grey1 = '#46494c' + grey2 = '#c6c9cc' + grey3 = '#e3e6ea' + hellgrau = '#d2d2d2' + mittelgrau = '#b4b4b4' + dunkelgrau = '#969696' + ganzdunkelgrau = '#404040' + silbergrau = '#cccccc' + hellsilbergrau = '#e0e0e0' + fastweiss = '#f0f0f0' + graugelb = '#e1e49a' + rotbraun = '#9b2b2a' + dunkelbraun = '#782828' + cyan = '#8de0e0' + mgrey = '#707070' + lgrey = '#c0c0c0' + red = '#cc4444' + hellrot = '#f00000' + rosa = '#ffc7c7' + hellrosa = '#ffe2e2' + green = '#66aa66' + darkgreen = '#3d663d' + blue = '#89b8df' + darkblue = '#000080' + orange = '#f08900' + graublau = '#acbdcd' + hellgraublau = '#d6ebff' + hhellgraublau = '#c1d4e6' + dunkelgraublau = '#808d99' + hdunkelgraublau = '#96a5b2' + dunkelblau = '#1010c0' + hellmagenta = '#d7cfec' + mittelmgenta = '#babadd' + dunkelmagenta = '#666699' + dunkelgraugelb = '#404822' + }; + + site.col = { + page = site.rgb.hellmagenta + text = site.rgb.black + head = site.rgb.dunkelmagenta + head_text = site.rgb.white + line = site.rgb.dunkelgraugelb + message = site.rgb.green + error = site.rgb.red + warn = site.rgb.darkgreen + alink = site.rgb.darkblue + statusbarbg = site.rgb.mittelmgenta + statusbartext = site.rgb.dunkelgraugelb + statusbarborder = site.rgb.dunkelgraugelb + footertext = site.rgb.dunkelgraublau + border = site.rgb.ganzdunkelgrau + table_bg = site.rgb.white + list_head = site.rgb.silbergrau + list_row = site.rgb.hellsilbergrau + list_row_bold = site.rgb.fastweiss + text_free_day = site.rgb.hellrot + text_hfree_day = site.rgb.dunkelbraun + bg_free_day = site.rgb.rosa + bg_hfree_day = site.rgb.hellrosa + border_hell = site.rgb.hellgraublau + border_dunkel = site.rgb.dunkelgraublau + bg_table = site.rgb.graublau + bg_table_head = site.rgb.hdunkelgraublau + link_table = site.rgb.dunkelblau + }; + +-%] + diff --git a/root/lib/config/main.tt2 b/root/lib/config/main.tt2 new file mode 100644 index 0000000..6f57bd3 --- /dev/null +++ b/root/lib/config/main.tt2 @@ -0,0 +1,26 @@ +[%# config/main + + $Id: main.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + + This is the main configuration template which is processed before + any other page, by virtue of it being defined as a PRE_PROCESS + template. This is the place to define any extra template variables, + macros, load plugins, and perform any other template setup. + +-%] +[%- + + # define a data structure to hold sitewide data + site = { + title => 'Inhalt', + copyright => '2008, Frank Brehm, Berlin', + }; + + # load up any other configuration items + PROCESS config/colors.tt2 + config/url.tt2; + + # set defaults for variables, etc. + DEFAULT message = 'Es gibt nichts darzustellen.'; + +-%] diff --git a/root/lib/config/url.tt2 b/root/lib/config/url.tt2 new file mode 100644 index 0000000..8941f2b --- /dev/null +++ b/root/lib/config/url.tt2 @@ -0,0 +1,18 @@ +[%# + + config/url.tt2 + + # alle URL-Definitionen + # + # $Id: url.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + # $URL$ + # +-%] +[%- base = Catalyst.req.base; + + site.url = { + base = base + home = "${base}welcome" + message = "${base}message" + } +-%] diff --git a/root/lib/site/footer.tt2 b/root/lib/site/footer.tt2 new file mode 100644 index 0000000..0eab06b --- /dev/null +++ b/root/lib/site/footer.tt2 @@ -0,0 +1,7 @@ +[%# + ** Template fuer Fusszeile + ** + ** $Id: styles.css 1986 2008-03-04 14:25:18Z fbrehm $ + ** $URL$ + ** -%] + diff --git a/root/lib/site/header.tt2 b/root/lib/site/header.tt2 new file mode 100644 index 0000000..305ce13 --- /dev/null +++ b/root/lib/site/header.tt2 @@ -0,0 +1,8 @@ +[%# + ** Template fuer Seitenkopf + ** + ** $Id: styles.css 1986 2008-03-04 14:25:18Z fbrehm $ + ** $URL$ + ** + ** -%] +

[% site_title or template.title or site.title %]

diff --git a/root/lib/site/html.tt2 b/root/lib/site/html.tt2 new file mode 100644 index 0000000..2b361f9 --- /dev/null +++ b/root/lib/site/html.tt2 @@ -0,0 +1,27 @@ +[%# + + Template fuer HTML-Seite als Ganzes + + $Id: html.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + +-%] + + + + + + +[% PROCESS site/jsfiles.tt2 -%] + + [% site_title or template.title or site.title %] + +[% PROCESS site/jscript.tt2 %] + + +[% content %] + + diff --git a/root/lib/site/jscript.tt2 b/root/lib/site/jscript.tt2 new file mode 100644 index 0000000..24eb6e8 --- /dev/null +++ b/root/lib/site/jscript.tt2 @@ -0,0 +1,14 @@ +[%# + + Template fuer Einbindung reines JavaScripts + + $Id: jscript.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + +-%] + diff --git a/root/lib/site/jsfiles.tt2 b/root/lib/site/jsfiles.tt2 new file mode 100644 index 0000000..d99929d --- /dev/null +++ b/root/lib/site/jsfiles.tt2 @@ -0,0 +1,11 @@ +[%# + + Template fuer HTML-Seite als Ganzes + + $Id: jsfiles.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + +-%] +[%- FOREACH jsfile IN jsfiles %] + +[%- END %] diff --git a/root/lib/site/layout.tt2 b/root/lib/site/layout.tt2 new file mode 100644 index 0000000..d525e0c --- /dev/null +++ b/root/lib/site/layout.tt2 @@ -0,0 +1,15 @@ +[%# + ** Template fuer Allgemeines Seiten-Layout + ** + ** $Id: styles.css 1986 2008-03-04 14:25:18Z fbrehm $ + ** $URL$ + ** + ** -%] + +
[% PROCESS site/statusbar.tt2 %]
+ +
+[% content %] +
+ + diff --git a/root/lib/site/statusbar.tt2 b/root/lib/site/statusbar.tt2 new file mode 100644 index 0000000..34154b8 --- /dev/null +++ b/root/lib/site/statusbar.tt2 @@ -0,0 +1,9 @@ +[%# site/statusbar.tt2 + + Template fuer den Statusbalken / Menuezeile + + $Id: statusbar.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + +-%] +  diff --git a/root/lib/site/styles.css b/root/lib/site/styles.css new file mode 100644 index 0000000..ffddbe7 --- /dev/null +++ b/root/lib/site/styles.css @@ -0,0 +1,173 @@ +[%# + ** Allgemeine Stylesheets + ** + ** $Id: styles.css 1986 2008-03-04 14:25:18Z fbrehm $ + ** $URL$ + ** %] + +/* --- site/styles.css ----------------- */ + +html { + /* height: 100%; */ +} + +body { + background-color: [% site.col.page %]; + color: [% site.col.text %]; + margin: 0px; + padding: 0px; + height: 100%; + font-family: Verdana,Helvetica,Arial; + font-size: 10pt; +} + +A { + color: [% site.col.alink %]; + text-decoration: none; +} + +A:link { + color: [% site.col.alink %]; +} + +A:hover { + color: [% site.col.text %]; + text-decoration: underline; +} + +A:active { + color: [% site.col.text %]; + text-decoration: none; +} + +A:focus { + color: [% site.col.text %]; + text-decoration: none; +} + +#header { + background-color: [% site.col.head %]; + color: [% site.col.head_text %]; + margin: 0; + padding: 5px; +} + +DIV#header H1 { + margin: 0px; + font-weight: normal; + font-size: 2em; + letter-spacing: 1pt; + text-align: right; +} + + + +#statusbar { + background-color: [% site.col.statusbarbg %]; + color: [% site.col.statusbartext %]; + border-bottom: 1px solid [% site.col.statusbarborder %]; + border-top: 1px solid [% site.col.statusbarborder %]; + margin: 0; + padding: 0; + padding: 3px 0px 3px 2%; + font-weight: bold; +} + +#statusbar TABLE { + color: [% site.col.statusbartext %]; + font-size: 0.9em; +} + +#statusbar TABLE TD { + padding: 2px; + vertical-align: middle; +} + +#statusbar TABLE TD SPAN.login { + font-weight: bolder; +} + +#statusbar A { + color: [% site.col.statusbartext %]; +} + +#statusbar A:link { + color: [% site.col.statusbartext %]; +} + +#statusbar A:hover { + color: [% site.col.statusbartext %]; +} + +#statusbar A:active { + color: [% site.col.statusbartext %]; +} + +/* Message-Box */ +DIV#message_box { + font-family: monospace; + font-size: 9pt; + text-align: left; + margin: 0; + white-space: pre; + padding: 0.5em 2em; +} + +#footer { + background-color: [% site.col.page %]; + border-top: 1px solid [% site.col.statusbarborder %]; + position: fixed; + width: 100%; + margin: 0; + padding: 0; + bottom: 0; + font-size: 0.8em; + color: [% site.col.footertext %]; +} + +TABLE { + border-collapse: collapse; +} + +#content { + padding: 10px; +} + +H1.title { + padding: 4px; + margin: 0px; +} + +H2 { + text-align: center; +} + +H2.footer_title { + text-align: center; + padding: 4px; + margin: 0px; +} + +H3 { + text-align: center; +} + +DIV#copyright { + text-align: center; + padding: 4px; + margin: 0px; +} + +.message { + color: [% site.col.message %]; +} + +.error { + color: [% site.col.error %]; +} + +[%- FOREACH cssfile IN cssfiles %] +/* --- [% cssfile %] ----------------- */ + [% PROCESS $cssfile -%] +[%- END %] + diff --git a/root/lib/site/wrapper.tt2 b/root/lib/site/wrapper.tt2 new file mode 100644 index 0000000..23a2ac2 --- /dev/null +++ b/root/lib/site/wrapper.tt2 @@ -0,0 +1,17 @@ +[%# + + Template fuer HTML-Seite als Ganzes + + $Id: wrapper.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + $URL$ + +-%] +[%- + IF template.name.match('\.(css|js|txt)'); + debug("Passing page through as text: $template.name"); + content; + ELSE; + debug("Applying HTML page layout wrappers to $template.name\n"); + content WRAPPER site/html.tt2 + site/layout.tt2; + END; +-%] diff --git a/root/src/books/list.tt2 b/root/src/books/list.tt2 new file mode 100644 index 0000000..92f909e --- /dev/null +++ b/root/src/books/list.tt2 @@ -0,0 +1,32 @@ +[%# + ** Template fuer Buecherliste + ** + ** $Id: styles.css 1986 2008-03-04 14:25:18Z fbrehm $ + ** $URL$ + ** -%] + +[% META title = 'Bücherliste' -%] + + + + + + + + + + + +[% # Display each book in a table row %] +[% FOREACH book IN books -%][% buch_id = book.id -%] + + + + + + + + + +[% END -%] +
Autor (-en)TitelVerlagISBNBuch-NummerAusgabejahrPreis
[% tt_authors = [ ]; tt_authors.push(author) FOREACH author = buch2autor.$buch_id %][% tt_authors.join(', ') %][% book.title %][% IF book.title_original %] ([% book.title_original %])[% END %][% book.verlagsname_short %][% book.isbn %][% book.buch_nr %][% book.ausgabejahr %][% book.preis | format '%0.2f' | replace('\.', ',') %][% IF book.waehrungs_kuerzel %] [% book.waehrungs_kuerzel %][% END %]
diff --git a/root/src/books/styles.css b/root/src/books/styles.css new file mode 100644 index 0000000..4ec7514 --- /dev/null +++ b/root/src/books/styles.css @@ -0,0 +1,10 @@ +[%# + # Template fuer Stylesheets Buecherlisten + # + # $Id: styles.css 305 2008-03-14 13:53:44Z fbrehm $ + # $URL$ + # +-%] +/* Stylesheets Buecherlisten */ + + diff --git a/root/src/error.tt2 b/root/src/error.tt2 new file mode 100644 index 0000000..7b5f3b9 --- /dev/null +++ b/root/src/error.tt2 @@ -0,0 +1,14 @@ +[%# + + error.tt2 - Template zur Darstellung eines Template-Fehlers + + #$Id: error.tt2 1996 2008-03-05 14:06:03Z fbrehm $ + #$URL$ + +-%] +[% META title = 'Fehler' %] +

Ein Fehler ist aufgetreten.

+

Wir sind untröstlich darüber, aber es halt eines der Dinge, + die von Zeit zu Zeit auftreten können.

+

Hier die Fehlermeldung in der Hoffnung, daß sie Ihnen etwas sagen möge: + [% error %]

diff --git a/root/src/welcome.tt2 b/root/src/welcome.tt2 new file mode 100644 index 0000000..7c359b6 --- /dev/null +++ b/root/src/welcome.tt2 @@ -0,0 +1,15 @@ +[%# + + message.tt2 - Universal-Template + + #$Id: message.tt2 1986 2008-03-04 14:25:18Z fbrehm $ + #$URL$ + +-%] +[%- META title = 'Standard-Seite' %] +

Das ist die Standard-Seite.

+

Wir haben folgende Botschaft für Sie: [% message %].

+ +Verfügbare Sprachen:
    [% FOR lang IN avail_languages %] +
  • '[% lang %]'
  • +[% END %]
diff --git a/root/static/images/btn_120x50_built.png b/root/static/images/btn_120x50_built.png new file mode 100644 index 0000000..c709fd6 Binary files /dev/null and b/root/static/images/btn_120x50_built.png differ diff --git a/root/static/images/btn_120x50_built_shadow.png b/root/static/images/btn_120x50_built_shadow.png new file mode 100644 index 0000000..15142fe Binary files /dev/null and b/root/static/images/btn_120x50_built_shadow.png differ diff --git a/root/static/images/btn_120x50_powered.png b/root/static/images/btn_120x50_powered.png new file mode 100644 index 0000000..7249b47 Binary files /dev/null and b/root/static/images/btn_120x50_powered.png differ diff --git a/root/static/images/btn_120x50_powered_shadow.png b/root/static/images/btn_120x50_powered_shadow.png new file mode 100644 index 0000000..e6876c0 Binary files /dev/null and b/root/static/images/btn_120x50_powered_shadow.png differ diff --git a/root/static/images/btn_88x31_built.png b/root/static/images/btn_88x31_built.png new file mode 100644 index 0000000..007b5db Binary files /dev/null and b/root/static/images/btn_88x31_built.png differ diff --git a/root/static/images/btn_88x31_built_shadow.png b/root/static/images/btn_88x31_built_shadow.png new file mode 100644 index 0000000..ccf4624 Binary files /dev/null and b/root/static/images/btn_88x31_built_shadow.png differ diff --git a/root/static/images/btn_88x31_powered.png b/root/static/images/btn_88x31_powered.png new file mode 100644 index 0000000..8f0cd9f Binary files /dev/null and b/root/static/images/btn_88x31_powered.png differ diff --git a/root/static/images/btn_88x31_powered_shadow.png b/root/static/images/btn_88x31_powered_shadow.png new file mode 100644 index 0000000..aa776fa Binary files /dev/null and b/root/static/images/btn_88x31_powered_shadow.png differ diff --git a/root/static/images/catalyst_logo.png b/root/static/images/catalyst_logo.png new file mode 100644 index 0000000..21f1cac Binary files /dev/null and b/root/static/images/catalyst_logo.png differ diff --git a/root/static/pic/fbr.ico b/root/static/pic/fbr.ico new file mode 100644 index 0000000..5a0537a Binary files /dev/null and b/root/static/pic/fbr.ico differ diff --git a/script/frbr_books_cgi.pl b/script/frbr_books_cgi.pl new file mode 100755 index 0000000..82fb25b --- /dev/null +++ b/script/frbr_books_cgi.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' } + +use strict; +use warnings; +use FindBin; +use lib "$FindBin::Bin/../lib"; +use FrBr::Books; + +FrBr::Books->run; + +1; + +=head1 NAME + +frbr_books_cgi.pl - Catalyst CGI + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +Run a Catalyst application as a cgi script. + +=head1 AUTHOR + +Sebastian Riedel, C + +=head1 COPYRIGHT + + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/script/frbr_books_create.pl b/script/frbr_books_create.pl new file mode 100755 index 0000000..51a1e3d --- /dev/null +++ b/script/frbr_books_create.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use Getopt::Long; +use Pod::Usage; +use Catalyst::Helper; + +my $force = 0; +my $mech = 0; +my $help = 0; + +GetOptions( + 'nonew|force' => \$force, + 'mech|mechanize' => \$mech, + 'help|?' => \$help + ); + +pod2usage(1) if ( $help || !$ARGV[0] ); + +my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } ); + +pod2usage(1) unless $helper->mk_component( 'FrBr::Books', @ARGV ); + +1; + +=head1 NAME + +frbr_books_create.pl - Create a new Catalyst Component + +=head1 SYNOPSIS + +frbr_books_create.pl [options] model|view|controller name [helper] [options] + + Options: + -force don't create a .new file where a file to be created exists + -mechanize use Test::WWW::Mechanize::Catalyst for tests if available + -help display this help and exits + + Examples: + frbr_books_create.pl controller My::Controller + frbr_books_create.pl controller My::Controller BindLex + frbr_books_create.pl -mechanize controller My::Controller + frbr_books_create.pl view My::View + frbr_books_create.pl view MyView TT + frbr_books_create.pl view TT TT + frbr_books_create.pl model My::Model + frbr_books_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\ + dbi:SQLite:/tmp/my.db + frbr_books_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\ + dbi:Pg:dbname=foo root 4321 + + See also: + perldoc Catalyst::Manual + perldoc Catalyst::Manual::Intro + +=head1 DESCRIPTION + +Create a new Catalyst Component. + +Existing component files are not overwritten. If any of the component files +to be created already exist the file will be written with a '.new' suffix. +This behavior can be suppressed with the C<-force> option. + +=head1 AUTHOR + +Sebastian Riedel, C +Maintained by the Catalyst Core Team. + +=head1 COPYRIGHT + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/script/frbr_books_fastcgi.pl b/script/frbr_books_fastcgi.pl new file mode 100755 index 0000000..205800e --- /dev/null +++ b/script/frbr_books_fastcgi.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl -w + +BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' } + +use strict; +use warnings; +use Getopt::Long; +use Pod::Usage; +use FindBin; +use lib "$FindBin::Bin/../lib"; +use FrBr::Books; + +my $help = 0; +my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr ); + +GetOptions( + 'help|?' => \$help, + 'listen|l=s' => \$listen, + 'nproc|n=i' => \$nproc, + 'pidfile|p=s' => \$pidfile, + 'manager|M=s' => \$manager, + 'daemon|d' => \$detach, + 'keeperr|e' => \$keep_stderr, +); + +pod2usage(1) if $help; + +FrBr::Books->run( + $listen, + { nproc => $nproc, + pidfile => $pidfile, + manager => $manager, + detach => $detach, + keep_stderr => $keep_stderr, + } +); + +1; + +=head1 NAME + +frbr_books_fastcgi.pl - Catalyst FastCGI + +=head1 SYNOPSIS + +frbr_books_fastcgi.pl [options] + + Options: + -? -help display this help and exits + -l -listen Socket path to listen on + (defaults to standard input) + can be HOST:PORT, :PORT or a + filesystem path + -n -nproc specify number of processes to keep + to serve requests (defaults to 1, + requires -listen) + -p -pidfile specify filename for pid file + (requires -listen) + -d -daemon daemonize (requires -listen) + -M -manager specify alternate process manager + (FCGI::ProcManager sub-class) + or empty string to disable + -e -keeperr send error messages to STDOUT, not + to the webserver + +=head1 DESCRIPTION + +Run a Catalyst application as fastcgi. + +=head1 AUTHOR + +Sebastian Riedel, C +Maintained by the Catalyst Core Team. + +=head1 COPYRIGHT + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/script/frbr_books_server.pl b/script/frbr_books_server.pl new file mode 100755 index 0000000..f51db84 --- /dev/null +++ b/script/frbr_books_server.pl @@ -0,0 +1,111 @@ +#!/usr/bin/perl -w + +BEGIN { + $ENV{CATALYST_ENGINE} ||= 'HTTP'; + $ENV{CATALYST_SCRIPT_GEN} = 30; + require Catalyst::Engine::HTTP; +} + +use strict; +use warnings; +use Getopt::Long; +use Pod::Usage; +use FindBin; +use lib "$FindBin::Bin/../lib"; + +my $debug = 0; +my $fork = 0; +my $help = 0; +my $host = undef; +my $port = $ENV{FRBR_BOOKS_PORT} || $ENV{CATALYST_PORT} || 3000; +my $keepalive = 0; +my $restart = $ENV{FRBR_BOOKS_RELOAD} || $ENV{CATALYST_RELOAD} || 0; +my $restart_delay = 1; +my $restart_regex = '\.yml$|\.yaml$|\.pm$'; +my $restart_directory = undef; + +my @argv = @ARGV; + +GetOptions( + 'debug|d' => \$debug, + 'fork' => \$fork, + 'help|?' => \$help, + 'host=s' => \$host, + 'port=s' => \$port, + 'keepalive|k' => \$keepalive, + 'restart|r' => \$restart, + 'restartdelay|rd=s' => \$restart_delay, + 'restartregex|rr=s' => \$restart_regex, + 'restartdirectory=s' => \$restart_directory, +); + +pod2usage(1) if $help; + +if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) { + $ENV{CATALYST_ENGINE} = 'HTTP::Restarter'; +} +if ( $debug ) { + $ENV{CATALYST_DEBUG} = 1; +} + +# This is require instead of use so that the above environment +# variables can be set at runtime. +require FrBr::Books; + +FrBr::Books->run( $port, $host, { + argv => \@argv, + 'fork' => $fork, + keepalive => $keepalive, + restart => $restart, + restart_delay => $restart_delay, + restart_regex => qr/$restart_regex/, + restart_directory => $restart_directory, +} ); + +1; + +=head1 NAME + +frbr_books_server.pl - Catalyst Testserver + +=head1 SYNOPSIS + +frbr_books_server.pl [options] + + Options: + -d -debug force debug mode + -f -fork handle each request in a new process + (defaults to false) + -? -help display this help and exits + -host host (defaults to all) + -p -port port (defaults to 3000) + -k -keepalive enable keep-alive connections + -r -restart restart when files get modified + (defaults to false) + -rd -restartdelay delay between file checks + -rr -restartregex regex match files that trigger + a restart when modified + (defaults to '\.yml$|\.yaml$|\.pm$') + -restartdirectory the directory to search for + modified files + (defaults to '../') + + See also: + perldoc Catalyst::Manual + perldoc Catalyst::Manual::Intro + +=head1 DESCRIPTION + +Run a Catalyst Testserver for this application. + +=head1 AUTHOR + +Sebastian Riedel, C +Maintained by the Catalyst Core Team. + +=head1 COPYRIGHT + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/script/frbr_books_test.pl b/script/frbr_books_test.pl new file mode 100755 index 0000000..16e6f12 --- /dev/null +++ b/script/frbr_books_test.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use Getopt::Long; +use Pod::Usage; +use FindBin; +use lib "$FindBin::Bin/../lib"; +use Catalyst::Test 'FrBr::Books'; + +my $help = 0; + +GetOptions( 'help|?' => \$help ); + +pod2usage(1) if ( $help || !$ARGV[0] ); + +print request($ARGV[0])->content . "\n"; + +1; + +=head1 NAME + +frbr_books_test.pl - Catalyst Test + +=head1 SYNOPSIS + +frbr_books_test.pl [options] uri + + Options: + -help display this help and exits + + Examples: + frbr_books_test.pl http://localhost/some_action + frbr_books_test.pl /some_action + + See also: + perldoc Catalyst::Manual + perldoc Catalyst::Manual::Intro + +=head1 DESCRIPTION + +Run a Catalyst action from the command line. + +=head1 AUTHOR + +Sebastian Riedel, C +Maintained by the Catalyst Core Team. + +=head1 COPYRIGHT + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/t/01app.t b/t/01app.t new file mode 100644 index 0000000..c9c341b --- /dev/null +++ b/t/01app.t @@ -0,0 +1,7 @@ +use strict; +use warnings; +use Test::More tests => 2; + +BEGIN { use_ok 'Catalyst::Test', 'FrBr::Books' } + +ok( request('/')->is_success, 'Request should succeed' ); diff --git a/t/02pod.t b/t/02pod.t new file mode 100644 index 0000000..251640d --- /dev/null +++ b/t/02pod.t @@ -0,0 +1,9 @@ +use strict; +use warnings; +use Test::More; + +eval "use Test::Pod 1.14"; +plan skip_all => 'Test::Pod 1.14 required' if $@; +plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; + +all_pod_files_ok(); diff --git a/t/03podcoverage.t b/t/03podcoverage.t new file mode 100644 index 0000000..ae59d4c --- /dev/null +++ b/t/03podcoverage.t @@ -0,0 +1,9 @@ +use strict; +use warnings; +use Test::More; + +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; +plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; + +all_pod_coverage_ok(); diff --git a/t/controller_Books.t b/t/controller_Books.t new file mode 100644 index 0000000..e8de2c9 --- /dev/null +++ b/t/controller_Books.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::Books' } + +ok( request('/books')->is_success, 'Request should succeed' ); + + diff --git a/t/model_Schema.t b/t/model_Schema.t new file mode 100644 index 0000000..3b50119 --- /dev/null +++ b/t/model_Schema.t @@ -0,0 +1,6 @@ +use strict; +use warnings; +use Test::More tests => 1; + +BEGIN { use_ok 'FrBr::Books::Model::Schema' } + diff --git a/t/view_TtDefault.t b/t/view_TtDefault.t new file mode 100644 index 0000000..9815fcf --- /dev/null +++ b/t/view_TtDefault.t @@ -0,0 +1,6 @@ +use strict; +use warnings; +use Test::More tests => 1; + +BEGIN { use_ok 'FrBr::Books::View::TtDefault' } +