From 52d254200d32b47402461d325c2836c35af99201 Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Wed, 13 Oct 2004 11:07:28 +0000 Subject: [PATCH] Zero search fix and sweet new templates, wheee... git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@223 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 2 + lib/Maypole.pm | 6 +- lib/Maypole/Application.pm | 25 +++-- lib/Maypole/Model/CDBI.pm | 22 ++-- templates/beer/addnew | 2 + templates/factory/addnew | 5 +- templates/factory/footer | 2 +- templates/factory/frontpage | 22 ++-- templates/factory/header | 2 +- templates/factory/list | 11 +- templates/factory/macros | 4 +- templates/factory/maypole | 7 ++ templates/factory/search_form | 4 +- templates/factory/title | 7 ++ templates/factory/view | 3 +- templates/maypole.css | 192 +++++++++++++++++++++++++++++----- 16 files changed, 240 insertions(+), 76 deletions(-) create mode 100644 templates/factory/maypole create mode 100644 templates/factory/title diff --git a/Changes b/Changes index dd3db0e..4ce18b8 100644 --- a/Changes +++ b/Changes @@ -27,6 +27,8 @@ Revision history for Perl extension Maypole compability. - fixed search ordering in Maypole::Model::CDBI and parameter handling in CGI::Maypole (Dave Slack) + - sweet new factory templates (Danijel Milicevic) + - zero search fix (Dave Slack) 1.7 Sat Jul 17 20:15:26 BST 2004 - Emergency release - we lost the "use Maypole::Constants" from diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 6b4fe3f..4c66a67 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -396,15 +396,15 @@ http://maypole.perl.org/ L,L, L. -=head1 MAINTAINER +=head1 AUTHOR Sebastian Riedel, c -=head1 AUTHOR +=head1 AUTHOR EMERITUS Simon Cozens, C -=head1 THANK YOU +=head1 THANKS TO Danijel Milicevic, Dave Slack, Jesse Sheidlower, Jody Belka, Marcus Ramberg, Mickael Joanne, Simon Flack, Veljko Vidovic and all the others who've diff --git a/lib/Maypole/Application.pm b/lib/Maypole/Application.pm index b6789a8..4e8b624 100644 --- a/lib/Maypole/Application.pm +++ b/lib/Maypole/Application.pm @@ -7,35 +7,40 @@ our @ISA; sub import { my ( $self, @plugins ) = @_; - return unless $plugins[0]; - my $caller=caller(0); - no strict 'refs'; - push @{"${caller}::ISA"}, $self; - "Maypole::$_"->require && unshift @ISA, "Maypole::$_" foreach (@plugins); + return unless $plugins[0]; + my $caller = caller(0); + no strict 'refs'; + push @{"${caller}::ISA"}, $self; + "Maypole::$_"->require && unshift @ISA, "Maypole::$_" foreach (@plugins); } if ( $ENV{MOD_PERL} ) { require Apache::MVC; - push @ISA , qw(Apache::MVC); + push @ISA, qw(Apache::MVC); } else { require CGI::Maypole; - push @ISA , qw(CGI::Maypole); + push @ISA, qw(CGI::Maypole); } 1; =head1 NAME -Maypole::Application - all in wonder front-end +Maypole::Application - Maypole Universal Frontend =head1 SYNOPSIS - use base 'Maypole::Application'; + use Maypole::Application; =head1 DESCRIPTION -The all in wonder front-end. +This is a universal frontend for mod_perl1, mod_perl2 and CGI. + +You can omit the Maypole:: prefix from plugins. +So Maypole::Config::YAML becomes Config::YAML. + + use Maypole::Application qw(Config::YAML); =head1 AUTHOR diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 5432561..bba1c5c 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -66,15 +66,17 @@ sub related { return keys %{ $self->meta_info('has_many') || {} }; } -#sub related_class { -# my ( $self, $r, $accessor ) = @_; -# my $related=$self->related->{$accessor}; -# if ( my $mapping=$related->{args}->{mapping} ) { -# return $related->{foreign_class}->meta_info('has_a')->{$$mapping[0]}->{foreign_class}; -# } else { -# return $related->{foreign_class}; -# } -#} +sub related_class { + my ( $self, $r, $accessor ) = @_; + my $related = $self->related->{$accessor}; + if ( my $mapping = $related->{args}->{mapping} ) { + return $related->{foreign_class}->meta_info('has_a')->{ $$mapping[0] } + ->{foreign_class}; + } + else { + return $related->{foreign_class}; + } +} sub do_edit : Exported { my ( $self, $r ) = @_; @@ -144,7 +146,7 @@ sub search : Exported { my $oper = "like"; # For now my %params = %{ $r->{params} }; my %values = map { $_ => { $oper, $params{$_} } } - grep { $params{$_} and $fields{$_} } keys %params; + grep { defined $params{$_} and $fields{$_} } keys %params; $r->template("list"); if ( !%values ) { return $self->list($r) } diff --git a/templates/beer/addnew b/templates/beer/addnew index 32b97db..ad51f01 100644 --- a/templates/beer/addnew +++ b/templates/beer/addnew @@ -1,4 +1,5 @@ [% USE element_maker = Class("HTML::Element") %] +
Add a new [%classmetadata.moniker%] @@ -17,3 +18,4 @@
+
diff --git a/templates/factory/addnew b/templates/factory/addnew index 18d63d4..a6027ce 100644 --- a/templates/factory/addnew +++ b/templates/factory/addnew @@ -10,7 +10,9 @@ table. =cut #%] -
+ +
+
Add a new [% classmetadata.moniker %] [% FOR col = classmetadata.columns %] @@ -22,3 +24,4 @@ table.
+
diff --git a/templates/factory/footer b/templates/factory/footer index 64584ee..1b8ae55 100644 --- a/templates/factory/footer +++ b/templates/factory/footer @@ -1,3 +1,3 @@ - + diff --git a/templates/factory/frontpage b/templates/factory/frontpage index 407fc6e..2677c26 100644 --- a/templates/factory/frontpage +++ b/templates/factory/frontpage @@ -9,17 +9,19 @@ It shows a list of all tables it is allowed to display. #%] [% INCLUDE header %] -

