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 00abe30b 2023-01-14 thomas #include "got_error.h"
32 3c14c1f2 2023-01-06 thomas #include "got_object.h"
33 00abe30b 2023-01-14 thomas #include "got_reference.h"
35 e7e5fa49 2022-12-30 thomas #include "proc.h"
37 e7e5fa49 2022-12-30 thomas #include "gotwebd.h"
38 e7e5fa49 2022-12-30 thomas #include "tmpl.h"
40 b82440e1 2023-01-06 thomas static int gotweb_render_blob_line(struct template *, const char *, size_t);
41 3c14c1f2 2023-01-06 thomas static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
42 1cd5d437 2023-01-15 thomas static int blame_line(struct template *, const char *, struct blame_line *,
43 1cd5d437 2023-01-15 thomas int, int);
45 dccd05b4 2023-01-10 thomas static inline int diff_line(struct template *, char *);
46 617497a6 2023-01-09 thomas static inline int tag_item(struct template *, struct repo_tag *);
47 00abe30b 2023-01-14 thomas static inline int branch(struct template *, struct got_reflist_entry *);
48 d6795e9f 2022-12-30 thomas static inline int rss_tag_item(struct template *, struct repo_tag *);
49 d6795e9f 2022-12-30 thomas static inline int rss_author(struct template *, char *);
53 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_header(struct template *tp) }}
55 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
56 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
57 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
58 e7e5fa49 2022-12-30 thomas struct gotweb_url u_path;
59 3191e256 2022-12-30 thomas const char *prfx = c->document_uri;
60 e7e5fa49 2022-12-30 thomas const char *css = srv->custom_css;
62 e7e5fa49 2022-12-30 thomas memset(&u_path, 0, sizeof(u_path));
63 e7e5fa49 2022-12-30 thomas u_path.index_page = -1;
64 e7e5fa49 2022-12-30 thomas u_path.page = -1;
65 e7e5fa49 2022-12-30 thomas u_path.action = SUMMARY;
67 e7e5fa49 2022-12-30 thomas <!doctype html>
70 e7e5fa49 2022-12-30 thomas <meta charset="utf-8" />
71 e7e5fa49 2022-12-30 thomas <title>{{ srv->site_name }}</title>
72 e7e5fa49 2022-12-30 thomas <meta name="viewport" content="initial-scale=.75" />
73 e7e5fa49 2022-12-30 thomas <meta name="msapplication-TileColor" content="#da532c" />
74 e7e5fa49 2022-12-30 thomas <meta name="theme-color" content="#ffffff"/>
75 e7e5fa49 2022-12-30 thomas <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
76 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
77 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
78 e7e5fa49 2022-12-30 thomas <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
79 e7e5fa49 2022-12-30 thomas <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
80 e7e5fa49 2022-12-30 thomas <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
83 e7e5fa49 2022-12-30 thomas <div id="gw_body">
84 e7e5fa49 2022-12-30 thomas <div id="header">
85 e7e5fa49 2022-12-30 thomas <div id="got_link">
86 e7e5fa49 2022-12-30 thomas <a href="{{ srv->logo_url }}" target="_blank">
87 e7e5fa49 2022-12-30 thomas <img src="{{ prfx }}{{ srv->logo }}" />
91 e7e5fa49 2022-12-30 thomas <div id="site_path">
92 e7e5fa49 2022-12-30 thomas <div id="site_link">
93 e7e5fa49 2022-12-30 thomas <a href="?index_page={{ printf "%d", qs->index_page }}">
94 e7e5fa49 2022-12-30 thomas {{ srv->site_link }}
96 e7e5fa49 2022-12-30 thomas {{ if qs->path }}
97 e7e5fa49 2022-12-30 thomas {! u_path.path = qs->path; !}
98 e7e5fa49 2022-12-30 thomas {{ " / " }}
99 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
100 e7e5fa49 2022-12-30 thomas {{ qs->path }}
102 e7e5fa49 2022-12-30 thomas {{ end }}
103 e7e5fa49 2022-12-30 thomas {{ if qs->action != INDEX }}
104 e7e5fa49 2022-12-30 thomas {{ " / " }}{{ gotweb_action_name(qs->action) }}
105 e7e5fa49 2022-12-30 thomas {{ end }}
108 e7e5fa49 2022-12-30 thomas <div id="content">
109 e7e5fa49 2022-12-30 thomas {{ end }}
111 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_footer(struct template *tp) }}
113 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
114 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
116 e7e5fa49 2022-12-30 thomas <div id="site_owner_wrapper">
117 e7e5fa49 2022-12-30 thomas <div id="site_owner">
118 e7e5fa49 2022-12-30 thomas {{ if srv->show_site_owner }}
119 e7e5fa49 2022-12-30 thomas {{ srv->site_owner }}
120 e7e5fa49 2022-12-30 thomas {{ end }}
127 e7e5fa49 2022-12-30 thomas {{ end }}
129 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
131 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
132 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
134 e7e5fa49 2022-12-30 thomas <div id="index_header">
135 e7e5fa49 2022-12-30 thomas <div id="index_header_project">
138 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
139 e7e5fa49 2022-12-30 thomas <div id="index_header_description">
140 e7e5fa49 2022-12-30 thomas Description
142 e7e5fa49 2022-12-30 thomas {{ end }}
143 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
144 e7e5fa49 2022-12-30 thomas <div id="index_header_owner">
147 e7e5fa49 2022-12-30 thomas {{ end }}
148 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
149 e7e5fa49 2022-12-30 thomas <div id="index_header_age">
150 e7e5fa49 2022-12-30 thomas Last Change
152 e7e5fa49 2022-12-30 thomas {{ end }}
154 e7e5fa49 2022-12-30 thomas {{ end }}
156 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
158 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
159 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
160 e7e5fa49 2022-12-30 thomas struct gotweb_url summary = {
161 e7e5fa49 2022-12-30 thomas .action = SUMMARY,
162 e7e5fa49 2022-12-30 thomas .index_page = -1,
163 e7e5fa49 2022-12-30 thomas .page = -1,
164 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
165 e7e5fa49 2022-12-30 thomas }, briefs = {
166 e7e5fa49 2022-12-30 thomas .action = BRIEFS,
167 e7e5fa49 2022-12-30 thomas .index_page = -1,
168 e7e5fa49 2022-12-30 thomas .page = -1,
169 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
170 e7e5fa49 2022-12-30 thomas }, commits = {
171 e7e5fa49 2022-12-30 thomas .action = COMMITS,
172 e7e5fa49 2022-12-30 thomas .index_page = -1,
173 e7e5fa49 2022-12-30 thomas .page = -1,
174 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
175 e7e5fa49 2022-12-30 thomas }, tags = {
176 e7e5fa49 2022-12-30 thomas .action = TAGS,
177 e7e5fa49 2022-12-30 thomas .index_page = -1,
178 e7e5fa49 2022-12-30 thomas .page = -1,
179 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
180 e7e5fa49 2022-12-30 thomas }, tree = {
181 e7e5fa49 2022-12-30 thomas .action = TREE,
182 e7e5fa49 2022-12-30 thomas .index_page = -1,
183 e7e5fa49 2022-12-30 thomas .page = -1,
184 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
185 d6795e9f 2022-12-30 thomas }, rss = {
186 d6795e9f 2022-12-30 thomas .action = RSS,
187 d6795e9f 2022-12-30 thomas .index_page = -1,
188 d6795e9f 2022-12-30 thomas .page = -1,
189 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
192 e7e5fa49 2022-12-30 thomas <div class="index_wrapper">
193 e7e5fa49 2022-12-30 thomas <div class="index_project">
194 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
196 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
197 e7e5fa49 2022-12-30 thomas <div class="index_project_description">
198 e7e5fa49 2022-12-30 thomas {{ repo_dir->description }}
200 e7e5fa49 2022-12-30 thomas {{ end }}
201 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
202 e7e5fa49 2022-12-30 thomas <div class="index_project_owner">
203 e7e5fa49 2022-12-30 thomas {{ repo_dir->owner }}
205 e7e5fa49 2022-12-30 thomas {{ end }}
206 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
207 e7e5fa49 2022-12-30 thomas <div class="index_project_age">
208 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, repo_dir->age, TM_DIFF) }}
210 e7e5fa49 2022-12-30 thomas {{ end }}
211 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
212 e7e5fa49 2022-12-30 thomas <div class="navs">
213 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
214 e7e5fa49 2022-12-30 thomas {{ " | " }}
215 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
216 e7e5fa49 2022-12-30 thomas {{ " | " }}
217 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
218 e7e5fa49 2022-12-30 thomas {{ " | " }}
219 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
220 e7e5fa49 2022-12-30 thomas {{ " | " }}
221 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
222 d6795e9f 2022-12-30 thomas {{ " | " }}
223 d6795e9f 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
225 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
228 e7e5fa49 2022-12-30 thomas {{ end }}
230 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_briefs(struct template *tp) }}
232 e7e5fa49 2022-12-30 thomas const struct got_error *error;
233 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
234 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
235 e7e5fa49 2022-12-30 thomas struct transport *t = c->t;
236 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
237 e7e5fa49 2022-12-30 thomas struct repo_commit *rc;
238 e7e5fa49 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
239 e7e5fa49 2022-12-30 thomas struct gotweb_url diff_url, tree_url;
240 e7e5fa49 2022-12-30 thomas char *tmp;
242 e7e5fa49 2022-12-30 thomas diff_url = (struct gotweb_url){
243 e7e5fa49 2022-12-30 thomas .action = DIFF,
244 e7e5fa49 2022-12-30 thomas .index_page = -1,
245 e7e5fa49 2022-12-30 thomas .page = -1,
246 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
247 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
249 e7e5fa49 2022-12-30 thomas tree_url = (struct gotweb_url){
250 e7e5fa49 2022-12-30 thomas .action = TREE,
251 e7e5fa49 2022-12-30 thomas .index_page = -1,
252 e7e5fa49 2022-12-30 thomas .page = -1,
253 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
254 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
257 e7e5fa49 2022-12-30 thomas if (qs->action == SUMMARY) {
258 e7e5fa49 2022-12-30 thomas qs->action = BRIEFS;
259 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
261 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, srv->max_commits_display);
262 e7e5fa49 2022-12-30 thomas if (error)
263 e7e5fa49 2022-12-30 thomas return -1;
265 e7e5fa49 2022-12-30 thomas <div id="briefs_title_wrapper">
266 e7e5fa49 2022-12-30 thomas <div id="briefs_title">Commit Briefs</div>
268 e7e5fa49 2022-12-30 thomas <div id="briefs_content">
269 e7e5fa49 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
271 e7e5fa49 2022-12-30 thomas diff_url.commit = rc->commit_id;
272 e7e5fa49 2022-12-30 thomas tree_url.commit = rc->commit_id;
274 64d39587 2023-01-14 thomas tmp = strchr(rc->committer, '<');
276 e7e5fa49 2022-12-30 thomas *tmp = '\0';
278 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->commit_msg, '\n');
280 e7e5fa49 2022-12-30 thomas *tmp = '\0';
282 e7e5fa49 2022-12-30 thomas <div class="briefs_age">
283 e7e5fa49 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
285 e7e5fa49 2022-12-30 thomas <div class="briefs_author">
286 64d39587 2023-01-14 thomas {{ rc->committer }}
288 e7e5fa49 2022-12-30 thomas <div class="briefs_log">
289 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
290 e7e5fa49 2022-12-30 thomas {{ rc->commit_msg }}
292 e7e5fa49 2022-12-30 thomas {{ if rc->refs_str }}
293 e7e5fa49 2022-12-30 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
294 e7e5fa49 2022-12-30 thomas {{ end }}
297 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
298 e7e5fa49 2022-12-30 thomas <div class="navs">
299 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
300 e7e5fa49 2022-12-30 thomas {{ " | " }}
301 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
304 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
305 e7e5fa49 2022-12-30 thomas {{ end }}
306 e7e5fa49 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
307 2f4f0731 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
308 e7e5fa49 2022-12-30 thomas {{ end }}
310 2f4f0731 2022-12-30 thomas {{ end }}
312 2f4f0731 2022-12-30 thomas {{ define gotweb_render_navs(struct template *tp) }}
314 2f4f0731 2022-12-30 thomas struct request *c = tp->tp_arg;
315 2f4f0731 2022-12-30 thomas struct transport *t = c->t;
316 2f4f0731 2022-12-30 thomas struct gotweb_url prev, next;
317 2f4f0731 2022-12-30 thomas int have_prev, have_next;
319 2f4f0731 2022-12-30 thomas gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
321 2f4f0731 2022-12-30 thomas <div id="np_wrapper">
322 2f4f0731 2022-12-30 thomas <div id="nav_prev">
323 2f4f0731 2022-12-30 thomas {{ if have_prev }}
324 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &prev) }}">
327 2f4f0731 2022-12-30 thomas {{ end }}
329 2f4f0731 2022-12-30 thomas <div id="nav_next">
330 2f4f0731 2022-12-30 thomas {{ if have_next }}
331 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &next) }}">
334 2f4f0731 2022-12-30 thomas {{ end }}
337 2f4f0731 2022-12-30 thomas {{ finally }}
339 2f4f0731 2022-12-30 thomas free(t->next_id);
340 2f4f0731 2022-12-30 thomas t->next_id = NULL;
341 2f4f0731 2022-12-30 thomas free(t->prev_id);
342 2f4f0731 2022-12-30 thomas t->prev_id = NULL;
344 e7e5fa49 2022-12-30 thomas {{ end }}
346 7ade8b27 2022-12-30 thomas {{ define gotweb_render_commits(struct template *tp) }}
348 7ade8b27 2022-12-30 thomas struct request *c = tp->tp_arg;
349 7ade8b27 2022-12-30 thomas struct transport *t = c->t;
350 7ade8b27 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
351 7ade8b27 2022-12-30 thomas struct repo_commit *rc;
352 7ade8b27 2022-12-30 thomas struct gotweb_url diff, tree;
354 7ade8b27 2022-12-30 thomas diff = (struct gotweb_url){
355 7ade8b27 2022-12-30 thomas .action = DIFF,
356 7ade8b27 2022-12-30 thomas .index_page = -1,
357 7ade8b27 2022-12-30 thomas .page = -1,
358 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
360 7ade8b27 2022-12-30 thomas tree = (struct gotweb_url){
361 7ade8b27 2022-12-30 thomas .action = TREE,
362 7ade8b27 2022-12-30 thomas .index_page = -1,
363 7ade8b27 2022-12-30 thomas .page = -1,
364 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
367 7ade8b27 2022-12-30 thomas <div class="commits_title_wrapper">
368 7ade8b27 2022-12-30 thomas <div class="commits_title">Commits</div>
370 7ade8b27 2022-12-30 thomas <div class="commits_content">
371 7ade8b27 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
373 7ade8b27 2022-12-30 thomas diff.commit = rc->commit_id;
374 7ade8b27 2022-12-30 thomas tree.commit = rc->commit_id;
376 7ade8b27 2022-12-30 thomas <div class="commits_header_wrapper">
377 7ade8b27 2022-12-30 thomas <div class="commits_header">
378 7ade8b27 2022-12-30 thomas <div class="header_commit_title">Commit:</div>
379 7ade8b27 2022-12-30 thomas <div class="header_commit">{{ rc->commit_id }}</div>
380 54ffadaf 2023-01-14 thomas <div class="header_author_title">From:</div>
381 7ade8b27 2022-12-30 thomas <div class="header_author">{{ rc->author }}</div>
382 54ffadaf 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
383 54ffadaf 2023-01-14 thomas <div class="header_author_title">Via:</div>
384 54ffadaf 2023-01-14 thomas <div class="header_author">{{ rc->committer }}</div>
385 54ffadaf 2023-01-14 thomas {{ end }}
386 7ade8b27 2022-12-30 thomas <div class="header_age_title">Date:</div>
387 7ade8b27 2022-12-30 thomas <div class="header_age">
388 7ade8b27 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
392 bbf94fd6 2023-01-02 thomas <div class="dotted_line"></div>
393 bbf94fd6 2023-01-02 thomas <div class="commit">
394 bbf94fd6 2023-01-02 thomas {{ "\n" }}
395 bbf94fd6 2023-01-02 thomas {{ rc->commit_msg }}
397 7ade8b27 2022-12-30 thomas <div class="navs_wrapper">
398 7ade8b27 2022-12-30 thomas <div class="navs">
399 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
400 7ade8b27 2022-12-30 thomas {{ " | " }}
401 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
404 7ade8b27 2022-12-30 thomas <div class="dotted_line"></div>
405 7ade8b27 2022-12-30 thomas {{ end }}
406 7ade8b27 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
407 7ade8b27 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
408 7ade8b27 2022-12-30 thomas {{ end }}
410 b82440e1 2023-01-06 thomas {{ end }}
412 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob(struct template *tp,
413 b82440e1 2023-01-06 thomas struct got_blob_object *blob) }}
415 b82440e1 2023-01-06 thomas struct request *c = tp->tp_arg;
416 b82440e1 2023-01-06 thomas struct transport *t = c->t;
417 b82440e1 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
419 b82440e1 2023-01-06 thomas <div id="blob_title_wrapper">
420 b82440e1 2023-01-06 thomas <div id="blob_title">Blob</div>
422 b82440e1 2023-01-06 thomas <div id="blob_content">
423 b82440e1 2023-01-06 thomas <div id="blob_header_wrapper">
424 b82440e1 2023-01-06 thomas <div id="blob_header">
425 b82440e1 2023-01-06 thomas <div class="header_age_title">Date:</div>
426 b82440e1 2023-01-06 thomas <div class="header_age">
427 b82440e1 2023-01-06 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
429 b82440e1 2023-01-06 thomas <div id="header_commit_msg_title">Message:</div>
430 b82440e1 2023-01-06 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
433 b82440e1 2023-01-06 thomas <div class="dotted_line"></div>
434 b82440e1 2023-01-06 thomas <div id="blob">
436 b82440e1 2023-01-06 thomas {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
440 d6795e9f 2022-12-30 thomas {{ end }}
442 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob_line(struct template *tp, const char *line,
443 b82440e1 2023-01-06 thomas size_t no) }}
445 b82440e1 2023-01-06 thomas char lineno[16];
448 b82440e1 2023-01-06 thomas r = snprintf(lineno, sizeof(lineno), "%zu", no);
449 b82440e1 2023-01-06 thomas if (r < 0 || (size_t)r >= sizeof(lineno))
450 b82440e1 2023-01-06 thomas return -1;
452 b82440e1 2023-01-06 thomas <div class="blob_line" id="line{{ lineno }}">
453 b82440e1 2023-01-06 thomas <div class="blob_number">
454 b82440e1 2023-01-06 thomas <a href="#line{{ lineno }}">{{ lineno }}</a>
456 b82440e1 2023-01-06 thomas <div class="blob_code">{{ line }}</div>
458 3c14c1f2 2023-01-06 thomas {{ end }}
460 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree(struct template *tp) }}
462 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
463 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
464 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
466 3c14c1f2 2023-01-06 thomas <div id="tree_title_wrapper">
467 3c14c1f2 2023-01-06 thomas <div id="tree_title">Tree</div>
469 3c14c1f2 2023-01-06 thomas <div id="tree_content">
470 3c14c1f2 2023-01-06 thomas <div id="tree_header_wrapper">
471 3c14c1f2 2023-01-06 thomas <div id="tree_header">
472 3c14c1f2 2023-01-06 thomas <div id="header_tree_title">Tree:</div>
473 3c14c1f2 2023-01-06 thomas <div id="header_tree">{{ rc->tree_id }}</div>
474 3c14c1f2 2023-01-06 thomas <div class="header_age_title">Date:</div>
475 3c14c1f2 2023-01-06 thomas <div class="header_age">
476 3c14c1f2 2023-01-06 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
478 3c14c1f2 2023-01-06 thomas <div id="header_commit_msg_title">Message:</div>
479 3c14c1f2 2023-01-06 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
482 3c14c1f2 2023-01-06 thomas <div class="dotted_line"></div>
483 3c14c1f2 2023-01-06 thomas <div id="tree">
484 3c14c1f2 2023-01-06 thomas {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
487 3c14c1f2 2023-01-06 thomas {{ end }}
489 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree_item(struct template *tp,
490 3c14c1f2 2023-01-06 thomas struct got_tree_entry *te) }}
492 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
493 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
494 3c14c1f2 2023-01-06 thomas struct querystring *qs = t->qs;
495 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
496 3c14c1f2 2023-01-06 thomas const char *modestr = "";
497 3c14c1f2 2023-01-06 thomas const char *name;
498 3c14c1f2 2023-01-06 thomas const char *folder;
499 3c14c1f2 2023-01-06 thomas char *dir = NULL;
500 3c14c1f2 2023-01-06 thomas mode_t mode;
501 3c14c1f2 2023-01-06 thomas struct gotweb_url url = {
502 3c14c1f2 2023-01-06 thomas .index_page = -1,
503 3c14c1f2 2023-01-06 thomas .page = -1,
504 3c14c1f2 2023-01-06 thomas .commit = rc->commit_id,
505 3c14c1f2 2023-01-06 thomas .path = qs->path,
508 3c14c1f2 2023-01-06 thomas name = got_tree_entry_get_name(te);
509 3c14c1f2 2023-01-06 thomas mode = got_tree_entry_get_mode(te);
511 3c14c1f2 2023-01-06 thomas folder = qs->folder ? qs->folder : "";
512 3c14c1f2 2023-01-06 thomas if (S_ISDIR(mode)) {
513 3c14c1f2 2023-01-06 thomas if (asprintf(&dir, "%s/%s", folder, name) == -1)
514 3c14c1f2 2023-01-06 thomas return (-1);
516 3c14c1f2 2023-01-06 thomas url.action = TREE;
517 3c14c1f2 2023-01-06 thomas url.folder = dir;
519 3c14c1f2 2023-01-06 thomas url.action = BLOB;
520 3c14c1f2 2023-01-06 thomas url.folder = folder;
521 3c14c1f2 2023-01-06 thomas url.file = name;
524 3c14c1f2 2023-01-06 thomas if (got_object_tree_entry_is_submodule(te))
525 3c14c1f2 2023-01-06 thomas modestr = "$";
526 3c14c1f2 2023-01-06 thomas else if (S_ISLNK(mode))
527 3c14c1f2 2023-01-06 thomas modestr = "@";
528 3c14c1f2 2023-01-06 thomas else if (S_ISDIR(mode))
529 3c14c1f2 2023-01-06 thomas modestr = "/";
530 3c14c1f2 2023-01-06 thomas else if (mode & S_IXUSR)
531 3c14c1f2 2023-01-06 thomas modestr = "*";
533 3c14c1f2 2023-01-06 thomas <div class="tree_wrapper">
534 3c14c1f2 2023-01-06 thomas {{ if S_ISDIR(mode) }}
535 3c14c1f2 2023-01-06 thomas <div class="tree_line">
536 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
537 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
540 3c14c1f2 2023-01-06 thomas <div class="tree_line_blank"> </div>
541 3c14c1f2 2023-01-06 thomas {{ else }}
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">
548 3c14c1f2 2023-01-06 thomas {! url.action = COMMITS; !}
549 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
552 3c14c1f2 2023-01-06 thomas {{ " | " }}
553 3c14c1f2 2023-01-06 thomas {! url.action = BLAME; !}
554 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
558 3c14c1f2 2023-01-06 thomas {{ end }}
560 3c14c1f2 2023-01-06 thomas {{ finally }}
562 3c14c1f2 2023-01-06 thomas free(dir);
564 617497a6 2023-01-09 thomas {{ end }}
566 b3ba36c3 2023-01-14 thomas {{ define gotweb_render_tags(struct template *tp) }}
568 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
569 617497a6 2023-01-09 thomas struct transport *t = c->t;
570 617497a6 2023-01-09 thomas struct querystring *qs = t->qs;
571 617497a6 2023-01-09 thomas struct repo_tag *rt;
572 617497a6 2023-01-09 thomas int commit_found;
574 617497a6 2023-01-09 thomas commit_found = qs->commit == NULL;
576 617497a6 2023-01-09 thomas <div id="tags_title_wrapper">
577 617497a6 2023-01-09 thomas <div id="tags_title">Tags</div>
579 617497a6 2023-01-09 thomas <div id="tags_content">
580 617497a6 2023-01-09 thomas {{ if t->tag_count == 0 }}
581 617497a6 2023-01-09 thomas <div id="err_content">
582 617497a6 2023-01-09 thomas This repository contains no tags
584 617497a6 2023-01-09 thomas {{ else }}
585 617497a6 2023-01-09 thomas {{ tailq-foreach rt &t->repo_tags entry }}
586 617497a6 2023-01-09 thomas {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
587 617497a6 2023-01-09 thomas {! commit_found = 1; !}
588 617497a6 2023-01-09 thomas {{ render tag_item(tp, rt) }}
589 617497a6 2023-01-09 thomas {{ end }}
590 617497a6 2023-01-09 thomas {{ end }}
591 617497a6 2023-01-09 thomas {{ if t->next_id || t->prev_id }}
592 617497a6 2023-01-09 thomas {{ render gotweb_render_navs(tp) }}
593 617497a6 2023-01-09 thomas {{ end }}
594 617497a6 2023-01-09 thomas {{ end }}
596 b82440e1 2023-01-06 thomas {{ end }}
598 617497a6 2023-01-09 thomas {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
600 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
601 617497a6 2023-01-09 thomas struct transport *t = c->t;
602 617497a6 2023-01-09 thomas struct repo_dir *repo_dir = t->repo_dir;
603 617497a6 2023-01-09 thomas char *tag_name = rt->tag_name;
604 617497a6 2023-01-09 thomas char *msg = rt->tag_commit;
605 617497a6 2023-01-09 thomas char *nl;
606 617497a6 2023-01-09 thomas struct gotweb_url url = {
607 617497a6 2023-01-09 thomas .action = TAG,
608 617497a6 2023-01-09 thomas .index_page = -1,
609 617497a6 2023-01-09 thomas .page = -1,
610 617497a6 2023-01-09 thomas .path = repo_dir->name,
611 617497a6 2023-01-09 thomas .commit = rt->commit_id,
614 617497a6 2023-01-09 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
615 617497a6 2023-01-09 thomas tag_name += 10;
617 617497a6 2023-01-09 thomas if (msg) {
618 617497a6 2023-01-09 thomas nl = strchr(msg, '\n');
620 617497a6 2023-01-09 thomas *nl = '\0';
623 617497a6 2023-01-09 thomas <div class="tag_age">
624 617497a6 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_DIFF) }}
626 617497a6 2023-01-09 thomas <div class="tag">{{ tag_name }}</div>
627 617497a6 2023-01-09 thomas <div class="tag_log">
628 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
629 617497a6 2023-01-09 thomas {{ msg }}
632 617497a6 2023-01-09 thomas <div class="navs_wrapper">
633 617497a6 2023-01-09 thomas <div class="navs">
634 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
635 617497a6 2023-01-09 thomas {{ " | " }}
636 617497a6 2023-01-09 thomas {! url.action = BRIEFS; !}
637 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
638 617497a6 2023-01-09 thomas {{ " | " }}
639 617497a6 2023-01-09 thomas {! url.action = COMMITS; !}
640 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
643 617497a6 2023-01-09 thomas <div class="dotted_line"></div>
644 617497a6 2023-01-09 thomas {{ end }}
646 145ca42a 2023-01-09 thomas {{ define gotweb_render_tag(struct template *tp) }}
648 145ca42a 2023-01-09 thomas struct request *c = tp->tp_arg;
649 145ca42a 2023-01-09 thomas struct transport *t = c->t;
650 145ca42a 2023-01-09 thomas struct repo_tag *rt;
651 145ca42a 2023-01-09 thomas const char *tag_name;
653 145ca42a 2023-01-09 thomas rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
654 145ca42a 2023-01-09 thomas tag_name = rt->tag_name;
656 145ca42a 2023-01-09 thomas if (strncmp(tag_name, "refs/", 5) == 0)
657 145ca42a 2023-01-09 thomas tag_name += 5;
659 145ca42a 2023-01-09 thomas <div id="tags_title_wrapper">
660 145ca42a 2023-01-09 thomas <div id="tags_title">Tag</div>
662 145ca42a 2023-01-09 thomas <div id="tags_content">
663 145ca42a 2023-01-09 thomas <div id="tag_header_wrapper">
664 145ca42a 2023-01-09 thomas <div id="tag_header">
665 145ca42a 2023-01-09 thomas <div class="header_commit_title">Commit:</div>
666 145ca42a 2023-01-09 thomas <div class="header_commit">
667 145ca42a 2023-01-09 thomas {{ rt->commit_id }}
668 145ca42a 2023-01-09 thomas {{ " " }}
669 145ca42a 2023-01-09 thomas <span class="refs_str">({{ tag_name }})</span>
671 145ca42a 2023-01-09 thomas <div class="header_author_title">Tagger:</div>
672 145ca42a 2023-01-09 thomas <div class="header_author">{{ rt->tagger }}</div>
673 145ca42a 2023-01-09 thomas <div class="header_age_title">Date:</div>
674 145ca42a 2023-01-09 thomas <div class="header_age">
675 145ca42a 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_LONG)}}
677 145ca42a 2023-01-09 thomas <div id="header_commit_msg_title">Message:</div>
678 145ca42a 2023-01-09 thomas <div id="header_commit_msg">{{ rt->commit_msg }}</div>
680 145ca42a 2023-01-09 thomas <div class="dotted_line"></div>
681 145ca42a 2023-01-09 thomas <div id="tag_commit">
682 145ca42a 2023-01-09 thomas {{ "\n" }}
683 145ca42a 2023-01-09 thomas {{ rt->tag_commit }}
687 dccd05b4 2023-01-10 thomas {{ end }}
689 dccd05b4 2023-01-10 thomas {{ define gotweb_render_diff(struct template *tp, FILE *fp) }}
691 dccd05b4 2023-01-10 thomas struct request *c = tp->tp_arg;
692 dccd05b4 2023-01-10 thomas struct transport *t = c->t;
693 dccd05b4 2023-01-10 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
694 dccd05b4 2023-01-10 thomas char *line = NULL;
695 dccd05b4 2023-01-10 thomas size_t linesize = 0;
696 dccd05b4 2023-01-10 thomas ssize_t linelen;
698 dccd05b4 2023-01-10 thomas <div id="diff_title_wrapper">
699 dccd05b4 2023-01-10 thomas <div id="diff_title">Commit Diff</div>
701 dccd05b4 2023-01-10 thomas <div id="diff_content">
702 dccd05b4 2023-01-10 thomas <div id="diff_header_wrapper">
703 dccd05b4 2023-01-10 thomas <div id="diff_header">
704 dccd05b4 2023-01-10 thomas <div class="header_commit_title">Commit:</div>
705 dccd05b4 2023-01-10 thomas <div class="header_commit">{{ rc->commit_id }}</div>
706 f7ee7604 2023-01-14 thomas <div class="header_author_title">From:</div>
707 dccd05b4 2023-01-10 thomas <div class="header_author">{{ rc->author }}</div>
708 f7ee7604 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
709 f7ee7604 2023-01-14 thomas <div class="header_author_title">Via:</div>
710 f7ee7604 2023-01-14 thomas <div class="header_author">{{ rc->committer }}</div>
711 f7ee7604 2023-01-14 thomas {{ end }}
712 dccd05b4 2023-01-10 thomas <div class="header_age_title">Date:</div>
713 dccd05b4 2023-01-10 thomas <div class="header_age">
714 dccd05b4 2023-01-10 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
716 dccd05b4 2023-01-10 thomas <div id="header_commit_msg_title">Message</div>
717 dccd05b4 2023-01-10 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
720 dccd05b4 2023-01-10 thomas <div class="dotted_line"></div>
721 dccd05b4 2023-01-10 thomas <div id="diff">
722 dccd05b4 2023-01-10 thomas {{ "\n" }}
723 dccd05b4 2023-01-10 thomas {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
724 dccd05b4 2023-01-10 thomas {{ render diff_line(tp, line) }}
725 dccd05b4 2023-01-10 thomas {{ end }}
728 dccd05b4 2023-01-10 thomas {{ finally }}
729 dccd05b4 2023-01-10 thomas {! free(line); !}
730 145ca42a 2023-01-09 thomas {{ end }}
732 dccd05b4 2023-01-10 thomas {{ define diff_line(struct template *tp, char *line )}}
734 dccd05b4 2023-01-10 thomas const char *color = NULL;
735 dccd05b4 2023-01-10 thomas char *nl;
737 dccd05b4 2023-01-10 thomas if (!strncmp(line, "-", 1))
738 dccd05b4 2023-01-10 thomas color = "diff_minus";
739 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "+", 1))
740 dccd05b4 2023-01-10 thomas color = "diff_plus";
741 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "@@", 2))
742 dccd05b4 2023-01-10 thomas color = "diff_chunk_header";
743 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "commit +", 8) ||
744 dccd05b4 2023-01-10 thomas !strncmp(line, "commit -", 8) ||
745 dccd05b4 2023-01-10 thomas !strncmp(line, "blob +", 6) ||
746 dccd05b4 2023-01-10 thomas !strncmp(line, "blob -", 6) ||
747 dccd05b4 2023-01-10 thomas !strncmp(line, "file +", 6) ||
748 dccd05b4 2023-01-10 thomas !strncmp(line, "file -", 6))
749 dccd05b4 2023-01-10 thomas color = "diff_meta";
750 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
751 dccd05b4 2023-01-10 thomas color = "diff_author";
752 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "date:", 5))
753 dccd05b4 2023-01-10 thomas color = "diff_date";
755 dccd05b4 2023-01-10 thomas nl = strchr(line, '\n');
757 dccd05b4 2023-01-10 thomas *nl = '\0';
759 dccd05b4 2023-01-10 thomas <div class="diff_line {{ color }}">{{ line }}</div>
760 dccd05b4 2023-01-10 thomas {{ end }}
762 00abe30b 2023-01-14 thomas {{ define gotweb_render_branches(struct template *tp,
763 00abe30b 2023-01-14 thomas struct got_reflist_head *refs) }}
765 00abe30b 2023-01-14 thomas struct got_reflist_entry *re;
767 00abe30b 2023-01-14 thomas <div id="branches_title_wrapper">
768 00abe30b 2023-01-14 thomas <div id="branches_title">Branches</div>
770 00abe30b 2023-01-14 thomas <div id="branches_content">
771 00abe30b 2023-01-14 thomas {{ tailq-foreach re refs entry }}
772 00abe30b 2023-01-14 thomas {{ if !got_ref_is_symbolic(re->ref) }}
773 00abe30b 2023-01-14 thomas {{ render branch(tp, re) }}
774 00abe30b 2023-01-14 thomas {{ end }}
775 00abe30b 2023-01-14 thomas {{ end }}
777 00abe30b 2023-01-14 thomas {{ end }}
779 00abe30b 2023-01-14 thomas {{ define branch(struct template *tp, struct got_reflist_entry *re) }}
781 00abe30b 2023-01-14 thomas const struct got_error *err;
782 00abe30b 2023-01-14 thomas struct request *c = tp->tp_arg;
783 00abe30b 2023-01-14 thomas struct querystring *qs = c->t->qs;
784 00abe30b 2023-01-14 thomas const char *refname;
785 53bf32b8 2023-01-23 thomas time_t age;
786 00abe30b 2023-01-14 thomas struct gotweb_url url = {
787 00abe30b 2023-01-14 thomas .action = SUMMARY,
788 00abe30b 2023-01-14 thomas .index_page = -1,
789 00abe30b 2023-01-14 thomas .page = -1,
790 00abe30b 2023-01-14 thomas .path = qs->path,
793 00abe30b 2023-01-14 thomas refname = got_ref_get_name(re->ref);
795 53bf32b8 2023-01-23 thomas err = got_get_repo_age(&age, c, refname);
796 00abe30b 2023-01-14 thomas if (err) {
797 00abe30b 2023-01-14 thomas log_warnx("%s: %s", __func__, err->msg);
798 00abe30b 2023-01-14 thomas return -1;
801 00abe30b 2023-01-14 thomas if (strncmp(refname, "refs/heads/", 11) == 0)
802 00abe30b 2023-01-14 thomas refname += 11;
804 00abe30b 2023-01-14 thomas url.headref = refname;
806 00abe30b 2023-01-14 thomas <div class="branches_wrapper">
807 53bf32b8 2023-01-23 thomas <div class="branches_age">
808 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, age, TM_DIFF) }}
810 00abe30b 2023-01-14 thomas <div class="branches_space"> </div>
811 00abe30b 2023-01-14 thomas <div class="branch">
812 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
814 00abe30b 2023-01-14 thomas <div class="navs_wrapper">
815 00abe30b 2023-01-14 thomas <div class="navs">
816 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">summary</a>
817 00abe30b 2023-01-14 thomas {{" | "}}
818 00abe30b 2023-01-14 thomas {! url.action = BRIEFS; !}
819 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
820 00abe30b 2023-01-14 thomas {{" | "}}
821 00abe30b 2023-01-14 thomas {! url.action = COMMITS; !}
822 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
825 00abe30b 2023-01-14 thomas <div class="dotted_line"></div>
827 18e466eb 2023-01-14 thomas {{ end }}
829 18e466eb 2023-01-14 thomas {{ define gotweb_render_summary(struct template *tp,
830 18e466eb 2023-01-14 thomas struct got_reflist_head *refs) }}
832 18e466eb 2023-01-14 thomas struct request *c = tp->tp_arg;
833 18e466eb 2023-01-14 thomas struct server *srv = c->srv;
834 18e466eb 2023-01-14 thomas struct transport *t = c->t;
836 18e466eb 2023-01-14 thomas <div id="summary_wrapper">
837 18e466eb 2023-01-14 thomas {{ if srv->show_repo_description }}
838 18e466eb 2023-01-14 thomas <div id="description_title">Description:</div>
839 18e466eb 2023-01-14 thomas <div id="description">{{ t->repo_dir->description }}</div>
840 18e466eb 2023-01-14 thomas {{ end }}
841 18e466eb 2023-01-14 thomas {{ if srv->show_repo_owner }}
842 18e466eb 2023-01-14 thomas <div id="repo_owner_title">Owner:</div>
843 18e466eb 2023-01-14 thomas <div id="repo_owner">{{ t->repo_dir->owner }}</div>
844 18e466eb 2023-01-14 thomas {{ end }}
845 18e466eb 2023-01-14 thomas {{ if srv->show_repo_age }}
846 18e466eb 2023-01-14 thomas <div id="last_change_title">Last Change:</div>
847 53bf32b8 2023-01-23 thomas <div id="last_change">
848 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, t->repo_dir->age, TM_DIFF) }}
850 18e466eb 2023-01-14 thomas {{ end }}
851 18e466eb 2023-01-14 thomas {{ if srv->show_repo_cloneurl }}
852 18e466eb 2023-01-14 thomas <div id="cloneurl_title">Clone URL:</div>
853 18e466eb 2023-01-14 thomas <div id="cloneurl">{{ t->repo_dir->url }}</div>
854 18e466eb 2023-01-14 thomas {{ end }}
856 18e466eb 2023-01-14 thomas {{ render gotweb_render_briefs(tp) }}
857 18e466eb 2023-01-14 thomas {{ render gotweb_render_tags(tp) }}
858 18e466eb 2023-01-14 thomas {{ render gotweb_render_branches(tp, refs) }}
859 00abe30b 2023-01-14 thomas {{ end }}
861 1cd5d437 2023-01-15 thomas {{ define gotweb_render_blame(struct template *tp) }}
863 1cd5d437 2023-01-15 thomas const struct got_error *err;
864 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
865 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
866 1cd5d437 2023-01-15 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
868 1cd5d437 2023-01-15 thomas <div id="blame_title_wrapper">
869 1cd5d437 2023-01-15 thomas <div id="blame_title">Blame</div>
871 1cd5d437 2023-01-15 thomas <div id="blame_content">
872 1cd5d437 2023-01-15 thomas <div id="blame_header_wrapper">
873 1cd5d437 2023-01-15 thomas <div id="blame_header">
874 1cd5d437 2023-01-15 thomas <div class="header_age_title">Date:</div>
875 1cd5d437 2023-01-15 thomas <div class="header_age">
876 1cd5d437 2023-01-15 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
878 1cd5d437 2023-01-15 thomas <div id="header_commit_msg_title">Message:</div>
879 1cd5d437 2023-01-15 thomas <div id="header_commit_msg">{{ rc->commit_msg }}</div>
882 1cd5d437 2023-01-15 thomas <div class="dotted_line"></div>
883 1cd5d437 2023-01-15 thomas <div id="blame">
884 1cd5d437 2023-01-15 thomas {{ "\n" }}
886 1cd5d437 2023-01-15 thomas err = got_output_file_blame(c, &blame_line);
887 1cd5d437 2023-01-15 thomas if (err) {
888 1cd5d437 2023-01-15 thomas log_warnx("%s: got_output_file_blame: %s", __func__,
889 1cd5d437 2023-01-15 thomas err->msg);
890 1cd5d437 2023-01-15 thomas return (-1);
895 1cd5d437 2023-01-15 thomas {{ end }}
897 1cd5d437 2023-01-15 thomas {{ define blame_line(struct template *tp, const char *line,
898 1cd5d437 2023-01-15 thomas struct blame_line *bline, int lprec, int lcur) }}
900 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
901 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
902 1cd5d437 2023-01-15 thomas struct repo_dir *repo_dir = t->repo_dir;
903 1cd5d437 2023-01-15 thomas char *committer, *s;
904 1cd5d437 2023-01-15 thomas struct gotweb_url url = {
905 1cd5d437 2023-01-15 thomas .action = DIFF,
906 1cd5d437 2023-01-15 thomas .index_page = -1,
907 1cd5d437 2023-01-15 thomas .page = -1,
908 1cd5d437 2023-01-15 thomas .path = repo_dir->name,
909 1cd5d437 2023-01-15 thomas .commit = bline->id_str,
912 1cd5d437 2023-01-15 thomas s = strchr(bline->committer, '<');
913 1cd5d437 2023-01-15 thomas committer = s ? s + 1 : bline->committer;
915 1cd5d437 2023-01-15 thomas s = strchr(committer, '@');
917 1cd5d437 2023-01-15 thomas *s = '\0';
919 1cd5d437 2023-01-15 thomas <div class="blame_wrapper">
920 1cd5d437 2023-01-15 thomas <div class="blame_number">{{ printf "%.*d", lprec, lcur }}</div>
921 1cd5d437 2023-01-15 thomas <div class="blame_hash">
922 1cd5d437 2023-01-15 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
923 1cd5d437 2023-01-15 thomas {{ printf "%.8s", bline->id_str }}
926 1cd5d437 2023-01-15 thomas <div class="blame_date">{{ bline->datebuf }}</div>
927 1cd5d437 2023-01-15 thomas <div class="blame_author">{{ printf "%.9s", committer }}</div>
928 1cd5d437 2023-01-15 thomas <div class="blame_code">{{ line }}</div>
930 1cd5d437 2023-01-15 thomas {{ end }}
932 d6795e9f 2022-12-30 thomas {{ define gotweb_render_rss(struct template *tp) }}
934 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
935 d6795e9f 2022-12-30 thomas struct server *srv = c->srv;
936 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
937 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
938 d6795e9f 2022-12-30 thomas struct repo_tag *rt;
939 d6795e9f 2022-12-30 thomas struct gotweb_url summary = {
940 d6795e9f 2022-12-30 thomas .action = SUMMARY,
941 d6795e9f 2022-12-30 thomas .index_page = -1,
942 d6795e9f 2022-12-30 thomas .page = -1,
943 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
946 d6795e9f 2022-12-30 thomas <?xml version="1.0" encoding="UTF-8"?>
947 d6795e9f 2022-12-30 thomas <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
948 d6795e9f 2022-12-30 thomas <channel>
949 d6795e9f 2022-12-30 thomas <title>Tags of {{ repo_dir->name }}</title>
951 d6795e9f 2022-12-30 thomas <![CDATA[
952 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &summary) }}
955 d6795e9f 2022-12-30 thomas {{ if srv->show_repo_description }}
956 d6795e9f 2022-12-30 thomas <description>{{ repo_dir->description }}</description>
957 d6795e9f 2022-12-30 thomas {{ end }}
958 d6795e9f 2022-12-30 thomas {{ tailq-foreach rt &t->repo_tags entry }}
959 d6795e9f 2022-12-30 thomas {{ render rss_tag_item(tp, rt) }}
960 d6795e9f 2022-12-30 thomas {{ end }}
961 d6795e9f 2022-12-30 thomas </channel>
963 d6795e9f 2022-12-30 thomas {{ end }}
965 d6795e9f 2022-12-30 thomas {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
967 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
968 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
969 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
970 d6795e9f 2022-12-30 thomas char *tag_name = rt->tag_name;
971 d6795e9f 2022-12-30 thomas struct gotweb_url tag = {
972 d6795e9f 2022-12-30 thomas .action = TAG,
973 d6795e9f 2022-12-30 thomas .index_page = -1,
974 d6795e9f 2022-12-30 thomas .page = -1,
975 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
976 d6795e9f 2022-12-30 thomas .commit = rt->commit_id,
979 d6795e9f 2022-12-30 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
980 d6795e9f 2022-12-30 thomas tag_name += 10;
983 d6795e9f 2022-12-30 thomas <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
985 d6795e9f 2022-12-30 thomas <![CDATA[
986 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &tag) }}
989 d6795e9f 2022-12-30 thomas <description>
990 d6795e9f 2022-12-30 thomas <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
991 d6795e9f 2022-12-30 thomas </description>
992 d6795e9f 2022-12-30 thomas {{ render rss_author(tp, rt->tagger) }}
993 d6795e9f 2022-12-30 thomas <guid isPermaLink="false">{{ rt->commit_id }}</guid>
994 d6795e9f 2022-12-30 thomas <pubDate>
995 d6795e9f 2022-12-30 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
996 d6795e9f 2022-12-30 thomas </pubDate>
998 7ade8b27 2022-12-30 thomas {{ end }}
1000 d6795e9f 2022-12-30 thomas {{ define rss_author(struct template *tp, char *author) }}
1002 d6795e9f 2022-12-30 thomas char *t, *mail;
1004 d6795e9f 2022-12-30 thomas /* what to do if the author name contains a paren? */
1005 d6795e9f 2022-12-30 thomas if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
1006 d6795e9f 2022-12-30 thomas return 0;
1008 d6795e9f 2022-12-30 thomas t = strchr(author, '<');
1009 d6795e9f 2022-12-30 thomas if (t == NULL)
1010 d6795e9f 2022-12-30 thomas return 0;
1011 d6795e9f 2022-12-30 thomas *t = '\0';
1012 d6795e9f 2022-12-30 thomas mail = t+1;
1014 d6795e9f 2022-12-30 thomas while (isspace((unsigned char)*--t))
1015 d6795e9f 2022-12-30 thomas *t = '\0';
1017 d6795e9f 2022-12-30 thomas t = strchr(mail, '>');
1018 d6795e9f 2022-12-30 thomas if (t == NULL)
1019 d6795e9f 2022-12-30 thomas return 0;
1020 d6795e9f 2022-12-30 thomas *t = '\0';
1022 d6795e9f 2022-12-30 thomas <author>
1023 d6795e9f 2022-12-30 thomas {{ mail }} {{" "}} ({{ author }})
1024 d6795e9f 2022-12-30 thomas </author>
1025 d6795e9f 2022-12-30 thomas {{ end }}