Blame


1 e7e5fa49 2022-12-30 thomas {!
2 e7e5fa49 2022-12-30 thomas /*
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>
5 e7e5fa49 2022-12-30 thomas *
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.
9 e7e5fa49 2022-12-30 thomas *
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.
17 e7e5fa49 2022-12-30 thomas */
18 4fccd2fe 2023-03-08 thomas
19 4fccd2fe 2023-03-08 thomas #include "got_compat.h"
20 e7e5fa49 2022-12-30 thomas
21 e7e5fa49 2022-12-30 thomas #include <sys/types.h>
22 e7e5fa49 2022-12-30 thomas #include <sys/queue.h>
23 3c14c1f2 2023-01-06 thomas #include <sys/stat.h>
24 e7e5fa49 2022-12-30 thomas
25 d6795e9f 2022-12-30 thomas #include <ctype.h>
26 e7e5fa49 2022-12-30 thomas #include <event.h>
27 e7e5fa49 2022-12-30 thomas #include <stdint.h>
28 3c14c1f2 2023-01-06 thomas #include <stdio.h>
29 e7e5fa49 2022-12-30 thomas #include <stdlib.h>
30 e7e5fa49 2022-12-30 thomas #include <string.h>
31 e7e5fa49 2022-12-30 thomas #include <imsg.h>
32 e7e5fa49 2022-12-30 thomas
33 00abe30b 2023-01-14 thomas #include "got_error.h"
34 3c14c1f2 2023-01-06 thomas #include "got_object.h"
35 00abe30b 2023-01-14 thomas #include "got_reference.h"
36 3c14c1f2 2023-01-06 thomas
37 e7e5fa49 2022-12-30 thomas #include "proc.h"
38 e7e5fa49 2022-12-30 thomas
39 e7e5fa49 2022-12-30 thomas #include "gotwebd.h"
40 e7e5fa49 2022-12-30 thomas #include "tmpl.h"
41 e7e5fa49 2022-12-30 thomas
42 b82440e1 2023-01-06 thomas static int gotweb_render_blob_line(struct template *, const char *, size_t);
43 3c14c1f2 2023-01-06 thomas static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
44 1cd5d437 2023-01-15 thomas static int blame_line(struct template *, const char *, struct blame_line *,
45 1cd5d437 2023-01-15 thomas int, int);
46 20bab626 2023-02-03 thomas
47 20bab626 2023-02-03 thomas static inline int gotweb_render_more(struct template *, int);
48 b82440e1 2023-01-06 thomas
49 dccd05b4 2023-01-10 thomas static inline int diff_line(struct template *, char *);
50 617497a6 2023-01-09 thomas static inline int tag_item(struct template *, struct repo_tag *);
51 00abe30b 2023-01-14 thomas static inline int branch(struct template *, struct got_reflist_entry *);
52 d6795e9f 2022-12-30 thomas static inline int rss_tag_item(struct template *, struct repo_tag *);
53 d6795e9f 2022-12-30 thomas static inline int rss_author(struct template *, char *);
54 d6795e9f 2022-12-30 thomas
55 e7e5fa49 2022-12-30 thomas !}
56 e7e5fa49 2022-12-30 thomas
57 161663e7 2023-03-11 thomas {{ define gotweb_render_page(struct template *tp,
58 161663e7 2023-03-11 thomas int (*body)(struct template *)) }}
59 e7e5fa49 2022-12-30 thomas {!
60 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
61 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
62 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
63 e7e5fa49 2022-12-30 thomas struct gotweb_url u_path;
64 3191e256 2022-12-30 thomas const char *prfx = c->document_uri;
65 e7e5fa49 2022-12-30 thomas const char *css = srv->custom_css;
66 e7e5fa49 2022-12-30 thomas
67 e7e5fa49 2022-12-30 thomas memset(&u_path, 0, sizeof(u_path));
68 e7e5fa49 2022-12-30 thomas u_path.index_page = -1;
69 e7e5fa49 2022-12-30 thomas u_path.page = -1;
70 e7e5fa49 2022-12-30 thomas u_path.action = SUMMARY;
71 e7e5fa49 2022-12-30 thomas !}
72 e7e5fa49 2022-12-30 thomas <!doctype html>
73 e7e5fa49 2022-12-30 thomas <html>
74 e7e5fa49 2022-12-30 thomas <head>
75 e7e5fa49 2022-12-30 thomas <meta charset="utf-8" />
76 e7e5fa49 2022-12-30 thomas <title>{{ srv->site_name }}</title>
77 fdd79f2f 2023-09-12 thomas <meta name="viewport" content="initial-scale=1.0" />
78 e7e5fa49 2022-12-30 thomas <meta name="msapplication-TileColor" content="#da532c" />
79 e7e5fa49 2022-12-30 thomas <meta name="theme-color" content="#ffffff"/>
80 e7e5fa49 2022-12-30 thomas <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
81 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
82 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
83 e7e5fa49 2022-12-30 thomas <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
84 e7e5fa49 2022-12-30 thomas <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
85 e7e5fa49 2022-12-30 thomas <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
86 e7e5fa49 2022-12-30 thomas </head>
87 e7e5fa49 2022-12-30 thomas <body>
88 fdd79f2f 2023-09-12 thomas <header id="header">
89 fdd79f2f 2023-09-12 thomas <div id="got_link">
90 fdd79f2f 2023-09-12 thomas <a href="{{ srv->logo_url }}" target="_blank">
91 fdd79f2f 2023-09-12 thomas <img src="{{ prfx }}{{ srv->logo }}" />
92 fdd79f2f 2023-09-12 thomas </a>
93 e7e5fa49 2022-12-30 thomas </div>
94 fdd79f2f 2023-09-12 thomas </header>
95 fdd79f2f 2023-09-12 thomas <nav id="site_path">
96 fdd79f2f 2023-09-12 thomas <div id="site_link">
97 fdd79f2f 2023-09-12 thomas <a href="?index_page={{ printf "%d", qs->index_page }}">
98 fdd79f2f 2023-09-12 thomas {{ srv->site_link }}
99 fdd79f2f 2023-09-12 thomas </a>
100 fdd79f2f 2023-09-12 thomas {{ if qs->path }}
101 fdd79f2f 2023-09-12 thomas {! u_path.path = qs->path; !}
102 fdd79f2f 2023-09-12 thomas {{ " / " }}
103 fdd79f2f 2023-09-12 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
104 fdd79f2f 2023-09-12 thomas {{ qs->path }}
105 e7e5fa49 2022-12-30 thomas </a>
106 fdd79f2f 2023-09-12 thomas {{ end }}
107 fdd79f2f 2023-09-12 thomas {{ if qs->action != INDEX }}
108 fdd79f2f 2023-09-12 thomas {{ " / " }}{{ gotweb_action_name(qs->action) }}
109 fdd79f2f 2023-09-12 thomas {{ end }}
110 e7e5fa49 2022-12-30 thomas </div>
111 fdd79f2f 2023-09-12 thomas </nav>
112 fdd79f2f 2023-09-12 thomas <main>
113 fdd79f2f 2023-09-12 thomas {{ render body(tp) }}
114 fdd79f2f 2023-09-12 thomas </main>
115 fdd79f2f 2023-09-12 thomas <footer id="site_owner_wrapper">
116 fdd79f2f 2023-09-12 thomas <p id="site_owner">
117 fdd79f2f 2023-09-12 thomas {{ if srv->show_site_owner }}
118 fdd79f2f 2023-09-12 thomas {{ srv->site_owner }}
119 fdd79f2f 2023-09-12 thomas {{ end }}
120 fdd79f2f 2023-09-12 thomas </p>
121 fdd79f2f 2023-09-12 thomas </footer>
122 e7e5fa49 2022-12-30 thomas </body>
123 e7e5fa49 2022-12-30 thomas </html>
124 164b5ddc 2023-03-11 thomas {{ end }}
125 164b5ddc 2023-03-11 thomas
126 164b5ddc 2023-03-11 thomas {{ define gotweb_render_error(struct template *tp) }}
127 164b5ddc 2023-03-11 thomas {!
128 164b5ddc 2023-03-11 thomas struct request *c = tp->tp_arg;
129 164b5ddc 2023-03-11 thomas struct transport *t = c->t;
130 164b5ddc 2023-03-11 thomas !}
131 164b5ddc 2023-03-11 thomas <div id="err_content">
132 164b5ddc 2023-03-11 thomas {{ if t->error }}
133 164b5ddc 2023-03-11 thomas {{ t->error->msg }}
134 164b5ddc 2023-03-11 thomas {{ else }}
135 164b5ddc 2023-03-11 thomas See daemon logs for details
136 164b5ddc 2023-03-11 thomas {{ end }}
137 164b5ddc 2023-03-11 thomas </div>
138 e7e5fa49 2022-12-30 thomas {{ end }}
139 e7e5fa49 2022-12-30 thomas
140 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
141 e7e5fa49 2022-12-30 thomas {!
142 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
143 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
144 e7e5fa49 2022-12-30 thomas !}
145 e7e5fa49 2022-12-30 thomas <div id="index_header">
146 fdd79f2f 2023-09-12 thomas <div class="index_project">
147 e7e5fa49 2022-12-30 thomas Project
148 e7e5fa49 2022-12-30 thomas </div>
149 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
150 fdd79f2f 2023-09-12 thomas <div class="index_project_description">
151 e7e5fa49 2022-12-30 thomas Description
152 e7e5fa49 2022-12-30 thomas </div>
153 e7e5fa49 2022-12-30 thomas {{ end }}
154 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
155 fdd79f2f 2023-09-12 thomas <div class="index_project_owner">
156 e7e5fa49 2022-12-30 thomas Owner
157 e7e5fa49 2022-12-30 thomas </div>
158 e7e5fa49 2022-12-30 thomas {{ end }}
159 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
160 fdd79f2f 2023-09-12 thomas <div class="index_project_age">
161 e7e5fa49 2022-12-30 thomas Last Change
162 e7e5fa49 2022-12-30 thomas </div>
163 e7e5fa49 2022-12-30 thomas {{ end }}
164 e7e5fa49 2022-12-30 thomas </div>
165 e7e5fa49 2022-12-30 thomas {{ end }}
166 e7e5fa49 2022-12-30 thomas
167 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
168 e7e5fa49 2022-12-30 thomas {!
169 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
170 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
171 e7e5fa49 2022-12-30 thomas struct gotweb_url summary = {
172 e7e5fa49 2022-12-30 thomas .action = SUMMARY,
173 e7e5fa49 2022-12-30 thomas .index_page = -1,
174 e7e5fa49 2022-12-30 thomas .page = -1,
175 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
176 e7e5fa49 2022-12-30 thomas }, briefs = {
177 e7e5fa49 2022-12-30 thomas .action = BRIEFS,
178 e7e5fa49 2022-12-30 thomas .index_page = -1,
179 e7e5fa49 2022-12-30 thomas .page = -1,
180 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
181 e7e5fa49 2022-12-30 thomas }, commits = {
182 e7e5fa49 2022-12-30 thomas .action = COMMITS,
183 e7e5fa49 2022-12-30 thomas .index_page = -1,
184 e7e5fa49 2022-12-30 thomas .page = -1,
185 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
186 e7e5fa49 2022-12-30 thomas }, tags = {
187 e7e5fa49 2022-12-30 thomas .action = TAGS,
188 e7e5fa49 2022-12-30 thomas .index_page = -1,
189 e7e5fa49 2022-12-30 thomas .page = -1,
190 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
191 e7e5fa49 2022-12-30 thomas }, tree = {
192 e7e5fa49 2022-12-30 thomas .action = TREE,
193 e7e5fa49 2022-12-30 thomas .index_page = -1,
194 e7e5fa49 2022-12-30 thomas .page = -1,
195 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
196 d6795e9f 2022-12-30 thomas }, rss = {
197 d6795e9f 2022-12-30 thomas .action = RSS,
198 d6795e9f 2022-12-30 thomas .index_page = -1,
199 d6795e9f 2022-12-30 thomas .page = -1,
200 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
201 e7e5fa49 2022-12-30 thomas };
202 e7e5fa49 2022-12-30 thomas !}
203 e7e5fa49 2022-12-30 thomas <div class="index_wrapper">
204 e7e5fa49 2022-12-30 thomas <div class="index_project">
205 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
206 e7e5fa49 2022-12-30 thomas </div>
207 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
208 e7e5fa49 2022-12-30 thomas <div class="index_project_description">
209 e7e5fa49 2022-12-30 thomas {{ repo_dir->description }}
210 e7e5fa49 2022-12-30 thomas </div>
211 e7e5fa49 2022-12-30 thomas {{ end }}
212 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
213 e7e5fa49 2022-12-30 thomas <div class="index_project_owner">
214 e7e5fa49 2022-12-30 thomas {{ repo_dir->owner }}
215 e7e5fa49 2022-12-30 thomas </div>
216 e7e5fa49 2022-12-30 thomas {{ end }}
217 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
218 e7e5fa49 2022-12-30 thomas <div class="index_project_age">
219 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, repo_dir->age, TM_DIFF) }}
220 e7e5fa49 2022-12-30 thomas </div>
221 e7e5fa49 2022-12-30 thomas {{ end }}
222 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
223 e7e5fa49 2022-12-30 thomas <div class="navs">
224 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
225 e7e5fa49 2022-12-30 thomas {{ " | " }}
226 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
227 e7e5fa49 2022-12-30 thomas {{ " | " }}
228 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
229 e7e5fa49 2022-12-30 thomas {{ " | " }}
230 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
231 e7e5fa49 2022-12-30 thomas {{ " | " }}
232 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
233 d6795e9f 2022-12-30 thomas {{ " | " }}
234 d6795e9f 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
235 e7e5fa49 2022-12-30 thomas </div>
236 fdd79f2f 2023-09-12 thomas <hr />
237 e7e5fa49 2022-12-30 thomas </div>
238 e7e5fa49 2022-12-30 thomas </div>
239 e7e5fa49 2022-12-30 thomas {{ end }}
240 e7e5fa49 2022-12-30 thomas
241 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_briefs(struct template *tp) }}
242 e7e5fa49 2022-12-30 thomas {!
243 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
244 e7e5fa49 2022-12-30 thomas struct transport *t = c->t;
245 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
246 e7e5fa49 2022-12-30 thomas struct repo_commit *rc;
247 e7e5fa49 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
248 e7e5fa49 2022-12-30 thomas struct gotweb_url diff_url, tree_url;
249 e7e5fa49 2022-12-30 thomas char *tmp;
250 e7e5fa49 2022-12-30 thomas
251 e7e5fa49 2022-12-30 thomas diff_url = (struct gotweb_url){
252 e7e5fa49 2022-12-30 thomas .action = DIFF,
253 e7e5fa49 2022-12-30 thomas .index_page = -1,
254 e7e5fa49 2022-12-30 thomas .page = -1,
255 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
256 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
257 e7e5fa49 2022-12-30 thomas };
258 e7e5fa49 2022-12-30 thomas tree_url = (struct gotweb_url){
259 e7e5fa49 2022-12-30 thomas .action = TREE,
260 e7e5fa49 2022-12-30 thomas .index_page = -1,
261 e7e5fa49 2022-12-30 thomas .page = -1,
262 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
263 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
264 e7e5fa49 2022-12-30 thomas };
265 e7e5fa49 2022-12-30 thomas !}
266 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
267 fdd79f2f 2023-09-12 thomas <h2>Commit Briefs</h2>
268 fdd79f2f 2023-09-12 thomas </header>
269 e7e5fa49 2022-12-30 thomas <div id="briefs_content">
270 e7e5fa49 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
271 e7e5fa49 2022-12-30 thomas {!
272 e7e5fa49 2022-12-30 thomas diff_url.commit = rc->commit_id;
273 e7e5fa49 2022-12-30 thomas tree_url.commit = rc->commit_id;
274 e7e5fa49 2022-12-30 thomas
275 64d39587 2023-01-14 thomas tmp = strchr(rc->committer, '<');
276 e7e5fa49 2022-12-30 thomas if (tmp)
277 e7e5fa49 2022-12-30 thomas *tmp = '\0';
278 e7e5fa49 2022-12-30 thomas
279 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->commit_msg, '\n');
280 e7e5fa49 2022-12-30 thomas if (tmp)
281 e7e5fa49 2022-12-30 thomas *tmp = '\0';
282 e7e5fa49 2022-12-30 thomas !}
283 fdd79f2f 2023-09-12 thomas <div class='brief'>
284 fdd79f2f 2023-09-12 thomas <p class='brief_meta'>
285 fdd79f2f 2023-09-12 thomas <span class='briefs_age'>
286 fdd79f2f 2023-09-12 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
287 fdd79f2f 2023-09-12 thomas </span>
288 fdd79f2f 2023-09-12 thomas {{" "}}
289 fdd79f2f 2023-09-12 thomas <span class="briefs_author">
290 fdd79f2f 2023-09-12 thomas {{ rc->committer }}
291 fdd79f2f 2023-09-12 thomas </span>
292 fdd79f2f 2023-09-12 thomas </p>
293 fdd79f2f 2023-09-12 thomas <p class="briefs_log">
294 fdd79f2f 2023-09-12 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
295 fdd79f2f 2023-09-12 thomas {{ rc->commit_msg }}
296 fdd79f2f 2023-09-12 thomas </a>
297 fdd79f2f 2023-09-12 thomas {{ if rc->refs_str }}
298 fdd79f2f 2023-09-12 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
299 fdd79f2f 2023-09-12 thomas {{ end }}
300 fdd79f2f 2023-09-12 thomas </a>
301 fdd79f2f 2023-09-12 thomas </p>
302 e7e5fa49 2022-12-30 thomas </div>
303 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
304 e7e5fa49 2022-12-30 thomas <div class="navs">
305 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
306 e7e5fa49 2022-12-30 thomas {{ " | " }}
307 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
308 e7e5fa49 2022-12-30 thomas </div>
309 e7e5fa49 2022-12-30 thomas </div>
310 fdd79f2f 2023-09-12 thomas <hr />
311 e7e5fa49 2022-12-30 thomas {{ end }}
312 20bab626 2023-02-03 thomas {{ render gotweb_render_more(tp, BRIEFS) }}
313 2f4f0731 2022-12-30 thomas </div>
314 2f4f0731 2022-12-30 thomas {{ end }}
315 2f4f0731 2022-12-30 thomas
316 20bab626 2023-02-03 thomas {{ define gotweb_render_more(struct template *tp, int action) }}
317 20bab626 2023-02-03 thomas {!
318 20bab626 2023-02-03 thomas struct request *c = tp->tp_arg;
319 20bab626 2023-02-03 thomas struct transport *t = c->t;
320 20bab626 2023-02-03 thomas struct querystring *qs = t->qs;
321 20bab626 2023-02-03 thomas struct gotweb_url more = {
322 20bab626 2023-02-03 thomas .action = action,
323 20bab626 2023-02-03 thomas .index_page = -1,
324 20bab626 2023-02-03 thomas .path = qs->path,
325 20bab626 2023-02-03 thomas .commit = t->more_id,
326 20bab626 2023-02-03 thomas .headref = qs->headref,
327 882ee74d 2023-09-14 thomas .file = qs->file,
328 20bab626 2023-02-03 thomas };
329 20bab626 2023-02-03 thomas !}
330 20bab626 2023-02-03 thomas {{ if t->more_id }}
331 20bab626 2023-02-03 thomas <div id="np_wrapper">
332 20bab626 2023-02-03 thomas <div id="nav_more">
333 20bab626 2023-02-03 thomas <a href="{{ render gotweb_render_url(c, &more) }}">
334 bd6e9c73 2023-02-03 thomas More&nbsp;&darr;
335 20bab626 2023-02-03 thomas </a>
336 20bab626 2023-02-03 thomas </div>
337 20bab626 2023-02-03 thomas </div>
338 20bab626 2023-02-03 thomas {{ end }}
339 20bab626 2023-02-03 thomas {{ end }}
340 20bab626 2023-02-03 thomas
341 2f4f0731 2022-12-30 thomas {{ define gotweb_render_navs(struct template *tp) }}
342 2f4f0731 2022-12-30 thomas {!
343 2f4f0731 2022-12-30 thomas struct request *c = tp->tp_arg;
344 2f4f0731 2022-12-30 thomas struct transport *t = c->t;
345 2f4f0731 2022-12-30 thomas struct gotweb_url prev, next;
346 2f4f0731 2022-12-30 thomas int have_prev, have_next;
347 2f4f0731 2022-12-30 thomas
348 2f4f0731 2022-12-30 thomas gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
349 2f4f0731 2022-12-30 thomas !}
350 2f4f0731 2022-12-30 thomas <div id="np_wrapper">
351 2f4f0731 2022-12-30 thomas <div id="nav_prev">
352 2f4f0731 2022-12-30 thomas {{ if have_prev }}
353 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &prev) }}">
354 2f4f0731 2022-12-30 thomas Previous
355 2f4f0731 2022-12-30 thomas </a>
356 2f4f0731 2022-12-30 thomas {{ end }}
357 2f4f0731 2022-12-30 thomas </div>
358 2f4f0731 2022-12-30 thomas <div id="nav_next">
359 2f4f0731 2022-12-30 thomas {{ if have_next }}
360 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &next) }}">
361 2f4f0731 2022-12-30 thomas Next
362 2f4f0731 2022-12-30 thomas </a>
363 2f4f0731 2022-12-30 thomas {{ end }}
364 2f4f0731 2022-12-30 thomas </div>
365 e7e5fa49 2022-12-30 thomas </div>
366 2f4f0731 2022-12-30 thomas {{ finally }}
367 2f4f0731 2022-12-30 thomas {!
368 2f4f0731 2022-12-30 thomas free(t->next_id);
369 2f4f0731 2022-12-30 thomas t->next_id = NULL;
370 2f4f0731 2022-12-30 thomas free(t->prev_id);
371 2f4f0731 2022-12-30 thomas t->prev_id = NULL;
372 2f4f0731 2022-12-30 thomas !}
373 e7e5fa49 2022-12-30 thomas {{ end }}
374 7ade8b27 2022-12-30 thomas
375 7ade8b27 2022-12-30 thomas {{ define gotweb_render_commits(struct template *tp) }}
376 7ade8b27 2022-12-30 thomas {!
377 7ade8b27 2022-12-30 thomas struct request *c = tp->tp_arg;
378 7ade8b27 2022-12-30 thomas struct transport *t = c->t;
379 7ade8b27 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
380 7ade8b27 2022-12-30 thomas struct repo_commit *rc;
381 7ade8b27 2022-12-30 thomas struct gotweb_url diff, tree;
382 7ade8b27 2022-12-30 thomas
383 7ade8b27 2022-12-30 thomas diff = (struct gotweb_url){
384 7ade8b27 2022-12-30 thomas .action = DIFF,
385 7ade8b27 2022-12-30 thomas .index_page = -1,
386 7ade8b27 2022-12-30 thomas .page = -1,
387 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
388 7ade8b27 2022-12-30 thomas };
389 7ade8b27 2022-12-30 thomas tree = (struct gotweb_url){
390 7ade8b27 2022-12-30 thomas .action = TREE,
391 7ade8b27 2022-12-30 thomas .index_page = -1,
392 7ade8b27 2022-12-30 thomas .page = -1,
393 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
394 7ade8b27 2022-12-30 thomas };
395 7ade8b27 2022-12-30 thomas !}
396 fdd79f2f 2023-09-12 thomas <header class="subtitle">
397 fdd79f2f 2023-09-12 thomas <h2>Commits</h2>
398 fdd79f2f 2023-09-12 thomas </header>
399 7ade8b27 2022-12-30 thomas <div class="commits_content">
400 7ade8b27 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
401 7ade8b27 2022-12-30 thomas {!
402 7ade8b27 2022-12-30 thomas diff.commit = rc->commit_id;
403 7ade8b27 2022-12-30 thomas tree.commit = rc->commit_id;
404 7ade8b27 2022-12-30 thomas !}
405 7ade8b27 2022-12-30 thomas <div class="commits_header_wrapper">
406 fdd79f2f 2023-09-12 thomas <dl class="commits_header">
407 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
408 fdd79f2f 2023-09-12 thomas <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
409 fdd79f2f 2023-09-12 thomas <dt>From:</dt>
410 fdd79f2f 2023-09-12 thomas <dd>{{ rc->author }}</dd>
411 54ffadaf 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
412 fdd79f2f 2023-09-12 thomas <dt>Via:</dt>
413 fdd79f2f 2023-09-12 thomas <dd>{{ rc->committer }}</dd>
414 54ffadaf 2023-01-14 thomas {{ end }}
415 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
416 fdd79f2f 2023-09-12 thomas <dd>
417 7ade8b27 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
418 fdd79f2f 2023-09-12 thomas </dd>
419 fdd79f2f 2023-09-12 thomas </dl>
420 7ade8b27 2022-12-30 thomas </div>
421 fdd79f2f 2023-09-12 thomas <hr />
422 bbf94fd6 2023-01-02 thomas <div class="commit">
423 bbf94fd6 2023-01-02 thomas {{ "\n" }}
424 bbf94fd6 2023-01-02 thomas {{ rc->commit_msg }}
425 bbf94fd6 2023-01-02 thomas </div>
426 7ade8b27 2022-12-30 thomas <div class="navs_wrapper">
427 7ade8b27 2022-12-30 thomas <div class="navs">
428 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
429 7ade8b27 2022-12-30 thomas {{ " | " }}
430 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
431 7ade8b27 2022-12-30 thomas </div>
432 7ade8b27 2022-12-30 thomas </div>
433 fdd79f2f 2023-09-12 thomas <hr />
434 7ade8b27 2022-12-30 thomas {{ end }}
435 20bab626 2023-02-03 thomas {{ render gotweb_render_more(tp, COMMITS) }}
436 b82440e1 2023-01-06 thomas </div>
437 b82440e1 2023-01-06 thomas {{ end }}
438 b82440e1 2023-01-06 thomas
439 161663e7 2023-03-11 thomas {{ define gotweb_render_blob(struct template *tp) }}
440 b82440e1 2023-01-06 thomas {!
441 b82440e1 2023-01-06 thomas struct request *c = tp->tp_arg;
442 b82440e1 2023-01-06 thomas struct transport *t = c->t;
443 161663e7 2023-03-11 thomas struct got_blob_object *blob = t->blob;
444 b82440e1 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
445 b82440e1 2023-01-06 thomas !}
446 fdd79f2f 2023-09-12 thomas <header class="subtitle">
447 fdd79f2f 2023-09-12 thomas <h2>Blob</h2>
448 fdd79f2f 2023-09-12 thomas </header>
449 b82440e1 2023-01-06 thomas <div id="blob_content">
450 b82440e1 2023-01-06 thomas <div id="blob_header_wrapper">
451 fdd79f2f 2023-09-12 thomas <dl id="blob_header">
452 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
453 fdd79f2f 2023-09-12 thomas <dd>
454 fdd79f2f 2023-09-12 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
455 fdd79f2f 2023-09-12 thomas </dd>
456 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
457 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
458 fdd79f2f 2023-09-12 thomas </dl>
459 b82440e1 2023-01-06 thomas </div>
460 fdd79f2f 2023-09-12 thomas <hr />
461 b82440e1 2023-01-06 thomas <div id="blob">
462 b82440e1 2023-01-06 thomas <pre>
463 b82440e1 2023-01-06 thomas {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
464 b82440e1 2023-01-06 thomas </pre>
465 b82440e1 2023-01-06 thomas </div>
466 7ade8b27 2022-12-30 thomas </div>
467 d6795e9f 2022-12-30 thomas {{ end }}
468 d6795e9f 2022-12-30 thomas
469 b82440e1 2023-01-06 thomas {{ define gotweb_render_blob_line(struct template *tp, const char *line,
470 b82440e1 2023-01-06 thomas size_t no) }}
471 b82440e1 2023-01-06 thomas {!
472 b82440e1 2023-01-06 thomas char lineno[16];
473 b82440e1 2023-01-06 thomas int r;
474 b82440e1 2023-01-06 thomas
475 b82440e1 2023-01-06 thomas r = snprintf(lineno, sizeof(lineno), "%zu", no);
476 b82440e1 2023-01-06 thomas if (r < 0 || (size_t)r >= sizeof(lineno))
477 b82440e1 2023-01-06 thomas return -1;
478 b82440e1 2023-01-06 thomas !}
479 b82440e1 2023-01-06 thomas <div class="blob_line" id="line{{ lineno }}">
480 fdd79f2f 2023-09-12 thomas <a href="#line{{ lineno }}">{{ lineno }}</a>
481 fdd79f2f 2023-09-12 thomas <span class="blob_code">{{ line }}</span>
482 3c14c1f2 2023-01-06 thomas </div>
483 3c14c1f2 2023-01-06 thomas {{ end }}
484 3c14c1f2 2023-01-06 thomas
485 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree(struct template *tp) }}
486 3c14c1f2 2023-01-06 thomas {!
487 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
488 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
489 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
490 3c14c1f2 2023-01-06 thomas !}
491 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
492 fdd79f2f 2023-09-12 thomas <h2>Tree</h2>
493 fdd79f2f 2023-09-12 thomas </header>
494 3c14c1f2 2023-01-06 thomas <div id="tree_content">
495 3c14c1f2 2023-01-06 thomas <div id="tree_header_wrapper">
496 fdd79f2f 2023-09-12 thomas <dl id="tree_header">
497 fdd79f2f 2023-09-12 thomas <dt>Tree:</dt>
498 fdd79f2f 2023-09-12 thomas <dd><code class="commit-id">{{ rc->tree_id }}</code></dd>
499 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
500 fdd79f2f 2023-09-12 thomas <dd>
501 3c14c1f2 2023-01-06 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
502 fdd79f2f 2023-09-12 thomas </dd>
503 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
504 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</d>
505 fdd79f2f 2023-09-12 thomas </dl>
506 3c14c1f2 2023-01-06 thomas </div>
507 fdd79f2f 2023-09-12 thomas <hr />
508 fdd79f2f 2023-09-12 thomas <table id="tree">
509 3c14c1f2 2023-01-06 thomas {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
510 fdd79f2f 2023-09-12 thomas </table>
511 3c14c1f2 2023-01-06 thomas </div>
512 3c14c1f2 2023-01-06 thomas {{ end }}
513 3c14c1f2 2023-01-06 thomas
514 3c14c1f2 2023-01-06 thomas {{ define gotweb_render_tree_item(struct template *tp,
515 3c14c1f2 2023-01-06 thomas struct got_tree_entry *te) }}
516 3c14c1f2 2023-01-06 thomas {!
517 3c14c1f2 2023-01-06 thomas struct request *c = tp->tp_arg;
518 3c14c1f2 2023-01-06 thomas struct transport *t = c->t;
519 3c14c1f2 2023-01-06 thomas struct querystring *qs = t->qs;
520 3c14c1f2 2023-01-06 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
521 3c14c1f2 2023-01-06 thomas const char *modestr = "";
522 3c14c1f2 2023-01-06 thomas const char *name;
523 3c14c1f2 2023-01-06 thomas const char *folder;
524 3c14c1f2 2023-01-06 thomas char *dir = NULL;
525 3c14c1f2 2023-01-06 thomas mode_t mode;
526 3c14c1f2 2023-01-06 thomas struct gotweb_url url = {
527 3c14c1f2 2023-01-06 thomas .index_page = -1,
528 3c14c1f2 2023-01-06 thomas .page = -1,
529 3c14c1f2 2023-01-06 thomas .commit = rc->commit_id,
530 3c14c1f2 2023-01-06 thomas .path = qs->path,
531 3c14c1f2 2023-01-06 thomas };
532 3c14c1f2 2023-01-06 thomas
533 3c14c1f2 2023-01-06 thomas name = got_tree_entry_get_name(te);
534 3c14c1f2 2023-01-06 thomas mode = got_tree_entry_get_mode(te);
535 3c14c1f2 2023-01-06 thomas
536 3c14c1f2 2023-01-06 thomas folder = qs->folder ? qs->folder : "";
537 3c14c1f2 2023-01-06 thomas if (S_ISDIR(mode)) {
538 3c14c1f2 2023-01-06 thomas if (asprintf(&dir, "%s/%s", folder, name) == -1)
539 3c14c1f2 2023-01-06 thomas return (-1);
540 3c14c1f2 2023-01-06 thomas
541 3c14c1f2 2023-01-06 thomas url.action = TREE;
542 3c14c1f2 2023-01-06 thomas url.folder = dir;
543 3c14c1f2 2023-01-06 thomas } else {
544 3c14c1f2 2023-01-06 thomas url.action = BLOB;
545 3c14c1f2 2023-01-06 thomas url.folder = folder;
546 3c14c1f2 2023-01-06 thomas url.file = name;
547 3c14c1f2 2023-01-06 thomas }
548 3c14c1f2 2023-01-06 thomas
549 3c14c1f2 2023-01-06 thomas if (got_object_tree_entry_is_submodule(te))
550 3c14c1f2 2023-01-06 thomas modestr = "$";
551 3c14c1f2 2023-01-06 thomas else if (S_ISLNK(mode))
552 3c14c1f2 2023-01-06 thomas modestr = "@";
553 3c14c1f2 2023-01-06 thomas else if (S_ISDIR(mode))
554 3c14c1f2 2023-01-06 thomas modestr = "/";
555 3c14c1f2 2023-01-06 thomas else if (mode & S_IXUSR)
556 3c14c1f2 2023-01-06 thomas modestr = "*";
557 3c14c1f2 2023-01-06 thomas !}
558 fdd79f2f 2023-09-12 thomas <tr class="tree_wrapper">
559 3c14c1f2 2023-01-06 thomas {{ if S_ISDIR(mode) }}
560 fdd79f2f 2023-09-12 thomas <td class="tree_line" colspan=2>
561 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
562 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
563 3c14c1f2 2023-01-06 thomas </a>
564 fdd79f2f 2023-09-12 thomas </td>
565 3c14c1f2 2023-01-06 thomas {{ else }}
566 fdd79f2f 2023-09-12 thomas <td class="tree_line">
567 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
568 3c14c1f2 2023-01-06 thomas {{ name }}{{ modestr }}
569 3c14c1f2 2023-01-06 thomas </a>
570 fdd79f2f 2023-09-12 thomas </td>
571 fdd79f2f 2023-09-12 thomas <td class="tree_line_blank">
572 3c14c1f2 2023-01-06 thomas {! url.action = COMMITS; !}
573 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
574 3c14c1f2 2023-01-06 thomas commits
575 3c14c1f2 2023-01-06 thomas </a>
576 3c14c1f2 2023-01-06 thomas {{ " | " }}
577 3c14c1f2 2023-01-06 thomas {! url.action = BLAME; !}
578 3c14c1f2 2023-01-06 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
579 3c14c1f2 2023-01-06 thomas blame
580 3c14c1f2 2023-01-06 thomas </a>
581 fdd79f2f 2023-09-12 thomas </td>
582 3c14c1f2 2023-01-06 thomas {{ end }}
583 fdd79f2f 2023-09-12 thomas </tr>
584 3c14c1f2 2023-01-06 thomas {{ finally }}
585 3c14c1f2 2023-01-06 thomas {!
586 3c14c1f2 2023-01-06 thomas free(dir);
587 617497a6 2023-01-09 thomas !}
588 617497a6 2023-01-09 thomas {{ end }}
589 617497a6 2023-01-09 thomas
590 b3ba36c3 2023-01-14 thomas {{ define gotweb_render_tags(struct template *tp) }}
591 617497a6 2023-01-09 thomas {!
592 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
593 617497a6 2023-01-09 thomas struct transport *t = c->t;
594 617497a6 2023-01-09 thomas struct querystring *qs = t->qs;
595 617497a6 2023-01-09 thomas struct repo_tag *rt;
596 617497a6 2023-01-09 thomas int commit_found;
597 617497a6 2023-01-09 thomas
598 617497a6 2023-01-09 thomas commit_found = qs->commit == NULL;
599 3c14c1f2 2023-01-06 thomas !}
600 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
601 fdd79f2f 2023-09-12 thomas <h2>Tags</h2>
602 fdd79f2f 2023-09-12 thomas </header>
603 617497a6 2023-01-09 thomas <div id="tags_content">
604 617497a6 2023-01-09 thomas {{ if t->tag_count == 0 }}
605 617497a6 2023-01-09 thomas <div id="err_content">
606 617497a6 2023-01-09 thomas This repository contains no tags
607 617497a6 2023-01-09 thomas </div>
608 617497a6 2023-01-09 thomas {{ else }}
609 617497a6 2023-01-09 thomas {{ tailq-foreach rt &t->repo_tags entry }}
610 617497a6 2023-01-09 thomas {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
611 617497a6 2023-01-09 thomas {! commit_found = 1; !}
612 617497a6 2023-01-09 thomas {{ render tag_item(tp, rt) }}
613 617497a6 2023-01-09 thomas {{ end }}
614 617497a6 2023-01-09 thomas {{ end }}
615 617497a6 2023-01-09 thomas {{ if t->next_id || t->prev_id }}
616 20bab626 2023-02-03 thomas {! qs->action = TAGS; !}
617 617497a6 2023-01-09 thomas {{ render gotweb_render_navs(tp) }}
618 617497a6 2023-01-09 thomas {{ end }}
619 617497a6 2023-01-09 thomas {{ end }}
620 617497a6 2023-01-09 thomas </div>
621 b82440e1 2023-01-06 thomas {{ end }}
622 b82440e1 2023-01-06 thomas
623 617497a6 2023-01-09 thomas {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
624 617497a6 2023-01-09 thomas {!
625 617497a6 2023-01-09 thomas struct request *c = tp->tp_arg;
626 617497a6 2023-01-09 thomas struct transport *t = c->t;
627 617497a6 2023-01-09 thomas struct repo_dir *repo_dir = t->repo_dir;
628 617497a6 2023-01-09 thomas char *tag_name = rt->tag_name;
629 617497a6 2023-01-09 thomas char *msg = rt->tag_commit;
630 617497a6 2023-01-09 thomas char *nl;
631 617497a6 2023-01-09 thomas struct gotweb_url url = {
632 617497a6 2023-01-09 thomas .action = TAG,
633 617497a6 2023-01-09 thomas .index_page = -1,
634 617497a6 2023-01-09 thomas .page = -1,
635 617497a6 2023-01-09 thomas .path = repo_dir->name,
636 617497a6 2023-01-09 thomas .commit = rt->commit_id,
637 617497a6 2023-01-09 thomas };
638 617497a6 2023-01-09 thomas
639 617497a6 2023-01-09 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
640 617497a6 2023-01-09 thomas tag_name += 10;
641 617497a6 2023-01-09 thomas
642 617497a6 2023-01-09 thomas if (msg) {
643 617497a6 2023-01-09 thomas nl = strchr(msg, '\n');
644 617497a6 2023-01-09 thomas if (nl)
645 617497a6 2023-01-09 thomas *nl = '\0';
646 617497a6 2023-01-09 thomas }
647 617497a6 2023-01-09 thomas !}
648 617497a6 2023-01-09 thomas <div class="tag_age">
649 617497a6 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_DIFF) }}
650 617497a6 2023-01-09 thomas </div>
651 fdd79f2f 2023-09-12 thomas <div class="tag_name">{{ tag_name }}</div>
652 617497a6 2023-01-09 thomas <div class="tag_log">
653 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
654 617497a6 2023-01-09 thomas {{ msg }}
655 617497a6 2023-01-09 thomas </a>
656 617497a6 2023-01-09 thomas </div>
657 617497a6 2023-01-09 thomas <div class="navs_wrapper">
658 617497a6 2023-01-09 thomas <div class="navs">
659 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
660 617497a6 2023-01-09 thomas {{ " | " }}
661 617497a6 2023-01-09 thomas {! url.action = BRIEFS; !}
662 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
663 617497a6 2023-01-09 thomas {{ " | " }}
664 617497a6 2023-01-09 thomas {! url.action = COMMITS; !}
665 617497a6 2023-01-09 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
666 617497a6 2023-01-09 thomas </div>
667 617497a6 2023-01-09 thomas </div>
668 fdd79f2f 2023-09-12 thomas <hr />
669 617497a6 2023-01-09 thomas {{ end }}
670 145ca42a 2023-01-09 thomas
671 145ca42a 2023-01-09 thomas {{ define gotweb_render_tag(struct template *tp) }}
672 145ca42a 2023-01-09 thomas {!
673 145ca42a 2023-01-09 thomas struct request *c = tp->tp_arg;
674 145ca42a 2023-01-09 thomas struct transport *t = c->t;
675 145ca42a 2023-01-09 thomas struct repo_tag *rt;
676 145ca42a 2023-01-09 thomas const char *tag_name;
677 617497a6 2023-01-09 thomas
678 145ca42a 2023-01-09 thomas rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
679 145ca42a 2023-01-09 thomas tag_name = rt->tag_name;
680 145ca42a 2023-01-09 thomas
681 145ca42a 2023-01-09 thomas if (strncmp(tag_name, "refs/", 5) == 0)
682 145ca42a 2023-01-09 thomas tag_name += 5;
683 145ca42a 2023-01-09 thomas !}
684 fdd79f2f 2023-09-12 thomas <header class="subtitle">
685 fdd79f2f 2023-09-12 thomas <h2>Tag</h2>
686 fdd79f2f 2023-09-12 thomas </header>
687 145ca42a 2023-01-09 thomas <div id="tags_content">
688 145ca42a 2023-01-09 thomas <div id="tag_header_wrapper">
689 fdd79f2f 2023-09-12 thomas <dl id="tag_header">
690 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
691 fdd79f2f 2023-09-12 thomas <dd>
692 fdd79f2f 2023-09-12 thomas <code class="commit-id">{{ rt->commit_id }}</code>
693 145ca42a 2023-01-09 thomas {{ " " }}
694 145ca42a 2023-01-09 thomas <span class="refs_str">({{ tag_name }})</span>
695 fdd79f2f 2023-09-12 thomas </dd>
696 fdd79f2f 2023-09-12 thomas <dt>Tagger:</dt>
697 fdd79f2f 2023-09-12 thomas <dd>{{ rt->tagger }}</dd>
698 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
699 fdd79f2f 2023-09-12 thomas <dd>
700 145ca42a 2023-01-09 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_LONG)}}
701 fdd79f2f 2023-09-12 thomas </dd>
702 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
703 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rt->commit_msg }}</dd>
704 fdd79f2f 2023-09-12 thomas </dl>
705 fdd79f2f 2023-09-12 thomas <hr />
706 fdd79f2f 2023-09-12 thomas <pre id="tag_commit">
707 145ca42a 2023-01-09 thomas {{ rt->tag_commit }}
708 fdd79f2f 2023-09-12 thomas </pre>
709 dccd05b4 2023-01-10 thomas </div>
710 dccd05b4 2023-01-10 thomas </div>
711 dccd05b4 2023-01-10 thomas {{ end }}
712 dccd05b4 2023-01-10 thomas
713 161663e7 2023-03-11 thomas {{ define gotweb_render_diff(struct template *tp) }}
714 dccd05b4 2023-01-10 thomas {!
715 dccd05b4 2023-01-10 thomas struct request *c = tp->tp_arg;
716 dccd05b4 2023-01-10 thomas struct transport *t = c->t;
717 161663e7 2023-03-11 thomas FILE *fp = t->fp;
718 dccd05b4 2023-01-10 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
719 dccd05b4 2023-01-10 thomas char *line = NULL;
720 dccd05b4 2023-01-10 thomas size_t linesize = 0;
721 dccd05b4 2023-01-10 thomas ssize_t linelen;
722 dccd05b4 2023-01-10 thomas !}
723 fdd79f2f 2023-09-12 thomas <header class="subtitle">
724 fdd79f2f 2023-09-12 thomas <h2>Commit Diff</h2>
725 fdd79f2f 2023-09-12 thomas </header>
726 dccd05b4 2023-01-10 thomas <div id="diff_content">
727 dccd05b4 2023-01-10 thomas <div id="diff_header_wrapper">
728 fdd79f2f 2023-09-12 thomas <dl id="diff_header">
729 fdd79f2f 2023-09-12 thomas <dt>Commit:</dt>
730 fdd79f2f 2023-09-12 thomas <dd><code class="commit-id">{{ rc->commit_id }}</code></dd>
731 fdd79f2f 2023-09-12 thomas <dt>From:</dt>
732 fdd79f2f 2023-09-12 thomas <dd>{{ rc->author }}</dd>
733 f7ee7604 2023-01-14 thomas {{ if strcmp(rc->committer, rc->author) != 0 }}
734 fdd79f2f 2023-09-12 thomas <dt>Via:</dt>
735 fdd79f2f 2023-09-12 thomas <dd>{{ rc->committer }}</dd>
736 f7ee7604 2023-01-14 thomas {{ end }}
737 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
738 fdd79f2f 2023-09-12 thomas <dd>
739 dccd05b4 2023-01-10 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
740 fdd79f2f 2023-09-12 thomas </dd>
741 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
742 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
743 fdd79f2f 2023-09-12 thomas </dl>
744 145ca42a 2023-01-09 thomas </div>
745 fdd79f2f 2023-09-12 thomas <hr />
746 fdd79f2f 2023-09-12 thomas <pre id="diff">
747 dccd05b4 2023-01-10 thomas {{ while (linelen = getline(&line, &linesize, fp)) != -1 }}
748 dccd05b4 2023-01-10 thomas {{ render diff_line(tp, line) }}
749 dccd05b4 2023-01-10 thomas {{ end }}
750 fdd79f2f 2023-09-12 thomas </pre>
751 145ca42a 2023-01-09 thomas </div>
752 dccd05b4 2023-01-10 thomas {{ finally }}
753 dccd05b4 2023-01-10 thomas {! free(line); !}
754 145ca42a 2023-01-09 thomas {{ end }}
755 145ca42a 2023-01-09 thomas
756 dccd05b4 2023-01-10 thomas {{ define diff_line(struct template *tp, char *line )}}
757 dccd05b4 2023-01-10 thomas {!
758 dccd05b4 2023-01-10 thomas const char *color = NULL;
759 dccd05b4 2023-01-10 thomas char *nl;
760 dccd05b4 2023-01-10 thomas
761 dccd05b4 2023-01-10 thomas if (!strncmp(line, "-", 1))
762 dccd05b4 2023-01-10 thomas color = "diff_minus";
763 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "+", 1))
764 dccd05b4 2023-01-10 thomas color = "diff_plus";
765 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "@@", 2))
766 dccd05b4 2023-01-10 thomas color = "diff_chunk_header";
767 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "commit +", 8) ||
768 dccd05b4 2023-01-10 thomas !strncmp(line, "commit -", 8) ||
769 dccd05b4 2023-01-10 thomas !strncmp(line, "blob +", 6) ||
770 dccd05b4 2023-01-10 thomas !strncmp(line, "blob -", 6) ||
771 dccd05b4 2023-01-10 thomas !strncmp(line, "file +", 6) ||
772 dccd05b4 2023-01-10 thomas !strncmp(line, "file -", 6))
773 dccd05b4 2023-01-10 thomas color = "diff_meta";
774 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "from:", 5) || !strncmp(line, "via:", 4))
775 dccd05b4 2023-01-10 thomas color = "diff_author";
776 dccd05b4 2023-01-10 thomas else if (!strncmp(line, "date:", 5))
777 dccd05b4 2023-01-10 thomas color = "diff_date";
778 dccd05b4 2023-01-10 thomas
779 dccd05b4 2023-01-10 thomas nl = strchr(line, '\n');
780 dccd05b4 2023-01-10 thomas if (nl)
781 dccd05b4 2023-01-10 thomas *nl = '\0';
782 dccd05b4 2023-01-10 thomas !}
783 fdd79f2f 2023-09-12 thomas <span class="diff_line {{ color }}">{{ line }}</span>{{"\n"}}
784 dccd05b4 2023-01-10 thomas {{ end }}
785 dccd05b4 2023-01-10 thomas
786 00abe30b 2023-01-14 thomas {{ define gotweb_render_branches(struct template *tp,
787 00abe30b 2023-01-14 thomas struct got_reflist_head *refs) }}
788 00abe30b 2023-01-14 thomas {!
789 00abe30b 2023-01-14 thomas struct got_reflist_entry *re;
790 00abe30b 2023-01-14 thomas !}
791 fdd79f2f 2023-09-12 thomas <header class='subtitle'>
792 fdd79f2f 2023-09-12 thomas <h2>Branches</h2>
793 fdd79f2f 2023-09-12 thomas </header>
794 00abe30b 2023-01-14 thomas <div id="branches_content">
795 00abe30b 2023-01-14 thomas {{ tailq-foreach re refs entry }}
796 00abe30b 2023-01-14 thomas {{ if !got_ref_is_symbolic(re->ref) }}
797 00abe30b 2023-01-14 thomas {{ render branch(tp, re) }}
798 00abe30b 2023-01-14 thomas {{ end }}
799 00abe30b 2023-01-14 thomas {{ end }}
800 00abe30b 2023-01-14 thomas </div>
801 00abe30b 2023-01-14 thomas {{ end }}
802 00abe30b 2023-01-14 thomas
803 00abe30b 2023-01-14 thomas {{ define branch(struct template *tp, struct got_reflist_entry *re) }}
804 00abe30b 2023-01-14 thomas {!
805 00abe30b 2023-01-14 thomas const struct got_error *err;
806 00abe30b 2023-01-14 thomas struct request *c = tp->tp_arg;
807 00abe30b 2023-01-14 thomas struct querystring *qs = c->t->qs;
808 00abe30b 2023-01-14 thomas const char *refname;
809 53bf32b8 2023-01-23 thomas time_t age;
810 00abe30b 2023-01-14 thomas struct gotweb_url url = {
811 00abe30b 2023-01-14 thomas .action = SUMMARY,
812 00abe30b 2023-01-14 thomas .index_page = -1,
813 00abe30b 2023-01-14 thomas .page = -1,
814 00abe30b 2023-01-14 thomas .path = qs->path,
815 00abe30b 2023-01-14 thomas };
816 00abe30b 2023-01-14 thomas
817 00abe30b 2023-01-14 thomas refname = got_ref_get_name(re->ref);
818 00abe30b 2023-01-14 thomas
819 53bf32b8 2023-01-23 thomas err = got_get_repo_age(&age, c, refname);
820 00abe30b 2023-01-14 thomas if (err) {
821 00abe30b 2023-01-14 thomas log_warnx("%s: %s", __func__, err->msg);
822 00abe30b 2023-01-14 thomas return -1;
823 00abe30b 2023-01-14 thomas }
824 00abe30b 2023-01-14 thomas
825 00abe30b 2023-01-14 thomas if (strncmp(refname, "refs/heads/", 11) == 0)
826 00abe30b 2023-01-14 thomas refname += 11;
827 00abe30b 2023-01-14 thomas
828 00abe30b 2023-01-14 thomas url.headref = refname;
829 00abe30b 2023-01-14 thomas !}
830 fdd79f2f 2023-09-12 thomas <section class="branches_wrapper">
831 53bf32b8 2023-01-23 thomas <div class="branches_age">
832 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, age, TM_DIFF) }}
833 53bf32b8 2023-01-23 thomas </div>
834 00abe30b 2023-01-14 thomas <div class="branch">
835 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
836 00abe30b 2023-01-14 thomas </div>
837 00abe30b 2023-01-14 thomas <div class="navs_wrapper">
838 00abe30b 2023-01-14 thomas <div class="navs">
839 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">summary</a>
840 00abe30b 2023-01-14 thomas {{" | "}}
841 00abe30b 2023-01-14 thomas {! url.action = BRIEFS; !}
842 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
843 00abe30b 2023-01-14 thomas {{" | "}}
844 00abe30b 2023-01-14 thomas {! url.action = COMMITS; !}
845 00abe30b 2023-01-14 thomas <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
846 00abe30b 2023-01-14 thomas </div>
847 00abe30b 2023-01-14 thomas </div>
848 fdd79f2f 2023-09-12 thomas <hr />
849 fdd79f2f 2023-09-12 thomas </section>
850 18e466eb 2023-01-14 thomas {{ end }}
851 18e466eb 2023-01-14 thomas
852 161663e7 2023-03-11 thomas {{ define gotweb_render_summary(struct template *tp) }}
853 18e466eb 2023-01-14 thomas {!
854 18e466eb 2023-01-14 thomas struct request *c = tp->tp_arg;
855 18e466eb 2023-01-14 thomas struct server *srv = c->srv;
856 18e466eb 2023-01-14 thomas struct transport *t = c->t;
857 161663e7 2023-03-11 thomas struct got_reflist_head *refs = &t->refs;
858 18e466eb 2023-01-14 thomas !}
859 fdd79f2f 2023-09-12 thomas <dl id="summary_wrapper">
860 18e466eb 2023-01-14 thomas {{ if srv->show_repo_description }}
861 fdd79f2f 2023-09-12 thomas <dt>Description:</dt>
862 fdd79f2f 2023-09-12 thomas <dd>{{ t->repo_dir->description }}</dd>
863 18e466eb 2023-01-14 thomas {{ end }}
864 18e466eb 2023-01-14 thomas {{ if srv->show_repo_owner }}
865 fdd79f2f 2023-09-12 thomas <dt>Owner:</dt>
866 fdd79f2f 2023-09-12 thomas <dd>{{ t->repo_dir->owner }}</dd>
867 18e466eb 2023-01-14 thomas {{ end }}
868 18e466eb 2023-01-14 thomas {{ if srv->show_repo_age }}
869 fdd79f2f 2023-09-12 thomas <dt>Last Change:</dt>
870 fdd79f2f 2023-09-12 thomas <dd>
871 53bf32b8 2023-01-23 thomas {{ render gotweb_render_age(tp, t->repo_dir->age, TM_DIFF) }}
872 fdd79f2f 2023-09-12 thomas </dd>
873 18e466eb 2023-01-14 thomas {{ end }}
874 18e466eb 2023-01-14 thomas {{ if srv->show_repo_cloneurl }}
875 fdd79f2f 2023-09-12 thomas <dt>Clone URL:</dt>
876 fdd79f2f 2023-09-12 thomas <dd><pre class="clone-url">{{ t->repo_dir->url }}</pre></dd>
877 18e466eb 2023-01-14 thomas {{ end }}
878 fdd79f2f 2023-09-12 thomas </dl>
879 18e466eb 2023-01-14 thomas {{ render gotweb_render_briefs(tp) }}
880 18e466eb 2023-01-14 thomas {{ render gotweb_render_tags(tp) }}
881 18e466eb 2023-01-14 thomas {{ render gotweb_render_branches(tp, refs) }}
882 00abe30b 2023-01-14 thomas {{ end }}
883 00abe30b 2023-01-14 thomas
884 1cd5d437 2023-01-15 thomas {{ define gotweb_render_blame(struct template *tp) }}
885 1cd5d437 2023-01-15 thomas {!
886 1cd5d437 2023-01-15 thomas const struct got_error *err;
887 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
888 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
889 1cd5d437 2023-01-15 thomas struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
890 1cd5d437 2023-01-15 thomas !}
891 fdd79f2f 2023-09-12 thomas <header class="subtitle">
892 fdd79f2f 2023-09-12 thomas <h2>Blame</h2>
893 fdd79f2f 2023-09-12 thomas </header>
894 1cd5d437 2023-01-15 thomas <div id="blame_content">
895 1cd5d437 2023-01-15 thomas <div id="blame_header_wrapper">
896 fdd79f2f 2023-09-12 thomas <dl id="blame_header">
897 fdd79f2f 2023-09-12 thomas <dt>Date:</dt>
898 fdd79f2f 2023-09-12 thomas <dd>
899 1cd5d437 2023-01-15 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
900 fdd79f2f 2023-09-12 thomas </dd>
901 fdd79f2f 2023-09-12 thomas <dt>Message:</dt>
902 fdd79f2f 2023-09-12 thomas <dd class="commit-msg">{{ rc->commit_msg }}</dd>
903 fdd79f2f 2023-09-12 thomas </dl>
904 1cd5d437 2023-01-15 thomas </div>
905 fdd79f2f 2023-09-12 thomas <hr />
906 fdd79f2f 2023-09-12 thomas <pre id="blame">
907 1cd5d437 2023-01-15 thomas {!
908 1cd5d437 2023-01-15 thomas err = got_output_file_blame(c, &blame_line);
909 aa2aecab 2023-05-25 thomas if (err && err->code != GOT_ERR_CANCELLED)
910 1cd5d437 2023-01-15 thomas log_warnx("%s: got_output_file_blame: %s", __func__,
911 1cd5d437 2023-01-15 thomas err->msg);
912 aa2aecab 2023-05-25 thomas if (err)
913 1cd5d437 2023-01-15 thomas return (-1);
914 1cd5d437 2023-01-15 thomas !}
915 fdd79f2f 2023-09-12 thomas </pre>
916 1cd5d437 2023-01-15 thomas </div>
917 1cd5d437 2023-01-15 thomas {{ end }}
918 1cd5d437 2023-01-15 thomas
919 1cd5d437 2023-01-15 thomas {{ define blame_line(struct template *tp, const char *line,
920 1cd5d437 2023-01-15 thomas struct blame_line *bline, int lprec, int lcur) }}
921 1cd5d437 2023-01-15 thomas {!
922 1cd5d437 2023-01-15 thomas struct request *c = tp->tp_arg;
923 1cd5d437 2023-01-15 thomas struct transport *t = c->t;
924 1cd5d437 2023-01-15 thomas struct repo_dir *repo_dir = t->repo_dir;
925 1cd5d437 2023-01-15 thomas char *committer, *s;
926 1cd5d437 2023-01-15 thomas struct gotweb_url url = {
927 1cd5d437 2023-01-15 thomas .action = DIFF,
928 1cd5d437 2023-01-15 thomas .index_page = -1,
929 1cd5d437 2023-01-15 thomas .page = -1,
930 1cd5d437 2023-01-15 thomas .path = repo_dir->name,
931 1cd5d437 2023-01-15 thomas .commit = bline->id_str,
932 1cd5d437 2023-01-15 thomas };
933 1cd5d437 2023-01-15 thomas
934 1cd5d437 2023-01-15 thomas s = strchr(bline->committer, '<');
935 1cd5d437 2023-01-15 thomas committer = s ? s + 1 : bline->committer;
936 1cd5d437 2023-01-15 thomas
937 1cd5d437 2023-01-15 thomas s = strchr(committer, '@');
938 1cd5d437 2023-01-15 thomas if (s)
939 1cd5d437 2023-01-15 thomas *s = '\0';
940 1cd5d437 2023-01-15 thomas !}
941 1cd5d437 2023-01-15 thomas <div class="blame_wrapper">
942 1cd5d437 2023-01-15 thomas <div class="blame_number">{{ printf "%.*d", lprec, lcur }}</div>
943 1cd5d437 2023-01-15 thomas <div class="blame_hash">
944 1cd5d437 2023-01-15 thomas <a href="{{ render gotweb_render_url(c, &url) }}">
945 1cd5d437 2023-01-15 thomas {{ printf "%.8s", bline->id_str }}
946 1cd5d437 2023-01-15 thomas </a>
947 1cd5d437 2023-01-15 thomas </div>
948 1cd5d437 2023-01-15 thomas <div class="blame_date">{{ bline->datebuf }}</div>
949 1cd5d437 2023-01-15 thomas <div class="blame_author">{{ printf "%.9s", committer }}</div>
950 1cd5d437 2023-01-15 thomas <div class="blame_code">{{ line }}</div>
951 1cd5d437 2023-01-15 thomas </div>
952 1cd5d437 2023-01-15 thomas {{ end }}
953 1cd5d437 2023-01-15 thomas
954 d6795e9f 2022-12-30 thomas {{ define gotweb_render_rss(struct template *tp) }}
955 d6795e9f 2022-12-30 thomas {!
956 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
957 d6795e9f 2022-12-30 thomas struct server *srv = c->srv;
958 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
959 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
960 d6795e9f 2022-12-30 thomas struct repo_tag *rt;
961 d6795e9f 2022-12-30 thomas struct gotweb_url summary = {
962 d6795e9f 2022-12-30 thomas .action = SUMMARY,
963 d6795e9f 2022-12-30 thomas .index_page = -1,
964 d6795e9f 2022-12-30 thomas .page = -1,
965 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
966 d6795e9f 2022-12-30 thomas };
967 d6795e9f 2022-12-30 thomas !}
968 d6795e9f 2022-12-30 thomas <?xml version="1.0" encoding="UTF-8"?>
969 d6795e9f 2022-12-30 thomas <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
970 d6795e9f 2022-12-30 thomas <channel>
971 d6795e9f 2022-12-30 thomas <title>Tags of {{ repo_dir->name }}</title>
972 d6795e9f 2022-12-30 thomas <link>
973 d6795e9f 2022-12-30 thomas <![CDATA[
974 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &summary) }}
975 d6795e9f 2022-12-30 thomas ]]>
976 d6795e9f 2022-12-30 thomas </link>
977 d6795e9f 2022-12-30 thomas {{ if srv->show_repo_description }}
978 d6795e9f 2022-12-30 thomas <description>{{ repo_dir->description }}</description>
979 d6795e9f 2022-12-30 thomas {{ end }}
980 d6795e9f 2022-12-30 thomas {{ tailq-foreach rt &t->repo_tags entry }}
981 d6795e9f 2022-12-30 thomas {{ render rss_tag_item(tp, rt) }}
982 d6795e9f 2022-12-30 thomas {{ end }}
983 d6795e9f 2022-12-30 thomas </channel>
984 d6795e9f 2022-12-30 thomas </rss>
985 d6795e9f 2022-12-30 thomas {{ end }}
986 d6795e9f 2022-12-30 thomas
987 d6795e9f 2022-12-30 thomas {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
988 d6795e9f 2022-12-30 thomas {!
989 d6795e9f 2022-12-30 thomas struct request *c = tp->tp_arg;
990 d6795e9f 2022-12-30 thomas struct transport *t = c->t;
991 d6795e9f 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
992 d6795e9f 2022-12-30 thomas char *tag_name = rt->tag_name;
993 d6795e9f 2022-12-30 thomas struct gotweb_url tag = {
994 d6795e9f 2022-12-30 thomas .action = TAG,
995 d6795e9f 2022-12-30 thomas .index_page = -1,
996 d6795e9f 2022-12-30 thomas .page = -1,
997 d6795e9f 2022-12-30 thomas .path = repo_dir->name,
998 d6795e9f 2022-12-30 thomas .commit = rt->commit_id,
999 d6795e9f 2022-12-30 thomas };
1000 d6795e9f 2022-12-30 thomas
1001 d6795e9f 2022-12-30 thomas if (strncmp(tag_name, "refs/tags/", 10) == 0)
1002 d6795e9f 2022-12-30 thomas tag_name += 10;
1003 d6795e9f 2022-12-30 thomas !}
1004 d6795e9f 2022-12-30 thomas <item>
1005 d6795e9f 2022-12-30 thomas <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
1006 d6795e9f 2022-12-30 thomas <link>
1007 d6795e9f 2022-12-30 thomas <![CDATA[
1008 d6795e9f 2022-12-30 thomas {{ render gotweb_render_absolute_url(c, &tag) }}
1009 d6795e9f 2022-12-30 thomas ]]>
1010 d6795e9f 2022-12-30 thomas </link>
1011 d6795e9f 2022-12-30 thomas <description>
1012 d6795e9f 2022-12-30 thomas <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
1013 d6795e9f 2022-12-30 thomas </description>
1014 d6795e9f 2022-12-30 thomas {{ render rss_author(tp, rt->tagger) }}
1015 d6795e9f 2022-12-30 thomas <guid isPermaLink="false">{{ rt->commit_id }}</guid>
1016 d6795e9f 2022-12-30 thomas <pubDate>
1017 d6795e9f 2022-12-30 thomas {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
1018 d6795e9f 2022-12-30 thomas </pubDate>
1019 d6795e9f 2022-12-30 thomas </item>
1020 7ade8b27 2022-12-30 thomas {{ end }}
1021 d6795e9f 2022-12-30 thomas
1022 d6795e9f 2022-12-30 thomas {{ define rss_author(struct template *tp, char *author) }}
1023 d6795e9f 2022-12-30 thomas {!
1024 d6795e9f 2022-12-30 thomas char *t, *mail;
1025 d6795e9f 2022-12-30 thomas
1026 d6795e9f 2022-12-30 thomas /* what to do if the author name contains a paren? */
1027 d6795e9f 2022-12-30 thomas if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
1028 d6795e9f 2022-12-30 thomas return 0;
1029 d6795e9f 2022-12-30 thomas
1030 d6795e9f 2022-12-30 thomas t = strchr(author, '<');
1031 d6795e9f 2022-12-30 thomas if (t == NULL)
1032 d6795e9f 2022-12-30 thomas return 0;
1033 d6795e9f 2022-12-30 thomas *t = '\0';
1034 d6795e9f 2022-12-30 thomas mail = t+1;
1035 d6795e9f 2022-12-30 thomas
1036 d6795e9f 2022-12-30 thomas while (isspace((unsigned char)*--t))
1037 d6795e9f 2022-12-30 thomas *t = '\0';
1038 d6795e9f 2022-12-30 thomas
1039 d6795e9f 2022-12-30 thomas t = strchr(mail, '>');
1040 d6795e9f 2022-12-30 thomas if (t == NULL)
1041 d6795e9f 2022-12-30 thomas return 0;
1042 d6795e9f 2022-12-30 thomas *t = '\0';
1043 d6795e9f 2022-12-30 thomas !}
1044 d6795e9f 2022-12-30 thomas <author>
1045 d6795e9f 2022-12-30 thomas {{ mail }} {{" "}} ({{ author }})
1046 d6795e9f 2022-12-30 thomas </author>
1047 d6795e9f 2022-12-30 thomas {{ end }}