Blob


1 {!
2 /*
3 * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
18 #include <sys/queue.h>
19 #include <sys/tree.h>
21 #include <netinet/in.h>
22 #include <arpa/inet.h>
24 #include <event.h>
25 #include <limits.h>
26 #include <stdint.h>
28 #include "galileo.h"
30 !}
32 {{ define tp_head(struct template *tp, const char *lang,
33 const char *stylesheet) }}
34 <!doctype html>
35 <html{{ if *lang != '\0' }}lang="{{ lang }}"{{ end }}>
36 <head>
37 <meta name="viewport" content="initial-scale=1" />
38 {{ if *stylesheet != '\0' }}
39 <link rel="stylesheet" href="{{ stylesheet|urlescape }}" />
40 {{ end }}
41 </head>
42 <body>
43 {{ end }}
45 {{ define tp_foot(struct template *tp) }}
46 {! struct client *clt = tp->tp_arg; !}
47 {! struct proxy_config *pc = clt->clt_pc; !}
48 {! const char *host = pc->proxy_name; !}
49 {! const char *path = clt->clt_path_info; !}
51 <footer>
52 <hr />
53 <dl>
54 <dt>Original URL:</dt>
55 <dd>
56 <a href="gemini://{{ host | urlescape }}{{ path | urlescape }}">
57 gemini://{{ host }}{{ path }}
58 </a>
59 </dd>
60 </dl>
61 </footer>
62 </body>
63 </html>
64 {{ end }}
66 {{ define tp_figure(struct template *tp, const char *url,
67 const char *label) }}
68 <figure>
69 <a href="{{ url | urlescape }}">
70 <img src="{{ url }}" />
71 </a>
72 <figcaption>
73 {{ label }}
74 </figcaption>
75 </figure>
76 {{ end }}