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 "gotwebd.h"
38 1220d7ea 2024-05-21 op #include "log.h"
39 ed619ca0 2022-12-14 op #include "tmpl.h"
41 7781b991 2023-10-05 op enum gotweb_ref_tm {
46 c2abf03c 2023-11-30 op static int breadcumbs(struct template *);
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 8957da7c 2023-12-08 op static inline int tree_listing(struct template *);
56 587550a5 2023-01-10 op static inline int diff_line(struct template *, char *);
57 067396e6 2023-01-09 op static inline int tag_item(struct template *, struct repo_tag *);
58 3ab2c914 2023-01-11 op static inline int branch(struct template *, struct got_reflist_entry *);
59 1abb18e1 2022-12-20 op static inline int rss_tag_item(struct template *, struct repo_tag *);
60 1abb18e1 2022-12-20 op static inline int rss_author(struct template *, char *);
62 c2abf03c 2023-11-30 op static inline char *
63 c2abf03c 2023-11-30 op nextsep(char *s, char **t)
67 c2abf03c 2023-11-30 op while (*s == '/')
70 c2abf03c 2023-11-30 op if (*s == '\0')
73 c2abf03c 2023-11-30 op q = strchr(s, '/');
74 c2abf03c 2023-11-30 op if (q == NULL)
75 c2abf03c 2023-11-30 op q = strchr(s, '\0');
81 7781b991 2023-10-05 op {{ define datetime(struct template *tp, time_t t, int fmt) }}
84 7781b991 2023-10-05 op char rfc3339[64];
85 7781b991 2023-10-05 op char datebuf[64];
87 7781b991 2023-10-05 op if (gmtime_r(&t, &tm) == NULL)
90 7781b991 2023-10-05 op if (strftime(rfc3339, sizeof(rfc3339), "%FT%TZ", &tm) == 0)
93 7781b991 2023-10-05 op if (fmt != TM_DIFF && asctime_r(&tm, datebuf) == NULL)
96 7781b991 2023-10-05 op <time datetime="{{ rfc3339 }}">
97 7781b991 2023-10-05 op {{ if fmt == TM_DIFF }}
98 7781b991 2023-10-05 op {{ render gotweb_render_age(tp, t) }}
100 7781b991 2023-10-05 op {{ datebuf }} {{ " UTC" }}
105 c2abf03c 2023-11-30 op {{ define breadcumbs(struct template *tp) }}
107 c2abf03c 2023-11-30 op struct request *c = tp->tp_arg;
108 c2abf03c 2023-11-30 op struct querystring *qs = c->t->qs;
109 c2abf03c 2023-11-30 op struct gotweb_url url;
110 c2abf03c 2023-11-30 op const char *folder = qs->folder;
111 d0b9836b 2023-12-03 op const char *action = "tree";
112 c2abf03c 2023-11-30 op char *t, *s = NULL, *dir = NULL;
115 c2abf03c 2023-11-30 op memset(&url, 0, sizeof(url));
116 c2abf03c 2023-11-30 op url.index_page = -1;
117 c2abf03c 2023-11-30 op url.action = TREE;
118 c2abf03c 2023-11-30 op url.path = qs->path;
119 c2abf03c 2023-11-30 op url.commit = qs->commit;
121 d0b9836b 2023-12-03 op if (qs->action != TREE && qs->action != BLOB) {
122 d0b9836b 2023-12-03 op action = gotweb_action_name(qs->action);
123 d0b9836b 2023-12-03 op url.action = qs->action;
126 c2abf03c 2023-11-30 op if (folder && *folder != '\0') {
127 c2abf03c 2023-11-30 op while (*folder == '/')
129 c2abf03c 2023-11-30 op dir = strdup(folder);
130 c2abf03c 2023-11-30 op if (dir == NULL)
136 d0b9836b 2023-12-03 op <a href="{{ render gotweb_render_url(c, &url) }}">{{ action }}</a>
139 c2abf03c 2023-11-30 op {{ while (s = nextsep(s, &t)) != NULL }}
143 c2abf03c 2023-11-30 op url.folder = dir;
146 c2abf03c 2023-11-30 op <a href="{{ render gotweb_render_url(c, &url) }}">
151 c2abf03c 2023-11-30 op {! *s = ch; !}
155 c2abf03c 2023-11-30 op {{ if qs->file }}
156 c2abf03c 2023-11-30 op {{ qs->file }}
159 c2abf03c 2023-11-30 op {{ finally }}
160 c2abf03c 2023-11-30 op {! free(dir); !}
163 df2d3cd2 2023-03-11 op {{ define gotweb_render_page(struct template *tp,
164 df2d3cd2 2023-03-11 op int (*body)(struct template *)) }}
166 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
167 ed619ca0 2022-12-14 op struct server *srv = c->srv;
168 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
169 ed619ca0 2022-12-14 op struct gotweb_url u_path;
170 d19d9fce 2022-12-20 op const char *prfx = c->document_uri;
171 ed619ca0 2022-12-14 op const char *css = srv->custom_css;
173 ed619ca0 2022-12-14 op memset(&u_path, 0, sizeof(u_path));
174 ed619ca0 2022-12-14 op u_path.index_page = -1;
175 ed619ca0 2022-12-14 op u_path.action = SUMMARY;
177 ed619ca0 2022-12-14 op <!doctype html>
180 ed619ca0 2022-12-14 op <meta charset="utf-8" />
181 ed619ca0 2022-12-14 op <title>{{ srv->site_name }}</title>
182 424803ac 2023-09-12 op <meta name="viewport" content="initial-scale=1.0" />
183 ed619ca0 2022-12-14 op <meta name="msapplication-TileColor" content="#da532c" />
184 ed619ca0 2022-12-14 op <meta name="theme-color" content="#ffffff"/>
185 ed619ca0 2022-12-14 op <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
186 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
187 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
188 ed619ca0 2022-12-14 op <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
189 ed619ca0 2022-12-14 op <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
190 ed619ca0 2022-12-14 op <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
193 424803ac 2023-09-12 op <header id="header">
194 424803ac 2023-09-12 op <div id="got_link">
195 424803ac 2023-09-12 op <a href="{{ srv->logo_url }}" target="_blank">
196 424803ac 2023-09-12 op <img src="{{ prfx }}{{ srv->logo }}" />
200 424803ac 2023-09-12 op <nav id="site_path">
201 424803ac 2023-09-12 op <div id="site_link">
202 424803ac 2023-09-12 op <a href="?index_page={{ printf "%d", qs->index_page }}">
203 424803ac 2023-09-12 op {{ srv->site_link }}
205 424803ac 2023-09-12 op {{ if qs->path }}
206 424803ac 2023-09-12 op {! u_path.path = qs->path; !}
208 424803ac 2023-09-12 op <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
209 424803ac 2023-09-12 op {{ qs->path }}
212 d0b9836b 2023-12-03 op {{ if qs->action == SUMMARY || qs->action == DIFF ||
213 d0b9836b 2023-12-03 op qs->action == TAG || qs->action == TAGS }}
214 424803ac 2023-09-12 op {{ " / " }}{{ gotweb_action_name(qs->action) }}
215 d0b9836b 2023-12-03 op {{ else if qs->action != INDEX}}
216 d0b9836b 2023-12-03 op {{ render breadcumbs(tp) }}
221 424803ac 2023-09-12 op {{ render body(tp) }}
223 424803ac 2023-09-12 op <footer id="site_owner_wrapper">
224 424803ac 2023-09-12 op <p id="site_owner">
225 424803ac 2023-09-12 op {{ if srv->show_site_owner }}
226 424803ac 2023-09-12 op {{ srv->site_owner }}
234 8f37175d 2023-03-11 op {{ define gotweb_render_error(struct template *tp) }}
236 8f37175d 2023-03-11 op struct request *c = tp->tp_arg;
237 8f37175d 2023-03-11 op struct transport *t = c->t;
239 8f37175d 2023-03-11 op <div id="err_content">
240 8f37175d 2023-03-11 op {{ if t->error }}
241 8f37175d 2023-03-11 op {{ t->error->msg }}
243 8f37175d 2023-03-11 op See daemon logs for details
248 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
250 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
251 ed619ca0 2022-12-14 op struct server *srv = c->srv;
253 ed619ca0 2022-12-14 op <div id="index_header">
254 424803ac 2023-09-12 op <div class="index_project">
257 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
258 424803ac 2023-09-12 op <div class="index_project_description">
262 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
263 424803ac 2023-09-12 op <div class="index_project_owner">
267 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
268 424803ac 2023-09-12 op <div class="index_project_age">
275 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
277 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
278 ed619ca0 2022-12-14 op struct server *srv = c->srv;
279 ed619ca0 2022-12-14 op struct gotweb_url summary = {
280 ed619ca0 2022-12-14 op .action = SUMMARY,
281 ed619ca0 2022-12-14 op .index_page = -1,
282 ed619ca0 2022-12-14 op .path = repo_dir->name,
283 ed619ca0 2022-12-14 op }, briefs = {
284 ed619ca0 2022-12-14 op .action = BRIEFS,
285 ed619ca0 2022-12-14 op .index_page = -1,
286 ed619ca0 2022-12-14 op .path = repo_dir->name,
287 ed619ca0 2022-12-14 op }, commits = {
288 ed619ca0 2022-12-14 op .action = COMMITS,
289 ed619ca0 2022-12-14 op .index_page = -1,
290 ed619ca0 2022-12-14 op .path = repo_dir->name,
292 ed619ca0 2022-12-14 op .action = TAGS,
293 ed619ca0 2022-12-14 op .index_page = -1,
294 ed619ca0 2022-12-14 op .path = repo_dir->name,
296 ed619ca0 2022-12-14 op .action = TREE,
297 ed619ca0 2022-12-14 op .index_page = -1,
298 ed619ca0 2022-12-14 op .path = repo_dir->name,
300 1abb18e1 2022-12-20 op .action = RSS,
301 1abb18e1 2022-12-20 op .index_page = -1,
302 1abb18e1 2022-12-20 op .path = repo_dir->name,
305 ed619ca0 2022-12-14 op <div class="index_wrapper">
306 ed619ca0 2022-12-14 op <div class="index_project">
307 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
309 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
310 ed619ca0 2022-12-14 op <div class="index_project_description">
311 ed619ca0 2022-12-14 op {{ repo_dir->description }}
314 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
315 ed619ca0 2022-12-14 op <div class="index_project_owner">
316 ed619ca0 2022-12-14 op {{ repo_dir->owner }}
319 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
320 ed619ca0 2022-12-14 op <div class="index_project_age">
321 7781b991 2023-10-05 op {{ render datetime(tp, repo_dir->age, TM_DIFF) }}
324 ed619ca0 2022-12-14 op <div class="navs_wrapper">
325 ed619ca0 2022-12-14 op <div class="navs">
326 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
328 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
330 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
332 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
334 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
336 1abb18e1 2022-12-20 op <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
343 ed619ca0 2022-12-14 op {{ define gotweb_render_briefs(struct template *tp) }}
345 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
346 ed619ca0 2022-12-14 op struct transport *t = c->t;
347 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
348 ed619ca0 2022-12-14 op struct repo_commit *rc;
349 ed619ca0 2022-12-14 op struct repo_dir *repo_dir = t->repo_dir;
350 7f65bb55 2023-12-01 op struct gotweb_url diff_url, patch_url, tree_url;
351 976ccb69 2023-12-08 op char *tmp, *body;
353 ed619ca0 2022-12-14 op diff_url = (struct gotweb_url){
354 ed619ca0 2022-12-14 op .action = DIFF,
355 7f65bb55 2023-12-01 op .index_page = -1,
356 7f65bb55 2023-12-01 op .path = repo_dir->name,
357 7f65bb55 2023-12-01 op .headref = qs->headref,
359 7f65bb55 2023-12-01 op patch_url = (struct gotweb_url){
360 7f65bb55 2023-12-01 op .action = PATCH,
361 ed619ca0 2022-12-14 op .index_page = -1,
362 ed619ca0 2022-12-14 op .path = repo_dir->name,
363 ed619ca0 2022-12-14 op .headref = qs->headref,
365 ed619ca0 2022-12-14 op tree_url = (struct gotweb_url){
366 ed619ca0 2022-12-14 op .action = TREE,
367 ed619ca0 2022-12-14 op .index_page = -1,
368 ed619ca0 2022-12-14 op .path = repo_dir->name,
369 ed619ca0 2022-12-14 op .headref = qs->headref,
372 424803ac 2023-09-12 op <header class='subtitle'>
373 424803ac 2023-09-12 op <h2>Commit Briefs</h2>
375 ed619ca0 2022-12-14 op <div id="briefs_content">
376 ed619ca0 2022-12-14 op {{ tailq-foreach rc &t->repo_commits entry }}
378 ed619ca0 2022-12-14 op diff_url.commit = rc->commit_id;
379 7f65bb55 2023-12-01 op patch_url.commit = rc->commit_id;
380 ed619ca0 2022-12-14 op tree_url.commit = rc->commit_id;
382 6c3d3263 2023-01-10 op tmp = strchr(rc->committer, '<');
386 976ccb69 2023-12-08 op body = strchr(rc->commit_msg, '\n');
388 976ccb69 2023-12-08 op *body++ = '\0';
389 976ccb69 2023-12-08 op while (*body == '\n')
393 424803ac 2023-09-12 op <div class='brief'>
394 424803ac 2023-09-12 op <p class='brief_meta'>
395 424803ac 2023-09-12 op <span class='briefs_age'>
396 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_DIFF) }}
399 424803ac 2023-09-12 op <span class="briefs_author">
400 424803ac 2023-09-12 op {{ rc->committer }}
403 976ccb69 2023-12-08 op {{ if body && *body != '\0' }}
404 976ccb69 2023-12-08 op <details class="briefs_log">
406 976ccb69 2023-12-08 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
407 976ccb69 2023-12-08 op {{ rc->commit_msg }}
409 976ccb69 2023-12-08 op {{ if rc->refs_str }}
410 976ccb69 2023-12-08 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
413 976ccb69 2023-12-08 op <span class="briefs_toggle" aria-hidden="true">
414 976ccb69 2023-12-08 op {{ " â‹…â‹…â‹… " }}
418 976ccb69 2023-12-08 op <p>{{ body }}</p>
421 976ccb69 2023-12-08 op <p class="briefs_log">
422 976ccb69 2023-12-08 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
423 976ccb69 2023-12-08 op {{ rc->commit_msg }}
425 976ccb69 2023-12-08 op {{ if rc->refs_str }}
426 976ccb69 2023-12-08 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
431 ed619ca0 2022-12-14 op <div class="navs_wrapper">
432 ed619ca0 2022-12-14 op <div class="navs">
433 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
435 7f65bb55 2023-12-01 op <a href="{{ render gotweb_render_url(tp->tp_arg, &patch_url) }}">patch</a>
437 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
442 e3662697 2023-02-03 op {{ render gotweb_render_more(tp, BRIEFS) }}
446 e3662697 2023-02-03 op {{ define gotweb_render_more(struct template *tp, int action) }}
448 e3662697 2023-02-03 op struct request *c = tp->tp_arg;
449 e3662697 2023-02-03 op struct transport *t = c->t;
450 e3662697 2023-02-03 op struct querystring *qs = t->qs;
451 e3662697 2023-02-03 op struct gotweb_url more = {
452 e3662697 2023-02-03 op .action = action,
453 e3662697 2023-02-03 op .index_page = -1,
454 e3662697 2023-02-03 op .path = qs->path,
455 e3662697 2023-02-03 op .commit = t->more_id,
456 e3662697 2023-02-03 op .headref = qs->headref,
457 de8c0409 2023-09-12 op .file = qs->file,
460 723721e2 2023-12-08 op if (action == TAGS)
461 723721e2 2023-12-08 op more.commit = t->tags_more_id;
463 723721e2 2023-12-08 op {{ if more.commit }}
464 e3662697 2023-02-03 op <div id="np_wrapper">
465 e3662697 2023-02-03 op <div id="nav_more">
466 e3662697 2023-02-03 op <a href="{{ render gotweb_render_url(c, &more) }}">
467 0af50e04 2023-02-03 op More ↓
474 b4c0bd72 2022-12-17 op {{ define gotweb_render_navs(struct template *tp) }}
476 b4c0bd72 2022-12-17 op struct request *c = tp->tp_arg;
477 b4c0bd72 2022-12-17 op struct gotweb_url prev, next;
478 b4c0bd72 2022-12-17 op int have_prev, have_next;
480 723721e2 2023-12-08 op gotweb_index_navs(c, &prev, &have_prev, &next, &have_next);
482 b4c0bd72 2022-12-17 op <div id="np_wrapper">
483 b4c0bd72 2022-12-17 op <div id="nav_prev">
484 b4c0bd72 2022-12-17 op {{ if have_prev }}
485 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &prev) }}">
490 b4c0bd72 2022-12-17 op <div id="nav_next">
491 b4c0bd72 2022-12-17 op {{ if have_next }}
492 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &next) }}">
500 156a1144 2022-12-17 op {{ define gotweb_render_commits(struct template *tp) }}
502 156a1144 2022-12-17 op struct request *c = tp->tp_arg;
503 156a1144 2022-12-17 op struct transport *t = c->t;
504 156a1144 2022-12-17 op struct repo_dir *repo_dir = t->repo_dir;
505 156a1144 2022-12-17 op struct repo_commit *rc;
506 7f65bb55 2023-12-01 op struct gotweb_url diff, patch, tree;
508 156a1144 2022-12-17 op diff = (struct gotweb_url){
509 156a1144 2022-12-17 op .action = DIFF,
510 156a1144 2022-12-17 op .index_page = -1,
511 156a1144 2022-12-17 op .path = repo_dir->name,
513 7f65bb55 2023-12-01 op patch = (struct gotweb_url){
514 7f65bb55 2023-12-01 op .action = PATCH,
515 7f65bb55 2023-12-01 op .index_page = -1,
516 7f65bb55 2023-12-01 op .path = repo_dir->name,
518 156a1144 2022-12-17 op tree = (struct gotweb_url){
519 156a1144 2022-12-17 op .action = TREE,
520 156a1144 2022-12-17 op .index_page = -1,
521 156a1144 2022-12-17 op .path = repo_dir->name,
524 424803ac 2023-09-12 op <header class="subtitle">
525 424803ac 2023-09-12 op <h2>Commits</h2>
527 156a1144 2022-12-17 op <div class="commits_content">
528 156a1144 2022-12-17 op {{ tailq-foreach rc &t->repo_commits entry }}
530 156a1144 2022-12-17 op diff.commit = rc->commit_id;
531 7f65bb55 2023-12-01 op patch.commit = rc->commit_id;
532 156a1144 2022-12-17 op tree.commit = rc->commit_id;
534 6595d730 2023-11-30 op <div class="page_header_wrapper">
536 424803ac 2023-09-12 op <dt>Commit:</dt>
537 424803ac 2023-09-12 op <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
538 424803ac 2023-09-12 op <dt>From:</dt>
539 424803ac 2023-09-12 op <dd>{{ rc->author }}</dd>
540 af800df5 2023-01-10 op {{ if strcmp(rc->committer, rc->author) != 0 }}
541 424803ac 2023-09-12 op <dt>Via:</dt>
542 424803ac 2023-09-12 op <dd>{{ rc->committer }}</dd>
544 424803ac 2023-09-12 op <dt>Date:</dt>
546 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
551 cf536071 2022-12-31 op <div class="commit">
553 cf536071 2022-12-31 op {{ rc->commit_msg }}
555 156a1144 2022-12-17 op <div class="navs_wrapper">
556 156a1144 2022-12-17 op <div class="navs">
557 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
559 7f65bb55 2023-12-01 op <a href="{{ render gotweb_render_url(c, &patch) }}">patch</a>
561 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
566 e3662697 2023-02-03 op {{ render gotweb_render_more(tp, COMMITS) }}
570 df2d3cd2 2023-03-11 op {{ define gotweb_render_blob(struct template *tp) }}
572 298f95fb 2023-01-05 op struct request *c = tp->tp_arg;
573 298f95fb 2023-01-05 op struct transport *t = c->t;
574 4dfd9794 2023-12-01 op struct querystring *qs = t->qs;
575 df2d3cd2 2023-03-11 op struct got_blob_object *blob = t->blob;
576 298f95fb 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
577 4dfd9794 2023-12-01 op struct gotweb_url briefs_url, blame_url, raw_url;
579 4dfd9794 2023-12-01 op memset(&briefs_url, 0, sizeof(briefs_url));
580 4dfd9794 2023-12-01 op briefs_url.index_page = -1,
581 4dfd9794 2023-12-01 op briefs_url.action = BRIEFS,
582 4dfd9794 2023-12-01 op briefs_url.path = qs->path,
583 4dfd9794 2023-12-01 op briefs_url.commit = qs->commit,
584 4dfd9794 2023-12-01 op briefs_url.folder = qs->folder,
585 4dfd9794 2023-12-01 op briefs_url.file = qs->file,
587 4dfd9794 2023-12-01 op memcpy(&blame_url, &briefs_url, sizeof(blame_url));
588 4dfd9794 2023-12-01 op blame_url.action = BLAME;
590 4dfd9794 2023-12-01 op memcpy(&raw_url, &briefs_url, sizeof(raw_url));
591 4dfd9794 2023-12-01 op raw_url.action = BLOBRAW;
593 424803ac 2023-09-12 op <header class="subtitle">
594 424803ac 2023-09-12 op <h2>Blob</h2>
596 298f95fb 2023-01-05 op <div id="blob_content">
597 6595d730 2023-11-30 op <div class="page_header_wrapper">
599 424803ac 2023-09-12 op <dt>Date:</dt>
601 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
603 424803ac 2023-09-12 op <dt>Message:</dt>
604 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
605 4dfd9794 2023-12-01 op <dt>Actions:</dt>
607 4dfd9794 2023-12-01 op <a href="{{ render gotweb_render_url(c, &briefs_url) }}">
611 4dfd9794 2023-12-01 op <a href="{{ render gotweb_render_url(c, &blame_url) }}">
615 4dfd9794 2023-12-01 op <a href="{{ render gotweb_render_url(c, &raw_url) }}">
622 298f95fb 2023-01-05 op <div id="blob">
624 298f95fb 2023-01-05 op {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
630 298f95fb 2023-01-05 op {{ define gotweb_render_blob_line(struct template *tp, const char *line,
631 298f95fb 2023-01-05 op size_t no) }}
633 298f95fb 2023-01-05 op char lineno[16];
636 298f95fb 2023-01-05 op r = snprintf(lineno, sizeof(lineno), "%zu", no);
637 298f95fb 2023-01-05 op if (r < 0 || (size_t)r >= sizeof(lineno))
640 298f95fb 2023-01-05 op <div class="blob_line" id="line{{ lineno }}">
641 50b6e2b8 2024-01-30 op <a href="#line{{ lineno }}">{{ lineno }}{{" "}}</a>
642 424803ac 2023-09-12 op <span class="blob_code">{{ line }}</span>
646 8957da7c 2023-12-08 op {{ define tree_listing(struct template *tp) }}
648 ac15152e 2023-12-08 op const struct got_error *error;
649 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
650 43d421de 2023-01-05 op struct transport *t = c->t;
651 8957da7c 2023-12-08 op struct querystring *qs = c->t->qs;
652 ac15152e 2023-12-08 op struct gotweb_url url;
653 ac15152e 2023-12-08 op char *readme = NULL;
655 ac15152e 2023-12-08 op const uint8_t *buf;
658 424803ac 2023-09-12 op <table id="tree">
659 ac15152e 2023-12-08 op {{ render got_output_repo_tree(c, &readme, gotweb_render_tree_item) }}
661 ac15152e 2023-12-08 op {{ if readme }}
663 ac15152e 2023-12-08 op error = got_open_blob_for_output(&t->blob, &t->fd, &binary, c,
664 ac15152e 2023-12-08 op qs->folder, readme, qs->commit);
666 ac15152e 2023-12-08 op free(readme);
670 ac15152e 2023-12-08 op memset(&url, 0, sizeof(url));
671 ac15152e 2023-12-08 op url.index_page = -1;
672 ac15152e 2023-12-08 op url.action = BLOB;
673 ac15152e 2023-12-08 op url.path = t->qs->path;
674 ac15152e 2023-12-08 op url.file = readme;
675 ac15152e 2023-12-08 op url.folder = t->qs->folder;
676 ac15152e 2023-12-08 op url.commit = t->qs->commit;
678 ac15152e 2023-12-08 op {{ if !binary }}
680 ac15152e 2023-12-08 op <a href="{{ render gotweb_render_url(c, &url) }}">
687 ac15152e 2023-12-08 op error = got_object_blob_read_block(&len, t->blob);
689 ac15152e 2023-12-08 op free(readme);
692 ac15152e 2023-12-08 op if (len == 0)
694 ac15152e 2023-12-08 op buf = got_object_blob_get_read_buf(t->blob);
695 ac15152e 2023-12-08 op if (tp_write_htmlescape(tp, buf, len) == -1) {
696 ac15152e 2023-12-08 op free(readme);
704 ac15152e 2023-12-08 op {{ finally }}
705 8957da7c 2023-12-08 op {! free(readme); !}
708 8957da7c 2023-12-08 op {{ define gotweb_render_tree(struct template *tp) }}
710 8957da7c 2023-12-08 op struct request *c = tp->tp_arg;
711 8957da7c 2023-12-08 op struct transport *t = c->t;
712 8957da7c 2023-12-08 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
714 8957da7c 2023-12-08 op <header class='subtitle'>
715 8957da7c 2023-12-08 op <h2>Tree</h2>
717 8957da7c 2023-12-08 op <div id="tree_content">
718 8957da7c 2023-12-08 op <div class="page_header_wrapper">
720 8957da7c 2023-12-08 op <dt>Tree:</dt>
721 8957da7c 2023-12-08 op <dd><code class="commit-id">{{ rc->tree_id }}</code></dd>
722 8957da7c 2023-12-08 op <dt>Date:</dt>
724 8957da7c 2023-12-08 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
726 8957da7c 2023-12-08 op <dt>Message:</dt>
727 8957da7c 2023-12-08 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
731 8957da7c 2023-12-08 op {{ render tree_listing(tp) }}
735 43d421de 2023-01-05 op {{ define gotweb_render_tree_item(struct template *tp,
736 43d421de 2023-01-05 op struct got_tree_entry *te) }}
738 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
739 43d421de 2023-01-05 op struct transport *t = c->t;
740 43d421de 2023-01-05 op struct querystring *qs = t->qs;
741 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
742 43d421de 2023-01-05 op const char *modestr = "";
743 43d421de 2023-01-05 op const char *name;
744 43d421de 2023-01-05 op const char *folder;
745 43d421de 2023-01-05 op char *dir = NULL;
747 43d421de 2023-01-05 op struct gotweb_url url = {
748 43d421de 2023-01-05 op .index_page = -1,
749 43d421de 2023-01-05 op .commit = rc->commit_id,
750 43d421de 2023-01-05 op .path = qs->path,
753 43d421de 2023-01-05 op name = got_tree_entry_get_name(te);
754 43d421de 2023-01-05 op mode = got_tree_entry_get_mode(te);
756 43d421de 2023-01-05 op folder = qs->folder ? qs->folder : "";
757 43d421de 2023-01-05 op if (S_ISDIR(mode)) {
758 43d421de 2023-01-05 op if (asprintf(&dir, "%s/%s", folder, name) == -1)
761 43d421de 2023-01-05 op url.action = TREE;
762 43d421de 2023-01-05 op url.folder = dir;
764 43d421de 2023-01-05 op url.action = BLOB;
765 43d421de 2023-01-05 op url.folder = folder;
766 43d421de 2023-01-05 op url.file = name;
769 43d421de 2023-01-05 op if (got_object_tree_entry_is_submodule(te))
770 43d421de 2023-01-05 op modestr = "$";
771 43d421de 2023-01-05 op else if (S_ISLNK(mode))
772 43d421de 2023-01-05 op modestr = "@";
773 43d421de 2023-01-05 op else if (S_ISDIR(mode))
774 43d421de 2023-01-05 op modestr = "/";
775 43d421de 2023-01-05 op else if (mode & S_IXUSR)
776 43d421de 2023-01-05 op modestr = "*";
778 424803ac 2023-09-12 op <tr class="tree_wrapper">
779 43d421de 2023-01-05 op {{ if S_ISDIR(mode) }}
780 424803ac 2023-09-12 op <td class="tree_line" colspan=2>
781 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
782 43d421de 2023-01-05 op {{ name }}{{ modestr }}
786 424803ac 2023-09-12 op <td class="tree_line">
787 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
788 43d421de 2023-01-05 op {{ name }}{{ modestr }}
791 424803ac 2023-09-12 op <td class="tree_line_blank">
792 43d421de 2023-01-05 op {! url.action = COMMITS; !}
793 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
797 43d421de 2023-01-05 op {! url.action = BLAME; !}
798 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
804 43d421de 2023-01-05 op {{ finally }}
810 d60961d2 2023-01-13 op {{ define gotweb_render_tags(struct template *tp) }}
812 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
813 067396e6 2023-01-09 op struct transport *t = c->t;
814 067396e6 2023-01-09 op struct querystring *qs = t->qs;
815 067396e6 2023-01-09 op struct repo_tag *rt;
816 067396e6 2023-01-09 op int commit_found;
818 067396e6 2023-01-09 op commit_found = qs->commit == NULL;
820 424803ac 2023-09-12 op <header class='subtitle'>
821 424803ac 2023-09-12 op <h2>Tags</h2>
823 067396e6 2023-01-09 op <div id="tags_content">
824 067396e6 2023-01-09 op {{ if t->tag_count == 0 }}
825 067396e6 2023-01-09 op <div id="err_content">
826 067396e6 2023-01-09 op This repository contains no tags
829 067396e6 2023-01-09 op {{ tailq-foreach rt &t->repo_tags entry }}
830 067396e6 2023-01-09 op {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
831 067396e6 2023-01-09 op {! commit_found = 1; !}
832 067396e6 2023-01-09 op {{ render tag_item(tp, rt) }}
835 723721e2 2023-12-08 op {{ render gotweb_render_more(tp, TAGS) }}
840 067396e6 2023-01-09 op {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
842 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
843 067396e6 2023-01-09 op struct transport *t = c->t;
844 067396e6 2023-01-09 op struct repo_dir *repo_dir = t->repo_dir;
845 067396e6 2023-01-09 op char *tag_name = rt->tag_name;
846 067396e6 2023-01-09 op char *msg = rt->tag_commit;
848 067396e6 2023-01-09 op struct gotweb_url url = {
849 067396e6 2023-01-09 op .action = TAG,
850 067396e6 2023-01-09 op .index_page = -1,
851 067396e6 2023-01-09 op .path = repo_dir->name,
852 067396e6 2023-01-09 op .commit = rt->commit_id,
855 067396e6 2023-01-09 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
856 067396e6 2023-01-09 op tag_name += 10;
859 067396e6 2023-01-09 op nl = strchr(msg, '\n');
864 067396e6 2023-01-09 op <div class="tag_age">
865 7781b991 2023-10-05 op {{ render datetime(tp, rt->tagger_time, TM_DIFF) }}
867 424803ac 2023-09-12 op <div class="tag_name">{{ tag_name }}</div>
868 067396e6 2023-01-09 op <div class="tag_log">
869 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">
873 067396e6 2023-01-09 op <div class="navs_wrapper">
874 067396e6 2023-01-09 op <div class="navs">
875 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
877 067396e6 2023-01-09 op {! url.action = BRIEFS; !}
878 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
880 067396e6 2023-01-09 op {! url.action = COMMITS; !}
881 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
887 dc07f76c 2023-01-09 op {{ define gotweb_render_tag(struct template *tp) }}
889 dc07f76c 2023-01-09 op struct request *c = tp->tp_arg;
890 dc07f76c 2023-01-09 op struct transport *t = c->t;
891 dc07f76c 2023-01-09 op struct repo_tag *rt;
892 dc07f76c 2023-01-09 op const char *tag_name;
894 dc07f76c 2023-01-09 op rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
895 dc07f76c 2023-01-09 op tag_name = rt->tag_name;
897 dc07f76c 2023-01-09 op if (strncmp(tag_name, "refs/", 5) == 0)
898 dc07f76c 2023-01-09 op tag_name += 5;
900 424803ac 2023-09-12 op <header class="subtitle">
903 dc07f76c 2023-01-09 op <div id="tags_content">
904 6595d730 2023-11-30 op <div class="page_header_wrapper">
906 424803ac 2023-09-12 op <dt>Commit:</dt>
908 424803ac 2023-09-12 op <code class="commit-id">{{ rt->commit_id }}</code>
910 dc07f76c 2023-01-09 op <span class="refs_str">({{ tag_name }})</span>
912 424803ac 2023-09-12 op <dt>Tagger:</dt>
913 424803ac 2023-09-12 op <dd>{{ rt->tagger }}</dd>
914 424803ac 2023-09-12 op <dt>Date:</dt>
916 7781b991 2023-10-05 op {{ render datetime(tp, rt->tagger_time, TM_LONG)}}
918 424803ac 2023-09-12 op <dt>Message:</dt>
919 424803ac 2023-09-12 op <dd class="commit-msg">{{ rt->commit_msg }}</dd>
922 424803ac 2023-09-12 op <pre id="tag_commit">
923 dc07f76c 2023-01-09 op {{ rt->tag_commit }}
929 df2d3cd2 2023-03-11 op {{ define gotweb_render_diff(struct template *tp) }}
931 587550a5 2023-01-10 op struct request *c = tp->tp_arg;
932 587550a5 2023-01-10 op struct transport *t = c->t;
933 e6b69762 2023-12-01 op struct querystring *qs = t->qs;
934 df2d3cd2 2023-03-11 op FILE *fp = t->fp;
935 587550a5 2023-01-10 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
936 587550a5 2023-01-10 op char *line = NULL;
937 587550a5 2023-01-10 op size_t linesize = 0;
938 587550a5 2023-01-10 op ssize_t linelen;
939 e6b69762 2023-12-01 op struct gotweb_url patch_url, tree_url = {
940 e6b69762 2023-12-01 op .action = TREE,
941 e6b69762 2023-12-01 op .index_page = -1,
942 e6b69762 2023-12-01 op .path = qs->path,
943 e6b69762 2023-12-01 op .commit = rc->commit_id,
946 e6b69762 2023-12-01 op memcpy(&patch_url, &tree_url, sizeof(patch_url));
947 e6b69762 2023-12-01 op patch_url.action = PATCH;
949 424803ac 2023-09-12 op <header class="subtitle">
950 424803ac 2023-09-12 op <h2>Commit Diff</h2>
952 587550a5 2023-01-10 op <div id="diff_content">
953 6595d730 2023-11-30 op <div class="page_header_wrapper">
955 424803ac 2023-09-12 op <dt>Commit:</dt>
956 424803ac 2023-09-12 op <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
957 424803ac 2023-09-12 op <dt>From:</dt>
958 424803ac 2023-09-12 op <dd>{{ rc->author }}</dd>
959 49632cd3 2023-01-10 op {{ if strcmp(rc->committer, rc->author) != 0 }}
960 424803ac 2023-09-12 op <dt>Via:</dt>
961 424803ac 2023-09-12 op <dd>{{ rc->committer }}</dd>
963 424803ac 2023-09-12 op <dt>Date:</dt>
965 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
967 424803ac 2023-09-12 op <dt>Message:</dt>
968 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
969 e6b69762 2023-12-01 op <dt>Actions:</dt>
971 e6b69762 2023-12-01 op <a href="{{ render gotweb_render_url(c, &patch_url) }}">
975 e6b69762 2023-12-01 op <a href="{{ render gotweb_render_url(c, &tree_url) }}">
982 424803ac 2023-09-12 op <pre id="diff">
983 587550a5 2023-01-10 op {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
984 587550a5 2023-01-10 op {{ render diff_line(tp, line) }}
988 587550a5 2023-01-10 op {{ finally }}
989 587550a5 2023-01-10 op {! free(line); !}
992 587550a5 2023-01-10 op {{ define diff_line(struct template *tp, char *line )}}
994 587550a5 2023-01-10 op const char *color = NULL;
997 587550a5 2023-01-10 op if (!strncmp(line, "-", 1))
998 587550a5 2023-01-10 op color = "diff_minus";
999 587550a5 2023-01-10 op else if (!strncmp(line, "+", 1))
1000 587550a5 2023-01-10 op color = "diff_plus";
1001 587550a5 2023-01-10 op else if (!strncmp(line, "@@", 2))
1002 587550a5 2023-01-10 op color = "diff_chunk_header";
1003 587550a5 2023-01-10 op else if (!strncmp(line, "commit +", 8) ||
1004 587550a5 2023-01-10 op !strncmp(line, "commit -", 8) ||
1005 587550a5 2023-01-10 op !strncmp(line, "blob +", 6) ||
1006 587550a5 2023-01-10 op !strncmp(line, "blob -", 6) ||
1007 587550a5 2023-01-10 op !strncmp(line, "file +", 6) ||
1008 587550a5 2023-01-10 op !strncmp(line, "file -", 6))
1009 587550a5 2023-01-10 op color = "diff_meta";
1010 587550a5 2023-01-10 op else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
1011 587550a5 2023-01-10 op color = "diff_author";
1012 587550a5 2023-01-10 op else if (!strncmp(line, "date:", 5))
1013 587550a5 2023-01-10 op color = "diff_date";
1015 587550a5 2023-01-10 op nl = strchr(line, '\n');
1019 424803ac 2023-09-12 op <span class="diff_line {{ color }}">{{ line }}</span>{{"\n"}}
1022 3ab2c914 2023-01-11 op {{ define gotweb_render_branches(struct template *tp,
1023 3ab2c914 2023-01-11 op struct got_reflist_head *refs) }}
1025 3ab2c914 2023-01-11 op struct got_reflist_entry *re;
1027 424803ac 2023-09-12 op <header class='subtitle'>
1028 424803ac 2023-09-12 op <h2>Branches</h2>
1030 3ab2c914 2023-01-11 op <div id="branches_content">
1031 3ab2c914 2023-01-11 op {{ tailq-foreach re refs entry }}
1032 3ab2c914 2023-01-11 op {{ if !got_ref_is_symbolic(re->ref) }}
1033 3ab2c914 2023-01-11 op {{ render branch(tp, re) }}
1039 3ab2c914 2023-01-11 op {{ define branch(struct template *tp, struct got_reflist_entry *re) }}
1041 3ab2c914 2023-01-11 op const struct got_error *err;
1042 3ab2c914 2023-01-11 op struct request *c = tp->tp_arg;
1043 3ab2c914 2023-01-11 op struct querystring *qs = c->t->qs;
1044 3ab2c914 2023-01-11 op const char *refname;
1046 3ab2c914 2023-01-11 op struct gotweb_url url = {
1047 3ab2c914 2023-01-11 op .action = SUMMARY,
1048 3ab2c914 2023-01-11 op .index_page = -1,
1049 3ab2c914 2023-01-11 op .path = qs->path,
1052 3ab2c914 2023-01-11 op refname = got_ref_get_name(re->ref);
1054 cb93ab40 2023-01-22 op err = got_get_repo_age(&age, c, refname);
1056 3ab2c914 2023-01-11 op log_warnx("%s: %s", __func__, err->msg);
1060 3ab2c914 2023-01-11 op if (strncmp(refname, "refs/heads/", 11) == 0)
1061 3ab2c914 2023-01-11 op refname += 11;
1063 3ab2c914 2023-01-11 op url.headref = refname;
1065 424803ac 2023-09-12 op <section class="branches_wrapper">
1066 cb93ab40 2023-01-22 op <div class="branches_age">
1067 7781b991 2023-10-05 op {{ render datetime(tp, age, TM_DIFF) }}
1069 3ab2c914 2023-01-11 op <div class="branch">
1070 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
1072 3ab2c914 2023-01-11 op <div class="navs_wrapper">
1073 3ab2c914 2023-01-11 op <div class="navs">
1074 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">summary</a>
1076 3ab2c914 2023-01-11 op {! url.action = BRIEFS; !}
1077 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
1079 3ab2c914 2023-01-11 op {! url.action = COMMITS; !}
1080 3ab2c914 2023-01-11 op <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
1087 df2d3cd2 2023-03-11 op {{ define gotweb_render_summary(struct template *tp) }}
1089 69525b4e 2023-01-13 op struct request *c = tp->tp_arg;
1090 69525b4e 2023-01-13 op struct server *srv = c->srv;
1091 69525b4e 2023-01-13 op struct transport *t = c->t;
1092 df2d3cd2 2023-03-11 op struct got_reflist_head *refs = &t->refs;
1094 7f65bb55 2023-12-01 op <dl id="summary_wrapper" class="page_header_wrapper">
1095 69525b4e 2023-01-13 op {{ if srv->show_repo_description }}
1096 424803ac 2023-09-12 op <dt>Description:</dt>
1097 424803ac 2023-09-12 op <dd>{{ t->repo_dir->description }}</dd>
1099 69525b4e 2023-01-13 op {{ if srv->show_repo_owner }}
1100 424803ac 2023-09-12 op <dt>Owner:</dt>
1101 424803ac 2023-09-12 op <dd>{{ t->repo_dir->owner }}</dd>
1103 69525b4e 2023-01-13 op {{ if srv->show_repo_age }}
1104 424803ac 2023-09-12 op <dt>Last Change:</dt>
1106 7781b991 2023-10-05 op {{ render datetime(tp, t->repo_dir->age, TM_DIFF) }}
1109 69525b4e 2023-01-13 op {{ if srv->show_repo_cloneurl }}
1110 424803ac 2023-09-12 op <dt>Clone URL:</dt>
1111 424803ac 2023-09-12 op <dd><pre class="clone-url">{{ t->repo_dir->url }}</pre></dd>
1114 69525b4e 2023-01-13 op {{ render gotweb_render_briefs(tp) }}
1115 69525b4e 2023-01-13 op {{ render gotweb_render_branches(tp, refs) }}
1116 89f6914c 2023-12-08 op {{ render gotweb_render_tags(tp) }}
1117 1be82a44 2023-12-08 stsp <header class='subtitle'>
1118 1be82a44 2023-12-08 stsp <h2>Tree</h2>
1120 1be82a44 2023-12-08 stsp <div id="tree_content">
1121 8957da7c 2023-12-08 op {{ render tree_listing(tp) }}
1125 8319855f 2023-01-15 op {{ define gotweb_render_blame(struct template *tp) }}
1127 8319855f 2023-01-15 op const struct got_error *err;
1128 8319855f 2023-01-15 op struct request *c = tp->tp_arg;
1129 8319855f 2023-01-15 op struct transport *t = c->t;
1130 2faeb3c6 2023-12-01 op struct querystring *qs = t->qs;
1131 8319855f 2023-01-15 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
1132 2faeb3c6 2023-12-01 op struct gotweb_url briefs_url, blob_url, raw_url;
1134 2faeb3c6 2023-12-01 op memset(&briefs_url, 0, sizeof(briefs_url));
1135 2faeb3c6 2023-12-01 op briefs_url.index_page = -1,
1136 2faeb3c6 2023-12-01 op briefs_url.action = BRIEFS,
1137 2faeb3c6 2023-12-01 op briefs_url.path = qs->path,
1138 2faeb3c6 2023-12-01 op briefs_url.commit = qs->commit,
1139 2faeb3c6 2023-12-01 op briefs_url.folder = qs->folder,
1140 2faeb3c6 2023-12-01 op briefs_url.file = qs->file,
1142 2faeb3c6 2023-12-01 op memcpy(&blob_url, &briefs_url, sizeof(blob_url));
1143 2faeb3c6 2023-12-01 op blob_url.action = BLOB;
1145 2faeb3c6 2023-12-01 op memcpy(&raw_url, &briefs_url, sizeof(raw_url));
1146 2faeb3c6 2023-12-01 op raw_url.action = BLOBRAW;
1148 424803ac 2023-09-12 op <header class="subtitle">
1149 424803ac 2023-09-12 op <h2>Blame</h2>
1151 8319855f 2023-01-15 op <div id="blame_content">
1152 6595d730 2023-11-30 op <div class="page_header_wrapper">
1154 424803ac 2023-09-12 op <dt>Date:</dt>
1156 7781b991 2023-10-05 op {{ render datetime(tp, rc->committer_time, TM_LONG) }}
1158 424803ac 2023-09-12 op <dt>Message:</dt>
1159 424803ac 2023-09-12 op <dd class="commit-msg">{{ rc->commit_msg }}</dd>
1160 2faeb3c6 2023-12-01 op <dt>Actions:</dt>
1162 2faeb3c6 2023-12-01 op <a href="{{ render gotweb_render_url(c, &briefs_url) }}">
1166 2faeb3c6 2023-12-01 op <a href="{{ render gotweb_render_url(c, &blob_url) }}">
1170 2faeb3c6 2023-12-01 op <a href="{{ render gotweb_render_url(c, &raw_url) }}">
1177 424803ac 2023-09-12 op <pre id="blame">
1179 8319855f 2023-01-15 op err = got_output_file_blame(c, &blame_line);
1180 8a078d7f 2023-05-17 op if (err && err->code != GOT_ERR_CANCELLED)
1181 8319855f 2023-01-15 op log_warnx("%s: got_output_file_blame: %s", __func__,
1184 8319855f 2023-01-15 op return (-1);
1190 8319855f 2023-01-15 op {{ define blame_line(struct template *tp, const char *line,
1191 8319855f 2023-01-15 op struct blame_line *bline, int lprec, int lcur) }}
1193 8319855f 2023-01-15 op struct request *c = tp->tp_arg;
1194 8319855f 2023-01-15 op struct transport *t = c->t;
1195 8319855f 2023-01-15 op struct repo_dir *repo_dir = t->repo_dir;
1196 8319855f 2023-01-15 op char *committer, *s;
1197 8319855f 2023-01-15 op struct gotweb_url url = {
1198 8319855f 2023-01-15 op .action = DIFF,
1199 8319855f 2023-01-15 op .index_page = -1,
1200 8319855f 2023-01-15 op .path = repo_dir->name,
1201 8319855f 2023-01-15 op .commit = bline->id_str,
1204 8319855f 2023-01-15 op s = strchr(bline->committer, '<');
1205 8319855f 2023-01-15 op committer = s ? s + 1 : bline->committer;
1207 8319855f 2023-01-15 op s = strchr(committer, '@');
1211 4ba8b606 2023-12-01 op <div class="blame_line">
1212 4ba8b606 2023-12-01 op <span class="blame_number">{{ printf "%*d ", lprec, lcur }}</span>
1213 4ba8b606 2023-12-01 op <span class="blame_hash">
1214 8319855f 2023-01-15 op <a href="{{ render gotweb_render_url(c, &url) }}">
1215 8319855f 2023-01-15 op {{ printf "%.8s", bline->id_str }}
1219 4ba8b606 2023-12-01 op <span class="blame_date">{{ bline->datebuf }}</span>
1221 4ba8b606 2023-12-01 op <span class="blame_author">{{ printf "%.9s", committer }}</span>
1223 4ba8b606 2023-12-01 op <span class="blame_code">{{ line }}</span>
1227 7f65bb55 2023-12-01 op {{ define gotweb_render_patch(struct template *tp) }}
1229 7f65bb55 2023-12-01 op struct request *c = tp->tp_arg;
1230 7f65bb55 2023-12-01 op struct transport *t = c->t;
1231 7f65bb55 2023-12-01 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
1232 7f65bb55 2023-12-01 op struct tm tm;
1233 7f65bb55 2023-12-01 op char buf[BUFSIZ], datebuf[64];
1236 7f65bb55 2023-12-01 op if (gmtime_r(&rc->committer_time, &tm) == NULL ||
1237 7f65bb55 2023-12-01 op strftime(datebuf, sizeof(datebuf), "%a %b %d %T %Y UTC", &tm) == 0)
1238 7f65bb55 2023-12-01 op return (-1);
1240 7f65bb55 2023-12-01 op commit {{ rc->commit_id }} {{ "\n" }}
1241 7f65bb55 2023-12-01 op from: {{ rc->author | unsafe }} {{ "\n" }}
1242 7f65bb55 2023-12-01 op {{ if strcmp(rc->committer, rc->author) != 0 }}
1243 7f65bb55 2023-12-01 op via: {{ rc->committer | unsafe }} {{ "\n" }}
1245 7f65bb55 2023-12-01 op date: {{ datebuf }} {{ "\n" }}
1247 7f65bb55 2023-12-01 op {{ rc->commit_msg | unsafe }} {{ "\n" }}
1249 7f65bb55 2023-12-01 op if (template_flush(tp) == -1)
1250 7f65bb55 2023-12-01 op return (-1);
1252 7f65bb55 2023-12-01 op r = fread(buf, 1, sizeof(buf), t->fp);
1253 7f65bb55 2023-12-01 op if (fcgi_write(c, buf, r) == -1 ||
1254 7f65bb55 2023-12-01 op r != sizeof(buf))
1260 1abb18e1 2022-12-20 op {{ define gotweb_render_rss(struct template *tp) }}
1262 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
1263 1abb18e1 2022-12-20 op struct server *srv = c->srv;
1264 1abb18e1 2022-12-20 op struct transport *t = c->t;
1265 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
1266 1abb18e1 2022-12-20 op struct repo_tag *rt;
1267 1abb18e1 2022-12-20 op struct gotweb_url summary = {
1268 1abb18e1 2022-12-20 op .action = SUMMARY,
1269 1abb18e1 2022-12-20 op .index_page = -1,
1270 1abb18e1 2022-12-20 op .path = repo_dir->name,
1273 1abb18e1 2022-12-20 op <?xml version="1.0" encoding="UTF-8"?>
1274 1abb18e1 2022-12-20 op <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
1276 1abb18e1 2022-12-20 op <title>Tags of {{ repo_dir->name }}</title>
1279 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &summary) }}
1282 1abb18e1 2022-12-20 op {{ if srv->show_repo_description }}
1283 1abb18e1 2022-12-20 op <description>{{ repo_dir->description }}</description>
1285 1abb18e1 2022-12-20 op {{ tailq-foreach rt &t->repo_tags entry }}
1286 1abb18e1 2022-12-20 op {{ render rss_tag_item(tp, rt) }}
1292 1abb18e1 2022-12-20 op {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
1294 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
1295 1abb18e1 2022-12-20 op struct transport *t = c->t;
1296 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
1297 bf26a633 2023-10-05 op struct tm tm;
1298 bf26a633 2023-10-05 op char rfc822[128];
1300 1abb18e1 2022-12-20 op char *tag_name = rt->tag_name;
1301 1abb18e1 2022-12-20 op struct gotweb_url tag = {
1302 1abb18e1 2022-12-20 op .action = TAG,
1303 1abb18e1 2022-12-20 op .index_page = -1,
1304 1abb18e1 2022-12-20 op .path = repo_dir->name,
1305 1abb18e1 2022-12-20 op .commit = rt->commit_id,
1308 1abb18e1 2022-12-20 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
1309 1abb18e1 2022-12-20 op tag_name += 10;
1311 bf26a633 2023-10-05 op if (gmtime_r(&rt->tagger_time, &tm) == NULL)
1313 bf26a633 2023-10-05 op r = strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S GMT", &tm);
1318 1abb18e1 2022-12-20 op <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
1321 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &tag) }}
1324 1abb18e1 2022-12-20 op <description>
1325 1abb18e1 2022-12-20 op <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
1326 1abb18e1 2022-12-20 op </description>
1327 1abb18e1 2022-12-20 op {{ render rss_author(tp, rt->tagger) }}
1328 1abb18e1 2022-12-20 op <guid isPermaLink="false">{{ rt->commit_id }}</guid>
1330 bf26a633 2023-10-05 op {{ rfc822 }}
1335 1abb18e1 2022-12-20 op {{ define rss_author(struct template *tp, char *author) }}
1337 1abb18e1 2022-12-20 op char *t, *mail;
1339 1abb18e1 2022-12-20 op /* what to do if the author name contains a paren? */
1340 1abb18e1 2022-12-20 op if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
1343 1abb18e1 2022-12-20 op t = strchr(author, '<');
1344 1abb18e1 2022-12-20 op if (t == NULL)
1349 1abb18e1 2022-12-20 op while (isspace((unsigned char)*--t))
1352 1abb18e1 2022-12-20 op t = strchr(mail, '>');
1353 1abb18e1 2022-12-20 op if (t == NULL)
1358 1abb18e1 2022-12-20 op {{ mail }} {{" "}} ({{ author }})