From 77fb5cc34c9a87077dc65548f0d890b366e78c61 Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Wed, 15 Sep 2004 16:46:58 +0000 Subject: [PATCH] Templates should be valid XHTML now... git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@176 48953598-375a-da11-a14b-00016c27c3ee --- templates/factory/addnew | 25 ++++++------- templates/factory/edit | 31 ++++++++-------- templates/factory/footer | 5 ++- templates/factory/frontpage | 31 ++++++++++------ templates/factory/header | 46 +++++++++++++----------- templates/factory/list | 68 +++++++++++++++++------------------ templates/factory/macros | 27 +++++++------- templates/factory/navbar | 7 ++-- templates/factory/pager | 16 ++++++--- templates/factory/search_form | 43 +++++++++++----------- templates/factory/view | 67 +++++++++++++--------------------- 11 files changed, 179 insertions(+), 187 deletions(-) diff --git a/templates/factory/addnew b/templates/factory/addnew index cdf21a6..f56fcf4 100644 --- a/templates/factory/addnew +++ b/templates/factory/addnew @@ -10,16 +10,17 @@ table. =cut #%] -

Add a new [%classmetadata.moniker%]

-
- - - [% FOR col = classmetadata.columns; - NEXT IF col == "id"; - %] - - +

Add a new [% classmetadata.moniker %]

+ + +
[% classmetadata.colnames.$col; %] [% classmetadata.cgi.$col.as_HTML; %]
+ [% FOR col = classmetadata.columns %] + [% NEXT IF col == "id" %] + + + + [% END; %] -
[% classmetadata.colnames.$col %][% classmetadata.cgi.$col.as_HTML; %]
- -
+ + + diff --git a/templates/factory/edit b/templates/factory/edit index 69ca0d2..f1e0fbf 100644 --- a/templates/factory/edit +++ b/templates/factory/edit @@ -5,27 +5,24 @@ This is the edit page. It edits the passed-in object, by displaying a form similar to L but with the current values filled in. -#%] +=cut +#%] [% PROCESS macros %] [% INCLUDE header %] - [% FOR item = objects; %] -

Edit [% item.name %]