+
[% config.application_name || "A poorly configured Maypole application" %] -

- + +
+
    [% FOR table = config.display_tables %] -
- - +
  • + List by [%table %] +
  • [% END %] -
    - List by [%table %] -
    -
    + + + +[% INCLUDE maypole %] + [% INCLUDE footer %] diff --git a/templates/factory/header b/templates/factory/header index 148cc94..a7bc348 100644 --- a/templates/factory/header +++ b/templates/factory/header @@ -4,7 +4,7 @@ [% - config.application_name || + title || config.application_name || "A poorly configured Maypole application" %] diff --git a/templates/factory/list b/templates/factory/list index a8fd016..beade40 100644 --- a/templates/factory/list +++ b/templates/factory/list @@ -1,12 +1,7 @@ [% PROCESS macros %] [% INCLUDE header %] -[% IF search %] -

    Search results

    -[% ELSE %] -

    Listing of all [% classmetadata.plural %]

    -[% END %] +[% INCLUDE title %] [% INCLUDE navbar %] -[% INCLUDE search_form %]
    @@ -29,7 +24,7 @@ END; ""; END %] - + [% SET count = 0; FOR item = objects; @@ -41,7 +36,9 @@ ""; END %]
    ActionsActions
    + [% INCLUDE pager %] [% INCLUDE addnew %] +[% INCLUDE search_form %]
    [% INCLUDE footer %] diff --git a/templates/factory/macros b/templates/factory/macros index 234b8f9..d4c0e5d 100644 --- a/templates/factory/macros +++ b/templates/factory/macros @@ -66,7 +66,7 @@ for some. END; ""; END; - ""; + ""; button(item, "edit"); button(item, "delete"); ""; @@ -99,7 +99,7 @@ brewery) calls the accesor, and displays a list of the results. [% MACRO view_related(object) BLOCK; FOR accessor = classmetadata.related_accessors.list; - "

    "; accessor | ucfirst; "

    \n"; + "
    "; accessor | ucfirst; "
    \n"; "
      "; FOR thing = object.$accessor; "
    • "; maybe_link_view(thing); "
    • \n"; diff --git a/templates/factory/maypole b/templates/factory/maypole new file mode 100644 index 0000000..7ab2744 --- /dev/null +++ b/templates/factory/maypole @@ -0,0 +1,7 @@ + +
       
      +
       
      +
       
      +
       
      +
       
      + diff --git a/templates/factory/search_form b/templates/factory/search_form index 1e90dbf..1f07194 100644 --- a/templates/factory/search_form +++ b/templates/factory/search_form @@ -1,5 +1,6 @@ + diff --git a/templates/factory/title b/templates/factory/title new file mode 100644 index 0000000..052ecf5 --- /dev/null +++ b/templates/factory/title @@ -0,0 +1,7 @@ + [% config.application_name %] +[% IF search %] +
      Search results
      +[% ELSE %] +
      Listing of all [% classmetadata.plural %]
      +[% END %] + diff --git a/templates/factory/view b/templates/factory/view index cf7822e..19117b5 100644 --- a/templates/factory/view +++ b/templates/factory/view @@ -12,7 +12,7 @@ C and displays the object's properties in a table. [% INCLUDE header %] [% FOR item = objects %] [% SET string = item.stringify_column %] -

      [% item.$string %]

      +
      [% item.$string %]
      [% INCLUDE navbar %] @@ -65,6 +65,7 @@ a list of has-many accessors. Next it calls each of those accessors, and displays the results in a table. #%] +
      Back to listing [% view_related(item); %] [% diff --git a/templates/maypole.css b/templates/maypole.css index c6dba91..124130f 100644 --- a/templates/maypole.css +++ b/templates/maypole.css @@ -6,12 +6,31 @@ html { padding-top: 0px } body { + font-family: sans-serif; padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px; - background-color: #ffffea; + background-color: #fff; } +#frontpage_list { + position: absolute; + z-index: 5; + padding: 0px 100px 0px 0px; + margin:0 0.5%; + margin-bottom:1em; + margin-top: 1em; + background-color: #fff; +} + +#frontpage_list a:hover { + background-color: #d0d8e4; +} + +#frontpage_list ul { + list-style-type: square; +} + .content { padding: 12px; margin-top: 1px; @@ -24,23 +43,6 @@ body { border-left: 1px; border-right: 1px; } -h1 { - font-size: 30pt; - margin: 0px; - font-family: Optima, "Lucida Grande",Sans-serif; - text-align: center; - padding-bottom: 1em; -} -h2 { - padding-right: 0.25em; - padding-left: 0.25em; - font-size: 16pt; - padding-bottom: 0.5em; - margin: 0px; - padding-top: 0.1em; - font-family: Optima, "Lucida Grande",Sans-serif; - text-align: center; -} A { text-decoration: none; @@ -51,23 +53,121 @@ A:hover { color:#222 } +#title { + z-index: 6; + width: 100%; + height: 18px; + margin-top: 10px; + font-size: 90%; + border-bottom: 1px solid #ddf; + text-align: left; +} + +#subtitle { + postion: absolute; + z-index: 6; + padding: 10px; + margin-top: 2em; + height: 18px; + text-align: left; + background-color: #fff; +} + +input[type=text] { + height: 16px; + width: 136px; + font-family: sans-serif; + font-size: 11px; + color: #2E415A; + padding: 0px; + margin-bottom: 5px; +} + +input[type=submit] { + height: 18px; + width: 60px; + font-family: sans-serif; + font-size: 11px; + border: 1px outset; + background-color: #fff; + color: #2E415A; + padding: 0px 0px 2px 0px; + margin-bottom: 5px; +} + +textarea { + width: 136px; + font-family: sans-serif; + font-size: 11px; + color: #2E415A; + padding: 0px; + margin-bottom: 5px; +} + +select { + height: 16px; + width: 140px; + font-family: sans-serif; + font-size: 12px; + color: #202020; + padding: 0px; + margin-bottom: 5px; +} + +.deco1 { + font-size: 0px; + z-index:1; + border:0px; + border-style:solid; + border-color:#4d6d99; + background-color:#4d6d99; +} + +.deco2 { + z-index:2; + border:0px; + border-style:solid; + border-color:#627ea5; + background-color:#627ea5; +} + + +.deco3 { + z-index:3; + border:0px; + border-style:solid; + border-color:#7d95b5; + background-color:#7d95b5; +} + +.deco4 { + z-index:4; + border:0px; + border-style:solid; + border-color:#d0d8e4; + background-color:#d0d8e4; +} + + table { border: 0px solid; background-color: #ffffff; } #matrix th { - background-color: #DDE; - border: 1px solid; + background-color: #b5cadc; + border: 1px solid #778; font: bold 12px Verdana, sans-serif; } -#matrix tr.alternate { background-color:#EEF; } +#matrix tr.alternate { background-color:#e3eaf0; } +#matrix tr:hover { background-color: #b5cadc; } #matrix td { font: 12px Verdana, sans-serif; } #navlist { padding: 3px 0; margin-left: 0; + margin-top:3em; border-bottom: 1px solid #778; font: bold 12px Verdana, sans-serif; } @@ -83,7 +183,7 @@ table { margin-left: 3px; border: 1px solid #778; border-bottom: none; - background: #DDE; + background: #b5cadc; text-decoration: none; } @@ -92,26 +192,31 @@ table { #navlist li a:hover { color: #000; - background: #AAE; + background: #eef; + border-top: 4px solid #7d95b5; border-color: #227; } #navlist #active a { background: white; border-bottom: 1px solid white; + border-top: 4px solid; } td { font: 12px Verdana, sans-serif; } fieldset { + margin-top: 1em; padding: 1em; + background-color: #f3f6f8; font:80%/1 sans-serif; border:1px solid #8484ce; } legend { padding: 0.2em 0.5em; + background-color: #fff; border:1px solid #8484ce; font-size:90%; text-align:right; @@ -148,20 +253,49 @@ label .field { #vlist li a { display: block; padding: 0.25em 0.5em 0.25em 0.75em; - border-left: 1em solid #AAB; - background: #CCD; + border-left: 1em solid #7d95b5; + background: #d0d8e4; text-decoration: none; } + #vlist li a:hover { border-color: #227; } -.search {width: 25%;border:1px outset #000;float:right; background: #eef;} -.search legend {border:none;} + +.view .field { + background-color: #f3f6f8; + border-left: 1px solid #7695b5; + border-top: 1px solid #7695b5; + padding: 1px 10px 0px 2px; +} + +#addnew { + width: 50%; + float: left; +} + +#search { + width: 50%; + float:right; +} .error { color: #d00; } -.list { width: 70%; } .action { + border: 1px outset #7d95b5; style:block; } -.pager { text-align:center;} + +.action:hover { + text-decoration: none; + background-color: #7d95b5; +} + +.pager { + font:80%/1 sans-serif; + background-color: #f3f6f8; + padding: 2px; + border: 1px solid #8484ce; + text-align:center; +} + -- 2.39.5