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>
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.
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.
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>
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>
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"
37 ed619ca0 2022-12-14 op #include "proc.h"
39 ed619ca0 2022-12-14 op #include "gotwebd.h"
40 ed619ca0 2022-12-14 op #include "tmpl.h"
42 7781b991 2023-10-05 op enum gotweb_ref_tm {
47 7781b991 2023-10-05 op static int datetime(struct template *, time_t, int);
48 298f95fb 2023-01-05 op static int gotweb_render_blob_line(struct template *, const char *, size_t);
49 43d421de 2023-01-05 op static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
50 8319855f 2023-01-15 op static int blame_line(struct template *, const char *, struct blame_line *,
53 e3662697 2023-02-03 op static inline int gotweb_render_more(struct template *, int);
55 587550a5 2023-01-10 op static inline int diff_line(struct template *, char *);
56 067396e6 2023-01-09 op static inline int tag_item(struct template *, struct repo_tag *);
57 3ab2c914 2023-01-11 op static inline int branch(struct template *, struct got_reflist_entry *);
58 1abb18e1 2022-12-20 op static inline int rss_tag_item(struct template *, struct repo_tag *);
59 1abb18e1 2022-12-20 op static inline int rss_author(struct template *, char *);
63 7781b991 2023-10-05 op {{ define datetime(struct template *tp, time_t t, int fmt) }}
66 7781b991 2023-10-05 op char rfc3339[64];
67 7781b991 2023-10-05 op char datebuf[64];
69 7781b991 2023-10-05 op if (gmtime_r(&t, &tm) == NULL)
72 7781b991 2023-10-05 op if (strftime(rfc3339, sizeof(rfc3339), "%FT%TZ", &tm) == 0)
75 7781b991 2023-10-05 op if (fmt != TM_DIFF && asctime_r(&tm, datebuf) == NULL)
78 7781b991 2023-10-05 op <time datetime="{{ rfc3339 }}">
79 7781b991 2023-10-05 op {{ if fmt == TM_DIFF }}
80 7781b991 2023-10-05 op {{ render gotweb_render_age(tp, t) }}
82 7781b991 2023-10-05 op {{ datebuf }} {{ " UTC" }}
87 df2d3cd2 2023-03-11 op {{ define gotweb_render_page(struct template *tp,
88 df2d3cd2 2023-03-11 op int (*body)(struct template *)) }}
90 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
91 ed619ca0 2022-12-14 op struct server *srv = c->srv;
92 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
93 ed619ca0 2022-12-14 op struct gotweb_url u_path;
94 d19d9fce 2022-12-20 op const char *prfx = c->document_uri;
95 ed619ca0 2022-12-14 op const char *css = srv->custom_css;
97 ed619ca0 2022-12-14 op memset(&u_path, 0, sizeof(u_path));
98 ed619ca0 2022-12-14 op u_path.index_page = -1;
99 ed619ca0 2022-12-14 op u_path.page = -1;
100 ed619ca0 2022-12-14 op u_path.action = SUMMARY;
102 ed619ca0 2022-12-14 op <!doctype html>
105 ed619ca0 2022-12-14 op <meta charset="utf-8" />
106 ed619ca0 2022-12-14 op <title>{{ srv->site_name }}</title>
107 424803ac 2023-09-12 op <meta name="viewport" content="initial-scale=1.0" />
108 ed619ca0 2022-12-14 op <meta name="msapplication-TileColor" content="#da532c" />
109 ed619ca0 2022-12-14 op <meta name="theme-color" content="#ffffff"/>
110 ed619ca0 2022-12-14 op <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
111 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
112 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
113 ed619ca0 2022-12-14 op <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
114 ed619ca0 2022-12-14 op <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
115 ed619ca0 2022-12-14 op <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
118 424803ac 2023-09-12 op <header id="header">
119 424803ac 2023-09-12 op <div id="got_link">
120 424803ac 2023-09-12 op <a href="{{ srv->logo_url }}" target="_blank">
121 424803ac 2023-09-12 op <img src="{{ prfx }}{{ srv->logo }}" />
125 424803ac 2023-09-12 op <nav id="site_path">
126 424803ac 2023-09-12 op <div id="site_link">
127 424803ac 2023-09-12 op <a href="?index_page={{ printf "%d", qs->index_page }}">
128 424803ac 2023-09-12 op {{ srv->site_link }}
130 424803ac 2023-09-12 op {{ if qs->path }}
131 424803ac 2023-09-12 op {! u_path.path = qs->path; !}
133 424803ac 2023-09-12 op <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
134 424803ac 2023-09-12 op {{ qs->path }}
137 424803ac 2023-09-12 op {{ if qs->action != INDEX }}
138 424803ac 2023-09-12 op {{ " / " }}{{ gotweb_action_name(qs->action) }}
143 424803ac 2023-09-12 op {{ render body(tp) }}
145 424803ac 2023-09-12 op <footer id="site_owner_wrapper">
146 424803ac 2023-09-12 op <p id="site_owner">
147 424803ac 2023-09-12 op {{ if srv->show_site_owner }}
148 424803ac 2023-09-12 op {{ srv->site_owner }}
156 8f37175d 2023-03-11 op {{ define gotweb_render_error(struct template *tp) }}
158 8f37175d 2023-03-11 op struct request *c = tp->tp_arg;
159 8f37175d 2023-03-11 op struct transport *t = c->t;
161 8f37175d 2023-03-11 op <div id="err_content">
162 8f37175d 2023-03-11 op {{ if t->error }}
163 8f37175d 2023-03-11 op {{ t->error->msg }}
165 8f37175d 2023-03-11 op See daemon logs for details
170 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
172 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
173 ed619ca0 2022-12-14 op struct server *srv = c->srv;
175 ed619ca0 2022-12-14 op <div id="index_header">
176 424803ac 2023-09-12 op <div class="index_project">
179 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
180 424803ac 2023-09-12 op <div class="index_project_description">
184 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
185 424803ac 2023-09-12 op <div class="index_project_owner">
189 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
190 424803ac 2023-09-12 op <div class="index_project_age">
197 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
199 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
200 ed619ca0 2022-12-14 op struct server *srv = c->srv;
201 ed619ca0 2022-12-14 op struct gotweb_url summary = {
202 ed619ca0 2022-12-14 op .action = SUMMARY,
203 ed619ca0 2022-12-14 op .index_page = -1,
205 ed619ca0 2022-12-14 op .path = repo_dir->name,
206 ed619ca0 2022-12-14 op }, briefs = {
207 ed619ca0 2022-12-14 op .action = BRIEFS,
208 ed619ca0 2022-12-14 op .index_page = -1,
210 ed619ca0 2022-12-14 op .path = repo_dir->name,
211 ed619ca0 2022-12-14 op }, commits = {
212 ed619ca0 2022-12-14 op .action = COMMITS,
213 ed619ca0 2022-12-14 op .index_page = -1,
215 ed619ca0 2022-12-14 op .path = repo_dir->name,
217 ed619ca0 2022-12-14 op .action = TAGS,
218 ed619ca0 2022-12-14 op .index_page = -1,
220 ed619ca0 2022-12-14 op .path = repo_dir->name,
222 ed619ca0 2022-12-14 op .action = TREE,
223 ed619ca0 2022-12-14 op .index_page = -1,
225 ed619ca0 2022-12-14 op .path = repo_dir->name,
227 1abb18e1 2022-12-20 op .action = RSS,
228 1abb18e1 2022-12-20 op .index_page = -1,
230 1abb18e1 2022-12-20 op .path = repo_dir->name,
233 ed619ca0 2022-12-14 op <div class="index_wrapper">
234 ed619ca0 2022-12-14 op <div class="index_project">
235 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
237 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
238 ed619ca0 2022-12-14 op <div class="index_project_description">
239 ed619ca0 2022-12-14 op {{ repo_dir->description }}
242 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
243 ed619ca0 2022-12-14 op <div class="index_project_owner">
244 ed619ca0 2022-12-14 op {{ repo_dir->owner }}
247 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
248 ed619ca0 2022-12-14 op <div class="index_project_age">
249 7781b991 2023-10-05 op {{ render datetime(tp, repo_dir->age, TM_DIFF) }}
252 ed619ca0 2022-12-14 op <div class="navs_wrapper">
253 ed619ca0 2022-12-14 op <div class="navs">
254 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
256 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
258 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
260 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
262 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
264 1abb18e1 2022-12-20 op <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
271 ed619ca0 2022-12-14 op {{ define gotweb_render_briefs(struct template *tp) }}
273 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
274 ed619ca0 2022-12-14 op struct transport *t = c->t;
275 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
276 ed619ca0 2022-12-14 op struct repo_commit *rc;
277 ed619ca0 2022-12-14 op struct repo_dir *repo_dir = t->repo_dir;
278 ed619ca0 2022-12-14 op struct gotweb_url diff_url, tree_url;
281 ed619ca0 2022-12-14 op diff_url = (struct gotweb_url){
282 ed619ca0 2022-12-14 op .action = DIFF,
283 ed619ca0 2022-12-14 op .index_page = -1,
285 ed619ca0 2022-12-14 op .path = repo_dir->name,
286 ed619ca0 2022-12-14 op .headref = qs->headref,
288 ed619ca0 2022-12-14 op tree_url = (struct gotweb_url){
289 ed619ca0 2022-12-14 op .action = TREE,
290 ed619ca0 2022-12-14 op .index_page = -1,
292 ed619ca0 2022-12-14 op .path = repo_dir->name,
293 ed619ca0 2022-12-14 op .headref = qs->headref,
296 424803ac 2023-09-12 op <header class='subtitle'>
297 424803ac 2023-09-12 op <h2>Commit Briefs</h2>
299 ed619ca0 2022-12-14 op <div id="briefs_content">
300 ed619ca0 2022-12-14 op {{ tailq-foreach rc &t->repo_commits entry }}
302 ed619ca0 2022-12-14 op diff_url.commit = rc->commit_id;
303 ed619ca0 2022-12-14 op tree_url.commit = rc->commit_id;
305 6c3d3263 2023-01-10 op tmp = strchr(rc->committer, '<');
309 ed619ca0 2022-12-14 op tmp = strchr(rc->commit_msg, '\n');
313 424803ac 2023-09-12 op <div class='brief'>
314 424803ac 2023-09-12 op <p class='brief_meta'>
315 424803ac 2023-09-12 op <span class='briefs_age'>
316 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_DIFF) }}
319 424803ac 2023-09-12 op <span class="briefs_author">
320 424803ac 2023-09-12 op {{ rc->committer }}
323 424803ac 2023-09-12 op <p class="briefs_log">
324 424803ac 2023-09-12 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
325 424803ac 2023-09-12 op {{ rc->commit_msg }}
327 424803ac 2023-09-12 op {{ if rc->refs_str }}
328 424803ac 2023-09-12 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
333 ed619ca0 2022-12-14 op <div class="navs_wrapper">
334 ed619ca0 2022-12-14 op <div class="navs">
335 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
337 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
342 e3662697 2023-02-03 op {{ render gotweb_render_more(tp, BRIEFS) }}
346 e3662697 2023-02-03 op {{ define gotweb_render_more(struct template *tp, int action) }}
348 e3662697 2023-02-03 op struct request *c = tp->tp_arg;
349 e3662697 2023-02-03 op struct transport *t = c->t;
350 e3662697 2023-02-03 op struct querystring *qs = t->qs;
351 e3662697 2023-02-03 op struct gotweb_url more = {
352 e3662697 2023-02-03 op .action = action,
353 e3662697 2023-02-03 op .index_page = -1,
354 e3662697 2023-02-03 op .path = qs->path,
355 e3662697 2023-02-03 op .commit = t->more_id,
356 e3662697 2023-02-03 op .headref = qs->headref,
357 de8c0409 2023-09-12 op .file = qs->file,
360 e3662697 2023-02-03 op {{ if t->more_id }}
361 e3662697 2023-02-03 op <div id="np_wrapper">
362 e3662697 2023-02-03 op <div id="nav_more">
363 e3662697 2023-02-03 op <a href="{{ render gotweb_render_url(c, &more) }}">
364 0af50e04 2023-02-03 op More ↓
371 b4c0bd72 2022-12-17 op {{ define gotweb_render_navs(struct template *tp) }}
373 b4c0bd72 2022-12-17 op struct request *c = tp->tp_arg;
374 b4c0bd72 2022-12-17 op struct transport *t = c->t;
375 b4c0bd72 2022-12-17 op struct gotweb_url prev, next;
376 b4c0bd72 2022-12-17 op int have_prev, have_next;
378 b4c0bd72 2022-12-17 op gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
380 b4c0bd72 2022-12-17 op <div id="np_wrapper">
381 b4c0bd72 2022-12-17 op <div id="nav_prev">
382 b4c0bd72 2022-12-17 op {{ if have_prev }}
383 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &prev) }}">
388 b4c0bd72 2022-12-17 op <div id="nav_next">
389 b4c0bd72 2022-12-17 op {{ if have_next }}
390 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &next) }}">
396 b4c0bd72 2022-12-17 op {{ finally }}
398 b4c0bd72 2022-12-17 op free(t->next_id);
399 b4c0bd72 2022-12-17 op t->next_id = NULL;
400 b4c0bd72 2022-12-17 op free(t->prev_id);
401 b4c0bd72 2022-12-17 op t->prev_id = NULL;
405 156a1144 2022-12-17 op {{ define gotweb_render_commits(struct template *tp) }}
407 156a1144 2022-12-17 op struct request *c = tp->tp_arg;
408 156a1144 2022-12-17 op struct transport *t = c->t;
409 156a1144 2022-12-17 op struct repo_dir *repo_dir = t->repo_dir;
410 156a1144 2022-12-17 op struct repo_commit *rc;
411 156a1144 2022-12-17 op struct gotweb_url diff, tree;
413 156a1144 2022-12-17 op diff = (struct gotweb_url){
414 156a1144 2022-12-17 op .action = DIFF,
415 156a1144 2022-12-17 op .index_page = -1,
417 156a1144 2022-12-17 op .path = repo_dir->name,
419 156a1144 2022-12-17 op tree = (struct gotweb_url){
420 156a1144 2022-12-17 op .action = TREE,
421 156a1144 2022-12-17 op .index_page = -1,
423 156a1144 2022-12-17 op .path = repo_dir->name,
426 424803ac 2023-09-12 op <header class="subtitle">
427 424803ac 2023-09-12 op <h2>Commits</h2>
429 156a1144 2022-12-17 op <div class="commits_content">
430 156a1144 2022-12-17 op {{ tailq-foreach rc &t->repo_commits entry }}
432 156a1144 2022-12-17 op diff.commit = rc->commit_id;
433 156a1144 2022-12-17 op tree.commit = rc->commit_id;
435 156a1144 2022-12-17 op <div class="commits_header_wrapper">
436 424803ac 2023-09-12 op <dl class="commits_header">
437 424803ac 2023-09-12 op <dt>Commit:</dt>
438 424803ac 2023-09-12 op <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
439 424803ac 2023-09-12 op <dt>From:</dt>
440 424803ac 2023-09-12 op <dd>{{ rc->author }}</dd>
441 af800df5 2023-01-10 op {{ if strcmp(rc->committer, rc->author) != 0 }}
442 424803ac 2023-09-12 op <dt>Via:</dt>
443 424803ac 2023-09-12 op <dd>{{ rc->committer }}</dd>
445 424803ac 2023-09-12 op <dt>Date:</dt>
447 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
452 cf536071 2022-12-31 op <div class="commit">
454 cf536071 2022-12-31 op {{ rc->commit_msg }}
456 156a1144 2022-12-17 op <div class="navs_wrapper">
457 156a1144 2022-12-17 op <div class="navs">
458 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
460 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
465 e3662697 2023-02-03 op {{ render gotweb_render_more(tp, COMMITS) }}
469 df2d3cd2 2023-03-11 op {{ define gotweb_render_blob(struct template *tp) }}
471 298f95fb 2023-01-05 op struct request *c = tp->tp_arg;
472 298f95fb 2023-01-05 op struct transport *t = c->t;
473 df2d3cd2 2023-03-11 op struct got_blob_object *blob = t->blob;
474 298f95fb 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
476 424803ac 2023-09-12 op <header class="subtitle">
477 424803ac 2023-09-12 op <h2>Blob</h2>
479 298f95fb 2023-01-05 op <div id="blob_content">
480 298f95fb 2023-01-05 op <div id="blob_header_wrapper">
481 424803ac 2023-09-12 op <dl id="blob_header">
482 424803ac 2023-09-12 op <dt>Date:</dt>
484 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
486 424803ac 2023-09-12 op <dt>Message:</dt>
487 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
491 298f95fb 2023-01-05 op <div id="blob">
493 298f95fb 2023-01-05 op {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
499 298f95fb 2023-01-05 op {{ define gotweb_render_blob_line(struct template *tp, const char *line,
500 298f95fb 2023-01-05 op size_t no) }}
502 298f95fb 2023-01-05 op char lineno[16];
505 298f95fb 2023-01-05 op r = snprintf(lineno, sizeof(lineno), "%zu", no);
506 298f95fb 2023-01-05 op if (r < 0 || (size_t)r >= sizeof(lineno))
509 298f95fb 2023-01-05 op <div class="blob_line" id="line{{ lineno }}">
510 424803ac 2023-09-12 op <a href="#line{{ lineno }}">{{ lineno }}</a>
511 424803ac 2023-09-12 op <span class="blob_code">{{ line }}</span>
515 43d421de 2023-01-05 op {{ define gotweb_render_tree(struct template *tp) }}
517 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
518 43d421de 2023-01-05 op struct transport *t = c->t;
519 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
521 424803ac 2023-09-12 op <header class='subtitle'>
522 424803ac 2023-09-12 op <h2>Tree</h2>
524 43d421de 2023-01-05 op <div id="tree_content">
525 43d421de 2023-01-05 op <div id="tree_header_wrapper">
526 424803ac 2023-09-12 op <dl id="tree_header">
527 424803ac 2023-09-12 op <dt>Tree:</dt>
528 424803ac 2023-09-12 op <dd><code class="commit-id">{{ rc->tree_id }}</code></dd>
529 424803ac 2023-09-12 op <dt>Date:</dt>
531 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
533 424803ac 2023-09-12 op <dt>Message:</dt>
534 f8275511 2023-10-05 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
538 424803ac 2023-09-12 op <table id="tree">
539 43d421de 2023-01-05 op {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
544 43d421de 2023-01-05 op {{ define gotweb_render_tree_item(struct template *tp,
545 43d421de 2023-01-05 op struct got_tree_entry *te) }}
547 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
548 43d421de 2023-01-05 op struct transport *t = c->t;
549 43d421de 2023-01-05 op struct querystring *qs = t->qs;
550 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
551 43d421de 2023-01-05 op const char *modestr = "";
552 43d421de 2023-01-05 op const char *name;
553 43d421de 2023-01-05 op const char *folder;
554 43d421de 2023-01-05 op char *dir = NULL;
556 43d421de 2023-01-05 op struct gotweb_url url = {
557 43d421de 2023-01-05 op .index_page = -1,
559 43d421de 2023-01-05 op .commit = rc->commit_id,
560 43d421de 2023-01-05 op .path = qs->path,
563 43d421de 2023-01-05 op name = got_tree_entry_get_name(te);
564 43d421de 2023-01-05 op mode = got_tree_entry_get_mode(te);
566 43d421de 2023-01-05 op folder = qs->folder ? qs->folder : "";
567 43d421de 2023-01-05 op if (S_ISDIR(mode)) {
568 43d421de 2023-01-05 op if (asprintf(&dir, "%s/%s", folder, name) == -1)
571 43d421de 2023-01-05 op url.action = TREE;
572 43d421de 2023-01-05 op url.folder = dir;
574 43d421de 2023-01-05 op url.action = BLOB;
575 43d421de 2023-01-05 op url.folder = folder;
576 43d421de 2023-01-05 op url.file = name;
579 43d421de 2023-01-05 op if (got_object_tree_entry_is_submodule(te))
580 43d421de 2023-01-05 op modestr = "$";
581 43d421de 2023-01-05 op else if (S_ISLNK(mode))
582 43d421de 2023-01-05 op modestr = "@";
583 43d421de 2023-01-05 op else if (S_ISDIR(mode))
584 43d421de 2023-01-05 op modestr = "/";
585 43d421de 2023-01-05 op else if (mode & S_IXUSR)
586 43d421de 2023-01-05 op modestr = "*";
588 424803ac 2023-09-12 op <tr class="tree_wrapper">
589 43d421de 2023-01-05 op {{ if S_ISDIR(mode) }}
590 424803ac 2023-09-12 op <td class="tree_line" colspan=2>
591 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
592 43d421de 2023-01-05 op {{ name }}{{ modestr }}
596 424803ac 2023-09-12 op <td class="tree_line">
597 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
598 43d421de 2023-01-05 op {{ name }}{{ modestr }}
601 424803ac 2023-09-12 op <td class="tree_line_blank">
602 43d421de 2023-01-05 op {! url.action = COMMITS; !}
603 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
607 43d421de 2023-01-05 op {! url.action = BLAME; !}
608 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
614 43d421de 2023-01-05 op {{ finally }}
620 d60961d2 2023-01-13 op {{ define gotweb_render_tags(struct template *tp) }}
622 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
623 067396e6 2023-01-09 op struct transport *t = c->t;
624 067396e6 2023-01-09 op struct querystring *qs = t->qs;
625 067396e6 2023-01-09 op struct repo_tag *rt;
626 067396e6 2023-01-09 op int commit_found;
628 067396e6 2023-01-09 op commit_found = qs->commit == NULL;
630 424803ac 2023-09-12 op <header class='subtitle'>
631 424803ac 2023-09-12 op <h2>Tags</h2>
633 067396e6 2023-01-09 op <div id="tags_content">
634 067396e6 2023-01-09 op {{ if t->tag_count == 0 }}
635 067396e6 2023-01-09 op <div id="err_content">
636 067396e6 2023-01-09 op This repository contains no tags
639 067396e6 2023-01-09 op {{ tailq-foreach rt &t->repo_tags entry }}
640 067396e6 2023-01-09 op {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
641 067396e6 2023-01-09 op {! commit_found = 1; !}
642 067396e6 2023-01-09 op {{ render tag_item(tp, rt) }}
645 067396e6 2023-01-09 op {{ if t->next_id || t->prev_id }}
646 e3662697 2023-02-03 op {! qs->action = TAGS; !}
647 067396e6 2023-01-09 op {{ render gotweb_render_navs(tp) }}
653 067396e6 2023-01-09 op {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
655 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
656 067396e6 2023-01-09 op struct transport *t = c->t;
657 067396e6 2023-01-09 op struct repo_dir *repo_dir = t->repo_dir;
658 067396e6 2023-01-09 op char *tag_name = rt->tag_name;
659 067396e6 2023-01-09 op char *msg = rt->tag_commit;
661 067396e6 2023-01-09 op struct gotweb_url url = {
662 067396e6 2023-01-09 op .action = TAG,
663 067396e6 2023-01-09 op .index_page = -1,
665 067396e6 2023-01-09 op .path = repo_dir->name,
666 067396e6 2023-01-09 op .commit = rt->commit_id,
669 067396e6 2023-01-09 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
670 067396e6 2023-01-09 op tag_name += 10;
673 067396e6 2023-01-09 op nl = strchr(msg, '\n');
678 067396e6 2023-01-09 op <div class="tag_age">
679 7781b991 2023-10-05 op {{ render datetime(tp, rt->tagger_time, TM_DIFF) }}
681 424803ac 2023-09-12 op <div class="tag_name">{{ tag_name }}</div>
682 067396e6 2023-01-09 op <div class="tag_log">
683 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">
687 067396e6 2023-01-09 op <div class="navs_wrapper">
688 067396e6 2023-01-09 op <div class="navs">
689 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
691 067396e6 2023-01-09 op {! url.action = BRIEFS; !}
692 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
694 067396e6 2023-01-09 op {! url.action = COMMITS; !}
695 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
701 dc07f76c 2023-01-09 op {{ define gotweb_render_tag(struct template *tp) }}
703 dc07f76c 2023-01-09 op struct request *c = tp->tp_arg;
704 dc07f76c 2023-01-09 op struct transport *t = c->t;
705 dc07f76c 2023-01-09 op struct repo_tag *rt;
706 dc07f76c 2023-01-09 op const char *tag_name;
708 dc07f76c 2023-01-09 op rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
709 dc07f76c 2023-01-09 op tag_name = rt->tag_name;
711 dc07f76c 2023-01-09 op if (strncmp(tag_name, "refs/", 5) == 0)
712 dc07f76c 2023-01-09 op tag_name += 5;
714 424803ac 2023-09-12 op <header class="subtitle">
717 dc07f76c 2023-01-09 op <div id="tags_content">
718 dc07f76c 2023-01-09 op <div id="tag_header_wrapper">
719 424803ac 2023-09-12 op <dl id="tag_header">
720 424803ac 2023-09-12 op <dt>Commit:</dt>
722 424803ac 2023-09-12 op <code class="commit-id">{{ rt->commit_id }}</code>
724 dc07f76c 2023-01-09 op <span class="refs_str">({{ tag_name }})</span>
726 424803ac 2023-09-12 op <dt>Tagger:</dt>
727 424803ac 2023-09-12 op <dd>{{ rt->tagger }}</dd>
728 424803ac 2023-09-12 op <dt>Date:</dt>
730 7781b991 2023-10-05 op {{ render datetime(tp, rt->tagger_time, TM_LONG)}}
732 424803ac 2023-09-12 op <dt>Message:</dt>
733 424803ac 2023-09-12 op <dd class="commit-msg">{{ rt->commit_msg }}</dd>
736 424803ac 2023-09-12 op <pre id="tag_commit">
737 dc07f76c 2023-01-09 op {{ rt->tag_commit }}
743 df2d3cd2 2023-03-11 op {{ define gotweb_render_diff(struct template *tp) }}
745 587550a5 2023-01-10 op struct request *c = tp->tp_arg;
746 587550a5 2023-01-10 op struct transport *t = c->t;
747 df2d3cd2 2023-03-11 op FILE *fp = t->fp;
748 587550a5 2023-01-10 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
749 587550a5 2023-01-10 op char *line = NULL;
750 587550a5 2023-01-10 op size_t linesize = 0;
751 587550a5 2023-01-10 op ssize_t linelen;
753 424803ac 2023-09-12 op <header class="subtitle">
754 424803ac 2023-09-12 op <h2>Commit Diff</h2>
756 587550a5 2023-01-10 op <div id="diff_content">
757 587550a5 2023-01-10 op <div id="diff_header_wrapper">
758 424803ac 2023-09-12 op <dl id="diff_header">
759 424803ac 2023-09-12 op <dt>Commit:</dt>
760 424803ac 2023-09-12 op <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
761 424803ac 2023-09-12 op <dt>From:</dt>
762 424803ac 2023-09-12 op <dd>{{ rc->author }}</dd>
763 49632cd3 2023-01-10 op {{ if strcmp(rc->committer, rc->author) != 0 }}
764 424803ac 2023-09-12 op <dt>Via:</dt>
765 424803ac 2023-09-12 op <dd>{{ rc->committer }}</dd>
767 424803ac 2023-09-12 op <dt>Date:</dt>
769 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
771 424803ac 2023-09-12 op <dt>Message:</dt>
772 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
776 424803ac 2023-09-12 op <pre id="diff">
777 587550a5 2023-01-10 op {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
778 587550a5 2023-01-10 op {{ render diff_line(tp, line) }}
782 587550a5 2023-01-10 op {{ finally }}
783 587550a5 2023-01-10 op {! free(line); !}
786 587550a5 2023-01-10 op {{ define diff_line(struct template *tp, char *line )}}
788 587550a5 2023-01-10 op const char *color = NULL;
791 587550a5 2023-01-10 op if (!strncmp(line, "-", 1))
792 587550a5 2023-01-10 op color = "diff_minus";
793 587550a5 2023-01-10 op else if (!strncmp(line, "+", 1))
794 587550a5 2023-01-10 op color = "diff_plus";
795 587550a5 2023-01-10 op else if (!strncmp(line, "@@", 2))
796 587550a5 2023-01-10 op color = "diff_chunk_header";
797 587550a5 2023-01-10 op else if (!strncmp(line, "commit +", 8) ||
798 587550a5 2023-01-10 op !strncmp(line, "commit -", 8) ||
799 587550a5 2023-01-10 op !strncmp(line, "blob +", 6) ||
800 587550a5 2023-01-10 op !strncmp(line, "blob -", 6) ||
801 587550a5 2023-01-10 op !strncmp(line, "file +", 6) ||
802 587550a5 2023-01-10 op !strncmp(line, "file -", 6))
803 587550a5 2023-01-10 op color = "diff_meta";
804 587550a5 2023-01-10 op else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
805 587550a5 2023-01-10 op color = "diff_author";
806 587550a5 2023-01-10 op else if (!strncmp(line, "date:", 5))
807 587550a5 2023-01-10 op color = "diff_date";
809 587550a5 2023-01-10 op nl = strchr(line, '\n');
813 424803ac 2023-09-12 op <span class="diff_line {{ color }}">{{ line }}</span>{{"\n"}}
816 3ab2c914 2023-01-11 op {{ define gotweb_render_branches(struct template *tp,
817 3ab2c914 2023-01-11 op struct got_reflist_head *refs) }}
819 3ab2c914 2023-01-11 op struct got_reflist_entry *re;
821 424803ac 2023-09-12 op <header class='subtitle'>
822 424803ac 2023-09-12 op <h2>Branches</h2>
824 3ab2c914 2023-01-11 op <div id="branches_content">
825 3ab2c914 2023-01-11 op {{ tailq-foreach re refs entry }}
826 3ab2c914 2023-01-11 op {{ if !got_ref_is_symbolic(re->ref) }}
827 3ab2c914 2023-01-11 op {{ render branch(tp, re) }}
833 3ab2c914 2023-01-11 op {{ define branch(struct template *tp, struct got_reflist_entry *re) }}
835 3ab2c914 2023-01-11 op const struct got_error *err;
836 3ab2c914 2023-01-11 op struct request *c = tp->tp_arg;
837 3ab2c914 2023-01-11 op struct querystring *qs = c->t->qs;
838 3ab2c914 2023-01-11 op const char *refname;
840 3ab2c914 2023-01-11 op struct gotweb_url url = {
841 3ab2c914 2023-01-11 op .action = SUMMARY,
842 3ab2c914 2023-01-11 op .index_page = -1,
844 3ab2c914 2023-01-11 op .path = qs->path,
847 3ab2c914 2023-01-11 op refname = got_ref_get_name(re->ref);
849 cb93ab40 2023-01-22 op err = got_get_repo_age(&age, c, refname);
851 3ab2c914 2023-01-11 op log_warnx("%s: %s", __func__, err->msg);
855 3ab2c914 2023-01-11 op if (strncmp(refname, "refs/heads/", 11) == 0)
856 3ab2c914 2023-01-11 op refname += 11;
858 3ab2c914 2023-01-11 op url.headref = refname;
860 424803ac 2023-09-12 op <section class="branches_wrapper">
861 cb93ab40 2023-01-22 op <div class="branches_age">
862 7781b991 2023-10-05 op {{ render datetime(tp, age, TM_DIFF) }}
864 3ab2c914 2023-01-11 op <div class="branch">
865 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
867 3ab2c914 2023-01-11 op <div class="navs_wrapper">
868 3ab2c914 2023-01-11 op <div class="navs">
869 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">summary</a>
871 3ab2c914 2023-01-11 op {! url.action = BRIEFS; !}
872 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
874 3ab2c914 2023-01-11 op {! url.action = COMMITS; !}
875 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
882 df2d3cd2 2023-03-11 op {{ define gotweb_render_summary(struct template *tp) }}
884 69525b4e 2023-01-13 op struct request *c = tp->tp_arg;
885 69525b4e 2023-01-13 op struct server *srv = c->srv;
886 69525b4e 2023-01-13 op struct transport *t = c->t;
887 df2d3cd2 2023-03-11 op struct got_reflist_head *refs = &t->refs;
889 424803ac 2023-09-12 op <dl id="summary_wrapper">
890 69525b4e 2023-01-13 op {{ if srv->show_repo_description }}
891 424803ac 2023-09-12 op <dt>Description:</dt>
892 424803ac 2023-09-12 op <dd>{{ t->repo_dir->description }}</dd>
894 69525b4e 2023-01-13 op {{ if srv->show_repo_owner }}
895 424803ac 2023-09-12 op <dt>Owner:</dt>
896 424803ac 2023-09-12 op <dd>{{ t->repo_dir->owner }}</dd>
898 69525b4e 2023-01-13 op {{ if srv->show_repo_age }}
899 424803ac 2023-09-12 op <dt>Last Change:</dt>
901 7781b991 2023-10-05 op {{ render datetime(tp, t->repo_dir->age, TM_DIFF) }}
904 69525b4e 2023-01-13 op {{ if srv->show_repo_cloneurl }}
905 424803ac 2023-09-12 op <dt>Clone URL:</dt>
906 424803ac 2023-09-12 op <dd><pre class="clone-url">{{ t->repo_dir->url }}</pre></dd>
909 69525b4e 2023-01-13 op {{ render gotweb_render_briefs(tp) }}
910 69525b4e 2023-01-13 op {{ render gotweb_render_tags(tp) }}
911 69525b4e 2023-01-13 op {{ render gotweb_render_branches(tp, refs) }}
914 8319855f 2023-01-15 op {{ define gotweb_render_blame(struct template *tp) }}
916 8319855f 2023-01-15 op const struct got_error *err;
917 8319855f 2023-01-15 op struct request *c = tp->tp_arg;
918 8319855f 2023-01-15 op struct transport *t = c->t;
919 8319855f 2023-01-15 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
921 424803ac 2023-09-12 op <header class="subtitle">
922 424803ac 2023-09-12 op <h2>Blame</h2>
924 8319855f 2023-01-15 op <div id="blame_content">
925 8319855f 2023-01-15 op <div id="blame_header_wrapper">
926 424803ac 2023-09-12 op <dl id="blame_header">
927 424803ac 2023-09-12 op <dt>Date:</dt>
929 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
931 424803ac 2023-09-12 op <dt>Message:</dt>
932 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
936 424803ac 2023-09-12 op <pre id="blame">
938 8319855f 2023-01-15 op err = got_output_file_blame(c, &blame_line);
939 8a078d7f 2023-05-17 op if (err && err->code != GOT_ERR_CANCELLED)
940 8319855f 2023-01-15 op log_warnx("%s: got_output_file_blame: %s", __func__,
949 8319855f 2023-01-15 op {{ define blame_line(struct template *tp, const char *line,
950 8319855f 2023-01-15 op struct blame_line *bline, int lprec, int lcur) }}
952 8319855f 2023-01-15 op struct request *c = tp->tp_arg;
953 8319855f 2023-01-15 op struct transport *t = c->t;
954 8319855f 2023-01-15 op struct repo_dir *repo_dir = t->repo_dir;
955 8319855f 2023-01-15 op char *committer, *s;
956 8319855f 2023-01-15 op struct gotweb_url url = {
957 8319855f 2023-01-15 op .action = DIFF,
958 8319855f 2023-01-15 op .index_page = -1,
960 8319855f 2023-01-15 op .path = repo_dir->name,
961 8319855f 2023-01-15 op .commit = bline->id_str,
964 8319855f 2023-01-15 op s = strchr(bline->committer, '<');
965 8319855f 2023-01-15 op committer = s ? s + 1 : bline->committer;
967 8319855f 2023-01-15 op s = strchr(committer, '@');
971 8319855f 2023-01-15 op <div class="blame_wrapper">
972 8319855f 2023-01-15 op <div class="blame_number">{{ printf "%.*d", lprec, lcur }}</div>
973 8319855f 2023-01-15 op <div class="blame_hash">
974 8319855f 2023-01-15 op <a href="{{ render gotweb_render_url(c, &url) }}">
975 8319855f 2023-01-15 op {{ printf "%.8s", bline->id_str }}
978 8319855f 2023-01-15 op <div class="blame_date">{{ bline->datebuf }}</div>
979 8319855f 2023-01-15 op <div class="blame_author">{{ printf "%.9s", committer }}</div>
980 8319855f 2023-01-15 op <div class="blame_code">{{ line }}</div>
984 1abb18e1 2022-12-20 op {{ define gotweb_render_rss(struct template *tp) }}
986 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
987 1abb18e1 2022-12-20 op struct server *srv = c->srv;
988 1abb18e1 2022-12-20 op struct transport *t = c->t;
989 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
990 1abb18e1 2022-12-20 op struct repo_tag *rt;
991 1abb18e1 2022-12-20 op struct gotweb_url summary = {
992 1abb18e1 2022-12-20 op .action = SUMMARY,
993 1abb18e1 2022-12-20 op .index_page = -1,
995 1abb18e1 2022-12-20 op .path = repo_dir->name,
998 1abb18e1 2022-12-20 op <?xml version="1.0" encoding="UTF-8"?>
999 1abb18e1 2022-12-20 op <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
1001 1abb18e1 2022-12-20 op <title>Tags of {{ repo_dir->name }}</title>
1004 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &summary) }}
1007 1abb18e1 2022-12-20 op {{ if srv->show_repo_description }}
1008 1abb18e1 2022-12-20 op <description>{{ repo_dir->description }}</description>
1010 1abb18e1 2022-12-20 op {{ tailq-foreach rt &t->repo_tags entry }}
1011 1abb18e1 2022-12-20 op {{ render rss_tag_item(tp, rt) }}
1017 1abb18e1 2022-12-20 op {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
1019 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
1020 1abb18e1 2022-12-20 op struct transport *t = c->t;
1021 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
1022 bf26a633 2023-10-05 op struct tm tm;
1023 bf26a633 2023-10-05 op char rfc822[128];
1025 1abb18e1 2022-12-20 op char *tag_name = rt->tag_name;
1026 1abb18e1 2022-12-20 op struct gotweb_url tag = {
1027 1abb18e1 2022-12-20 op .action = TAG,
1028 1abb18e1 2022-12-20 op .index_page = -1,
1030 1abb18e1 2022-12-20 op .path = repo_dir->name,
1031 1abb18e1 2022-12-20 op .commit = rt->commit_id,
1034 1abb18e1 2022-12-20 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
1035 1abb18e1 2022-12-20 op tag_name += 10;
1037 bf26a633 2023-10-05 op if (gmtime_r(&rt->tagger_time, &tm) == NULL)
1039 bf26a633 2023-10-05 op r = strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S GMT", &tm);
1044 1abb18e1 2022-12-20 op <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
1047 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &tag) }}
1050 1abb18e1 2022-12-20 op <description>
1051 1abb18e1 2022-12-20 op <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
1052 1abb18e1 2022-12-20 op </description>
1053 1abb18e1 2022-12-20 op {{ render rss_author(tp, rt->tagger) }}
1054 1abb18e1 2022-12-20 op <guid isPermaLink="false">{{ rt->commit_id }}</guid>
1056 bf26a633 2023-10-05 op {{ rfc822 }}
1061 1abb18e1 2022-12-20 op {{ define rss_author(struct template *tp, char *author) }}
1063 1abb18e1 2022-12-20 op char *t, *mail;
1065 1abb18e1 2022-12-20 op /* what to do if the author name contains a paren? */
1066 1abb18e1 2022-12-20 op if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
1069 1abb18e1 2022-12-20 op t = strchr(author, '<');
1070 1abb18e1 2022-12-20 op if (t == NULL)
1075 1abb18e1 2022-12-20 op while (isspace((unsigned char)*--t))
1078 1abb18e1 2022-12-20 op t = strchr(mail, '>');
1079 1abb18e1 2022-12-20 op if (t == NULL)
1084 1abb18e1 2022-12-20 op {{ mail }} {{" "}} ({{ author }})