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 ed619ca0 2022-12-14 op #include <imsg.h>
32 43d421de 2023-01-05 op #include "got_object.h"
34 ed619ca0 2022-12-14 op #include "proc.h"
36 ed619ca0 2022-12-14 op #include "gotwebd.h"
37 ed619ca0 2022-12-14 op #include "tmpl.h"
39 298f95fb 2023-01-05 op static int gotweb_render_blob_line(struct template *, const char *, size_t);
40 43d421de 2023-01-05 op static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
42 1abb18e1 2022-12-20 op static inline int rss_tag_item(struct template *, struct repo_tag *);
43 1abb18e1 2022-12-20 op static inline int rss_author(struct template *, char *);
46 ed619ca0 2022-12-14 op gotweb_render_age(struct template *tp, time_t time, int ref_tm)
48 ed619ca0 2022-12-14 op const struct got_error *err;
52 ed619ca0 2022-12-14 op err = gotweb_get_time_str(&age, time, ref_tm);
55 ed619ca0 2022-12-14 op r = tp->tp_puts(tp, age);
62 ed619ca0 2022-12-14 op {{ define gotweb_render_header(struct template *tp) }}
64 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
65 ed619ca0 2022-12-14 op struct server *srv = c->srv;
66 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
67 ed619ca0 2022-12-14 op struct gotweb_url u_path;
68 d19d9fce 2022-12-20 op const char *prfx = c->document_uri;
69 ed619ca0 2022-12-14 op const char *css = srv->custom_css;
71 ed619ca0 2022-12-14 op memset(&u_path, 0, sizeof(u_path));
72 ed619ca0 2022-12-14 op u_path.index_page = -1;
73 ed619ca0 2022-12-14 op u_path.page = -1;
74 ed619ca0 2022-12-14 op u_path.action = SUMMARY;
76 ed619ca0 2022-12-14 op <!doctype html>
79 ed619ca0 2022-12-14 op <meta charset="utf-8" />
80 ed619ca0 2022-12-14 op <title>{{ srv->site_name }}</title>
81 ed619ca0 2022-12-14 op <meta name="viewport" content="initial-scale=.75" />
82 ed619ca0 2022-12-14 op <meta name="msapplication-TileColor" content="#da532c" />
83 ed619ca0 2022-12-14 op <meta name="theme-color" content="#ffffff"/>
84 ed619ca0 2022-12-14 op <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
85 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
86 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
87 ed619ca0 2022-12-14 op <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
88 ed619ca0 2022-12-14 op <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
89 ed619ca0 2022-12-14 op <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
92 ed619ca0 2022-12-14 op <div id="gw_body">
93 ed619ca0 2022-12-14 op <div id="header">
94 ed619ca0 2022-12-14 op <div id="got_link">
95 ed619ca0 2022-12-14 op <a href="{{ srv->logo_url }}" target="_blank">
96 ed619ca0 2022-12-14 op <img src="{{ prfx }}{{ srv->logo }}" />
100 ed619ca0 2022-12-14 op <div id="site_path">
101 ed619ca0 2022-12-14 op <div id="site_link">
102 ed619ca0 2022-12-14 op <a href="?index_page={{ printf "%d", qs->index_page }}">
103 ed619ca0 2022-12-14 op {{ srv->site_link }}
105 ed619ca0 2022-12-14 op {{ if qs->path }}
106 ed619ca0 2022-12-14 op {! u_path.path = qs->path; !}
108 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
109 ed619ca0 2022-12-14 op {{ qs->path }}
112 ed619ca0 2022-12-14 op {{ if qs->action != INDEX }}
113 ed619ca0 2022-12-14 op {{ " / " }}{{ gotweb_action_name(qs->action) }}
117 ed619ca0 2022-12-14 op <div id="content">
120 ed619ca0 2022-12-14 op {{ define gotweb_render_footer(struct template *tp) }}
122 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
123 ed619ca0 2022-12-14 op struct server *srv = c->srv;
125 ed619ca0 2022-12-14 op <div id="site_owner_wrapper">
126 ed619ca0 2022-12-14 op <div id="site_owner">
127 ed619ca0 2022-12-14 op {{ if srv->show_site_owner }}
128 ed619ca0 2022-12-14 op {{ srv->site_owner }}
138 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
140 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
141 ed619ca0 2022-12-14 op struct server *srv = c->srv;
143 ed619ca0 2022-12-14 op <div id="index_header">
144 ed619ca0 2022-12-14 op <div id="index_header_project">
147 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
148 ed619ca0 2022-12-14 op <div id="index_header_description">
152 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
153 ed619ca0 2022-12-14 op <div id="index_header_owner">
157 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
158 ed619ca0 2022-12-14 op <div id="index_header_age">
165 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
167 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
168 ed619ca0 2022-12-14 op struct server *srv = c->srv;
169 ed619ca0 2022-12-14 op struct gotweb_url summary = {
170 ed619ca0 2022-12-14 op .action = SUMMARY,
171 ed619ca0 2022-12-14 op .index_page = -1,
173 ed619ca0 2022-12-14 op .path = repo_dir->name,
174 ed619ca0 2022-12-14 op }, briefs = {
175 ed619ca0 2022-12-14 op .action = BRIEFS,
176 ed619ca0 2022-12-14 op .index_page = -1,
178 ed619ca0 2022-12-14 op .path = repo_dir->name,
179 ed619ca0 2022-12-14 op }, commits = {
180 ed619ca0 2022-12-14 op .action = COMMITS,
181 ed619ca0 2022-12-14 op .index_page = -1,
183 ed619ca0 2022-12-14 op .path = repo_dir->name,
185 ed619ca0 2022-12-14 op .action = TAGS,
186 ed619ca0 2022-12-14 op .index_page = -1,
188 ed619ca0 2022-12-14 op .path = repo_dir->name,
190 ed619ca0 2022-12-14 op .action = TREE,
191 ed619ca0 2022-12-14 op .index_page = -1,
193 ed619ca0 2022-12-14 op .path = repo_dir->name,
195 1abb18e1 2022-12-20 op .action = RSS,
196 1abb18e1 2022-12-20 op .index_page = -1,
198 1abb18e1 2022-12-20 op .path = repo_dir->name,
201 ed619ca0 2022-12-14 op <div class="index_wrapper">
202 ed619ca0 2022-12-14 op <div class="index_project">
203 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
205 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
206 ed619ca0 2022-12-14 op <div class="index_project_description">
207 ed619ca0 2022-12-14 op {{ repo_dir->description }}
210 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
211 ed619ca0 2022-12-14 op <div class="index_project_owner">
212 ed619ca0 2022-12-14 op {{ repo_dir->owner }}
215 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
216 ed619ca0 2022-12-14 op <div class="index_project_age">
217 ed619ca0 2022-12-14 op {{ repo_dir->age }}
220 ed619ca0 2022-12-14 op <div class="navs_wrapper">
221 ed619ca0 2022-12-14 op <div class="navs">
222 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
224 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
226 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
228 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
230 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
232 1abb18e1 2022-12-20 op <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
234 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
239 ed619ca0 2022-12-14 op {{ define gotweb_render_briefs(struct template *tp) }}
241 ed619ca0 2022-12-14 op const struct got_error *error;
242 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
243 ed619ca0 2022-12-14 op struct server *srv = c->srv;
244 ed619ca0 2022-12-14 op struct transport *t = c->t;
245 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
246 ed619ca0 2022-12-14 op struct repo_commit *rc;
247 ed619ca0 2022-12-14 op struct repo_dir *repo_dir = t->repo_dir;
248 ed619ca0 2022-12-14 op struct gotweb_url diff_url, tree_url;
251 ed619ca0 2022-12-14 op diff_url = (struct gotweb_url){
252 ed619ca0 2022-12-14 op .action = DIFF,
253 ed619ca0 2022-12-14 op .index_page = -1,
255 ed619ca0 2022-12-14 op .path = repo_dir->name,
256 ed619ca0 2022-12-14 op .headref = qs->headref,
258 ed619ca0 2022-12-14 op tree_url = (struct gotweb_url){
259 ed619ca0 2022-12-14 op .action = TREE,
260 ed619ca0 2022-12-14 op .index_page = -1,
262 ed619ca0 2022-12-14 op .path = repo_dir->name,
263 ed619ca0 2022-12-14 op .headref = qs->headref,
266 ed619ca0 2022-12-14 op if (qs->action == SUMMARY) {
267 ed619ca0 2022-12-14 op qs->action = BRIEFS;
268 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
270 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, srv->max_commits_display);
274 ed619ca0 2022-12-14 op <div id="briefs_title_wrapper">
275 ed619ca0 2022-12-14 op <div id="briefs_title">Commit Briefs</div>
277 ed619ca0 2022-12-14 op <div id="briefs_content">
278 ed619ca0 2022-12-14 op {{ tailq-foreach rc &t->repo_commits entry }}
280 ed619ca0 2022-12-14 op diff_url.commit = rc->commit_id;
281 ed619ca0 2022-12-14 op tree_url.commit = rc->commit_id;
283 ed619ca0 2022-12-14 op tmp = strchr(rc->author, '<');
287 ed619ca0 2022-12-14 op tmp = strchr(rc->commit_msg, '\n');
291 ed619ca0 2022-12-14 op <div class="briefs_age">
292 ed619ca0 2022-12-14 op {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
294 ed619ca0 2022-12-14 op <div class="briefs_author">
295 ed619ca0 2022-12-14 op {{ rc->author }}
297 ed619ca0 2022-12-14 op <div class="briefs_log">
298 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
299 ed619ca0 2022-12-14 op {{ rc->commit_msg }}
301 ed619ca0 2022-12-14 op {{ if rc->refs_str }}
302 ed619ca0 2022-12-14 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
306 ed619ca0 2022-12-14 op <div class="navs_wrapper">
307 ed619ca0 2022-12-14 op <div class="navs">
308 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
310 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
313 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
315 ed619ca0 2022-12-14 op {{ if t->next_id || t->prev_id }}
316 b4c0bd72 2022-12-17 op {{ render gotweb_render_navs(tp) }}
321 b4c0bd72 2022-12-17 op {{ define gotweb_render_navs(struct template *tp) }}
323 b4c0bd72 2022-12-17 op struct request *c = tp->tp_arg;
324 b4c0bd72 2022-12-17 op struct transport *t = c->t;
325 b4c0bd72 2022-12-17 op struct gotweb_url prev, next;
326 b4c0bd72 2022-12-17 op int have_prev, have_next;
328 b4c0bd72 2022-12-17 op gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
330 b4c0bd72 2022-12-17 op <div id="np_wrapper">
331 b4c0bd72 2022-12-17 op <div id="nav_prev">
332 b4c0bd72 2022-12-17 op {{ if have_prev }}
333 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &prev) }}">
338 b4c0bd72 2022-12-17 op <div id="nav_next">
339 b4c0bd72 2022-12-17 op {{ if have_next }}
340 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &next) }}">
346 b4c0bd72 2022-12-17 op {{ finally }}
348 b4c0bd72 2022-12-17 op free(t->next_id);
349 b4c0bd72 2022-12-17 op t->next_id = NULL;
350 b4c0bd72 2022-12-17 op free(t->prev_id);
351 b4c0bd72 2022-12-17 op t->prev_id = NULL;
355 156a1144 2022-12-17 op {{ define gotweb_render_commits(struct template *tp) }}
357 156a1144 2022-12-17 op struct request *c = tp->tp_arg;
358 156a1144 2022-12-17 op struct transport *t = c->t;
359 156a1144 2022-12-17 op struct repo_dir *repo_dir = t->repo_dir;
360 156a1144 2022-12-17 op struct repo_commit *rc;
361 156a1144 2022-12-17 op struct gotweb_url diff, tree;
363 156a1144 2022-12-17 op diff = (struct gotweb_url){
364 156a1144 2022-12-17 op .action = DIFF,
365 156a1144 2022-12-17 op .index_page = -1,
367 156a1144 2022-12-17 op .path = repo_dir->name,
369 156a1144 2022-12-17 op tree = (struct gotweb_url){
370 156a1144 2022-12-17 op .action = TREE,
371 156a1144 2022-12-17 op .index_page = -1,
373 156a1144 2022-12-17 op .path = repo_dir->name,
376 156a1144 2022-12-17 op <div class="commits_title_wrapper">
377 156a1144 2022-12-17 op <div class="commits_title">Commits</div>
379 156a1144 2022-12-17 op <div class="commits_content">
380 156a1144 2022-12-17 op {{ tailq-foreach rc &t->repo_commits entry }}
382 156a1144 2022-12-17 op diff.commit = rc->commit_id;
383 156a1144 2022-12-17 op tree.commit = rc->commit_id;
385 156a1144 2022-12-17 op <div class="commits_header_wrapper">
386 156a1144 2022-12-17 op <div class="commits_header">
387 156a1144 2022-12-17 op <div class="header_commit_title">Commit:</div>
388 156a1144 2022-12-17 op <div class="header_commit">{{ rc->commit_id }}</div>
389 156a1144 2022-12-17 op <div class="header_author_title">Author:</div>
390 156a1144 2022-12-17 op <div class="header_author">{{ rc->author }}</div>
391 156a1144 2022-12-17 op <div class="header_age_title">Date:</div>
392 156a1144 2022-12-17 op <div class="header_age">
393 156a1144 2022-12-17 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
397 cf536071 2022-12-31 op <div class="dotted_line"></div>
398 cf536071 2022-12-31 op <div class="commit">
400 cf536071 2022-12-31 op {{ rc->commit_msg }}
402 156a1144 2022-12-17 op <div class="navs_wrapper">
403 156a1144 2022-12-17 op <div class="navs">
404 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
406 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
409 156a1144 2022-12-17 op <div class="dotted_line"></div>
411 156a1144 2022-12-17 op {{ if t->next_id || t->prev_id }}
412 156a1144 2022-12-17 op {{ render gotweb_render_navs(tp) }}
417 298f95fb 2023-01-05 op {{ define gotweb_render_blob(struct template *tp,
418 298f95fb 2023-01-05 op struct got_blob_object *blob) }}
420 298f95fb 2023-01-05 op struct request *c = tp->tp_arg;
421 298f95fb 2023-01-05 op struct transport *t = c->t;
422 298f95fb 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
424 298f95fb 2023-01-05 op <div id="blob_title_wrapper">
425 298f95fb 2023-01-05 op <div id="blob_title">Blob</div>
427 298f95fb 2023-01-05 op <div id="blob_content">
428 298f95fb 2023-01-05 op <div id="blob_header_wrapper">
429 298f95fb 2023-01-05 op <div id="blob_header">
430 298f95fb 2023-01-05 op <div class="header_age_title">Date:</div>
431 298f95fb 2023-01-05 op <div class="header_age">
432 298f95fb 2023-01-05 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
434 298f95fb 2023-01-05 op <div id="header_commit_msg_title">Message:</div>
435 298f95fb 2023-01-05 op <div id="header_commit_msg">{{ rc->commit_msg }}</div>
438 298f95fb 2023-01-05 op <div class="dotted_line"></div>
439 298f95fb 2023-01-05 op <div id="blob">
441 298f95fb 2023-01-05 op {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
447 298f95fb 2023-01-05 op {{ define gotweb_render_blob_line(struct template *tp, const char *line,
448 298f95fb 2023-01-05 op size_t no) }}
450 298f95fb 2023-01-05 op char lineno[16];
453 298f95fb 2023-01-05 op r = snprintf(lineno, sizeof(lineno), "%zu", no);
454 298f95fb 2023-01-05 op if (r < 0 || (size_t)r >= sizeof(lineno))
457 298f95fb 2023-01-05 op <div class="blob_line" id="line{{ lineno }}">
458 298f95fb 2023-01-05 op <div class="blob_number">
459 298f95fb 2023-01-05 op <a href="#line{{ lineno }}">{{ lineno }}</a>
461 298f95fb 2023-01-05 op <div class="blob_code">{{ line }}</div>
465 43d421de 2023-01-05 op {{ define gotweb_render_tree(struct template *tp) }}
467 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
468 43d421de 2023-01-05 op struct transport *t = c->t;
469 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
471 43d421de 2023-01-05 op <div id="tree_title_wrapper">
472 43d421de 2023-01-05 op <div id="tree_title">Tree</div>
474 43d421de 2023-01-05 op <div id="tree_content">
475 43d421de 2023-01-05 op <div id="tree_header_wrapper">
476 43d421de 2023-01-05 op <div id="tree_header">
477 43d421de 2023-01-05 op <div id="header_tree_title">Tree:</div>
478 43d421de 2023-01-05 op <div id="header_tree">{{ rc->tree_id }}</div>
479 43d421de 2023-01-05 op <div class="header_age_title">Date:</div>
480 43d421de 2023-01-05 op <div class="header_age">
481 43d421de 2023-01-05 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
483 43d421de 2023-01-05 op <div id="header_commit_msg_title">Message:</div>
484 43d421de 2023-01-05 op <div id="header_commit_msg">{{ rc->commit_msg }}</div>
487 43d421de 2023-01-05 op <div class="dotted_line"></div>
488 43d421de 2023-01-05 op <div id="tree">
489 43d421de 2023-01-05 op {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
494 43d421de 2023-01-05 op {{ define gotweb_render_tree_item(struct template *tp,
495 43d421de 2023-01-05 op struct got_tree_entry *te) }}
497 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
498 43d421de 2023-01-05 op struct transport *t = c->t;
499 43d421de 2023-01-05 op struct querystring *qs = t->qs;
500 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
501 43d421de 2023-01-05 op const char *modestr = "";
502 43d421de 2023-01-05 op const char *name;
503 43d421de 2023-01-05 op const char *folder;
504 43d421de 2023-01-05 op char *dir = NULL;
506 43d421de 2023-01-05 op struct gotweb_url url = {
507 43d421de 2023-01-05 op .index_page = -1,
509 43d421de 2023-01-05 op .commit = rc->commit_id,
510 43d421de 2023-01-05 op .path = qs->path,
513 43d421de 2023-01-05 op name = got_tree_entry_get_name(te);
514 43d421de 2023-01-05 op mode = got_tree_entry_get_mode(te);
516 43d421de 2023-01-05 op folder = qs->folder ? qs->folder : "";
517 43d421de 2023-01-05 op if (S_ISDIR(mode)) {
518 43d421de 2023-01-05 op if (asprintf(&dir, "%s/%s", folder, name) == -1)
521 43d421de 2023-01-05 op url.action = TREE;
522 43d421de 2023-01-05 op url.folder = dir;
524 43d421de 2023-01-05 op url.action = BLOB;
525 43d421de 2023-01-05 op url.folder = folder;
526 43d421de 2023-01-05 op url.file = name;
529 43d421de 2023-01-05 op if (got_object_tree_entry_is_submodule(te))
530 43d421de 2023-01-05 op modestr = "$";
531 43d421de 2023-01-05 op else if (S_ISLNK(mode))
532 43d421de 2023-01-05 op modestr = "@";
533 43d421de 2023-01-05 op else if (S_ISDIR(mode))
534 43d421de 2023-01-05 op modestr = "/";
535 43d421de 2023-01-05 op else if (mode & S_IXUSR)
536 43d421de 2023-01-05 op modestr = "*";
538 43d421de 2023-01-05 op <div class="tree_wrapper">
539 43d421de 2023-01-05 op {{ if S_ISDIR(mode) }}
540 43d421de 2023-01-05 op <div class="tree_line">
541 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
542 43d421de 2023-01-05 op {{ name }}{{ modestr }}
545 43d421de 2023-01-05 op <div class="tree_line_blank"> </div>
547 43d421de 2023-01-05 op <div class="tree_line">
548 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
549 43d421de 2023-01-05 op {{ name }}{{ modestr }}
552 43d421de 2023-01-05 op <div class="tree_line_blank">
553 43d421de 2023-01-05 op {! url.action = COMMITS; !}
554 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
558 43d421de 2023-01-05 op {! url.action = BLAME; !}
559 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
565 43d421de 2023-01-05 op {{ finally }}
571 1abb18e1 2022-12-20 op {{ define gotweb_render_rss(struct template *tp) }}
573 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
574 1abb18e1 2022-12-20 op struct server *srv = c->srv;
575 1abb18e1 2022-12-20 op struct transport *t = c->t;
576 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
577 1abb18e1 2022-12-20 op struct repo_tag *rt;
578 1abb18e1 2022-12-20 op struct gotweb_url summary = {
579 1abb18e1 2022-12-20 op .action = SUMMARY,
580 1abb18e1 2022-12-20 op .index_page = -1,
582 1abb18e1 2022-12-20 op .path = repo_dir->name,
585 1abb18e1 2022-12-20 op <?xml version="1.0" encoding="UTF-8"?>
586 1abb18e1 2022-12-20 op <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
588 1abb18e1 2022-12-20 op <title>Tags of {{ repo_dir->name }}</title>
591 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &summary) }}
594 1abb18e1 2022-12-20 op {{ if srv->show_repo_description }}
595 1abb18e1 2022-12-20 op <description>{{ repo_dir->description }}</description>
597 1abb18e1 2022-12-20 op {{ tailq-foreach rt &t->repo_tags entry }}
598 1abb18e1 2022-12-20 op {{ render rss_tag_item(tp, rt) }}
604 1abb18e1 2022-12-20 op {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
606 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
607 1abb18e1 2022-12-20 op struct transport *t = c->t;
608 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
609 1abb18e1 2022-12-20 op char *tag_name = rt->tag_name;
610 1abb18e1 2022-12-20 op struct gotweb_url tag = {
611 1abb18e1 2022-12-20 op .action = TAG,
612 1abb18e1 2022-12-20 op .index_page = -1,
614 1abb18e1 2022-12-20 op .path = repo_dir->name,
615 1abb18e1 2022-12-20 op .commit = rt->commit_id,
618 1abb18e1 2022-12-20 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
619 1abb18e1 2022-12-20 op tag_name += 10;
622 1abb18e1 2022-12-20 op <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
625 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &tag) }}
628 1abb18e1 2022-12-20 op <description>
629 1abb18e1 2022-12-20 op <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
630 1abb18e1 2022-12-20 op </description>
631 1abb18e1 2022-12-20 op {{ render rss_author(tp, rt->tagger) }}
632 1abb18e1 2022-12-20 op <guid isPermaLink="false">{{ rt->commit_id }}</guid>
634 1abb18e1 2022-12-20 op {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
639 1abb18e1 2022-12-20 op {{ define rss_author(struct template *tp, char *author) }}
641 1abb18e1 2022-12-20 op char *t, *mail;
643 1abb18e1 2022-12-20 op /* what to do if the author name contains a paren? */
644 1abb18e1 2022-12-20 op if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
647 1abb18e1 2022-12-20 op t = strchr(author, '<');
648 1abb18e1 2022-12-20 op if (t == NULL)
653 1abb18e1 2022-12-20 op while (isspace((unsigned char)*--t))
656 1abb18e1 2022-12-20 op t = strchr(mail, '>');
657 1abb18e1 2022-12-20 op if (t == NULL)
662 1abb18e1 2022-12-20 op {{ mail }} {{" "}} ({{ author }})