Blame


1 e7e5fa49 2022-12-30 thomas {!
2 e7e5fa49 2022-12-30 thomas /*
3 e7e5fa49 2022-12-30 thomas * Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 e7e5fa49 2022-12-30 thomas * Copyright (c) 2016, 2019, 2020-2022 Tracey Emery <tracey@traceyemery.net>
5 e7e5fa49 2022-12-30 thomas *
6 e7e5fa49 2022-12-30 thomas * Permission to use, copy, modify, and distribute this software for any
7 e7e5fa49 2022-12-30 thomas * purpose with or without fee is hereby granted, provided that the above
8 e7e5fa49 2022-12-30 thomas * copyright notice and this permission notice appear in all copies.
9 e7e5fa49 2022-12-30 thomas *
10 e7e5fa49 2022-12-30 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 e7e5fa49 2022-12-30 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 e7e5fa49 2022-12-30 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 e7e5fa49 2022-12-30 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 e7e5fa49 2022-12-30 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 e7e5fa49 2022-12-30 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 e7e5fa49 2022-12-30 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 e7e5fa49 2022-12-30 thomas */
18 4fccd2fe 2023-03-08 thomas
19 4fccd2fe 2023-03-08 thomas #include "got_compat.h"
20 e7e5fa49 2022-12-30 thomas
21 e7e5fa49 2022-12-30 thomas #include <sys/types.h>
22 e7e5fa49 2022-12-30 thomas #include <sys/queue.h>
23 3c14c1f2 2023-01-06 thomas #include <sys/stat.h>
24 e7e5fa49 2022-12-30 thomas
25 d6795e9f 2022-12-30 thomas #include <ctype.h>
26 e7e5fa49 2022-12-30 thomas #include <event.h>
27 e7e5fa49 2022-12-30 thomas #include <stdint.h>
28 3c14c1f2 2023-01-06 thomas #include <stdio.h>
29 e7e5fa49 2022-12-30 thomas #include <stdlib.h>
30 e7e5fa49 2022-12-30 thomas #include <string.h>
31 e7e5fa49 2022-12-30 thomas #include <imsg.h>
32 e7e5fa49 2022-12-30 thomas
33 00abe30b 2023-01-14 thomas #include "got_error.h"
34 3c14c1f2 2023-01-06 thomas #include "got_object.h"
35 00abe30b 2023-01-14 thomas #include "got_reference.h"
36 e7e5fa49 2022-12-30 thomas
37 e7e5fa49 2022-12-30 thomas #include "gotwebd.h"
38 e7e5fa49 2022-12-30 thomas #include "tmpl.h"
39 e7e5fa49 2022-12-30 thomas
40 4cc0851e 2023-10-08 thomas enum gotweb_ref_tm {
41 4cc0851e 2023-10-08 thomas TM_DIFF,
42 4cc0851e 2023-10-08 thomas TM_LONG,
43 4cc0851e 2023-10-08 thomas };
44 4cc0851e 2023-10-08 thomas
45 6da1aa18 2023-12-01 thomas static int breadcumbs(struct template *);
46 4cc0851e 2023-10-08 thomas static int datetime(struct template *, time_t, int);
47 b82440e1 2023-01-06 thomas static int gotweb_render_blob_line(struct template *, const char *, size_t);
48 3c14c1f2 2023-01-06 thomas static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
49 1cd5d437 2023-01-15 thomas static int blame_line(struct template *, const char *, struct blame_line *,
50 1cd5d437 2023-01-15 thomas int, int);
51 20bab626 2023-02-03 thomas
52 20bab626 2023-02-03 thomas static inline int gotweb_render_more(struct template *, int);
53 b82440e1 2023-01-06 thomas
54 6e7d5e74 2023-12-08 thomas static inline int tree_listing(struct template *);
55 dccd05b4 2023-01-10 thomas static inline int diff_line(struct template *, char *);
56 617497a6 2023-01-09 thomas static inline int tag_item(struct template *, struct repo_tag *);
57 00abe30b 2023-01-14 thomas static inline int branch(struct template *, struct got_reflist_entry *);
58 d6795e9f 2022-12-30 thomas static inline int rss_tag_item(struct template *, struct repo_tag *);
59 d6795e9f 2022-12-30 thomas static inline int rss_author(struct template *, char *);
60 d6795e9f 2022-12-30 thomas
61 6da1aa18 2023-12-01 thomas static inline char *
62 6da1aa18 2023-12-01 thomas nextsep(char *s, char **t)
63 6da1aa18 2023-12-01 thomas {
64 6da1aa18 2023-12-01 thomas char *q;
65 6da1aa18 2023-12-01 thomas
66 6da1aa18 2023-12-01 thomas while (*s == '/')
67 6da1aa18 2023-12-01 thomas s++;
68 6da1aa18 2023-12-01 thomas *t = s;
69 6da1aa18 2023-12-01 thomas if (*s == '\0')
70 6da1aa18 2023-12-01 thomas return NULL;
71 6da1aa18 2023-12-01 thomas
72 6da1aa18 2023-12-01 thomas q = strchr(s, '/');
73 6da1aa18 2023-12-01 thomas if (q == NULL)
74 6da1aa18 2023-12-01 thomas q = strchr(s, '\0');
75 6da1aa18 2023-12-01 thomas return q;
76 6da1aa18 2023-12-01 thomas }
77 6da1aa18 2023-12-01 thomas
78 e7e5fa49 2022-12-30 thomas !}
79 4cc0851e 2023-10-08 thomas
80 4cc0851e 2023-10-08 thomas {{ define datetime(struct template *tp, time_t t, int fmt) }}
81 4cc0851e 2023-10-08 thomas {!
82 4cc0851e 2023-10-08 thomas struct tm tm;
83 4cc0851e 2023-10-08 thomas char rfc3339[64];
84 4cc0851e 2023-10-08 thomas char datebuf[64];
85 4cc0851e 2023-10-08 thomas
86 4cc0851e 2023-10-08 thomas if (gmtime_r(&t, &tm) == NULL)
87 4cc0851e 2023-10-08 thomas return -1;
88 4cc0851e 2023-10-08 thomas
89 4cc0851e 2023-10-08 thomas if (strftime(rfc3339, sizeof(rfc3339), "%FT%TZ", &tm) == 0)
90 4cc0851e 2023-10-08 thomas return -1;
91 4cc0851e 2023-10-08 thomas
92 4cc0851e 2023-10-08 thomas if (fmt != TM_DIFF && asctime_r(&tm, datebuf) == NULL)
93 4cc0851e 2023-10-08 thomas return -1;
94 4cc0851e 2023-10-08 thomas !}
95 4cc0851e 2023-10-08 thomas <time datetime="{{ rfc3339 }}">
96 4cc0851e 2023-10-08 thomas {{ if fmt == TM_DIFF }}
97 4cc0851e 2023-10-08 thomas {{ render gotweb_render_age(tp, t) }}
98 4cc0851e 2023-10-08 thomas {{ else }}
99 4cc0851e 2023-10-08 thomas {{ datebuf }} {{ " UTC" }}
100 4cc0851e 2023-10-08 thomas {{ end }}
101 4cc0851e 2023-10-08 thomas </time>
102 4cc0851e 2023-10-08 thomas {{ end }}
103 e7e5fa49 2022-12-30 thomas
104 6da1aa18 2023-12-01 thomas {{ define breadcumbs(struct template *tp) }}
105 6da1aa18 2023-12-01 thomas {!
106 6da1aa18 2023-12-01 thomas struct request *c = tp->tp_arg;
107 6da1aa18 2023-12-01 thomas struct querystring *qs = c->t->qs;
108 6da1aa18 2023-12-01 thomas struct gotweb_url url;
109 6da1aa18 2023-12-01 thomas const char *folder = qs->folder;
110 df7661fb 2023-12-03 thomas const char *action = "tree";
111 6da1aa18 2023-12-01 thomas char *t, *s = NULL, *dir = NULL;
112 6da1aa18 2023-12-01 thomas char ch;
113 6da1aa18 2023-12-01 thomas
114 6da1aa18 2023-12-01 thomas memset(&url, 0, sizeof(url));
115 6da1aa18 2023-12-01 thomas url.index_page = -1;
116 6da1aa18 2023-12-01 thomas url.action = TREE;
117 6da1aa18 2023-12-01 thomas url.path = qs->path;
118 6da1aa18 2023-12-01 thomas url.commit = qs->commit;
119 6da1aa18 2023-12-01 thomas
120 df7661fb 2023-12-03 thomas if (qs->action != TREE && qs->action != BLOB) {
121 df7661fb 2023-12-03 thomas action = gotweb_action_name(qs->action);
122 df7661fb 2023-12-03 thomas url.action = qs->action;
123 df7661fb 2023-12-03 thomas }
124 df7661fb 2023-12-03 thomas
125 6da1aa18 2023-12-01 thomas if (folder && *folder != '\0') {
126 6da1aa18 2023-12-01 thomas while (*folder == '/')
127 6da1aa18 2023-12-01 thomas folder++;
128 6da1aa18 2023-12-01 thomas dir = strdup(folder);
129 6da1aa18 2023-12-01 thomas if (dir == NULL)
130 6da1aa18 2023-12-01 thomas return (-1);
131 6da1aa18 2023-12-01 thomas s = dir;
132 6da1aa18 2023-12-01 thomas }
133 6da1aa18 2023-12-01 thomas !}
134 6da1aa18 2023-12-01 thomas {{ " / " }}
135 df7661fb 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &url) }}">{{ action }}</a>
136 6da1aa18 2023-12-01 thomas {{ " / " }}
137 6da1aa18 2023-12-01 thomas {{ if dir }}
138 6da1aa18 2023-12-01 thomas {{ while (s = nextsep(s, &t)) != NULL }}
139 6da1aa18 2023-12-01 thomas {!
140 6da1aa18 2023-12-01 thomas ch = *s;
141 6da1aa18 2023-12-01 thomas *s = '\0';
142 6da1aa18 2023-12-01 thomas url.folder = dir;
143 6da1aa18 2023-12-01 thomas !}
144 6da1aa18 2023-12-01 thomas
145 6da1aa18 2023-12-01 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
146 6da1aa18 2023-12-01 thomas {{ t }}
147 6da1aa18 2023-12-01 thomas </a>
148 6da1aa18 2023-12-01 thomas {{ " / " }}
149 6da1aa18 2023-12-01 thomas
150 6da1aa18 2023-12-01 thomas {! *s = ch; !}
151 6da1aa18 2023-12-01 thomas {{ end }}
152 6da1aa18 2023-12-01 thomas {{ end }}
153 6da1aa18 2023-12-01 thomas
154 6da1aa18 2023-12-01 thomas {{ if qs->file }}
155 6da1aa18 2023-12-01 thomas {{ qs->file }}
156 6da1aa18 2023-12-01 thomas {{ end}}
157 6da1aa18 2023-12-01 thomas
158 6da1aa18 2023-12-01 thomas {{ finally }}
159 6da1aa18 2023-12-01 thomas {! free(dir); !}
160 6da1aa18 2023-12-01 thomas {{ end }}
161 6da1aa18 2023-12-01 thomas
162 161663e7 2023-03-11 thomas {{ define gotweb_render_page(struct template *tp,
163 161663e7 2023-03-11 thomas int (*body)(struct template *)) }}
164 e7e5fa49 2022-12-30 thomas {!
165 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
166 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
167 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
168 e7e5fa49 2022-12-30 thomas struct gotweb_url u_path;
169 3191e256 2022-12-30 thomas const char *prfx = c->document_uri;
170 e7e5fa49 2022-12-30 thomas const char *css = srv->custom_css;
171 e7e5fa49 2022-12-30 thomas
172 e7e5fa49 2022-12-30 thomas memset(&u_path, 0, sizeof(u_path));
173 e7e5fa49 2022-12-30 thomas u_path.index_page = -1;
174 e7e5fa49 2022-12-30 thomas u_path.action = SUMMARY;
175 e7e5fa49 2022-12-30 thomas !}
176 e7e5fa49 2022-12-30 thomas <!doctype html>
177 e7e5fa49 2022-12-30 thomas <html>
178 e7e5fa49 2022-12-30 thomas <head>
179 e7e5fa49 2022-12-30 thomas <meta charset="utf-8" />
180 e7e5fa49 2022-12-30 thomas <title>{{ srv->site_name }}</title>
181 fdd79f2f 2023-09-12 thomas <meta name="viewport" content="initial-scale=1.0" />
182 e7e5fa49 2022-12-30 thomas <meta name="msapplication-TileColor" content="#da532c" />
183 e7e5fa49 2022-12-30 thomas <meta name="theme-color" content="#ffffff"/>
184 e7e5fa49 2022-12-30 thomas <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
185 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
186 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
187 e7e5fa49 2022-12-30 thomas <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
188 e7e5fa49 2022-12-30 thomas <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
189 e7e5fa49 2022-12-30 thomas <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
190 e7e5fa49 2022-12-30 thomas </head>
191 e7e5fa49 2022-12-30 thomas <body>
192 fdd79f2f 2023-09-12 thomas <header id="header">
193 fdd79f2f 2023-09-12 thomas <div id="got_link">
194 fdd79f2f 2023-09-12 thomas <a href="{{ srv->logo_url }}" target="_blank">
195 fdd79f2f 2023-09-12 thomas <img src="{{ prfx }}{{ srv->logo }}" />
196 fdd79f2f 2023-09-12 thomas </a>
197 e7e5fa49 2022-12-30 thomas </div>
198 fdd79f2f 2023-09-12 thomas </header>
199 fdd79f2f 2023-09-12 thomas <nav id="site_path">
200 fdd79f2f 2023-09-12 thomas <div id="site_link">
201 fdd79f2f 2023-09-12 thomas <a href="?index_page={{ printf "%d", qs->index_page }}">
202 fdd79f2f 2023-09-12 thomas {{ srv->site_link }}
203 fdd79f2f 2023-09-12 thomas </a>
204 fdd79f2f 2023-09-12 thomas {{ if qs->path }}
205 fdd79f2f 2023-09-12 thomas {! u_path.path = qs->path; !}
206 fdd79f2f 2023-09-12 thomas {{ " / " }}
207 fdd79f2f 2023-09-12 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
208 fdd79f2f 2023-09-12 thomas {{ qs->path }}
209 e7e5fa49 2022-12-30 thomas </a>
210 fdd79f2f 2023-09-12 thomas {{ end }}
211 df7661fb 2023-12-03 thomas {{ if qs->action == SUMMARY || qs->action == DIFF ||
212 df7661fb 2023-12-03 thomas qs->action == TAG || qs->action == TAGS }}
213 fdd79f2f 2023-09-12 thomas {{ " / " }}{{ gotweb_action_name(qs->action) }}
214 df7661fb 2023-12-03 thomas {{ else if qs->action != INDEX}}
215 df7661fb 2023-12-03 thomas {{ render breadcumbs(tp) }}
216 fdd79f2f 2023-09-12 thomas {{ end }}
217 e7e5fa49 2022-12-30 thomas </div>
218 fdd79f2f 2023-09-12 thomas </nav>
219 fdd79f2f 2023-09-12 thomas <main>
220 fdd79f2f 2023-09-12 thomas {{ render body(tp) }}
221 fdd79f2f 2023-09-12 thomas </main>
222 fdd79f2f 2023-09-12 thomas <footer id="site_owner_wrapper">
223 fdd79f2f 2023-09-12 thomas <p id="site_owner">
224 fdd79f2f 2023-09-12 thomas {{ if srv->show_site_owner }}
225 fdd79f2f 2023-09-12 thomas {{ srv->site_owner }}
226 fdd79f2f 2023-09-12 thomas {{ end }}
227 fdd79f2f 2023-09-12 thomas </p>
228 fdd79f2f 2023-09-12 thomas </footer>
229 e7e5fa49 2022-12-30 thomas </body>
230 e7e5fa49 2022-12-30 thomas </html>
231 164b5ddc 2023-03-11 thomas {{ end }}
232 164b5ddc 2023-03-11 thomas
233 164b5ddc 2023-03-11 thomas {{ define gotweb_render_error(struct template *tp) }}
234 164b5ddc 2023-03-11 thomas {!
235 164b5ddc 2023-03-11 thomas struct request *c = tp->tp_arg;
236 164b5ddc 2023-03-11 thomas struct transport *t = c->t;
237 164b5ddc 2023-03-11 thomas !}
238 164b5ddc 2023-03-11 thomas <div id="err_content">
239 164b5ddc 2023-03-11 thomas {{ if t->error }}
240 164b5ddc 2023-03-11 thomas {{ t->error->msg }}
241 164b5ddc 2023-03-11 thomas {{ else }}
242 164b5ddc 2023-03-11 thomas See daemon logs for details
243 164b5ddc 2023-03-11 thomas {{ end }}
244 164b5ddc 2023-03-11 thomas </div>
245 e7e5fa49 2022-12-30 thomas {{ end }}
246 e7e5fa49 2022-12-30 thomas
247 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
248 e7e5fa49 2022-12-30 thomas {!
249 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
250 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
251 e7e5fa49 2022-12-30 thomas !}
252 e7e5fa49 2022-12-30 thomas <div id="index_header">
253 fdd79f2f 2023-09-12 thomas <div class="index_project">
254 e7e5fa49 2022-12-30 thomas Project
255 e7e5fa49 2022-12-30 thomas </div>
256 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
257 fdd79f2f 2023-09-12 thomas <div class="index_project_description">
258 e7e5fa49 2022-12-30 thomas Description
259 e7e5fa49 2022-12-30 thomas </div>
260 e7e5fa49 2022-12-30 thomas {{ end }}
261 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
262 fdd79f2f 2023-09-12 thomas <div class="index_project_owner">
263 e7e5fa49 2022-12-30 thomas Owner
264 e7e5fa49 2022-12-30 thomas </div>
265 e7e5fa49 2022-12-30 thomas {{ end }}
266 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
267 fdd79f2f 2023-09-12 thomas <div class="index_project_age">
268 e7e5fa49 2022-12-30 thomas Last Change
269 e7e5fa49 2022-12-30 thomas </div>
270 e7e5fa49 2022-12-30 thomas {{ end }}
271 e7e5fa49 2022-12-30 thomas </div>
272 e7e5fa49 2022-12-30 thomas {{ end }}
273 e7e5fa49 2022-12-30 thomas
274 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
275 e7e5fa49 2022-12-30 thomas {!
276 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
277 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
278 e7e5fa49 2022-12-30 thomas struct gotweb_url summary = {
279 e7e5fa49 2022-12-30 thomas .action = SUMMARY,
280 e7e5fa49 2022-12-30 thomas .index_page = -1,
281 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
282 e7e5fa49 2022-12-30 thomas }, briefs = {
283 e7e5fa49 2022-12-30 thomas .action = BRIEFS,
284 e7e5fa49 2022-12-30 thomas .index_page = -1,
285 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
286 e7e5fa49 2022-12-30 thomas }, commits = {
287 e7e5fa49 2022-12-30 thomas .action = COMMITS,
288 e7e5fa49 2022-12-30 thomas .index_page = -1,
289 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
290 e7e5fa49 2022-12-30 thomas }, tags = {
291 e7e5fa49 2022-12-30 thomas .action = TAGS,
292 e7e5fa49 2022-12-30 thomas .index_page = -1,
293 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
294 e7e5fa49 2022-12-30 thomas }, tree = {
295 e7e5fa49 2022-12-30 thomas .action = TREE,
296 e7e5fa49 2022-12-30 thomas .index_page = -1,
297 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
298 d6795e9f 2022-12-30 thomas }, rss = {
299 d6795e9f 2022-12-30 thomas .action = RSS,
300 d6795e9f 2022-12-30 thomas .index_page = -1,
301 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
302 e7e5fa49 2022-12-30 thomas };
303 e7e5fa49 2022-12-30 thomas !}
304 e7e5fa49 2022-12-30 thomas <div class="index_wrapper">
305 e7e5fa49 2022-12-30 thomas <div class="index_project">
306 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
307 e7e5fa49 2022-12-30 thomas </div>
308 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
309 e7e5fa49 2022-12-30 thomas <div class="index_project_description">
310 e7e5fa49 2022-12-30 thomas {{ repo_dir->description }}
311 e7e5fa49 2022-12-30 thomas </div>
312 e7e5fa49 2022-12-30 thomas {{ end }}
313 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
314 e7e5fa49 2022-12-30 thomas <div class="index_project_owner">
315 e7e5fa49 2022-12-30 thomas {{ repo_dir->owner }}
316 e7e5fa49 2022-12-30 thomas </div>
317 e7e5fa49 2022-12-30 thomas {{ end }}
318 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
319 e7e5fa49 2022-12-30 thomas <div class="index_project_age">
320 4cc0851e 2023-10-08 thomas {{ render datetime(tp, repo_dir->age, TM_DIFF) }}
321 e7e5fa49 2022-12-30 thomas </div>
322 e7e5fa49 2022-12-30 thomas {{ end }}
323 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
324 e7e5fa49 2022-12-30 thomas <div class="navs">
325 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
326 e7e5fa49 2022-12-30 thomas {{ " | " }}
327 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
328 e7e5fa49 2022-12-30 thomas {{ " | " }}
329 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
330 e7e5fa49 2022-12-30 thomas {{ " | " }}
331 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
332 e7e5fa49 2022-12-30 thomas {{ " | " }}
333 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
334 d6795e9f 2022-12-30 thomas {{ " | " }}
335 d6795e9f 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
336 e7e5fa49 2022-12-30 thomas </div>
337 fdd79f2f 2023-09-12 thomas <hr />
338 e7e5fa49 2022-12-30 thomas </div>
339 e7e5fa49 2022-12-30 thomas </div>
340 e7e5fa49 2022-12-30 thomas {{ end }}
341 e7e5fa49 2022-12-30 thomas
342 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_briefs(struct template *tp) }}
343 e7e5fa49 2022-12-30 thomas {!
344 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
345 e7e5fa49 2022-12-30 thomas struct transport *t = c->t;
346 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
347 e7e5fa49 2022-12-30 thomas struct repo_commit *rc;
348 e7e5fa49 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
349 feaddee6 2023-12-03 thomas struct gotweb_url diff_url, patch_url, tree_url;
350 1154d0c0 2023-12-09 thomas char *tmp, *body;
351 e7e5fa49 2022-12-30 thomas
352 e7e5fa49 2022-12-30 thomas diff_url = (struct gotweb_url){
353 e7e5fa49 2022-12-30 thomas .action = DIFF,
354 feaddee6 2023-12-03 thomas .index_page = -1,
355 feaddee6 2023-12-03 thomas .path = repo_dir->name,
356 feaddee6 2023-12-03 thomas .headref = qs->headref,
357 feaddee6 2023-12-03 thomas };
358 feaddee6 2023-12-03 thomas patch_url = (struct gotweb_url){
359 feaddee6 2023-12-03 thomas .action = PATCH,
360 e7e5fa49 2022-12-30 thomas .index_page = -1,
361 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
362 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
363 e7e5fa49 2022-12-30 thomas };
364 e7e5fa49 2022-12-30 thomas tree_url = (struct gotweb_url){
365 e7e5fa49 2022-12-30 thomas .action = TREE,
366 e7e5fa49 2022-12-30 thomas .index_page = -1,
367 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
368 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
369 e7e5fa49 2022-12-30 thomas };
370 e7e5fa49 2022-12-30 thomas !}
371 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
372 fdd79f2f 2023-09-12 thomas <h2>Commit Briefs</h2>
373 fdd79f2f 2023-09-12 thomas </header>
374 e7e5fa49 2022-12-30 thomas <div id="briefs_content">
375 e7e5fa49 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
376 e7e5fa49 2022-12-30 thomas {!
377 e7e5fa49 2022-12-30 thomas diff_url.commit = rc->commit_id;
378 feaddee6 2023-12-03 thomas patch_url.commit = rc->commit_id;
379 e7e5fa49 2022-12-30 thomas tree_url.commit = rc->commit_id;
380 e7e5fa49 2022-12-30 thomas
381 64d39587 2023-01-14 thomas tmp = strchr(rc->committer, '<');
382 e7e5fa49 2022-12-30 thomas if (tmp)
383 e7e5fa49 2022-12-30 thomas *tmp = '\0';
384 e7e5fa49 2022-12-30 thomas
385 1154d0c0 2023-12-09 thomas body = strchr(rc->commit_msg, '\n');
386 1154d0c0 2023-12-09 thomas if (body) {
387 1154d0c0 2023-12-09 thomas *body++ = '\0';
388 1154d0c0 2023-12-09 thomas while (*body == '\n')
389 1154d0c0 2023-12-09 thomas body++;
390 1154d0c0 2023-12-09 thomas }
391 e7e5fa49 2022-12-30 thomas !}
392 fdd79f2f 2023-09-12 thomas <div class='brief'>
393 fdd79f2f 2023-09-12 thomas <p class='brief_meta'>
394 fdd79f2f 2023-09-12 thomas <span class='briefs_age'>
395 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rc->committer_time, TM_DIFF) }}
396 fdd79f2f 2023-09-12 thomas </span>
397 fdd79f2f 2023-09-12 thomas {{" "}}
398 fdd79f2f 2023-09-12 thomas <span class="briefs_author">
399 fdd79f2f 2023-09-12 thomas {{ rc->committer }}
400 fdd79f2f 2023-09-12 thomas </span>
401 fdd79f2f 2023-09-12 thomas </p>
402 1154d0c0 2023-12-09 thomas {{ if body && *body != '\0' }}
403 1154d0c0 2023-12-09 thomas <details class="briefs_log">
404 1154d0c0 2023-12-09 thomas <summary>
405 1154d0c0 2023-12-09 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
406 1154d0c0 2023-12-09 thomas {{ rc->commit_msg }}
407 1154d0c0 2023-12-09 thomas </a>
408 1154d0c0 2023-12-09 thomas {{ if rc->refs_str }}
409 1154d0c0 2023-12-09 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
410 1154d0c0 2023-12-09 thomas {{ end }}
411 1154d0c0 2023-12-09 thomas {{ " " }}
412 1154d0c0 2023-12-09 thomas <span class="briefs_toggle" aria-hidden="true">
413 1154d0c0 2023-12-09 thomas {{ " â‹…â‹…â‹… " }}
414 1154d0c0 2023-12-09 thomas </span>
415 1154d0c0 2023-12-09 thomas </summary>
416 1154d0c0 2023-12-09 thomas {{ "\n" }}
417 1154d0c0 2023-12-09 thomas <p>{{ body }}</p>
418 1154d0c0 2023-12-09 thomas </details>
419 1154d0c0 2023-12-09 thomas {{ else }}
420 1154d0c0 2023-12-09 thomas <p class="briefs_log">
421 1154d0c0 2023-12-09 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
422 1154d0c0 2023-12-09 thomas {{ rc->commit_msg }}
423 1154d0c0 2023-12-09 thomas </a>
424 1154d0c0 2023-12-09 thomas {{ if rc->refs_str }}
425 1154d0c0 2023-12-09 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
426 1154d0c0 2023-12-09 thomas {{ end }}
427 1154d0c0 2023-12-09 thomas </p>
428 1154d0c0 2023-12-09 thomas {{ end }}
429 e7e5fa49 2022-12-30 thomas </div>
430 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
431 e7e5fa49 2022-12-30 thomas <div class="navs">
432 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
433 e7e5fa49 2022-12-30 thomas {{ " | " }}
434 feaddee6 2023-12-03 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &patch_url) }}">patch</a>
435 feaddee6 2023-12-03 thomas {{ " | " }}
436 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
437 e7e5fa49 2022-12-30 thomas </div>
438 e7e5fa49 2022-12-30 thomas </div>
439 fdd79f2f 2023-09-12 thomas <hr />
440 e7e5fa49 2022-12-30 thomas {{ end }}
441 20bab626 2023-02-03 thomas {{ render gotweb_render_more(tp, BRIEFS) }}
442 2f4f0731 2022-12-30 thomas </div>
443 2f4f0731 2022-12-30 thomas {{ end }}
444 2f4f0731 2022-12-30 thomas
445 20bab626 2023-02-03 thomas {{ define gotweb_render_more(struct template *tp, int action) }}
446 20bab626 2023-02-03 thomas {!
447 20bab626 2023-02-03 thomas struct request *c = tp->tp_arg;
448 20bab626 2023-02-03 thomas struct transport *t = c->t;
449 20bab626 2023-02-03 thomas struct querystring *qs = t->qs;
450 20bab626 2023-02-03 thomas struct gotweb_url more = {
451 20bab626 2023-02-03 thomas .action = action,
452 20bab626 2023-02-03 thomas .index_page = -1,
453 20bab626 2023-02-03 thomas .path = qs->path,
454 20bab626 2023-02-03 thomas .commit = t->more_id,
455 20bab626 2023-02-03 thomas .headref = qs->headref,
456 882ee74d 2023-09-14 thomas .file = qs->file,
457 20bab626 2023-02-03 thomas };
458 978394e7 2023-12-08 thomas
459 978394e7 2023-12-08 thomas if (action == TAGS)
460 978394e7 2023-12-08 thomas more.commit = t->tags_more_id;
461 20bab626 2023-02-03 thomas !}
462 978394e7 2023-12-08 thomas {{ if more.commit }}
463 20bab626 2023-02-03 thomas <div id="np_wrapper">
464 20bab626 2023-02-03 thomas <div id="nav_more">
465 20bab626 2023-02-03 thomas <a href="{{ render gotweb_render_url(c, &more) }}">
466 bd6e9c73 2023-02-03 thomas More&nbsp;&darr;
467 20bab626 2023-02-03 thomas </a>
468 20bab626 2023-02-03 thomas </div>
469 20bab626 2023-02-03 thomas </div>
470 20bab626 2023-02-03 thomas {{ end }}
471 20bab626 2023-02-03 thomas {{ end }}
472 20bab626 2023-02-03 thomas
473 2f4f0731 2022-12-30 thomas {{ define gotweb_render_navs(struct template *tp) }}
474 2f4f0731 2022-12-30 thomas {!
475 2f4f0731 2022-12-30 thomas struct request *c = tp->tp_arg;
476 2f4f0731 2022-12-30 thomas struct gotweb_url prev, next;
477 2f4f0731 2022-12-30 thomas int have_prev, have_next;
478 2f4f0731 2022-12-30 thomas
479 978394e7 2023-12-08 thomas gotweb_index_navs(c, &prev, &have_prev, &next, &have_next);
480 2f4f0731 2022-12-30 thomas !}
481 2f4f0731 2022-12-30 thomas <div id="np_wrapper">
482 2f4f0731 2022-12-30 thomas <div id="nav_prev">
483 2f4f0731 2022-12-30 thomas {{ if have_prev }}
484 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &prev) }}">
485 2f4f0731 2022-12-30 thomas Previous
486 2f4f0731 2022-12-30 thomas </a>
487 2f4f0731 2022-12-30 thomas {{ end }}
488 2f4f0731 2022-12-30 thomas </div>
489 2f4f0731 2022-12-30 thomas <div id="nav_next">
490 2f4f0731 2022-12-30 thomas {{ if have_next }}
491 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &next) }}">
492 2f4f0731 2022-12-30 thomas Next
493 2f4f0731 2022-12-30 thomas </a>
494 2f4f0731 2022-12-30 thomas {{ end }}
495 2f4f0731 2022-12-30 thomas </div>
496 e7e5fa49 2022-12-30 thomas </div>
497 e7e5fa49 2022-12-30 thomas {{ end }}
498 7ade8b27 2022-12-30 thomas
499 7ade8b27 2022-12-30 thomas {{ define gotweb_render_commits(struct template *tp) }}
500 7ade8b27 2022-12-30 thomas {!
501 7ade8b27 2022-12-30 thomas struct request *c = tp->tp_arg;
502 7ade8b27 2022-12-30 thomas struct transport *t = c->t;
503 7ade8b27 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
504 7ade8b27 2022-12-30 thomas struct repo_commit *rc;
505 feaddee6 2023-12-03 thomas struct gotweb_url diff, patch, tree;
506 7ade8b27 2022-12-30 thomas
507 7ade8b27 2022-12-30 thomas diff = (struct gotweb_url){
508 7ade8b27 2022-12-30 thomas .action = DIFF,
509 7ade8b27 2022-12-30 thomas .index_page = -1,
510 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
511 7ade8b27 2022-12-30 thomas };
512 feaddee6 2023-12-03 thomas patch = (struct gotweb_url){
513 feaddee6 2023-12-03 thomas .action = PATCH,
514 feaddee6 2023-12-03 thomas .index_page = -1,
515 feaddee6 2023-12-03 thomas .path = repo_dir->name,
516 feaddee6 2023-12-03 thomas };
517 7ade8b27 2022-12-30 thomas tree = (struct gotweb_url){
518 7ade8b27 2022-12-30 thomas .action = TREE,
519 7ade8b27 2022-12-30 thomas .index_page = -1,
520 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
521 7ade8b27 2022-12-30 thomas };
522 7ade8b27 2022-12-30 thomas !}
523 fdd79f2f 2023-09-12 thomas <header class="subtitle">
524 fdd79f2f 2023-09-12 thomas <h2>Commits</h2>
525 fdd79f2f 2023-09-12 thomas </header>
526 7ade8b27 2022-12-30 thomas <div class="commits_content">
527 7ade8b27 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
528 7ade8b27 2022-12-30 thomas {!
529 7ade8b27 2022-12-30 thomas diff.commit = rc->commit_id;
530 feaddee6 2023-12-03 thomas patch.commit = rc->commit_id;
531 7ade8b27 2022-12-30 thomas tree.commit = rc->commit_id;
532 7ade8b27 2022-12-30 thomas !}
533 57cfad1e 2023-12-01 thomas <div class="page_header_wrapper">
534 57cfad1e 2023-12-01 thomas <dl>
535 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
536 fdd79f2f 2023-09-12 thomas <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
537 fdd79f2f 2023-09-12 thomas <dt>From:</dt>
538 fdd79f2f 2023-09-12 thomas <dd>{{ rc->author }}</dd>
539 54ffadaf 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
540 fdd79f2f 2023-09-12 thomas <dt>Via:</dt>
541 fdd79f2f 2023-09-12 thomas <dd>{{ rc->committer }}</dd>
542 54ffadaf 2023-01-14 thomas {{ end }}
543 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
544 fdd79f2f 2023-09-12 thomas <dd>
545 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rc->committer_time, TM_LONG) }}
546 fdd79f2f 2023-09-12 thomas </dd>
547 fdd79f2f 2023-09-12 thomas </dl>
548 7ade8b27 2022-12-30 thomas </div>
549 fdd79f2f 2023-09-12 thomas <hr />
550 bbf94fd6 2023-01-02 thomas <div class="commit">
551 bbf94fd6 2023-01-02 thomas {{ "\n" }}
552 bbf94fd6 2023-01-02 thomas {{ rc->commit_msg }}
553 bbf94fd6 2023-01-02 thomas </div>
554 7ade8b27 2022-12-30 thomas <div class="navs_wrapper">
555 7ade8b27 2022-12-30 thomas <div class="navs">
556 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
557 feaddee6 2023-12-03 thomas {{ " | " }}
558 feaddee6 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &patch) }}">patch</a>
559 7ade8b27 2022-12-30 thomas {{ " | " }}
560 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
561 7ade8b27 2022-12-30 thomas </div>
562 7ade8b27 2022-12-30 thomas </div>
563 fdd79f2f 2023-09-12 thomas <hr />
564 7ade8b27 2022-12-30 thomas {{ end }}
565 20bab626 2023-02-03 thomas {{ render gotweb_render_more(tp, COMMITS) }}
566 b82440e1 2023-01-06 thomas </div>
567 b82440e1 2023-01-06 thomas {{ end }}
568 b82440e1 2023-01-06 thomas
569 161663e7 2023-03-11 thomas {{ define gotweb_render_blob(struct template *tp) }}
570 b82440e1 2023-01-06 thomas {!
571 b82440e1 2023-01-06 thomas struct request *c = tp->tp_arg;
572 b82440e1 2023-01-06 thomas struct transport *t = c->t;
573 54f5c7d0 2023-12-01 thomas struct querystring *qs = t->qs;
574 161663e7 2023-03-11 thomas struct got_blob_object *blob = t->blob;
575 b82440e1 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
576 54f5c7d0 2023-12-01 thomas struct gotweb_url briefs_url, blame_url, raw_url;
577 54f5c7d0 2023-12-01 thomas
578 54f5c7d0 2023-12-01 thomas memset(&briefs_url, 0, sizeof(briefs_url));
579 54f5c7d0 2023-12-01 thomas briefs_url.index_page = -1,
580 54f5c7d0 2023-12-01 thomas briefs_url.action = BRIEFS,
581 54f5c7d0 2023-12-01 thomas briefs_url.path = qs->path,
582 54f5c7d0 2023-12-01 thomas briefs_url.commit = qs->commit,
583 54f5c7d0 2023-12-01 thomas briefs_url.folder = qs->folder,
584 54f5c7d0 2023-12-01 thomas briefs_url.file = qs->file,
585 54f5c7d0 2023-12-01 thomas
586 54f5c7d0 2023-12-01 thomas memcpy(&blame_url, &briefs_url, sizeof(blame_url));
587 54f5c7d0 2023-12-01 thomas blame_url.action = BLAME;
588 54f5c7d0 2023-12-01 thomas
589 54f5c7d0 2023-12-01 thomas memcpy(&raw_url, &briefs_url, sizeof(raw_url));
590 54f5c7d0 2023-12-01 thomas raw_url.action = BLOBRAW;
591 b82440e1 2023-01-06 thomas !}
592 fdd79f2f 2023-09-12 thomas <header class="subtitle">
593 fdd79f2f 2023-09-12 thomas <h2>Blob</h2>
594 fdd79f2f 2023-09-12 thomas </header>
595 b82440e1 2023-01-06 thomas <div id="blob_content">
596 57cfad1e 2023-12-01 thomas <div class="page_header_wrapper">
597 57cfad1e 2023-12-01 thomas <dl>
598 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
599 fdd79f2f 2023-09-12 thomas <dd>
600 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rc->committer_time, TM_LONG) }}
601 fdd79f2f 2023-09-12 thomas </dd>
602 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
603 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
604 54f5c7d0 2023-12-01 thomas <dt>Actions:</dt>
605 54f5c7d0 2023-12-01 thomas <dd>
606 54f5c7d0 2023-12-01 thomas <a href="{{ render gotweb_render_url(c, &briefs_url) }}">
607 54f5c7d0 2023-12-01 thomas History
608 54f5c7d0 2023-12-01 thomas </a>
609 54f5c7d0 2023-12-01 thomas {{" | "}}
610 54f5c7d0 2023-12-01 thomas <a href="{{ render gotweb_render_url(c, &blame_url) }}">
611 54f5c7d0 2023-12-01 thomas Blame
612 54f5c7d0 2023-12-01 thomas </a>
613 54f5c7d0 2023-12-01 thomas {{" | "}}
614 54f5c7d0 2023-12-01 thomas <a href="{{ render gotweb_render_url(c, &raw_url) }}">
615 54f5c7d0 2023-12-01 thomas Raw File
616 54f5c7d0 2023-12-01 thomas </a>
617 54f5c7d0 2023-12-01 thomas </dd>
618 fdd79f2f 2023-09-12 thomas </dl>
619 b82440e1 2023-01-06 thomas </div>
620 fdd79f2f 2023-09-12 thomas <hr />
621 b82440e1 2023-01-06 thomas <div id="blob">
622 b82440e1 2023-01-06 thomas <pre>
623 b82440e1 2023-01-06 thomas {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
624 b82440e1 2023-01-06 thomas </pre>
625 b82440e1 2023-01-06 thomas </div>
626 7ade8b27 2022-12-30 thomas </div>
627 d6795e9f 2022-12-30 thomas {{ end }}
628 d6795e9f 2022-12-30 thomas
629 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob_line(struct template *tp, const char *line,
630 b82440e1 2023-01-06 thomas size_t no) }}
631 b82440e1 2023-01-06 thomas {!
632 b82440e1 2023-01-06 thomas char lineno[16];
633 b82440e1 2023-01-06 thomas int r;
634 b82440e1 2023-01-06 thomas
635 b82440e1 2023-01-06 thomas r = snprintf(lineno, sizeof(lineno), "%zu", no);
636 b82440e1 2023-01-06 thomas if (r < 0 || (size_t)r >= sizeof(lineno))
637 b82440e1 2023-01-06 thomas return -1;
638 b82440e1 2023-01-06 thomas !}
639 b82440e1 2023-01-06 thomas <div class="blob_line" id="line{{ lineno }}">
640 fdd79f2f 2023-09-12 thomas <a href="#line{{ lineno }}">{{ lineno }}</a>
641 991e3353 2023-12-01 thomas {{" "}}
642 fdd79f2f 2023-09-12 thomas <span class="blob_code">{{ line }}</span>
643 3c14c1f2 2023-01-06 thomas </div>
644 3c14c1f2 2023-01-06 thomas {{ end }}
645 3c14c1f2 2023-01-06 thomas
646 6e7d5e74 2023-12-08 thomas {{ define tree_listing(struct template *tp) }}
647 3c14c1f2 2023-01-06 thomas {!
648 34875d49 2023-12-08 thomas const struct got_error *error;
649 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
650 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
651 6e7d5e74 2023-12-08 thomas struct querystring *qs = c->t->qs;
652 34875d49 2023-12-08 thomas struct gotweb_url url;
653 34875d49 2023-12-08 thomas char *readme = NULL;
654 34875d49 2023-12-08 thomas int binary;
655 34875d49 2023-12-08 thomas const uint8_t *buf;
656 34875d49 2023-12-08 thomas size_t len;
657 3c14c1f2 2023-01-06 thomas !}
658 fdd79f2f 2023-09-12 thomas <table id="tree">
659 34875d49 2023-12-08 thomas {{ render got_output_repo_tree(c, &readme, gotweb_render_tree_item) }}
660 fdd79f2f 2023-09-12 thomas </table>
661 34875d49 2023-12-08 thomas {{ if readme }}
662 34875d49 2023-12-08 thomas {!
663 34875d49 2023-12-08 thomas error = got_open_blob_for_output(&t->blob, &t->fd, &binary, c,
664 34875d49 2023-12-08 thomas qs->folder, readme, qs->commit);
665 34875d49 2023-12-08 thomas if (error) {
666 34875d49 2023-12-08 thomas free(readme);
667 34875d49 2023-12-08 thomas return (-1);
668 34875d49 2023-12-08 thomas }
669 34875d49 2023-12-08 thomas
670 34875d49 2023-12-08 thomas memset(&url, 0, sizeof(url));
671 34875d49 2023-12-08 thomas url.index_page = -1;
672 34875d49 2023-12-08 thomas url.action = BLOB;
673 34875d49 2023-12-08 thomas url.path = t->qs->path;
674 34875d49 2023-12-08 thomas url.file = readme;
675 34875d49 2023-12-08 thomas url.folder = t->qs->folder;
676 34875d49 2023-12-08 thomas url.commit = t->qs->commit;
677 34875d49 2023-12-08 thomas !}
678 34875d49 2023-12-08 thomas {{ if !binary }}
679 34875d49 2023-12-08 thomas <h2>
680 34875d49 2023-12-08 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
681 34875d49 2023-12-08 thomas {{ readme }}
682 34875d49 2023-12-08 thomas </a>
683 34875d49 2023-12-08 thomas </h2>
684 34875d49 2023-12-08 thomas <pre>
685 34875d49 2023-12-08 thomas {!
686 34875d49 2023-12-08 thomas for (;;) {
687 34875d49 2023-12-08 thomas error = got_object_blob_read_block(&len, t->blob);
688 34875d49 2023-12-08 thomas if (error) {
689 34875d49 2023-12-08 thomas free(readme);
690 34875d49 2023-12-08 thomas return (-1);
691 34875d49 2023-12-08 thomas }
692 34875d49 2023-12-08 thomas if (len == 0)
693 34875d49 2023-12-08 thomas break;
694 34875d49 2023-12-08 thomas buf = got_object_blob_get_read_buf(t->blob);
695 34875d49 2023-12-08 thomas if (tp_write_htmlescape(tp, buf, len) == -1) {
696 34875d49 2023-12-08 thomas free(readme);
697 34875d49 2023-12-08 thomas return (-1);
698 34875d49 2023-12-08 thomas }
699 34875d49 2023-12-08 thomas }
700 34875d49 2023-12-08 thomas !}
701 34875d49 2023-12-08 thomas </pre>
702 34875d49 2023-12-08 thomas {{ end }}
703 34875d49 2023-12-08 thomas {{ end }}
704 34875d49 2023-12-08 thomas {{ finally }}
705 6e7d5e74 2023-12-08 thomas {! free(readme); !}
706 6e7d5e74 2023-12-08 thomas {{ end }}
707 6e7d5e74 2023-12-08 thomas
708 6e7d5e74 2023-12-08 thomas {{ define gotweb_render_tree(struct template *tp) }}
709 6e7d5e74 2023-12-08 thomas {!
710 6e7d5e74 2023-12-08 thomas struct request *c = tp->tp_arg;
711 6e7d5e74 2023-12-08 thomas struct transport *t = c->t;
712 6e7d5e74 2023-12-08 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
713 6e7d5e74 2023-12-08 thomas !}
714 6e7d5e74 2023-12-08 thomas <header class='subtitle'>
715 6e7d5e74 2023-12-08 thomas <h2>Tree</h2>
716 6e7d5e74 2023-12-08 thomas </header>
717 6e7d5e74 2023-12-08 thomas <div id="tree_content">
718 6e7d5e74 2023-12-08 thomas <div class="page_header_wrapper">
719 6e7d5e74 2023-12-08 thomas <dl>
720 6e7d5e74 2023-12-08 thomas <dt>Tree:</dt>
721 6e7d5e74 2023-12-08 thomas <dd><code class="commit-id">{{ rc->tree_id }}</code></dd>
722 6e7d5e74 2023-12-08 thomas <dt>Date:</dt>
723 6e7d5e74 2023-12-08 thomas <dd>
724 6e7d5e74 2023-12-08 thomas {{ render datetime(tp, rc->committer_time, TM_LONG) }}
725 6e7d5e74 2023-12-08 thomas </dd>
726 6e7d5e74 2023-12-08 thomas <dt>Message:</dt>
727 6e7d5e74 2023-12-08 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
728 6e7d5e74 2023-12-08 thomas </dl>
729 6e7d5e74 2023-12-08 thomas </div>
730 6e7d5e74 2023-12-08 thomas <hr />
731 6e7d5e74 2023-12-08 thomas {{ render tree_listing(tp) }}
732 6e7d5e74 2023-12-08 thomas </div>
733 3c14c1f2 2023-01-06 thomas {{ end }}
734 3c14c1f2 2023-01-06 thomas
735 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree_item(struct template *tp,
736 3c14c1f2 2023-01-06 thomas struct got_tree_entry *te) }}
737 3c14c1f2 2023-01-06 thomas {!
738 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
739 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
740 3c14c1f2 2023-01-06 thomas struct querystring *qs = t->qs;
741 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
742 3c14c1f2 2023-01-06 thomas const char *modestr = "";
743 3c14c1f2 2023-01-06 thomas const char *name;
744 3c14c1f2 2023-01-06 thomas const char *folder;
745 3c14c1f2 2023-01-06 thomas char *dir = NULL;
746 3c14c1f2 2023-01-06 thomas mode_t mode;
747 3c14c1f2 2023-01-06 thomas struct gotweb_url url = {
748 3c14c1f2 2023-01-06 thomas .index_page = -1,
749 3c14c1f2 2023-01-06 thomas .commit = rc->commit_id,
750 3c14c1f2 2023-01-06 thomas .path = qs->path,
751 3c14c1f2 2023-01-06 thomas };
752 3c14c1f2 2023-01-06 thomas
753 3c14c1f2 2023-01-06 thomas name = got_tree_entry_get_name(te);
754 3c14c1f2 2023-01-06 thomas mode = got_tree_entry_get_mode(te);
755 3c14c1f2 2023-01-06 thomas
756 3c14c1f2 2023-01-06 thomas folder = qs->folder ? qs->folder : "";
757 3c14c1f2 2023-01-06 thomas if (S_ISDIR(mode)) {
758 3c14c1f2 2023-01-06 thomas if (asprintf(&dir, "%s/%s", folder, name) == -1)
759 3c14c1f2 2023-01-06 thomas return (-1);
760 3c14c1f2 2023-01-06 thomas
761 3c14c1f2 2023-01-06 thomas url.action = TREE;
762 3c14c1f2 2023-01-06 thomas url.folder = dir;
763 3c14c1f2 2023-01-06 thomas } else {
764 3c14c1f2 2023-01-06 thomas url.action = BLOB;
765 3c14c1f2 2023-01-06 thomas url.folder = folder;
766 3c14c1f2 2023-01-06 thomas url.file = name;
767 3c14c1f2 2023-01-06 thomas }
768 3c14c1f2 2023-01-06 thomas
769 3c14c1f2 2023-01-06 thomas if (got_object_tree_entry_is_submodule(te))
770 3c14c1f2 2023-01-06 thomas modestr = "$";
771 3c14c1f2 2023-01-06 thomas else if (S_ISLNK(mode))
772 3c14c1f2 2023-01-06 thomas modestr = "@";
773 3c14c1f2 2023-01-06 thomas else if (S_ISDIR(mode))
774 3c14c1f2 2023-01-06 thomas modestr = "/";
775 3c14c1f2 2023-01-06 thomas else if (mode & S_IXUSR)
776 3c14c1f2 2023-01-06 thomas modestr = "*";
777 3c14c1f2 2023-01-06 thomas !}
778 fdd79f2f 2023-09-12 thomas <tr class="tree_wrapper">
779 3c14c1f2 2023-01-06 thomas {{ if S_ISDIR(mode) }}
780 fdd79f2f 2023-09-12 thomas <td class="tree_line" colspan=2>
781 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
782 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
783 3c14c1f2 2023-01-06 thomas </a>
784 fdd79f2f 2023-09-12 thomas </td>
785 3c14c1f2 2023-01-06 thomas {{ else }}
786 fdd79f2f 2023-09-12 thomas <td class="tree_line">
787 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
788 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
789 3c14c1f2 2023-01-06 thomas </a>
790 fdd79f2f 2023-09-12 thomas </td>
791 fdd79f2f 2023-09-12 thomas <td class="tree_line_blank">
792 3c14c1f2 2023-01-06 thomas {! url.action = COMMITS; !}
793 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
794 3c14c1f2 2023-01-06 thomas commits
795 3c14c1f2 2023-01-06 thomas </a>
796 3c14c1f2 2023-01-06 thomas {{ " | " }}
797 3c14c1f2 2023-01-06 thomas {! url.action = BLAME; !}
798 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
799 3c14c1f2 2023-01-06 thomas blame
800 3c14c1f2 2023-01-06 thomas </a>
801 fdd79f2f 2023-09-12 thomas </td>
802 3c14c1f2 2023-01-06 thomas {{ end }}
803 fdd79f2f 2023-09-12 thomas </tr>
804 3c14c1f2 2023-01-06 thomas {{ finally }}
805 3c14c1f2 2023-01-06 thomas {!
806 3c14c1f2 2023-01-06 thomas free(dir);
807 617497a6 2023-01-09 thomas !}
808 617497a6 2023-01-09 thomas {{ end }}
809 617497a6 2023-01-09 thomas
810 b3ba36c3 2023-01-14 thomas {{ define gotweb_render_tags(struct template *tp) }}
811 617497a6 2023-01-09 thomas {!
812 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
813 617497a6 2023-01-09 thomas struct transport *t = c->t;
814 617497a6 2023-01-09 thomas struct querystring *qs = t->qs;
815 617497a6 2023-01-09 thomas struct repo_tag *rt;
816 617497a6 2023-01-09 thomas int commit_found;
817 617497a6 2023-01-09 thomas
818 617497a6 2023-01-09 thomas commit_found = qs->commit == NULL;
819 3c14c1f2 2023-01-06 thomas !}
820 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
821 fdd79f2f 2023-09-12 thomas <h2>Tags</h2>
822 fdd79f2f 2023-09-12 thomas </header>
823 617497a6 2023-01-09 thomas <div id="tags_content">
824 617497a6 2023-01-09 thomas {{ if t->tag_count == 0 }}
825 617497a6 2023-01-09 thomas <div id="err_content">
826 617497a6 2023-01-09 thomas This repository contains no tags
827 617497a6 2023-01-09 thomas </div>
828 617497a6 2023-01-09 thomas {{ else }}
829 617497a6 2023-01-09 thomas {{ tailq-foreach rt &t->repo_tags entry }}
830 617497a6 2023-01-09 thomas {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
831 617497a6 2023-01-09 thomas {! commit_found = 1; !}
832 617497a6 2023-01-09 thomas {{ render tag_item(tp, rt) }}
833 617497a6 2023-01-09 thomas {{ end }}
834 617497a6 2023-01-09 thomas {{ end }}
835 978394e7 2023-12-08 thomas {{ render gotweb_render_more(tp, TAGS) }}
836 617497a6 2023-01-09 thomas {{ end }}
837 617497a6 2023-01-09 thomas </div>
838 b82440e1 2023-01-06 thomas {{ end }}
839 b82440e1 2023-01-06 thomas
840 617497a6 2023-01-09 thomas {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
841 617497a6 2023-01-09 thomas {!
842 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
843 617497a6 2023-01-09 thomas struct transport *t = c->t;
844 617497a6 2023-01-09 thomas struct repo_dir *repo_dir = t->repo_dir;
845 617497a6 2023-01-09 thomas char *tag_name = rt->tag_name;
846 617497a6 2023-01-09 thomas char *msg = rt->tag_commit;
847 617497a6 2023-01-09 thomas char *nl;
848 617497a6 2023-01-09 thomas struct gotweb_url url = {
849 617497a6 2023-01-09 thomas .action = TAG,
850 617497a6 2023-01-09 thomas .index_page = -1,
851 617497a6 2023-01-09 thomas .path = repo_dir->name,
852 617497a6 2023-01-09 thomas .commit = rt->commit_id,
853 617497a6 2023-01-09 thomas };
854 617497a6 2023-01-09 thomas
855 617497a6 2023-01-09 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
856 617497a6 2023-01-09 thomas tag_name += 10;
857 617497a6 2023-01-09 thomas
858 617497a6 2023-01-09 thomas if (msg) {
859 617497a6 2023-01-09 thomas nl = strchr(msg, '\n');
860 617497a6 2023-01-09 thomas if (nl)
861 617497a6 2023-01-09 thomas *nl = '\0';
862 617497a6 2023-01-09 thomas }
863 617497a6 2023-01-09 thomas !}
864 617497a6 2023-01-09 thomas <div class="tag_age">
865 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rt->tagger_time, TM_DIFF) }}
866 617497a6 2023-01-09 thomas </div>
867 fdd79f2f 2023-09-12 thomas <div class="tag_name">{{ tag_name }}</div>
868 617497a6 2023-01-09 thomas <div class="tag_log">
869 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
870 617497a6 2023-01-09 thomas {{ msg }}
871 617497a6 2023-01-09 thomas </a>
872 617497a6 2023-01-09 thomas </div>
873 617497a6 2023-01-09 thomas <div class="navs_wrapper">
874 617497a6 2023-01-09 thomas <div class="navs">
875 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
876 617497a6 2023-01-09 thomas {{ " | " }}
877 617497a6 2023-01-09 thomas {! url.action = BRIEFS; !}
878 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
879 617497a6 2023-01-09 thomas {{ " | " }}
880 617497a6 2023-01-09 thomas {! url.action = COMMITS; !}
881 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
882 617497a6 2023-01-09 thomas </div>
883 617497a6 2023-01-09 thomas </div>
884 fdd79f2f 2023-09-12 thomas <hr />
885 617497a6 2023-01-09 thomas {{ end }}
886 145ca42a 2023-01-09 thomas
887 145ca42a 2023-01-09 thomas {{ define gotweb_render_tag(struct template *tp) }}
888 145ca42a 2023-01-09 thomas {!
889 145ca42a 2023-01-09 thomas struct request *c = tp->tp_arg;
890 145ca42a 2023-01-09 thomas struct transport *t = c->t;
891 145ca42a 2023-01-09 thomas struct repo_tag *rt;
892 145ca42a 2023-01-09 thomas const char *tag_name;
893 617497a6 2023-01-09 thomas
894 145ca42a 2023-01-09 thomas rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
895 145ca42a 2023-01-09 thomas tag_name = rt->tag_name;
896 145ca42a 2023-01-09 thomas
897 145ca42a 2023-01-09 thomas if (strncmp(tag_name, "refs/", 5) == 0)
898 145ca42a 2023-01-09 thomas tag_name += 5;
899 145ca42a 2023-01-09 thomas !}
900 fdd79f2f 2023-09-12 thomas <header class="subtitle">
901 fdd79f2f 2023-09-12 thomas <h2>Tag</h2>
902 fdd79f2f 2023-09-12 thomas </header>
903 145ca42a 2023-01-09 thomas <div id="tags_content">
904 57cfad1e 2023-12-01 thomas <div class="page_header_wrapper">
905 57cfad1e 2023-12-01 thomas <dl>
906 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
907 fdd79f2f 2023-09-12 thomas <dd>
908 fdd79f2f 2023-09-12 thomas <code class="commit-id">{{ rt->commit_id }}</code>
909 145ca42a 2023-01-09 thomas {{ " " }}
910 145ca42a 2023-01-09 thomas <span class="refs_str">({{ tag_name }})</span>
911 fdd79f2f 2023-09-12 thomas </dd>
912 fdd79f2f 2023-09-12 thomas <dt>Tagger:</dt>
913 fdd79f2f 2023-09-12 thomas <dd>{{ rt->tagger }}</dd>
914 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
915 fdd79f2f 2023-09-12 thomas <dd>
916 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rt->tagger_time, TM_LONG)}}
917 fdd79f2f 2023-09-12 thomas </dd>
918 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
919 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rt->commit_msg }}</dd>
920 fdd79f2f 2023-09-12 thomas </dl>
921 fdd79f2f 2023-09-12 thomas <hr />
922 fdd79f2f 2023-09-12 thomas <pre id="tag_commit">
923 145ca42a 2023-01-09 thomas {{ rt->tag_commit }}
924 fdd79f2f 2023-09-12 thomas </pre>
925 dccd05b4 2023-01-10 thomas </div>
926 dccd05b4 2023-01-10 thomas </div>
927 dccd05b4 2023-01-10 thomas {{ end }}
928 dccd05b4 2023-01-10 thomas
929 161663e7 2023-03-11 thomas {{ define gotweb_render_diff(struct template *tp) }}
930 dccd05b4 2023-01-10 thomas {!
931 dccd05b4 2023-01-10 thomas struct request *c = tp->tp_arg;
932 dccd05b4 2023-01-10 thomas struct transport *t = c->t;
933 184e6e6f 2023-12-03 thomas struct querystring *qs = t->qs;
934 161663e7 2023-03-11 thomas FILE *fp = t->fp;
935 dccd05b4 2023-01-10 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
936 dccd05b4 2023-01-10 thomas char *line = NULL;
937 dccd05b4 2023-01-10 thomas size_t linesize = 0;
938 dccd05b4 2023-01-10 thomas ssize_t linelen;
939 184e6e6f 2023-12-03 thomas struct gotweb_url patch_url, tree_url = {
940 184e6e6f 2023-12-03 thomas .action = TREE,
941 184e6e6f 2023-12-03 thomas .index_page = -1,
942 184e6e6f 2023-12-03 thomas .path = qs->path,
943 184e6e6f 2023-12-03 thomas .commit = rc->commit_id,
944 184e6e6f 2023-12-03 thomas };
945 184e6e6f 2023-12-03 thomas
946 184e6e6f 2023-12-03 thomas memcpy(&patch_url, &tree_url, sizeof(patch_url));
947 184e6e6f 2023-12-03 thomas patch_url.action = PATCH;
948 dccd05b4 2023-01-10 thomas !}
949 fdd79f2f 2023-09-12 thomas <header class="subtitle">
950 fdd79f2f 2023-09-12 thomas <h2>Commit Diff</h2>
951 fdd79f2f 2023-09-12 thomas </header>
952 dccd05b4 2023-01-10 thomas <div id="diff_content">
953 57cfad1e 2023-12-01 thomas <div class="page_header_wrapper">
954 57cfad1e 2023-12-01 thomas <dl>
955 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
956 fdd79f2f 2023-09-12 thomas <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
957 fdd79f2f 2023-09-12 thomas <dt>From:</dt>
958 fdd79f2f 2023-09-12 thomas <dd>{{ rc->author }}</dd>
959 f7ee7604 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
960 fdd79f2f 2023-09-12 thomas <dt>Via:</dt>
961 fdd79f2f 2023-09-12 thomas <dd>{{ rc->committer }}</dd>
962 f7ee7604 2023-01-14 thomas {{ end }}
963 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
964 fdd79f2f 2023-09-12 thomas <dd>
965 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rc->committer_time, TM_LONG) }}
966 fdd79f2f 2023-09-12 thomas </dd>
967 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
968 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
969 184e6e6f 2023-12-03 thomas <dt>Actions:</dt>
970 184e6e6f 2023-12-03 thomas <dd>
971 184e6e6f 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &patch_url) }}">
972 184e6e6f 2023-12-03 thomas Patch
973 184e6e6f 2023-12-03 thomas </a>
974 184e6e6f 2023-12-03 thomas {{" | "}}
975 184e6e6f 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &tree_url) }}">
976 184e6e6f 2023-12-03 thomas Tree
977 184e6e6f 2023-12-03 thomas </a>
978 184e6e6f 2023-12-03 thomas </dd>
979 fdd79f2f 2023-09-12 thomas </dl>
980 145ca42a 2023-01-09 thomas </div>
981 fdd79f2f 2023-09-12 thomas <hr />
982 fdd79f2f 2023-09-12 thomas <pre id="diff">
983 dccd05b4 2023-01-10 thomas {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
984 dccd05b4 2023-01-10 thomas {{ render diff_line(tp, line) }}
985 dccd05b4 2023-01-10 thomas {{ end }}
986 fdd79f2f 2023-09-12 thomas </pre>
987 145ca42a 2023-01-09 thomas </div>
988 dccd05b4 2023-01-10 thomas {{ finally }}
989 dccd05b4 2023-01-10 thomas {! free(line); !}
990 145ca42a 2023-01-09 thomas {{ end }}
991 145ca42a 2023-01-09 thomas
992 dccd05b4 2023-01-10 thomas {{ define diff_line(struct template *tp, char *line )}}
993 dccd05b4 2023-01-10 thomas {!
994 dccd05b4 2023-01-10 thomas const char *color = NULL;
995 dccd05b4 2023-01-10 thomas char *nl;
996 dccd05b4 2023-01-10 thomas
997 dccd05b4 2023-01-10 thomas if (!strncmp(line, "-", 1))
998 dccd05b4 2023-01-10 thomas color = "diff_minus";
999 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "+", 1))
1000 dccd05b4 2023-01-10 thomas color = "diff_plus";
1001 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "@@", 2))
1002 dccd05b4 2023-01-10 thomas color = "diff_chunk_header";
1003 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "commit +", 8) ||
1004 dccd05b4 2023-01-10 thomas !strncmp(line, "commit -", 8) ||
1005 dccd05b4 2023-01-10 thomas !strncmp(line, "blob +", 6) ||
1006 dccd05b4 2023-01-10 thomas !strncmp(line, "blob -", 6) ||
1007 dccd05b4 2023-01-10 thomas !strncmp(line, "file +", 6) ||
1008 dccd05b4 2023-01-10 thomas !strncmp(line, "file -", 6))
1009 dccd05b4 2023-01-10 thomas color = "diff_meta";
1010 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
1011 dccd05b4 2023-01-10 thomas color = "diff_author";
1012 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "date:", 5))
1013 dccd05b4 2023-01-10 thomas color = "diff_date";
1014 dccd05b4 2023-01-10 thomas
1015 dccd05b4 2023-01-10 thomas nl = strchr(line, '\n');
1016 dccd05b4 2023-01-10 thomas if (nl)
1017 dccd05b4 2023-01-10 thomas *nl = '\0';
1018 dccd05b4 2023-01-10 thomas !}
1019 fdd79f2f 2023-09-12 thomas <span class="diff_line {{ color }}">{{ line }}</span>{{"\n"}}
1020 dccd05b4 2023-01-10 thomas {{ end }}
1021 dccd05b4 2023-01-10 thomas
1022 00abe30b 2023-01-14 thomas {{ define gotweb_render_branches(struct template *tp,
1023 00abe30b 2023-01-14 thomas struct got_reflist_head *refs) }}
1024 00abe30b 2023-01-14 thomas {!
1025 00abe30b 2023-01-14 thomas struct got_reflist_entry *re;
1026 00abe30b 2023-01-14 thomas !}
1027 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
1028 fdd79f2f 2023-09-12 thomas <h2>Branches</h2>
1029 fdd79f2f 2023-09-12 thomas </header>
1030 00abe30b 2023-01-14 thomas <div id="branches_content">
1031 00abe30b 2023-01-14 thomas {{ tailq-foreach re refs entry }}
1032 00abe30b 2023-01-14 thomas {{ if !got_ref_is_symbolic(re->ref) }}
1033 00abe30b 2023-01-14 thomas {{ render branch(tp, re) }}
1034 00abe30b 2023-01-14 thomas {{ end }}
1035 00abe30b 2023-01-14 thomas {{ end }}
1036 00abe30b 2023-01-14 thomas </div>
1037 00abe30b 2023-01-14 thomas {{ end }}
1038 00abe30b 2023-01-14 thomas
1039 00abe30b 2023-01-14 thomas {{ define branch(struct template *tp, struct got_reflist_entry *re) }}
1040 00abe30b 2023-01-14 thomas {!
1041 00abe30b 2023-01-14 thomas const struct got_error *err;
1042 00abe30b 2023-01-14 thomas struct request *c = tp->tp_arg;
1043 00abe30b 2023-01-14 thomas struct querystring *qs = c->t->qs;
1044 00abe30b 2023-01-14 thomas const char *refname;
1045 53bf32b8 2023-01-23 thomas time_t age;
1046 00abe30b 2023-01-14 thomas struct gotweb_url url = {
1047 00abe30b 2023-01-14 thomas .action = SUMMARY,
1048 00abe30b 2023-01-14 thomas .index_page = -1,
1049 00abe30b 2023-01-14 thomas .path = qs->path,
1050 00abe30b 2023-01-14 thomas };
1051 00abe30b 2023-01-14 thomas
1052 00abe30b 2023-01-14 thomas refname = got_ref_get_name(re->ref);
1053 00abe30b 2023-01-14 thomas
1054 53bf32b8 2023-01-23 thomas err = got_get_repo_age(&age, c, refname);
1055 00abe30b 2023-01-14 thomas if (err) {
1056 00abe30b 2023-01-14 thomas log_warnx("%s: %s", __func__, err->msg);
1057 00abe30b 2023-01-14 thomas return -1;
1058 00abe30b 2023-01-14 thomas }
1059 00abe30b 2023-01-14 thomas
1060 00abe30b 2023-01-14 thomas if (strncmp(refname, "refs/heads/", 11) == 0)
1061 00abe30b 2023-01-14 thomas refname += 11;
1062 00abe30b 2023-01-14 thomas
1063 00abe30b 2023-01-14 thomas url.headref = refname;
1064 00abe30b 2023-01-14 thomas !}
1065 fdd79f2f 2023-09-12 thomas <section class="branches_wrapper">
1066 53bf32b8 2023-01-23 thomas <div class="branches_age">
1067 4cc0851e 2023-10-08 thomas {{ render datetime(tp, age, TM_DIFF) }}
1068 53bf32b8 2023-01-23 thomas </div>
1069 00abe30b 2023-01-14 thomas <div class="branch">
1070 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
1071 00abe30b 2023-01-14 thomas </div>
1072 00abe30b 2023-01-14 thomas <div class="navs_wrapper">
1073 00abe30b 2023-01-14 thomas <div class="navs">
1074 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">summary</a>
1075 00abe30b 2023-01-14 thomas {{" | "}}
1076 00abe30b 2023-01-14 thomas {! url.action = BRIEFS; !}
1077 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
1078 00abe30b 2023-01-14 thomas {{" | "}}
1079 00abe30b 2023-01-14 thomas {! url.action = COMMITS; !}
1080 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
1081 00abe30b 2023-01-14 thomas </div>
1082 00abe30b 2023-01-14 thomas </div>
1083 fdd79f2f 2023-09-12 thomas <hr />
1084 fdd79f2f 2023-09-12 thomas </section>
1085 18e466eb 2023-01-14 thomas {{ end }}
1086 18e466eb 2023-01-14 thomas
1087 161663e7 2023-03-11 thomas {{ define gotweb_render_summary(struct template *tp) }}
1088 18e466eb 2023-01-14 thomas {!
1089 18e466eb 2023-01-14 thomas struct request *c = tp->tp_arg;
1090 18e466eb 2023-01-14 thomas struct server *srv = c->srv;
1091 18e466eb 2023-01-14 thomas struct transport *t = c->t;
1092 161663e7 2023-03-11 thomas struct got_reflist_head *refs = &t->refs;
1093 18e466eb 2023-01-14 thomas !}
1094 feaddee6 2023-12-03 thomas <dl id="summary_wrapper" class="page_header_wrapper">
1095 18e466eb 2023-01-14 thomas {{ if srv->show_repo_description }}
1096 fdd79f2f 2023-09-12 thomas <dt>Description:</dt>
1097 fdd79f2f 2023-09-12 thomas <dd>{{ t->repo_dir->description }}</dd>
1098 18e466eb 2023-01-14 thomas {{ end }}
1099 18e466eb 2023-01-14 thomas {{ if srv->show_repo_owner }}
1100 fdd79f2f 2023-09-12 thomas <dt>Owner:</dt>
1101 fdd79f2f 2023-09-12 thomas <dd>{{ t->repo_dir->owner }}</dd>
1102 18e466eb 2023-01-14 thomas {{ end }}
1103 18e466eb 2023-01-14 thomas {{ if srv->show_repo_age }}
1104 fdd79f2f 2023-09-12 thomas <dt>Last Change:</dt>
1105 fdd79f2f 2023-09-12 thomas <dd>
1106 4cc0851e 2023-10-08 thomas {{ render datetime(tp, t->repo_dir->age, TM_DIFF) }}
1107 fdd79f2f 2023-09-12 thomas </dd>
1108 18e466eb 2023-01-14 thomas {{ end }}
1109 18e466eb 2023-01-14 thomas {{ if srv->show_repo_cloneurl }}
1110 fdd79f2f 2023-09-12 thomas <dt>Clone URL:</dt>
1111 fdd79f2f 2023-09-12 thomas <dd><pre class="clone-url">{{ t->repo_dir->url }}</pre></dd>
1112 18e466eb 2023-01-14 thomas {{ end }}
1113 fdd79f2f 2023-09-12 thomas </dl>
1114 18e466eb 2023-01-14 thomas {{ render gotweb_render_briefs(tp) }}
1115 18e466eb 2023-01-14 thomas {{ render gotweb_render_branches(tp, refs) }}
1116 3b8c462a 2023-12-08 thomas {{ render gotweb_render_tags(tp) }}
1117 544364ac 2023-12-08 thomas <header class='subtitle'>
1118 544364ac 2023-12-08 thomas <h2>Tree</h2>
1119 544364ac 2023-12-08 thomas </header>
1120 544364ac 2023-12-08 thomas <div id="tree_content">
1121 6e7d5e74 2023-12-08 thomas {{ render tree_listing(tp) }}
1122 544364ac 2023-12-08 thomas </div>
1123 00abe30b 2023-01-14 thomas {{ end }}
1124 00abe30b 2023-01-14 thomas
1125 1cd5d437 2023-01-15 thomas {{ define gotweb_render_blame(struct template *tp) }}
1126 1cd5d437 2023-01-15 thomas {!
1127 1cd5d437 2023-01-15 thomas const struct got_error *err;
1128 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
1129 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
1130 4f4afeeb 2023-12-03 thomas struct querystring *qs = t->qs;
1131 1cd5d437 2023-01-15 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
1132 4f4afeeb 2023-12-03 thomas struct gotweb_url briefs_url, blob_url, raw_url;
1133 4f4afeeb 2023-12-03 thomas
1134 4f4afeeb 2023-12-03 thomas memset(&briefs_url, 0, sizeof(briefs_url));
1135 4f4afeeb 2023-12-03 thomas briefs_url.index_page = -1,
1136 4f4afeeb 2023-12-03 thomas briefs_url.action = BRIEFS,
1137 4f4afeeb 2023-12-03 thomas briefs_url.path = qs->path,
1138 4f4afeeb 2023-12-03 thomas briefs_url.commit = qs->commit,
1139 4f4afeeb 2023-12-03 thomas briefs_url.folder = qs->folder,
1140 4f4afeeb 2023-12-03 thomas briefs_url.file = qs->file,
1141 4f4afeeb 2023-12-03 thomas
1142 4f4afeeb 2023-12-03 thomas memcpy(&blob_url, &briefs_url, sizeof(blob_url));
1143 4f4afeeb 2023-12-03 thomas blob_url.action = BLOB;
1144 4f4afeeb 2023-12-03 thomas
1145 4f4afeeb 2023-12-03 thomas memcpy(&raw_url, &briefs_url, sizeof(raw_url));
1146 4f4afeeb 2023-12-03 thomas raw_url.action = BLOBRAW;
1147 1cd5d437 2023-01-15 thomas !}
1148 fdd79f2f 2023-09-12 thomas <header class="subtitle">
1149 fdd79f2f 2023-09-12 thomas <h2>Blame</h2>
1150 fdd79f2f 2023-09-12 thomas </header>
1151 1cd5d437 2023-01-15 thomas <div id="blame_content">
1152 57cfad1e 2023-12-01 thomas <div class="page_header_wrapper">
1153 57cfad1e 2023-12-01 thomas <dl>
1154 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
1155 fdd79f2f 2023-09-12 thomas <dd>
1156 4cc0851e 2023-10-08 thomas {{ render datetime(tp, rc->committer_time, TM_LONG) }}
1157 fdd79f2f 2023-09-12 thomas </dd>
1158 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
1159 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
1160 4f4afeeb 2023-12-03 thomas <dt>Actions:</dt>
1161 4f4afeeb 2023-12-03 thomas <dd>
1162 4f4afeeb 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &briefs_url) }}">
1163 4f4afeeb 2023-12-03 thomas History
1164 4f4afeeb 2023-12-03 thomas </a>
1165 4f4afeeb 2023-12-03 thomas {{" | "}}
1166 4f4afeeb 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &blob_url) }}">
1167 4f4afeeb 2023-12-03 thomas Blob
1168 4f4afeeb 2023-12-03 thomas </a>
1169 4f4afeeb 2023-12-03 thomas {{" | "}}
1170 4f4afeeb 2023-12-03 thomas <a href="{{ render gotweb_render_url(c, &raw_url) }}">
1171 4f4afeeb 2023-12-03 thomas Raw File
1172 4f4afeeb 2023-12-03 thomas </a>
1173 4f4afeeb 2023-12-03 thomas </dd>
1174 fdd79f2f 2023-09-12 thomas </dl>
1175 1cd5d437 2023-01-15 thomas </div>
1176 fdd79f2f 2023-09-12 thomas <hr />
1177 fdd79f2f 2023-09-12 thomas <pre id="blame">
1178 1cd5d437 2023-01-15 thomas {!
1179 1cd5d437 2023-01-15 thomas err = got_output_file_blame(c, &blame_line);
1180 aa2aecab 2023-05-25 thomas if (err && err->code != GOT_ERR_CANCELLED)
1181 1cd5d437 2023-01-15 thomas log_warnx("%s: got_output_file_blame: %s", __func__,
1182 1cd5d437 2023-01-15 thomas err->msg);
1183 aa2aecab 2023-05-25 thomas if (err)
1184 1cd5d437 2023-01-15 thomas return (-1);
1185 1cd5d437 2023-01-15 thomas !}
1186 fdd79f2f 2023-09-12 thomas </pre>
1187 1cd5d437 2023-01-15 thomas </div>
1188 1cd5d437 2023-01-15 thomas {{ end }}
1189 1cd5d437 2023-01-15 thomas
1190 1cd5d437 2023-01-15 thomas {{ define blame_line(struct template *tp, const char *line,
1191 1cd5d437 2023-01-15 thomas struct blame_line *bline, int lprec, int lcur) }}
1192 1cd5d437 2023-01-15 thomas {!
1193 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
1194 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
1195 1cd5d437 2023-01-15 thomas struct repo_dir *repo_dir = t->repo_dir;
1196 1cd5d437 2023-01-15 thomas char *committer, *s;
1197 1cd5d437 2023-01-15 thomas struct gotweb_url url = {
1198 1cd5d437 2023-01-15 thomas .action = DIFF,
1199 1cd5d437 2023-01-15 thomas .index_page = -1,
1200 1cd5d437 2023-01-15 thomas .path = repo_dir->name,
1201 1cd5d437 2023-01-15 thomas .commit = bline->id_str,
1202 1cd5d437 2023-01-15 thomas };
1203 1cd5d437 2023-01-15 thomas
1204 1cd5d437 2023-01-15 thomas s = strchr(bline->committer, '<');
1205 1cd5d437 2023-01-15 thomas committer = s ? s + 1 : bline->committer;
1206 1cd5d437 2023-01-15 thomas
1207 1cd5d437 2023-01-15 thomas s = strchr(committer, '@');
1208 1cd5d437 2023-01-15 thomas if (s)
1209 1cd5d437 2023-01-15 thomas *s = '\0';
1210 1cd5d437 2023-01-15 thomas !}
1211 83d26b5a 2023-12-03 thomas <div class="blame_line">
1212 83d26b5a 2023-12-03 thomas <span class="blame_number">{{ printf "%*d ", lprec, lcur }}</span>
1213 83d26b5a 2023-12-03 thomas <span class="blame_hash">
1214 1cd5d437 2023-01-15 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
1215 1cd5d437 2023-01-15 thomas {{ printf "%.8s", bline->id_str }}
1216 1cd5d437 2023-01-15 thomas </a>
1217 83d26b5a 2023-12-03 thomas </span>
1218 83d26b5a 2023-12-03 thomas {{" "}}
1219 83d26b5a 2023-12-03 thomas <span class="blame_date">{{ bline->datebuf }}</span>
1220 83d26b5a 2023-12-03 thomas {{" "}}
1221 83d26b5a 2023-12-03 thomas <span class="blame_author">{{ printf "%.9s", committer }}</span>
1222 83d26b5a 2023-12-03 thomas {{" "}}
1223 83d26b5a 2023-12-03 thomas <span class="blame_code">{{ line }}</span>
1224 1cd5d437 2023-01-15 thomas </div>
1225 feaddee6 2023-12-03 thomas {{ end }}
1226 feaddee6 2023-12-03 thomas
1227 feaddee6 2023-12-03 thomas {{ define gotweb_render_patch(struct template *tp) }}
1228 feaddee6 2023-12-03 thomas {!
1229 feaddee6 2023-12-03 thomas struct request *c = tp->tp_arg;
1230 feaddee6 2023-12-03 thomas struct transport *t = c->t;
1231 feaddee6 2023-12-03 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
1232 feaddee6 2023-12-03 thomas struct tm tm;
1233 feaddee6 2023-12-03 thomas char buf[BUFSIZ], datebuf[64];
1234 feaddee6 2023-12-03 thomas size_t r;
1235 feaddee6 2023-12-03 thomas
1236 feaddee6 2023-12-03 thomas if (gmtime_r(&rc->committer_time, &tm) == NULL ||
1237 feaddee6 2023-12-03 thomas strftime(datebuf, sizeof(datebuf), "%a %b %d %T %Y UTC", &tm) == 0)
1238 feaddee6 2023-12-03 thomas return (-1);
1239 feaddee6 2023-12-03 thomas !}
1240 feaddee6 2023-12-03 thomas commit {{ rc->commit_id }} {{ "\n" }}
1241 feaddee6 2023-12-03 thomas from: {{ rc->author | unsafe }} {{ "\n" }}
1242 feaddee6 2023-12-03 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
1243 feaddee6 2023-12-03 thomas via: {{ rc->committer | unsafe }} {{ "\n" }}
1244 1cd5d437 2023-01-15 thomas {{ end }}
1245 feaddee6 2023-12-03 thomas date: {{ datebuf }} {{ "\n" }}
1246 feaddee6 2023-12-03 thomas {{ "\n" }}
1247 feaddee6 2023-12-03 thomas {{ rc->commit_msg | unsafe }} {{ "\n" }}
1248 feaddee6 2023-12-03 thomas {!
1249 feaddee6 2023-12-03 thomas if (template_flush(tp) == -1)
1250 feaddee6 2023-12-03 thomas return (-1);
1251 feaddee6 2023-12-03 thomas for (;;) {
1252 feaddee6 2023-12-03 thomas r = fread(buf, 1, sizeof(buf), t->fp);
1253 feaddee6 2023-12-03 thomas if (fcgi_write(c, buf, r) == -1 ||
1254 feaddee6 2023-12-03 thomas r != sizeof(buf))
1255 feaddee6 2023-12-03 thomas break;
1256 feaddee6 2023-12-03 thomas }
1257 feaddee6 2023-12-03 thomas !}
1258 feaddee6 2023-12-03 thomas {{ end }}
1259 1cd5d437 2023-01-15 thomas
1260 d6795e9f 2022-12-30 thomas {{ define gotweb_render_rss(struct template *tp) }}
1261 d6795e9f 2022-12-30 thomas {!
1262 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
1263 d6795e9f 2022-12-30 thomas struct server *srv = c->srv;
1264 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
1265 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
1266 d6795e9f 2022-12-30 thomas struct repo_tag *rt;
1267 d6795e9f 2022-12-30 thomas struct gotweb_url summary = {
1268 d6795e9f 2022-12-30 thomas .action = SUMMARY,
1269 d6795e9f 2022-12-30 thomas .index_page = -1,
1270 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
1271 d6795e9f 2022-12-30 thomas };
1272 d6795e9f 2022-12-30 thomas !}
1273 d6795e9f 2022-12-30 thomas <?xml version="1.0" encoding="UTF-8"?>
1274 d6795e9f 2022-12-30 thomas <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
1275 d6795e9f 2022-12-30 thomas <channel>
1276 d6795e9f 2022-12-30 thomas <title>Tags of {{ repo_dir->name }}</title>
1277 d6795e9f 2022-12-30 thomas <link>
1278 d6795e9f 2022-12-30 thomas <![CDATA[
1279 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &summary) }}
1280 d6795e9f 2022-12-30 thomas ]]>
1281 d6795e9f 2022-12-30 thomas </link>
1282 d6795e9f 2022-12-30 thomas {{ if srv->show_repo_description }}
1283 d6795e9f 2022-12-30 thomas <description>{{ repo_dir->description }}</description>
1284 d6795e9f 2022-12-30 thomas {{ end }}
1285 d6795e9f 2022-12-30 thomas {{ tailq-foreach rt &t->repo_tags entry }}
1286 d6795e9f 2022-12-30 thomas {{ render rss_tag_item(tp, rt) }}
1287 d6795e9f 2022-12-30 thomas {{ end }}
1288 d6795e9f 2022-12-30 thomas </channel>
1289 d6795e9f 2022-12-30 thomas </rss>
1290 d6795e9f 2022-12-30 thomas {{ end }}
1291 d6795e9f 2022-12-30 thomas
1292 d6795e9f 2022-12-30 thomas {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
1293 d6795e9f 2022-12-30 thomas {!
1294 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
1295 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
1296 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
1297 10fa70e2 2023-10-08 thomas struct tm tm;
1298 10fa70e2 2023-10-08 thomas char rfc822[128];
1299 10fa70e2 2023-10-08 thomas int r;
1300 d6795e9f 2022-12-30 thomas char *tag_name = rt->tag_name;
1301 d6795e9f 2022-12-30 thomas struct gotweb_url tag = {
1302 d6795e9f 2022-12-30 thomas .action = TAG,
1303 d6795e9f 2022-12-30 thomas .index_page = -1,
1304 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
1305 d6795e9f 2022-12-30 thomas .commit = rt->commit_id,
1306 d6795e9f 2022-12-30 thomas };
1307 d6795e9f 2022-12-30 thomas
1308 d6795e9f 2022-12-30 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
1309 d6795e9f 2022-12-30 thomas tag_name += 10;
1310 10fa70e2 2023-10-08 thomas
1311 10fa70e2 2023-10-08 thomas if (gmtime_r(&rt->tagger_time, &tm) == NULL)
1312 10fa70e2 2023-10-08 thomas return -1;
1313 10fa70e2 2023-10-08 thomas r = strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S GMT", &tm);
1314 10fa70e2 2023-10-08 thomas if (r == 0)
1315 10fa70e2 2023-10-08 thomas return 0;
1316 d6795e9f 2022-12-30 thomas !}
1317 d6795e9f 2022-12-30 thomas <item>
1318 d6795e9f 2022-12-30 thomas <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
1319 d6795e9f 2022-12-30 thomas <link>
1320 d6795e9f 2022-12-30 thomas <![CDATA[
1321 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &tag) }}
1322 d6795e9f 2022-12-30 thomas ]]>
1323 d6795e9f 2022-12-30 thomas </link>
1324 d6795e9f 2022-12-30 thomas <description>
1325 d6795e9f 2022-12-30 thomas <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
1326 d6795e9f 2022-12-30 thomas </description>
1327 d6795e9f 2022-12-30 thomas {{ render rss_author(tp, rt->tagger) }}
1328 d6795e9f 2022-12-30 thomas <guid isPermaLink="false">{{ rt->commit_id }}</guid>
1329 d6795e9f 2022-12-30 thomas <pubDate>
1330 10fa70e2 2023-10-08 thomas {{ rfc822 }}
1331 d6795e9f 2022-12-30 thomas </pubDate>
1332 d6795e9f 2022-12-30 thomas </item>
1333 7ade8b27 2022-12-30 thomas {{ end }}
1334 d6795e9f 2022-12-30 thomas
1335 d6795e9f 2022-12-30 thomas {{ define rss_author(struct template *tp, char *author) }}
1336 d6795e9f 2022-12-30 thomas {!
1337 d6795e9f 2022-12-30 thomas char *t, *mail;
1338 d6795e9f 2022-12-30 thomas
1339 d6795e9f 2022-12-30 thomas /* what to do if the author name contains a paren? */
1340 d6795e9f 2022-12-30 thomas if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
1341 d6795e9f 2022-12-30 thomas return 0;
1342 d6795e9f 2022-12-30 thomas
1343 d6795e9f 2022-12-30 thomas t = strchr(author, '<');
1344 d6795e9f 2022-12-30 thomas if (t == NULL)
1345 d6795e9f 2022-12-30 thomas return 0;
1346 d6795e9f 2022-12-30 thomas *t = '\0';
1347 d6795e9f 2022-12-30 thomas mail = t+1;
1348 d6795e9f 2022-12-30 thomas
1349 d6795e9f 2022-12-30 thomas while (isspace((unsigned char)*--t))
1350 d6795e9f 2022-12-30 thomas *t = '\0';
1351 d6795e9f 2022-12-30 thomas
1352 d6795e9f 2022-12-30 thomas t = strchr(mail, '>');
1353 d6795e9f 2022-12-30 thomas if (t == NULL)
1354 d6795e9f 2022-12-30 thomas return 0;
1355 d6795e9f 2022-12-30 thomas *t = '\0';
1356 d6795e9f 2022-12-30 thomas !}
1357 d6795e9f 2022-12-30 thomas <author>
1358 d6795e9f 2022-12-30 thomas {{ mail }} {{" "}} ({{ author }})
1359 d6795e9f 2022-12-30 thomas </author>
1360 d6795e9f 2022-12-30 thomas {{ end }}