mason/dhandler: Bring not-found handling into the dhandler.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 23 Feb 2014 17:30:26 +0000 (17:30 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 23 Feb 2014 17:31:09 +0000 (17:31 +0000)
This means we get the HTML skeleton correctly, and can kill the separate
`%not-found' component.

mason/%not-found [deleted file]
mason/dhandler

diff --git a/mason/%not-found b/mason/%not-found
deleted file mode 100644 (file)
index 9ba24d8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<%method title>Not found</%method>
-<h1>Not found</h1>
-Failed to find &lsquo;<code><% $what |h %></code>&rsquo;.
-% $m->abort(404);
-
-<%flags>
-inherit => ".html"
-</%flags>
-
-<%args>
-$what
-</%args>
index d7c1da5..59d5e3e 100755 (executable)
        $nrow => 4
 </%args>
 %#
-<%method title>Single hand</%method>
+<%method title>\
+% if ($fail) {
+Not found\
+% } else {
+Single hand\
+% }
+</%method>
+%#
+<%def .not-found>
+<h1>Not found</h1>
+Failed to find &lsquo;<code><% $what |h %></code>&rsquo;.
+% return 404;
+<%args>
+       $what
+</%args>
+</%def>
 %#
 <%once>
        use Deal;
 </%once>
 %#
+<%shared>
+       my $fail = ($m->dhandler_arg ne "");
+</%shared>
+%#
 <%init>
-       unless ($m->dhandler_arg eq "") {
-         $m->clear_buffer;
-         $m->comp("%not-found", what => $m->dhandler_arg);
-       }
+       return $m->comp(".not-found", what => $m->dhandler_arg)
+         if $fail;
 </%init>