- -
-[% - FOR col = classmetadata.columns; - NEXT IF col == "id"; - "

"; - ""; classmetadata.colnames.$col; ""; - ": "; - item.to_field(col).as_HTML; - "

"; - IF errors.$col; - ""; errors.$col; ""; - END; +

Edit [% item.name %]

+ +[% FOR col = classmetadata.columns; + NEXT IF col == "id"; + "

"; + ""; classmetadata.colnames.$col; ""; + ": "; + item.to_field(col).as_HTML; + "

"; + IF errors.$col; + errors.$col; END; - ''; + ''; END %] [% INCLUDE footer %] diff --git a/templates/factory/footer b/templates/factory/footer index 599e978..2ab5c0d 100644 --- a/templates/factory/footer +++ b/templates/factory/footer @@ -1,3 +1,2 @@ - - - \ No newline at end of file + + diff --git a/templates/factory/frontpage b/templates/factory/frontpage index acee7a7..9cf3562 100644 --- a/templates/factory/frontpage +++ b/templates/factory/frontpage @@ -1,16 +1,25 @@ -[% INCLUDE header %] +[%# + +=head1 frontpage + +This is the frontpage for your Maypole application. +It shows a list of all tables it is allowed to display. -

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

+=cut - +#%] +[% INCLUDE header %] +

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

+
[% FOR table = config.display_tables %] - - - + + + [% END %] -
-List by [%table %] -
+ List by [%table %] +
- -
+ +
[% INCLUDE footer %] diff --git a/templates/factory/header b/templates/factory/header index 90274d4..7e16e26 100644 --- a/templates/factory/header +++ b/templates/factory/header @@ -1,20 +1,26 @@ - - - - [% config.application_name || "A poorly configured Maypole application" %] - - - - - - -
\ No newline at end of file + + + + + [% + config.application_name || + "A poorly configured Maypole application" + %] + + + + + + +
diff --git a/templates/factory/list b/templates/factory/list index 9f7fe0e..8cd0209 100644 --- a/templates/factory/list +++ b/templates/factory/list @@ -1,43 +1,39 @@ [% PROCESS macros %] - [% INCLUDE header %] - [% IF search %] -

Search results

+

Search results

[% ELSE %] -

Listing of all [% classmetadata.plural %]

+

Listing of all [% classmetadata.plural %]

[% END %] - [% INCLUDE navbar %] - - -
- - -[% FOR col = classmetadata.columns.list; - NEXT IF col == "id"; - ""; -END %] - - -[% SET count = 0; -FOR item = objects; - SET count = count + 1; - ""; - display_line(item); - ""; -END %] -
"; - SET additional = "?order=" _ col; - SET additional = additional _ "&page=" _ pager.current_page IF pager; - SET additional = additional _ "&o2=desc" - IF col == request.query.order and request.query.o2 != "desc"; - link(classmetadata.table, "list", additional, classmetadata.colnames.$col); - "
- -[% INCLUDE pager; %] -[% INCLUDE addnew; %] -
+ +
+ + + [% FOR col = classmetadata.columns.list; + NEXT IF col == "id"; + ""; + END %] + + [% SET count = 0; + FOR item = objects; + SET count = count + 1; + ""; + display_line(item); + ""; + END %] +
"; + SET additional = "?order=" _ col; + SET additional = additional _ "&page=" _ pager.current_page + IF pager; + SET additional = additional _ "&o2=desc" + IF col == request.query.order and request.query.o2 != "desc"; + link(classmetadata.table, "list", additional, + classmetadata.colnames.$col); + "
+[% INCLUDE pager %] +[% INCLUDE addnew %] +
[% INCLUDE footer %] diff --git a/templates/factory/macros b/templates/factory/macros index edae5c1..2442dd5 100644 --- a/templates/factory/macros +++ b/templates/factory/macros @@ -13,9 +13,9 @@ catenating the base URL, table, command, and any arguments. #%] [% MACRO link(table, command, additional, label) BLOCK; - ''; + ''; label; - ""; + ""; END; %] @@ -31,7 +31,6 @@ command for that object. Otherwise, it just displays the data. #%] [% - MACRO maybe_link_view(object) BLOCK; IF object.table; # It's an object, i.e. a has-a link(object.table, "view", object.id, object); @@ -53,7 +52,7 @@ for some. #%] [% MACRO display_line(item) BLOCK; - FOR col = classmetadata.columns; + FOR col = classmetadata.columns; NEXT IF col == "id"; ""; IF col == "url"; @@ -64,7 +63,7 @@ for some. maybe_link_view(item.$col); END; ""; - END; + END; button(item, "edit"); button(item, "delete"); END %] @@ -78,11 +77,11 @@ This is a generic button, which performs an action on an object. #%] [% MACRO button(obj, action) BLOCK; %] - - - - - + +
+ +
+ [% END %] [%# @@ -99,12 +98,12 @@ 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"; + "
    • "; maybe_link_view(thing); "
    • \n"; END; - "
    "; + "
"; END; END; diff --git a/templates/factory/navbar b/templates/factory/navbar index 40050d3..60a69a9 100644 --- a/templates/factory/navbar +++ b/templates/factory/navbar @@ -12,16 +12,13 @@ accessible, with a link to the list page for each one.
- diff --git a/templates/factory/pager b/templates/factory/pager index 5f10f59..c10fdee 100644 --- a/templates/factory/pager +++ b/templates/factory/pager @@ -10,8 +10,7 @@ to the L interface. [% IF pager AND pager.first_page != pager.last_page; %] - -

Pages: +

Pages: [% SET begin_page = pager.current_page - 10; IF begin_page < 1; @@ -25,11 +24,18 @@ IF pager AND pager.first_page != pager.last_page; IF num == pager.current_page; "["; num; "] "; ELSE; - SET args = "?page=" _ num; # Order? SET label = "[" _ num _ "]"; - link(classmetadata.table, "list", args, label); + SET args = "?page=" _ num; + SET action = "list"; + FOR col = classmetadata.columns.list; + IF request.query.$col; + SET args = args _ "&" _ col _ "=" _ request.query.$col; + SET action = "search"; + END; + END; + link(classmetadata.table, action, args, label); END; END; %] -

+

[% END %] diff --git a/templates/factory/search_form b/templates/factory/search_form index 63f867d..e5458f8 100644 --- a/templates/factory/search_form +++ b/templates/factory/search_form @@ -1,23 +1,24 @@ -

Search

-
- - - - [% FOR col = classmetadata.columns; - NEXT IF col == "id"; - %] - - + + [% END; %] +
[% classmetadata.colnames.$col; %] [% - SET element = classmetadata.cgi.$col; - IF element.tag == "select"; - USE element_maker = Class("HTML::Element"); - SET element = element.unshift_content( + + + + + [% FOR col = classmetadata.columns; + NEXT IF col == "id"; + %] + + + - [% END; %] -
[% classmetadata.colnames.$col; %] + [% SET element = classmetadata.cgi.$col; + IF element.tag == "select"; + USE element_maker = Class("HTML::Element"); + SET element = element.unshift_content( element_maker.new("option", value," ")); - END; - element.as_HTML; - %]
- - + END; + element.as_HTML; %] +
+ + diff --git a/templates/factory/view b/templates/factory/view index 29b817e..c00046c 100644 --- a/templates/factory/view +++ b/templates/factory/view @@ -10,21 +10,19 @@ C and displays the object's properties in a table. #%] [% PROCESS macros %] [% INCLUDE header %] - [% FOR item = objects %] -[% SET string = item.stringify_column %] -

[% item.$string %]

- -[% INCLUDE navbar %] - - - -[% - FOR col = classmetadata.columns.list; - NEXT IF col == "id" OR col == string; - NEXT UNLESS item.$col; -%] - + [% SET string = item.stringify_column %] +

[% item.$string %]

+ [% INCLUDE navbar %] +
[% classmetadata.colnames.$string %] [% item.$string %]
+ + + + + [% FOR col = classmetadata.columns.list; + NEXT IF col == "id" OR col == string; + NEXT UNLESS item.$col; + %] [%# =for doc @@ -33,24 +31,14 @@ It gets the displayable form of a column's name from the hash returned from the C method: #%] - - - - + + - -[% END; %] -
[% classmetadata.colnames.$string %][% item.$string %]
[% classmetadata.colnames.$col; %] [% - -#=cut - - IF col == "url"; # Possibly too much magic. - " "; item.url; ""; - ELSE; - -#=for doc - -#One interesting macro used in this template is C: - - maybe_link_view(item.$col); -%] - +
[% classmetadata.colnames.$col; %] + [% IF col == "url"; # Possibly too much magic. + " "; item.url; ""; + ELSE; + maybe_link_view(item.$col); + END; %] [%# This tests whether or not the returned value is an object, and if so, @@ -62,13 +50,10 @@ if there is no C method or other stringification method defined. =cut #%] - -[% END; %] -
- + + + [% END; %] + [%# =for doc @@ -82,11 +67,7 @@ displays the results in a table. #%] [% view_related(item); - -#=cut - button(item, "edit"); button(item, "delete"); %] [% END; %] - -- 2.39.5