Mercurial > paster
comparison fragment-duration.c @ 51:07b6887d3557
pasterd: split into individual pages
While here add a similar mini.css theme as in imgup.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 21 Dec 2020 18:22:44 +0100 |
parents | |
children | fba88439ec0a |
comparison
equal
deleted
inserted
replaced
50:520f57836ff3 | 51:07b6887d3557 |
---|---|
1 /* | |
2 * fragment-duration.c -- duration renderer | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #include <sys/types.h> | |
20 #include <stdarg.h> | |
21 #include <stdint.h> | |
22 #include <assert.h> | |
23 | |
24 #include <kcgi.h> | |
25 | |
26 #include "fragment-duration.h" | |
27 #include "fragment.h" | |
28 #include "util.h" | |
29 | |
30 struct template { | |
31 struct kreq *req; | |
32 const char *value; | |
33 }; | |
34 | |
35 static const char *keywords[] = { | |
36 "duration" | |
37 }; | |
38 | |
39 static int | |
40 template(size_t keyword, void *arg) | |
41 { | |
42 struct template *t = arg; | |
43 | |
44 switch (keyword) { | |
45 case 0: | |
46 khttp_puts(t->req, t->value); | |
47 break; | |
48 default: | |
49 break; | |
50 } | |
51 | |
52 return 1; | |
53 } | |
54 | |
55 void | |
56 fragment_duration(struct kreq *r, const char *duration) | |
57 { | |
58 assert(r); | |
59 assert(duration); | |
60 | |
61 struct template data = { | |
62 .req = r, | |
63 .value = duration | |
64 }; | |
65 struct ktemplate kt = { | |
66 .key = keywords, | |
67 .keysz = NELEM(keywords), | |
68 .cb = template, | |
69 .arg = &data | |
70 }; | |
71 | |
72 fragment(r, &kt, "fragments/duration.html"); | |
73 } |