=cut
#%]
-<h3>Add a new [%classmetadata.moniker%]</h3>
-<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.table%]/do_edit/">
- <INPUT TYPE="hidden" NAME="action" VALUE="create">
- <TABLE class="view">
- [% FOR col = classmetadata.columns;
- NEXT IF col == "id";
- %]
- <TR> <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
- <TD> [% classmetadata.cgi.$col.as_HTML; %] </TD> </TR>
+<h3>Add a new [% classmetadata.moniker %]</h3>
+<form method=post action="[% base %]/[% classmetadata.table %]/do_edit/">
+ <input type=hidden name=action value=create />
+ <table class=view>
+ [% FOR col = classmetadata.columns %]
+ [% NEXT IF col == "id" %]
+ <tr>
+ <td>[% classmetadata.colnames.$col %]</td>
+ <td>[% classmetadata.cgi.$col.as_HTML; %]</td>
+ </tr>
[% END; %]
- </TABLE>
- <INPUT TYPE="submit" NAME="create" VALUE="create">
-</FORM>
+ </table>
+ <input type=submit name=create value=create />
+</form>
This is the edit page. It edits the passed-in object, by displaying a
form similar to L<add_new> but with the current values filled in.
-#%]
+=cut
+#%]
[% PROCESS macros %]
[% INCLUDE header %]
-
[% FOR item = objects; %]
-<h2> Edit [% item.name %]</h2>
-
-<FORM ACTION="[% base %]/[% item.table %]/do_edit/[% item.id %]" METHOD="post">
-[%
- FOR col = classmetadata.columns;
- NEXT IF col == "id";
- "<P>";
- "<B>"; classmetadata.colnames.$col; "</B>";
- ": ";
- item.to_field(col).as_HTML;
- "</P>";
- IF errors.$col;
- "<FONT COLOR=\"#ff0000\">"; errors.$col; "</FONT>";
- END;
+<h2>Edit [% item.name %]</h2>
+<form action="[% base %]/[% item.table %]/do_edit/[% item.id %]" method=post>
+[% FOR col = classmetadata.columns;
+ NEXT IF col == "id";
+ "<p>";
+ "<b>"; classmetadata.colnames.$col; "</b>";
+ ": ";
+ item.to_field(col).as_HTML;
+ "</p>";
+ IF errors.$col;
+ errors.$col;
END;
- '<INPUT TYPE="submit" NAME="edit" VALUE="edit">';
+ '<input type=submit name=edit value=edit />';
END %]
[% INCLUDE footer %]
- </div>\r
-</body>\r
-</html>
\ No newline at end of file
+ </body>
+</html>
-[% INCLUDE header %]
+[%#
+
+=head1 frontpage
+
+This is the frontpage for your Maypole application.
+It shows a list of all tables it is allowed to display.
-<h2> [% config.application_name || "A poorly configured Maypole application" %] </h2>
+=cut
-<TABLE BORDER="0" ALIGN="center" WIDTH="70%">
+#%]
+[% INCLUDE header %]
+<h2>
+ [% config.application_name || "A poorly configured Maypole application" %]
+</h2>
+<table border=0 align=center width=70%>
[% FOR table = config.display_tables %]
-<TR>
-<TD>
-<A HREF="[%table%]/list">List by [%table %]</A>
-</TD>
-</TR>
+ <tr>
+ <td>
+ <a href="[%table%]/list">List by [%table %]</a>
+ </td>
+ </tr>
[% END %]
-</TABLE>
-
-<BR>
+</table>
+<br/>
[% INCLUDE footer %]
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
-<head>\r
- <title>[% config.application_name || "A poorly configured Maypole application" %]</title>\r
- <meta http-equiv="Content-Language" content="en" />\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
- <link title="Maypole Default" href="/maypole.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript">\r
-<!--\r
-function go() {\r
- box = document.forms[-1].navi;\r
- destination = box.options[box.selectedIndex].value;\r
- if (box.options[box.selectedIndex].class == 'redirect')\r
- location.href = destination;\r
-}\r
-// -->\r
-</script>\r
-</head>\r
-<body>\r
- <div class="content">
\ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>
+ [%
+ config.application_name ||
+ "A poorly configured Maypole application"
+ %]
+ </title>
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8" />
+ <link title=Maypole href=/maypole.css type=text/css rel=stylesheet />
+ <script language="javascript" type="text/javascript">
+ <!--
+ function go()
+ {
+ box = document.forms[-1].navi;
+ destination = box.options[box.selectedIndex].value;
+ if (box.options[box.selectedIndex].class == 'redirect')
+ location.href = destination;
+ }
+ // -->
+ </script>
+ </head>
+ <body>
+ <div class="content">
[% PROCESS macros %]
-
[% INCLUDE header %]
-
[% IF search %]
-<h2> Search results </h2>
+ <h2>Search results</h2>
[% ELSE %]
-<h2> Listing of all [% classmetadata.plural %]</h2>
+ <h2>Listing of all [% classmetadata.plural %]</h2>
[% END %]
-
[% INCLUDE navbar %]
-<DIV class="search"> [% INCLUDE search_form %] </DIV>
-
-<DIV class="list">
-<TABLE id="matrix" WIDTH="100%">
-<TR>
-[% FOR col = classmetadata.columns.list;
- NEXT IF col == "id";
- "<TH>";
- 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);
- "</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 pager; %]
-[% INCLUDE addnew; %]
-</DIV>
+<div class=search>[% INCLUDE search_form %]</div>
+<div class=list>
+ <table id=matrix width=100%>
+ <tr>
+ [% FOR col = classmetadata.columns.list;
+ NEXT IF col == "id";
+ "<th>";
+ 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);
+ "</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 pager %]
+[% INCLUDE addnew %]
+</div>
[% INCLUDE footer %]
#%]
[%
MACRO link(table, command, additional, label) BLOCK;
- '<A HREF="' _ base _ "/" _ table _ "/" _ command _ "/" _ additional _ '">';
+ '<a href="' _ base _ "/" _ table _ "/" _ command _ "/" _ additional _ '">';
label;
- "</A>";
+ "</a>";
END;
%]
#%]
[%
-
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);
#%]
[% MACRO display_line(item) BLOCK;
- FOR col = classmetadata.columns;
+ FOR col = classmetadata.columns;
NEXT IF col == "id";
"<td>";
IF col == "url";
maybe_link_view(item.$col);
END;
"</td>";
- END;
+ END;
button(item, "edit");
button(item, "delete");
END %]
#%]
[% MACRO button(obj, action) BLOCK; %]
-<TD>
-<FORM METHOD="post" ACTION="[%base%]/[%obj.table%]/[%action%]/[%obj.id%]">
- <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
-</FORM>
-</TD>
+<td>
+<form method=post action="[% base %]/[% obj.table %]/[% action %]/[% obj.id %]">
+ <input type=submit name=[% action %] value=[% action %] />
+</form>
+</td>
[% END %]
[%#
[%
MACRO view_related(object) BLOCK;
FOR accessor = classmetadata.related_accessors.list;
- "<H3>"; accessor | ucfirst; "</H3>\n";
- "<UL id=\"vlist\">";
+ "<h3>"; accessor | ucfirst; "</h3>\n";
+ "<ul id=\"vlist\">";
FOR thing = object.$accessor;
- "<LI>"; maybe_link_view(thing); "</LI>\n";
+ "<li>"; maybe_link_view(thing); "</li>\n";
END;
- "</UL>";
+ "</ul>";
END;
END;
<ul id="navlist">
[%
FOR table = config.display_tables;
- '<LI '; 'id="active"' IF table == classmetadata.table; '>';
-
+ '<li '; 'id="active"' IF table == classmetadata.table; '>';
# Hack
SET active = '" id="current' IF table == classmetadata.table;
-
link(table, "list", active, table);
SET active = "";
- '</LI>';
+ '</li>';
END;
%]
</ul>
</div>
-
[%
IF pager AND pager.first_page != pager.last_page;
%]
-
-<P ALIGN="center">Pages:
+<p align=center>Pages:
[%
SET begin_page = pager.current_page - 10;
IF begin_page < 1;
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;
%]
-</P>
+</p>
[% END %]
-
<h3>Search</h3>
-<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/search/">
- <INPUT TYPE="hidden" NAME="action" VALUE="create">
- <INPUT TYPE="hidden" NAME="class" VALUE="[%classmetadata.name%]">
- <TABLE class="view">
- [% FOR col = classmetadata.columns;
- NEXT IF col == "id";
- %]
- <TR> <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
- <TD> [%
- SET element = classmetadata.cgi.$col;
- IF element.tag == "select";
- USE element_maker = Class("HTML::Element");
- SET element = element.unshift_content(
+<form method=get action="[% base %]/[% classmetadata.moniker %]/search/">
+ <input type=hidden name=action value=create />
+ <input type=hidden name=class value=[% classmetadata.name %] />
+ <table class=view>
+ [% FOR col = classmetadata.columns;
+ NEXT IF col == "id";
+ %]
+ <tr>
+ <td class=field>[% classmetadata.colnames.$col; %]</td>
+ <td>
+ [% 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;
- %] </TD> </TR>
- [% END; %]
- </TABLE>
- <INPUT TYPE="submit" NAME="search" VALUE="search">
-</FORM>
+ END;
+ element.as_HTML; %]
+ </td>
+ </tr>
+ [% END; %]
+ </table>
+ <input type=submit name=search value=search>
+</form>
#%]
[% PROCESS macros %]
[% INCLUDE header %]
-
[% FOR item = objects %]
-[% SET string = item.stringify_column %]
-<h2> [% item.$string %]</h2>
-
-[% INCLUDE navbar %]
-
-<TABLE class="view">
- <TR><TD class="field">[% classmetadata.colnames.$string %]</TD><TD> [% item.$string %] </TD></TR>
-[%
- FOR col = classmetadata.columns.list;
- NEXT IF col == "id" OR col == string;
- NEXT UNLESS item.$col;
-%]
-
+ [% SET string = item.stringify_column %]
+ <h2> [% item.$string %]</h2>
+ [% INCLUDE navbar %]
+ <table class=view>
+ <tr>
+ <td class="field">[% classmetadata.colnames.$string %]</td>
+ <td>[% item.$string %]</td>
+ </tr>
+ [% FOR col = classmetadata.columns.list;
+ NEXT IF col == "id" OR col == string;
+ NEXT UNLESS item.$col;
+ %]
[%#
=for doc
from the C<column_names> method:
#%]
-
- <TR>
- <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
- <TD> [%
-
-#=cut
-
- IF col == "url"; # Possibly too much magic.
- "<A HREF="; item.url; "> "; item.url; "</A>";
- ELSE;
-
-#=for doc
-
-#One interesting macro used in this template is C<maybe_link_view>:
-
- maybe_link_view(item.$col);
-%]
-
+ <tr>
+ <td class=field>[% classmetadata.colnames.$col; %]</td>
+ <td>
+ [% IF col == "url"; # Possibly too much magic.
+ "<A HREF="; item.url; "> "; item.url; "</A>";
+ ELSE;
+ maybe_link_view(item.$col);
+ END; %]
[%#
This tests whether or not the returned value is an object, and if so,
=cut
#%]
-
-[% END; %]
- </TD>
-</TR>
-[% END; %]
-</TABLE>
-
+ </td>
+ </tr>
+ [% END; %]
+ </table>
[%#
=for doc
#%]
[%
view_related(item);
-
-#=cut
-
button(item, "edit");
button(item, "delete");
%]
[% END; %]
-