chiark / gitweb /
Make a licensing decision: it's all AGPLv3+.
[odin-cgi] / mason / common / autohandler
1 %# -*-html-*-
2 %#
3 %# Common Mason machinery for Odin web services
4 %#
5 %# (c) 2015 Mark Wooding
6 %#
7 %#----- Licensing notice ----------------------------------------------------
8 %#
9 %# This file is part of the `odin.gg' service, `odin-cgi'.
10 %#
11 %# `odin-cgi' is free software; you can redistribute it and/or modify
12 %# it under the terms of the GNU Affero General Public License as
13 %# published by the Free Software Foundation; either version 3 of the
14 %# License, or (at your option) any later version.
15 %#
16 %# `odin-cgi' is distributed in the hope that it will be useful,
17 %# but WITHOUT ANY WARRANTY; without even the implied warranty of
18 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 %# GNU Affero General Public License for more details.
20 %#
21 %# You should have received a copy of the GNU Affero General Public
22 %# License along with `odin-cgi'; if not, see
23 %# <http://www.gnu.org/licenses/>.
24 %#
25 <%perl>
26         Odin::set_mason_failproc $m;
27         Odin::cgi_who $r;
28         Odin::fetch_cookies $r;
29         $r->content_type("text/html; charset=utf8");
30         $m->call_next;
31 </%perl>
32 %#
33 <%method wrapper>\
34 % $r->header_out(Status => $status) if defined $status;
35 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
36           "http://www.w3c.org/TR/html4/strict.dtd">
37
38 <html>
39 <head>
40 <link rel="stylesheet" type="text/css" href="<% $Odin::STATIC %>odin.css">
41 <meta name="viewport" content="width=device-width" initial-scale=1.0>
42 <& SELF:header &>
43 <title>\
44 % defined $title ? $m->print($title) : $m->comp("SELF:title");
45 </title>
46 </head>
47 <body>
48
49 <% $m->content %>
50 <div class="footer">
51 (c) 2015&ndash;2017 Mark Wooding;
52 <a href=<% $Odin::SRCURL %>>Free software</a><br>
53 </div>
54 </body>
55 </html>
56 <%args>
57         $status => undef
58         $title => undef
59 </%args>
60 </%method>
61 %#
62 <%method title>(Untitled page)</%method>
63 <%method header></%method>
64 %#
65 <%method error>\
66 <&| SELF:wrapper, status => $status, title => $title // $m->content &>\
67 <h1>\
68 % if (defined $title) {
69 Error: <% $title  %>\
70 % } else {
71 Error\
72 % }
73 </h1>
74 <p><% $m->content %>
75 </&>
76 <%args>
77         $status => 500
78         $title => undef
79 </%args>
80 </%method>
81 %#
82 <%init>
83         Odin::update_now;
84 </%init>
85 %#
86 <%once>
87         use utf8;
88         use Odin;
89 </%once>