3 e7e5fa49 2022-12-30 thomas * Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 e7e5fa49 2022-12-30 thomas * Copyright (c) 2016, 2019, 2020-2022 Tracey Emery <tracey@traceyemery.net>
6 e7e5fa49 2022-12-30 thomas * Permission to use, copy, modify, and distribute this software for any
7 e7e5fa49 2022-12-30 thomas * purpose with or without fee is hereby granted, provided that the above
8 e7e5fa49 2022-12-30 thomas * copyright notice and this permission notice appear in all copies.
10 e7e5fa49 2022-12-30 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 e7e5fa49 2022-12-30 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 e7e5fa49 2022-12-30 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 e7e5fa49 2022-12-30 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 e7e5fa49 2022-12-30 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 e7e5fa49 2022-12-30 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 e7e5fa49 2022-12-30 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 e7e5fa49 2022-12-30 thomas #include <sys/types.h>
20 e7e5fa49 2022-12-30 thomas #include <sys/queue.h>
21 3c14c1f2 2023-01-06 thomas #include <sys/stat.h>
23 d6795e9f 2022-12-30 thomas #include <ctype.h>
24 e7e5fa49 2022-12-30 thomas #include <event.h>
25 e7e5fa49 2022-12-30 thomas #include <stdint.h>
26 3c14c1f2 2023-01-06 thomas #include <stdio.h>
27 e7e5fa49 2022-12-30 thomas #include <stdlib.h>
28 e7e5fa49 2022-12-30 thomas #include <string.h>
29 e7e5fa49 2022-12-30 thomas #include <imsg.h>
31 171ba12a 2023-01-06 thomas #include "got_compat.h"
32 3c14c1f2 2023-01-06 thomas #include "got_object.h"
34 e7e5fa49 2022-12-30 thomas #include "proc.h"
36 e7e5fa49 2022-12-30 thomas #include "gotwebd.h"
37 e7e5fa49 2022-12-30 thomas #include "tmpl.h"
39 b82440e1 2023-01-06 thomas static int gotweb_render_blob_line(struct template *, const char *, size_t);
40 3c14c1f2 2023-01-06 thomas static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
42 dccd05b4 2023-01-10 thomas static inline int diff_line(struct template *, char *);
43 617497a6 2023-01-09 thomas static inline int tag_item(struct template *, struct repo_tag *);
44 d6795e9f 2022-12-30 thomas static inline int rss_tag_item(struct template *, struct repo_tag *);
45 d6795e9f 2022-12-30 thomas static inline int rss_author(struct template *, char *);
47 e7e5fa49 2022-12-30 thomas static int
48 e7e5fa49 2022-12-30 thomas gotweb_render_age(struct template *tp, time_t time, int ref_tm)
50 e7e5fa49 2022-12-30 thomas const struct got_error *err;
51 e7e5fa49 2022-12-30 thomas char *age;
54 e7e5fa49 2022-12-30 thomas err = gotweb_get_time_str(&age, time, ref_tm);
57 e7e5fa49 2022-12-30 thomas r = tp->tp_puts(tp, age);
58 e7e5fa49 2022-12-30 thomas free(age);
64 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_header(struct template *tp) }}
66 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
67 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
68 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
69 e7e5fa49 2022-12-30 thomas struct gotweb_url u_path;
70 3191e256 2022-12-30 thomas const char *prfx = c->document_uri;
71 e7e5fa49 2022-12-30 thomas const char *css = srv->custom_css;
73 e7e5fa49 2022-12-30 thomas memset(&u_path, 0, sizeof(u_path));
74 e7e5fa49 2022-12-30 thomas u_path.index_page = -1;
75 e7e5fa49 2022-12-30 thomas u_path.page = -1;
76 e7e5fa49 2022-12-30 thomas u_path.action = SUMMARY;
78 e7e5fa49 2022-12-30 thomas <!doctype html>
81 e7e5fa49 2022-12-30 thomas <meta charset="utf-8" />
82 e7e5fa49 2022-12-30 thomas <title>{{ srv->site_name }}</title>
83 e7e5fa49 2022-12-30 thomas <meta name="viewport" content="initial-scale=.75" />
84 e7e5fa49 2022-12-30 thomas <meta name="msapplication-TileColor" content="#da532c" />
85 e7e5fa49 2022-12-30 thomas <meta name="theme-color" content="#ffffff"/>
86 e7e5fa49 2022-12-30 thomas <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
87 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
88 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
89 e7e5fa49 2022-12-30 thomas <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
90 e7e5fa49 2022-12-30 thomas <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
91 e7e5fa49 2022-12-30 thomas <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
94 e7e5fa49 2022-12-30 thomas <div id="gw_body">
95 e7e5fa49 2022-12-30 thomas <div id="header">
96 e7e5fa49 2022-12-30 thomas <div id="got_link">
97 e7e5fa49 2022-12-30 thomas <a href="{{ srv->logo_url }}" target="_blank">
98 e7e5fa49 2022-12-30 thomas <img src="{{ prfx }}{{ srv->logo }}" />
102 e7e5fa49 2022-12-30 thomas <div id="site_path">
103 e7e5fa49 2022-12-30 thomas <div id="site_link">
104 e7e5fa49 2022-12-30 thomas <a href="?index_page={{ printf "%d", qs->index_page }}">
105 e7e5fa49 2022-12-30 thomas {{ srv->site_link }}
107 e7e5fa49 2022-12-30 thomas {{ if qs->path }}
108 e7e5fa49 2022-12-30 thomas {! u_path.path = qs->path; !}
109 e7e5fa49 2022-12-30 thomas {{ " / " }}
110 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
111 e7e5fa49 2022-12-30 thomas {{ qs->path }}
113 e7e5fa49 2022-12-30 thomas {{ end }}
114 e7e5fa49 2022-12-30 thomas {{ if qs->action != INDEX }}
115 e7e5fa49 2022-12-30 thomas {{ " / " }}{{ gotweb_action_name(qs->action) }}
116 e7e5fa49 2022-12-30 thomas {{ end }}
119 e7e5fa49 2022-12-30 thomas <div id="content">
120 e7e5fa49 2022-12-30 thomas {{ end }}
122 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_footer(struct template *tp) }}
124 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
125 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
127 e7e5fa49 2022-12-30 thomas <div id="site_owner_wrapper">
128 e7e5fa49 2022-12-30 thomas <div id="site_owner">
129 e7e5fa49 2022-12-30 thomas {{ if srv->show_site_owner }}
130 e7e5fa49 2022-12-30 thomas {{ srv->site_owner }}
131 e7e5fa49 2022-12-30 thomas {{ end }}
138 e7e5fa49 2022-12-30 thomas {{ end }}
140 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
142 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
143 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
145 e7e5fa49 2022-12-30 thomas <div id="index_header">
146 e7e5fa49 2022-12-30 thomas <div id="index_header_project">
149 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
150 e7e5fa49 2022-12-30 thomas <div id="index_header_description">
151 e7e5fa49 2022-12-30 thomas Description
153 e7e5fa49 2022-12-30 thomas {{ end }}
154 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
155 e7e5fa49 2022-12-30 thomas <div id="index_header_owner">
158 e7e5fa49 2022-12-30 thomas {{ end }}
159 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
160 e7e5fa49 2022-12-30 thomas <div id="index_header_age">
161 e7e5fa49 2022-12-30 thomas Last Change
163 e7e5fa49 2022-12-30 thomas {{ end }}
165 e7e5fa49 2022-12-30 thomas {{ end }}
167 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
169 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
170 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
171 e7e5fa49 2022-12-30 thomas struct gotweb_url summary = {
172 e7e5fa49 2022-12-30 thomas .action = SUMMARY,
173 e7e5fa49 2022-12-30 thomas .index_page = -1,
174 e7e5fa49 2022-12-30 thomas .page = -1,
175 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
176 e7e5fa49 2022-12-30 thomas }, briefs = {
177 e7e5fa49 2022-12-30 thomas .action = BRIEFS,
178 e7e5fa49 2022-12-30 thomas .index_page = -1,
179 e7e5fa49 2022-12-30 thomas .page = -1,
180 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
181 e7e5fa49 2022-12-30 thomas }, commits = {
182 e7e5fa49 2022-12-30 thomas .action = COMMITS,
183 e7e5fa49 2022-12-30 thomas .index_page = -1,
184 e7e5fa49 2022-12-30 thomas .page = -1,
185 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
186 e7e5fa49 2022-12-30 thomas }, tags = {
187 e7e5fa49 2022-12-30 thomas .action = TAGS,
188 e7e5fa49 2022-12-30 thomas .index_page = -1,
189 e7e5fa49 2022-12-30 thomas .page = -1,
190 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
191 e7e5fa49 2022-12-30 thomas }, tree = {
192 e7e5fa49 2022-12-30 thomas .action = TREE,
193 e7e5fa49 2022-12-30 thomas .index_page = -1,
194 e7e5fa49 2022-12-30 thomas .page = -1,
195 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
196 d6795e9f 2022-12-30 thomas }, rss = {
197 d6795e9f 2022-12-30 thomas .action = RSS,
198 d6795e9f 2022-12-30 thomas .index_page = -1,
199 d6795e9f 2022-12-30 thomas .page = -1,
200 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
203 e7e5fa49 2022-12-30 thomas <div class="index_wrapper">
204 e7e5fa49 2022-12-30 thomas <div class="index_project">
205 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
207 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
208 e7e5fa49 2022-12-30 thomas <div class="index_project_description">
209 e7e5fa49 2022-12-30 thomas {{ repo_dir->description }}
211 e7e5fa49 2022-12-30 thomas {{ end }}
212 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
213 e7e5fa49 2022-12-30 thomas <div class="index_project_owner">
214 e7e5fa49 2022-12-30 thomas {{ repo_dir->owner }}
216 e7e5fa49 2022-12-30 thomas {{ end }}
217 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
218 e7e5fa49 2022-12-30 thomas <div class="index_project_age">
219 e7e5fa49 2022-12-30 thomas {{ repo_dir->age }}
221 e7e5fa49 2022-12-30 thomas {{ end }}
222 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
223 e7e5fa49 2022-12-30 thomas <div class="navs">
224 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
225 e7e5fa49 2022-12-30 thomas {{ " | " }}
226 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
227 e7e5fa49 2022-12-30 thomas {{ " | " }}
228 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
229 e7e5fa49 2022-12-30 thomas {{ " | " }}
230 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
231 e7e5fa49 2022-12-30 thomas {{ " | " }}
232 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
233 d6795e9f 2022-12-30 thomas {{ " | " }}
234 d6795e9f 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
236 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
239 e7e5fa49 2022-12-30 thomas {{ end }}
241 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_briefs(struct template *tp) }}
243 e7e5fa49 2022-12-30 thomas const struct got_error *error;
244 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
245 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
246 e7e5fa49 2022-12-30 thomas struct transport *t = c->t;
247 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
248 e7e5fa49 2022-12-30 thomas struct repo_commit *rc;
249 e7e5fa49 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
250 e7e5fa49 2022-12-30 thomas struct gotweb_url diff_url, tree_url;
251 e7e5fa49 2022-12-30 thomas char *tmp;
253 e7e5fa49 2022-12-30 thomas diff_url = (struct gotweb_url){
254 e7e5fa49 2022-12-30 thomas .action = DIFF,
255 e7e5fa49 2022-12-30 thomas .index_page = -1,
256 e7e5fa49 2022-12-30 thomas .page = -1,
257 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
258 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
260 e7e5fa49 2022-12-30 thomas tree_url = (struct gotweb_url){
261 e7e5fa49 2022-12-30 thomas .action = TREE,
262 e7e5fa49 2022-12-30 thomas .index_page = -1,
263 e7e5fa49 2022-12-30 thomas .page = -1,
264 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
265 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
268 e7e5fa49 2022-12-30 thomas if (qs->action == SUMMARY) {
269 e7e5fa49 2022-12-30 thomas qs->action = BRIEFS;
270 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
272 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, srv->max_commits_display);
273 e7e5fa49 2022-12-30 thomas if (error)
274 e7e5fa49 2022-12-30 thomas return -1;
276 e7e5fa49 2022-12-30 thomas <div id="briefs_title_wrapper">
277 e7e5fa49 2022-12-30 thomas <div id="briefs_title">Commit Briefs</div>
279 e7e5fa49 2022-12-30 thomas <div id="briefs_content">
280 e7e5fa49 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
282 e7e5fa49 2022-12-30 thomas diff_url.commit = rc->commit_id;
283 e7e5fa49 2022-12-30 thomas tree_url.commit = rc->commit_id;
285 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->author, '<');
287 e7e5fa49 2022-12-30 thomas *tmp = '\0';
289 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->commit_msg, '\n');
291 e7e5fa49 2022-12-30 thomas *tmp = '\0';
293 e7e5fa49 2022-12-30 thomas <div class="briefs_age">
294 e7e5fa49 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
296 e7e5fa49 2022-12-30 thomas <div class="briefs_author">
297 e7e5fa49 2022-12-30 thomas {{ rc->author }}
299 e7e5fa49 2022-12-30 thomas <div class="briefs_log">
300 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
301 e7e5fa49 2022-12-30 thomas {{ rc->commit_msg }}
303 e7e5fa49 2022-12-30 thomas {{ if rc->refs_str }}
304 e7e5fa49 2022-12-30 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
305 e7e5fa49 2022-12-30 thomas {{ end }}
308 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
309 e7e5fa49 2022-12-30 thomas <div class="navs">
310 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
311 e7e5fa49 2022-12-30 thomas {{ " | " }}
312 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
315 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
316 e7e5fa49 2022-12-30 thomas {{ end }}
317 e7e5fa49 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
318 2f4f0731 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
319 e7e5fa49 2022-12-30 thomas {{ end }}
321 2f4f0731 2022-12-30 thomas {{ end }}
323 2f4f0731 2022-12-30 thomas {{ define gotweb_render_navs(struct template *tp) }}
325 2f4f0731 2022-12-30 thomas struct request *c = tp->tp_arg;
326 2f4f0731 2022-12-30 thomas struct transport *t = c->t;
327 2f4f0731 2022-12-30 thomas struct gotweb_url prev, next;
328 2f4f0731 2022-12-30 thomas int have_prev, have_next;
330 2f4f0731 2022-12-30 thomas gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
332 2f4f0731 2022-12-30 thomas <div id="np_wrapper">
333 2f4f0731 2022-12-30 thomas <div id="nav_prev">
334 2f4f0731 2022-12-30 thomas {{ if have_prev }}
335 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &prev) }}">
338 2f4f0731 2022-12-30 thomas {{ end }}
340 2f4f0731 2022-12-30 thomas <div id="nav_next">
341 2f4f0731 2022-12-30 thomas {{ if have_next }}
342 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &next) }}">
345 2f4f0731 2022-12-30 thomas {{ end }}
348 2f4f0731 2022-12-30 thomas {{ finally }}
350 2f4f0731 2022-12-30 thomas free(t->next_id);
351 2f4f0731 2022-12-30 thomas t->next_id = NULL;
352 2f4f0731 2022-12-30 thomas free(t->prev_id);
353 2f4f0731 2022-12-30 thomas t->prev_id = NULL;
355 e7e5fa49 2022-12-30 thomas {{ end }}
357 7ade8b27 2022-12-30 thomas {{ define gotweb_render_commits(struct template *tp) }}
359 7ade8b27 2022-12-30 thomas struct request *c = tp->tp_arg;
360 7ade8b27 2022-12-30 thomas struct transport *t = c->t;
361 7ade8b27 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
362 7ade8b27 2022-12-30 thomas struct repo_commit *rc;
363 7ade8b27 2022-12-30 thomas struct gotweb_url diff, tree;
365 7ade8b27 2022-12-30 thomas diff = (struct gotweb_url){
366 7ade8b27 2022-12-30 thomas .action = DIFF,
367 7ade8b27 2022-12-30 thomas .index_page = -1,
368 7ade8b27 2022-12-30 thomas .page = -1,
369 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
371 7ade8b27 2022-12-30 thomas tree = (struct gotweb_url){
372 7ade8b27 2022-12-30 thomas .action = TREE,
373 7ade8b27 2022-12-30 thomas .index_page = -1,
374 7ade8b27 2022-12-30 thomas .page = -1,
375 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
378 7ade8b27 2022-12-30 thomas <div class="commits_title_wrapper">
379 7ade8b27 2022-12-30 thomas <div class="commits_title">Commits</div>
381 7ade8b27 2022-12-30 thomas <div class="commits_content">
382 7ade8b27 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
384 7ade8b27 2022-12-30 thomas diff.commit = rc->commit_id;
385 7ade8b27 2022-12-30 thomas tree.commit = rc->commit_id;
387 7ade8b27 2022-12-30 thomas <div class="commits_header_wrapper">
388 7ade8b27 2022-12-30 thomas <div class="commits_header">
389 7ade8b27 2022-12-30 thomas <div class="header_commit_title">Commit:</div>
390 7ade8b27 2022-12-30 thomas <div class="header_commit">{{ rc->commit_id }}</div>
391 7ade8b27 2022-12-30 thomas <div class="header_author_title">Author:</div>
392 7ade8b27 2022-12-30 thomas <div class="header_author">{{ rc->author }}</div>
393 7ade8b27 2022-12-30 thomas <div class="header_age_title">Date:</div>
394 7ade8b27 2022-12-30 thomas <div class="header_age">
395 7ade8b27 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
399 bbf94fd6 2023-01-02 thomas <div class="dotted_line"></div>
400 bbf94fd6 2023-01-02 thomas <div class="commit">
401 bbf94fd6 2023-01-02 thomas {{ "\n" }}
402 bbf94fd6 2023-01-02 thomas {{ rc->commit_msg }}
404 7ade8b27 2022-12-30 thomas <div class="navs_wrapper">
405 7ade8b27 2022-12-30 thomas <div class="navs">
406 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
407 7ade8b27 2022-12-30 thomas {{ " | " }}
408 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
411 7ade8b27 2022-12-30 thomas <div class="dotted_line"></div>
412 7ade8b27 2022-12-30 thomas {{ end }}
413 7ade8b27 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
414 7ade8b27 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
415 7ade8b27 2022-12-30 thomas {{ end }}
417 b82440e1 2023-01-06 thomas {{ end }}
419 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob(struct template *tp,
420 b82440e1 2023-01-06 thomas struct got_blob_object *blob) }}
422 b82440e1 2023-01-06 thomas struct request *c = tp->tp_arg;
423 b82440e1 2023-01-06 thomas struct transport *t = c->t;
424 b82440e1 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
426 b82440e1 2023-01-06 thomas <div id="blob_title_wrapper">
427 b82440e1 2023-01-06 thomas <div id="blob_title">Blob</div>
429 b82440e1 2023-01-06 thomas <div id="blob_content">
430 b82440e1 2023-01-06 thomas <div id="blob_header_wrapper">
431 b82440e1 2023-01-06 thomas <div id="blob_header">
432 b82440e1 2023-01-06 thomas <div class="header_age_title">Date:</div>
433 b82440e1 2023-01-06 thomas <div class="header_age">
434 b82440e1 2023-01-06 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
436 b82440e1 2023-01-06 thomas <div id="header_commit_msg_title">Message:</div>
437 b82440e1 2023-01-06 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
440 b82440e1 2023-01-06 thomas <div class="dotted_line"></div>
441 b82440e1 2023-01-06 thomas <div id="blob">
443 b82440e1 2023-01-06 thomas {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
447 d6795e9f 2022-12-30 thomas {{ end }}
449 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob_line(struct template *tp, const char *line,
450 b82440e1 2023-01-06 thomas size_t no) }}
452 b82440e1 2023-01-06 thomas char lineno[16];
455 b82440e1 2023-01-06 thomas r = snprintf(lineno, sizeof(lineno), "%zu", no);
456 b82440e1 2023-01-06 thomas if (r < 0 || (size_t)r >= sizeof(lineno))
457 b82440e1 2023-01-06 thomas return -1;
459 b82440e1 2023-01-06 thomas <div class="blob_line" id="line{{ lineno }}">
460 b82440e1 2023-01-06 thomas <div class="blob_number">
461 b82440e1 2023-01-06 thomas <a href="#line{{ lineno }}">{{ lineno }}</a>
463 b82440e1 2023-01-06 thomas <div class="blob_code">{{ line }}</div>
465 3c14c1f2 2023-01-06 thomas {{ end }}
467 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree(struct template *tp) }}
469 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
470 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
471 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
473 3c14c1f2 2023-01-06 thomas <div id="tree_title_wrapper">
474 3c14c1f2 2023-01-06 thomas <div id="tree_title">Tree</div>
476 3c14c1f2 2023-01-06 thomas <div id="tree_content">
477 3c14c1f2 2023-01-06 thomas <div id="tree_header_wrapper">
478 3c14c1f2 2023-01-06 thomas <div id="tree_header">
479 3c14c1f2 2023-01-06 thomas <div id="header_tree_title">Tree:</div>
480 3c14c1f2 2023-01-06 thomas <div id="header_tree">{{ rc->tree_id }}</div>
481 3c14c1f2 2023-01-06 thomas <div class="header_age_title">Date:</div>
482 3c14c1f2 2023-01-06 thomas <div class="header_age">
483 3c14c1f2 2023-01-06 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
485 3c14c1f2 2023-01-06 thomas <div id="header_commit_msg_title">Message:</div>
486 3c14c1f2 2023-01-06 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
489 3c14c1f2 2023-01-06 thomas <div class="dotted_line"></div>
490 3c14c1f2 2023-01-06 thomas <div id="tree">
491 3c14c1f2 2023-01-06 thomas {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
494 3c14c1f2 2023-01-06 thomas {{ end }}
496 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree_item(struct template *tp,
497 3c14c1f2 2023-01-06 thomas struct got_tree_entry *te) }}
499 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
500 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
501 3c14c1f2 2023-01-06 thomas struct querystring *qs = t->qs;
502 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
503 3c14c1f2 2023-01-06 thomas const char *modestr = "";
504 3c14c1f2 2023-01-06 thomas const char *name;
505 3c14c1f2 2023-01-06 thomas const char *folder;
506 3c14c1f2 2023-01-06 thomas char *dir = NULL;
507 3c14c1f2 2023-01-06 thomas mode_t mode;
508 3c14c1f2 2023-01-06 thomas struct gotweb_url url = {
509 3c14c1f2 2023-01-06 thomas .index_page = -1,
510 3c14c1f2 2023-01-06 thomas .page = -1,
511 3c14c1f2 2023-01-06 thomas .commit = rc->commit_id,
512 3c14c1f2 2023-01-06 thomas .path = qs->path,
515 3c14c1f2 2023-01-06 thomas name = got_tree_entry_get_name(te);
516 3c14c1f2 2023-01-06 thomas mode = got_tree_entry_get_mode(te);
518 3c14c1f2 2023-01-06 thomas folder = qs->folder ? qs->folder : "";
519 3c14c1f2 2023-01-06 thomas if (S_ISDIR(mode)) {
520 3c14c1f2 2023-01-06 thomas if (asprintf(&dir, "%s/%s", folder, name) == -1)
521 3c14c1f2 2023-01-06 thomas return (-1);
523 3c14c1f2 2023-01-06 thomas url.action = TREE;
524 3c14c1f2 2023-01-06 thomas url.folder = dir;
526 3c14c1f2 2023-01-06 thomas url.action = BLOB;
527 3c14c1f2 2023-01-06 thomas url.folder = folder;
528 3c14c1f2 2023-01-06 thomas url.file = name;
531 3c14c1f2 2023-01-06 thomas if (got_object_tree_entry_is_submodule(te))
532 3c14c1f2 2023-01-06 thomas modestr = "$";
533 3c14c1f2 2023-01-06 thomas else if (S_ISLNK(mode))
534 3c14c1f2 2023-01-06 thomas modestr = "@";
535 3c14c1f2 2023-01-06 thomas else if (S_ISDIR(mode))
536 3c14c1f2 2023-01-06 thomas modestr = "/";
537 3c14c1f2 2023-01-06 thomas else if (mode & S_IXUSR)
538 3c14c1f2 2023-01-06 thomas modestr = "*";
540 3c14c1f2 2023-01-06 thomas <div class="tree_wrapper">
541 3c14c1f2 2023-01-06 thomas {{ if S_ISDIR(mode) }}
542 3c14c1f2 2023-01-06 thomas <div class="tree_line">
543 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
544 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
547 3c14c1f2 2023-01-06 thomas <div class="tree_line_blank"> </div>
548 3c14c1f2 2023-01-06 thomas {{ else }}
549 3c14c1f2 2023-01-06 thomas <div class="tree_line">
550 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
551 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
554 3c14c1f2 2023-01-06 thomas <div class="tree_line_blank">
555 3c14c1f2 2023-01-06 thomas {! url.action = COMMITS; !}
556 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
559 3c14c1f2 2023-01-06 thomas {{ " | " }}
560 3c14c1f2 2023-01-06 thomas {! url.action = BLAME; !}
561 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
565 3c14c1f2 2023-01-06 thomas {{ end }}
567 3c14c1f2 2023-01-06 thomas {{ finally }}
569 3c14c1f2 2023-01-06 thomas free(dir);
571 617497a6 2023-01-09 thomas {{ end }}
573 617497a6 2023-01-09 thomas {{ define gotweb_render_tags_tmpl(struct template *tp) }}
575 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
576 617497a6 2023-01-09 thomas struct transport *t = c->t;
577 617497a6 2023-01-09 thomas struct querystring *qs = t->qs;
578 617497a6 2023-01-09 thomas struct repo_tag *rt;
579 617497a6 2023-01-09 thomas int commit_found;
581 617497a6 2023-01-09 thomas commit_found = qs->commit == NULL;
583 617497a6 2023-01-09 thomas <div id="tags_title_wrapper">
584 617497a6 2023-01-09 thomas <div id="tags_title">Tags</div>
586 617497a6 2023-01-09 thomas <div id="tags_content">
587 617497a6 2023-01-09 thomas {{ if t->tag_count == 0 }}
588 617497a6 2023-01-09 thomas <div id="err_content">
589 617497a6 2023-01-09 thomas This repository contains no tags
591 617497a6 2023-01-09 thomas {{ else }}
592 617497a6 2023-01-09 thomas {{ tailq-foreach rt &t->repo_tags entry }}
593 617497a6 2023-01-09 thomas {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
594 617497a6 2023-01-09 thomas {! commit_found = 1; !}
595 617497a6 2023-01-09 thomas {{ render tag_item(tp, rt) }}
596 617497a6 2023-01-09 thomas {{ end }}
597 617497a6 2023-01-09 thomas {{ end }}
598 617497a6 2023-01-09 thomas {{ if t->next_id || t->prev_id }}
599 617497a6 2023-01-09 thomas {{ render gotweb_render_navs(tp) }}
600 617497a6 2023-01-09 thomas {{ end }}
601 617497a6 2023-01-09 thomas {{ end }}
603 b82440e1 2023-01-06 thomas {{ end }}
605 617497a6 2023-01-09 thomas {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
607 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
608 617497a6 2023-01-09 thomas struct transport *t = c->t;
609 617497a6 2023-01-09 thomas struct repo_dir *repo_dir = t->repo_dir;
610 617497a6 2023-01-09 thomas char *tag_name = rt->tag_name;
611 617497a6 2023-01-09 thomas char *msg = rt->tag_commit;
612 617497a6 2023-01-09 thomas char *nl;
613 617497a6 2023-01-09 thomas struct gotweb_url url = {
614 617497a6 2023-01-09 thomas .action = TAG,
615 617497a6 2023-01-09 thomas .index_page = -1,
616 617497a6 2023-01-09 thomas .page = -1,
617 617497a6 2023-01-09 thomas .path = repo_dir->name,
618 617497a6 2023-01-09 thomas .commit = rt->commit_id,
621 617497a6 2023-01-09 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
622 617497a6 2023-01-09 thomas tag_name += 10;
624 617497a6 2023-01-09 thomas if (msg) {
625 617497a6 2023-01-09 thomas nl = strchr(msg, '\n');
627 617497a6 2023-01-09 thomas *nl = '\0';
630 617497a6 2023-01-09 thomas <div class="tag_age">
631 617497a6 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_DIFF) }}
633 617497a6 2023-01-09 thomas <div class="tag">{{ tag_name }}</div>
634 617497a6 2023-01-09 thomas <div class="tag_log">
635 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
636 617497a6 2023-01-09 thomas {{ msg }}
639 617497a6 2023-01-09 thomas <div class="navs_wrapper">
640 617497a6 2023-01-09 thomas <div class="navs">
641 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
642 617497a6 2023-01-09 thomas {{ " | " }}
643 617497a6 2023-01-09 thomas {! url.action = BRIEFS; !}
644 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
645 617497a6 2023-01-09 thomas {{ " | " }}
646 617497a6 2023-01-09 thomas {! url.action = COMMITS; !}
647 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
650 617497a6 2023-01-09 thomas <div class="dotted_line"></div>
651 617497a6 2023-01-09 thomas {{ end }}
653 145ca42a 2023-01-09 thomas {{ define gotweb_render_tag(struct template *tp) }}
655 145ca42a 2023-01-09 thomas struct request *c = tp->tp_arg;
656 145ca42a 2023-01-09 thomas struct transport *t = c->t;
657 145ca42a 2023-01-09 thomas struct repo_tag *rt;
658 145ca42a 2023-01-09 thomas const char *tag_name;
660 145ca42a 2023-01-09 thomas rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
661 145ca42a 2023-01-09 thomas tag_name = rt->tag_name;
663 145ca42a 2023-01-09 thomas if (strncmp(tag_name, "refs/", 5) == 0)
664 145ca42a 2023-01-09 thomas tag_name += 5;
666 145ca42a 2023-01-09 thomas <div id="tags_title_wrapper">
667 145ca42a 2023-01-09 thomas <div id="tags_title">Tag</div>
669 145ca42a 2023-01-09 thomas <div id="tags_content">
670 145ca42a 2023-01-09 thomas <div id="tag_header_wrapper">
671 145ca42a 2023-01-09 thomas <div id="tag_header">
672 145ca42a 2023-01-09 thomas <div class="header_commit_title">Commit:</div>
673 145ca42a 2023-01-09 thomas <div class="header_commit">
674 145ca42a 2023-01-09 thomas {{ rt->commit_id }}
675 145ca42a 2023-01-09 thomas {{ " " }}
676 145ca42a 2023-01-09 thomas <span class="refs_str">({{ tag_name }})</span>
678 145ca42a 2023-01-09 thomas <div class="header_author_title">Tagger:</div>
679 145ca42a 2023-01-09 thomas <div class="header_author">{{ rt->tagger }}</div>
680 145ca42a 2023-01-09 thomas <div class="header_age_title">Date:</div>
681 145ca42a 2023-01-09 thomas <div class="header_age">
682 145ca42a 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_LONG)}}
684 145ca42a 2023-01-09 thomas <div id="header_commit_msg_title">Message:</div>
685 145ca42a 2023-01-09 thomas <div id="header_commit_msg">{{ rt->commit_msg }}</div>
687 145ca42a 2023-01-09 thomas <div class="dotted_line"></div>
688 145ca42a 2023-01-09 thomas <div id="tag_commit">
689 145ca42a 2023-01-09 thomas {{ "\n" }}
690 145ca42a 2023-01-09 thomas {{ rt->tag_commit }}
694 dccd05b4 2023-01-10 thomas {{ end }}
696 dccd05b4 2023-01-10 thomas {{ define gotweb_render_diff(struct template *tp, FILE *fp) }}
698 dccd05b4 2023-01-10 thomas struct request *c = tp->tp_arg;
699 dccd05b4 2023-01-10 thomas struct transport *t = c->t;
700 dccd05b4 2023-01-10 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
701 dccd05b4 2023-01-10 thomas char *line = NULL;
702 dccd05b4 2023-01-10 thomas size_t linesize = 0;
703 dccd05b4 2023-01-10 thomas ssize_t linelen;
705 dccd05b4 2023-01-10 thomas <div id="diff_title_wrapper">
706 dccd05b4 2023-01-10 thomas <div id="diff_title">Commit Diff</div>
708 dccd05b4 2023-01-10 thomas <div id="diff_content">
709 dccd05b4 2023-01-10 thomas <div id="diff_header_wrapper">
710 dccd05b4 2023-01-10 thomas <div id="diff_header">
711 dccd05b4 2023-01-10 thomas <div id="header_diff_title">Diff:</div>
712 dccd05b4 2023-01-10 thomas <div id="header_diff">
713 dccd05b4 2023-01-10 thomas {{ rc->parent_id }}
715 dccd05b4 2023-01-10 thomas {{ rc->commit_id }}
717 dccd05b4 2023-01-10 thomas <div class="header_commit_title">Commit:</div>
718 dccd05b4 2023-01-10 thomas <div class="header_commit">{{ rc->commit_id }}</div>
719 dccd05b4 2023-01-10 thomas <div id="header_tree_title">Tree:</div>
720 dccd05b4 2023-01-10 thomas <div id="header_tree">{{ rc->tree_id }}</div>
721 dccd05b4 2023-01-10 thomas <div class="header_author_title">Author:</div>
722 dccd05b4 2023-01-10 thomas <div class="header_author">{{ rc->author }}</div>
723 dccd05b4 2023-01-10 thomas <div class="header_age_title">Date:</div>
724 dccd05b4 2023-01-10 thomas <div class="header_age">
725 dccd05b4 2023-01-10 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
727 dccd05b4 2023-01-10 thomas <div id="header_commit_msg_title">Message</div>
728 dccd05b4 2023-01-10 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
731 dccd05b4 2023-01-10 thomas <div class="dotted_line"></div>
732 dccd05b4 2023-01-10 thomas <div id="diff">
733 dccd05b4 2023-01-10 thomas {{ "\n" }}
734 dccd05b4 2023-01-10 thomas {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
735 dccd05b4 2023-01-10 thomas {{ render diff_line(tp, line) }}
736 dccd05b4 2023-01-10 thomas {{ end }}
739 dccd05b4 2023-01-10 thomas {{ finally }}
740 dccd05b4 2023-01-10 thomas {! free(line); !}
741 145ca42a 2023-01-09 thomas {{ end }}
743 dccd05b4 2023-01-10 thomas {{ define diff_line(struct template *tp, char *line )}}
745 dccd05b4 2023-01-10 thomas const char *color = NULL;
746 dccd05b4 2023-01-10 thomas char *nl;
748 dccd05b4 2023-01-10 thomas if (!strncmp(line, "-", 1))
749 dccd05b4 2023-01-10 thomas color = "diff_minus";
750 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "+", 1))
751 dccd05b4 2023-01-10 thomas color = "diff_plus";
752 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "@@", 2))
753 dccd05b4 2023-01-10 thomas color = "diff_chunk_header";
754 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "commit +", 8) ||
755 dccd05b4 2023-01-10 thomas !strncmp(line, "commit -", 8) ||
756 dccd05b4 2023-01-10 thomas !strncmp(line, "blob +", 6) ||
757 dccd05b4 2023-01-10 thomas !strncmp(line, "blob -", 6) ||
758 dccd05b4 2023-01-10 thomas !strncmp(line, "file +", 6) ||
759 dccd05b4 2023-01-10 thomas !strncmp(line, "file -", 6))
760 dccd05b4 2023-01-10 thomas color = "diff_meta";
761 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
762 dccd05b4 2023-01-10 thomas color = "diff_author";
763 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "date:", 5))
764 dccd05b4 2023-01-10 thomas color = "diff_date";
766 dccd05b4 2023-01-10 thomas nl = strchr(line, '\n');
768 dccd05b4 2023-01-10 thomas *nl = '\0';
770 dccd05b4 2023-01-10 thomas <div class="diff_line {{ color }}">{{ line }}</div>
771 dccd05b4 2023-01-10 thomas {{ end }}
773 d6795e9f 2022-12-30 thomas {{ define gotweb_render_rss(struct template *tp) }}
775 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
776 d6795e9f 2022-12-30 thomas struct server *srv = c->srv;
777 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
778 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
779 d6795e9f 2022-12-30 thomas struct repo_tag *rt;
780 d6795e9f 2022-12-30 thomas struct gotweb_url summary = {
781 d6795e9f 2022-12-30 thomas .action = SUMMARY,
782 d6795e9f 2022-12-30 thomas .index_page = -1,
783 d6795e9f 2022-12-30 thomas .page = -1,
784 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
787 d6795e9f 2022-12-30 thomas <?xml version="1.0" encoding="UTF-8"?>
788 d6795e9f 2022-12-30 thomas <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
789 d6795e9f 2022-12-30 thomas <channel>
790 d6795e9f 2022-12-30 thomas <title>Tags of {{ repo_dir->name }}</title>
792 d6795e9f 2022-12-30 thomas <![CDATA[
793 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &summary) }}
796 d6795e9f 2022-12-30 thomas {{ if srv->show_repo_description }}
797 d6795e9f 2022-12-30 thomas <description>{{ repo_dir->description }}</description>
798 d6795e9f 2022-12-30 thomas {{ end }}
799 d6795e9f 2022-12-30 thomas {{ tailq-foreach rt &t->repo_tags entry }}
800 d6795e9f 2022-12-30 thomas {{ render rss_tag_item(tp, rt) }}
801 d6795e9f 2022-12-30 thomas {{ end }}
802 d6795e9f 2022-12-30 thomas </channel>
804 d6795e9f 2022-12-30 thomas {{ end }}
806 d6795e9f 2022-12-30 thomas {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
808 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
809 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
810 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
811 d6795e9f 2022-12-30 thomas char *tag_name = rt->tag_name;
812 d6795e9f 2022-12-30 thomas struct gotweb_url tag = {
813 d6795e9f 2022-12-30 thomas .action = TAG,
814 d6795e9f 2022-12-30 thomas .index_page = -1,
815 d6795e9f 2022-12-30 thomas .page = -1,
816 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
817 d6795e9f 2022-12-30 thomas .commit = rt->commit_id,
820 d6795e9f 2022-12-30 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
821 d6795e9f 2022-12-30 thomas tag_name += 10;
824 d6795e9f 2022-12-30 thomas <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
826 d6795e9f 2022-12-30 thomas <![CDATA[
827 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &tag) }}
830 d6795e9f 2022-12-30 thomas <description>
831 d6795e9f 2022-12-30 thomas <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
832 d6795e9f 2022-12-30 thomas </description>
833 d6795e9f 2022-12-30 thomas {{ render rss_author(tp, rt->tagger) }}
834 d6795e9f 2022-12-30 thomas <guid isPermaLink="false">{{ rt->commit_id }}</guid>
835 d6795e9f 2022-12-30 thomas <pubDate>
836 d6795e9f 2022-12-30 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
837 d6795e9f 2022-12-30 thomas </pubDate>
839 7ade8b27 2022-12-30 thomas {{ end }}
841 d6795e9f 2022-12-30 thomas {{ define rss_author(struct template *tp, char *author) }}
843 d6795e9f 2022-12-30 thomas char *t, *mail;
845 d6795e9f 2022-12-30 thomas /* what to do if the author name contains a paren? */
846 d6795e9f 2022-12-30 thomas if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
847 d6795e9f 2022-12-30 thomas return 0;
849 d6795e9f 2022-12-30 thomas t = strchr(author, '<');
850 d6795e9f 2022-12-30 thomas if (t == NULL)
851 d6795e9f 2022-12-30 thomas return 0;
852 d6795e9f 2022-12-30 thomas *t = '\0';
853 d6795e9f 2022-12-30 thomas mail = t+1;
855 d6795e9f 2022-12-30 thomas while (isspace((unsigned char)*--t))
856 d6795e9f 2022-12-30 thomas *t = '\0';
858 d6795e9f 2022-12-30 thomas t = strchr(mail, '>');
859 d6795e9f 2022-12-30 thomas if (t == NULL)
860 d6795e9f 2022-12-30 thomas return 0;
861 d6795e9f 2022-12-30 thomas *t = '\0';
864 d6795e9f 2022-12-30 thomas {{ mail }} {{" "}} ({{ author }})
865 d6795e9f 2022-12-30 thomas </author>
866 d6795e9f 2022-12-30 thomas {{ end }}