Blame


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