chiark / gitweb /
found
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 Sep 2012 20:12:26 +0000 (21:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 Sep 2012 20:12:26 +0000 (21:12 +0100)
mason/edit [new file with mode: 0755]
mason/txtable [new file with mode: 0644]

diff --git a/mason/edit b/mason/edit
new file mode 100755 (executable)
index 0000000..7869cc8
--- /dev/null
@@ -0,0 +1,42 @@
+<%init>
+use AwayMsg;
+db_connect();
+</%init>
+
+<%args>
+$create => undef
+</%args>
+
+<%perl>
+
+my $textid;
+
+if (defined $create) {
+} else {
+    foreach my $k (keys %ARGS) {
+       if ($k =~ m/^t(\d{0,7})$/) {
+           $textid= $1;
+           last;
+       }
+    }
+    die unless defined $textid;
+}
+
+my $sth = $dbh->prepare("SELECT * FROM texts WHERE textid=?");
+$sth->execute($textid);
+my $tx = $sth->fetchrow_hashref();#
+
+if (!$tx) { die "no such text $textid"; }
+
+</%perl>
+<html lang="en"><head>
+<title>Editing - <% $tx->{'desc'} |h %> - Email "out of office" setup</title>
+</head><body>
+<h1>Edit "<% $tx->{'desc'} |h %>"</h1>
+<form action="save" method="post">
+<&| txtable, tx => $tx, inputs => 1 &>
+<tr><td>TXTABLE CONTENT</td></tr>
+</&>
+
+<input type="submit" name="t<% $tx->{'textid'} %>"
+   value="Edit or configure this message">
diff --git a/mason/txtable b/mason/txtable
new file mode 100644 (file)
index 0000000..b2bdc72
--- /dev/null
@@ -0,0 +1,31 @@
+
+<%args>
+$tx
+$inputs => 0
+</%args>
+
+% my $ent = sub {
+%     my ($head,$name,$val,$style,$size,$input_xinfo) = @_;
+<tr><td><% $head %></td>
+<td>
+%     if ($inputs) {
+%         $size ||= 70;
+<input type="text" size="<% $size %>" name="<% $name %>" value="<% $val |h %>">
+<% $input_xinfo %>
+%     } else {
+%         if (defined $style) {
+<% "<$style>" %>
+%         }
+<% $val |h %>
+%         if (defined $style) {
+<% "</$style>" %>
+%         }
+%     }
+% };
+
+<table>
+% $ent->('Short name:', 'desc', $tx->{'desc'});
+<% $m->content %>
+% $ent->('Subject:', 'subject', $tx->{'subject'}, 'code');
+</table>
+<p>