From 0ad4ba7aa71b7dda17f0b07ccc9d8f0ad3424b82 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 29 Jan 2004 17:03:35 +0000 Subject: [PATCH] Here are the templates! git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@18 48953598-375a-da11-a14b-00016c27c3ee --- templates/beer/addnew | 29 +++++++++++++++++++++ templates/custom/frontpage | 49 +++++++++++++++++++++++++++++++++++ templates/custom/header | 23 ++++++++++++++++ templates/factory/addnew | 13 ++++++++++ templates/factory/edit | 21 +++++++++++++++ templates/factory/frontpage | 37 ++++++++++++++++++++++++++ templates/factory/header | 5 ++++ templates/factory/list | 29 +++++++++++++++++++++ templates/factory/list_macros | 22 ++++++++++++++++ templates/factory/navbar | 16 ++++++++++++ templates/factory/view | 26 +++++++++++++++++++ 11 files changed, 270 insertions(+) create mode 100644 templates/beer/addnew create mode 100644 templates/custom/frontpage create mode 100644 templates/custom/header create mode 100644 templates/factory/addnew create mode 100644 templates/factory/edit create mode 100644 templates/factory/frontpage create mode 100644 templates/factory/header create mode 100644 templates/factory/list create mode 100644 templates/factory/list_macros create mode 100644 templates/factory/navbar create mode 100644 templates/factory/view diff --git a/templates/beer/addnew b/templates/beer/addnew new file mode 100644 index 0000000..c3d351c --- /dev/null +++ b/templates/beer/addnew @@ -0,0 +1,29 @@ +

Add a new [%classmetadata.moniker%]

+[% USE element_maker = Class("HTML::Element") %] +

+

+ + + [% FOR col = classmetadata.columns; + NEXT IF col == "id"; + "";classmetadata.colnames.$col;" : "; + SET element = classmetadata.cgi.$col; + IF col == "brewery"; + SET create_url = base _ "/brewery/edit"; + SET new_element = element_maker.new("option", + "class", "redirect", + "value", create_url).push_content("Create new brewery"); + SET child = element.content_list.first; + SET foo = element.attr("name", "navi"); + SET child = child.attr("selected", "selected"); + SET element = + element.unshift_content(element_maker.new("option", value," ")); + element.attr("onChange", "go()"); + SET element = element.unshift_content(new_element); + END; + element.as_HTML; + %] +
+ [% END; %] + +
diff --git a/templates/custom/frontpage b/templates/custom/frontpage new file mode 100644 index 0000000..f19217b --- /dev/null +++ b/templates/custom/frontpage @@ -0,0 +1,49 @@ +[% INCLUDE header %] + +

Main menu

+ + + + + + + + + + + + + + + + +
+

+ Administer users +

+
+

+ Administer +computers +

+
+

+ House blog +

+
+

+ Register +phone calls +

+
+

+Stream music +

+
+

+

+
+ +
+[% INCLUDE small_blog %] diff --git a/templates/custom/header b/templates/custom/header new file mode 100644 index 0000000..bbc32bd --- /dev/null +++ b/templates/custom/header @@ -0,0 +1,23 @@ + + + Beer Database + + + + + + + +
+ diff --git a/templates/factory/addnew b/templates/factory/addnew new file mode 100644 index 0000000..daacf9c --- /dev/null +++ b/templates/factory/addnew @@ -0,0 +1,13 @@ +

Add a new [%classmetadata.moniker%]

+
+ + + [% FOR col = classmetadata.columns; + NEXT IF col == "id"; + "";classmetadata.colnames.$col;" : "; + classmetadata.cgi.$col.as_HTML; + %] +
+ [% END; %] + +
diff --git a/templates/factory/edit b/templates/factory/edit new file mode 100644 index 0000000..11a2539 --- /dev/null +++ b/templates/factory/edit @@ -0,0 +1,21 @@ +[% PROCESS list_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; + END; + ''; +END %] diff --git a/templates/factory/frontpage b/templates/factory/frontpage new file mode 100644 index 0000000..3da9ea3 --- /dev/null +++ b/templates/factory/frontpage @@ -0,0 +1,37 @@ +[% INCLUDE header %] + +

Main menu

+ + + + + + + + + + + + +
+

+ Administer users +

+
+

+ Administer +computers +

+
+

+ House blog +

+
+

+ Register +phone calls +

+
+ +
+[% INCLUDE small_blog %] diff --git a/templates/factory/header b/templates/factory/header new file mode 100644 index 0000000..213c22b --- /dev/null +++ b/templates/factory/header @@ -0,0 +1,5 @@ + + + You want to put the title of your application here <TITLE> + </HEAD> + <BODY> diff --git a/templates/factory/list b/templates/factory/list new file mode 100644 index 0000000..69bb868 --- /dev/null +++ b/templates/factory/list @@ -0,0 +1,29 @@ +[% PROCESS list_macros %] + +[% INCLUDE header %] + +<h2> Listing of all [% classmetadata.plural %]</h2> + +[% INCLUDE navbar %] + +<TABLE id="matrix" WIDTH="100%"> +<TR> +[% FOR col = classmetadata.columns.list; + NEXT IF col == "id"; + "<TH>"; classmetadata.colnames.$col; "</TH>"; +END %] +</TR> + +[% SET count = 0; +FOR item = objects; + SET count = count + 1; + "<tr"; + ' class="alternate"' IF count % 2; + ">"; + display_line(item); + "</tr>"; +END %] +</TABLE> + + +[% INCLUDE addnew; %] diff --git a/templates/factory/list_macros b/templates/factory/list_macros new file mode 100644 index 0000000..0a88996 --- /dev/null +++ b/templates/factory/list_macros @@ -0,0 +1,22 @@ +[% MACRO display_line(item) BLOCK; + FOR col = classmetadata.columns; + NEXT IF col == "id"; + "<td>"; + "<A HREF='" _ base _ item.$col.moniker _ "/view/" _ + item.$col.id _"'>" IF item.$col.moniker; # it's an object + item.$col; + "</A>" IF item.$col.moniker; + "</td>"; + END; + button(item, "edit"); + button(item, "delete"); +END %] +[% MACRO button(obj, action) BLOCK; %] + +<TD> +<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/[%action%]/[%obj.id%]"> + <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]"> +</FORM> +</TD> +[% END %] + diff --git a/templates/factory/navbar b/templates/factory/navbar new file mode 100644 index 0000000..3e5c1c5 --- /dev/null +++ b/templates/factory/navbar @@ -0,0 +1,16 @@ +<div id="navcontainer"> +<ul id="navlist"> +[% + FOR table = config.display_tables; + '<LI '; 'id="active"' IF table == classmetadata.moniker; + '>'; + '<A HREF="'; + base; table; "/list/"; + '"'; + ' id="current"' IF table == classmetadata.moniker; + '> '; table; "</A>"; + END; +%] +</ul> +</div> + diff --git a/templates/factory/view b/templates/factory/view new file mode 100644 index 0000000..48dec99 --- /dev/null +++ b/templates/factory/view @@ -0,0 +1,26 @@ +[% MACRO button(obj, action) BLOCK; %] + +<TD> +<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/[%action%]/[%obj.id%]"> + <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]"> +</FORM> +</TD> +[% END %] + +[% INCLUDE header %] + +[% FOR item = objects %] +<h2> [% item.name %]</h2> + +[% FOR col = classmetadata.columns.list; + NEXT IF col == "id"; + "<P>"; + classmetadata.colnames.$col; ":"; + " "; item.$col;"</p>"; + END; + button(item, "edit"); + button(item, "delete"); + "</tr>"; +END; +%] + -- 2.39.5