Blame


1 ed619ca0 2022-12-14 op {!
2 ed619ca0 2022-12-14 op /*
3 ed619ca0 2022-12-14 op * Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 ed619ca0 2022-12-14 op * Copyright (c) 2016, 2019, 2020-2022 Tracey Emery <tracey@traceyemery.net>
5 ed619ca0 2022-12-14 op *
6 ed619ca0 2022-12-14 op * Permission to use, copy, modify, and distribute this software for any
7 ed619ca0 2022-12-14 op * purpose with or without fee is hereby granted, provided that the above
8 ed619ca0 2022-12-14 op * copyright notice and this permission notice appear in all copies.
9 ed619ca0 2022-12-14 op *
10 ed619ca0 2022-12-14 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 ed619ca0 2022-12-14 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 ed619ca0 2022-12-14 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ed619ca0 2022-12-14 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 ed619ca0 2022-12-14 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ed619ca0 2022-12-14 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 ed619ca0 2022-12-14 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 ed619ca0 2022-12-14 op */
18 ed619ca0 2022-12-14 op
19 ed619ca0 2022-12-14 op #include <sys/types.h>
20 ed619ca0 2022-12-14 op #include <sys/queue.h>
21 43d421de 2023-01-05 op #include <sys/stat.h>
22 ed619ca0 2022-12-14 op
23 1abb18e1 2022-12-20 op #include <ctype.h>
24 ed619ca0 2022-12-14 op #include <event.h>
25 ed619ca0 2022-12-14 op #include <stdint.h>
26 43d421de 2023-01-05 op #include <stdio.h>
27 ed619ca0 2022-12-14 op #include <stdlib.h>
28 ed619ca0 2022-12-14 op #include <string.h>
29 43d421de 2023-01-05 op #include <sha1.h>
30 ed619ca0 2022-12-14 op #include <imsg.h>
31 ed619ca0 2022-12-14 op
32 43d421de 2023-01-05 op #include "got_object.h"
33 43d421de 2023-01-05 op
34 ed619ca0 2022-12-14 op #include "proc.h"
35 ed619ca0 2022-12-14 op
36 ed619ca0 2022-12-14 op #include "gotwebd.h"
37 ed619ca0 2022-12-14 op #include "tmpl.h"
38 ed619ca0 2022-12-14 op
39 298f95fb 2023-01-05 op static int gotweb_render_blob_line(struct template *, const char *, size_t);
40 43d421de 2023-01-05 op static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
41 298f95fb 2023-01-05 op
42 067396e6 2023-01-09 op static inline int tag_item(struct template *, struct repo_tag *);
43 1abb18e1 2022-12-20 op static inline int rss_tag_item(struct template *, struct repo_tag *);
44 1abb18e1 2022-12-20 op static inline int rss_author(struct template *, char *);
45 1abb18e1 2022-12-20 op
46 ed619ca0 2022-12-14 op static int
47 ed619ca0 2022-12-14 op gotweb_render_age(struct template *tp, time_t time, int ref_tm)
48 ed619ca0 2022-12-14 op {
49 ed619ca0 2022-12-14 op const struct got_error *err;
50 ed619ca0 2022-12-14 op char *age;
51 ed619ca0 2022-12-14 op int r;
52 ed619ca0 2022-12-14 op
53 ed619ca0 2022-12-14 op err = gotweb_get_time_str(&age, time, ref_tm);
54 ed619ca0 2022-12-14 op if (err)
55 ed619ca0 2022-12-14 op return 0;
56 ed619ca0 2022-12-14 op r = tp->tp_puts(tp, age);
57 ed619ca0 2022-12-14 op free(age);
58 ed619ca0 2022-12-14 op return r;
59 ed619ca0 2022-12-14 op }
60 ed619ca0 2022-12-14 op
61 ed619ca0 2022-12-14 op !}
62 ed619ca0 2022-12-14 op
63 ed619ca0 2022-12-14 op {{ define gotweb_render_header(struct template *tp) }}
64 ed619ca0 2022-12-14 op {!
65 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
66 ed619ca0 2022-12-14 op struct server *srv = c->srv;
67 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
68 ed619ca0 2022-12-14 op struct gotweb_url u_path;
69 d19d9fce 2022-12-20 op const char *prfx = c->document_uri;
70 ed619ca0 2022-12-14 op const char *css = srv->custom_css;
71 ed619ca0 2022-12-14 op
72 ed619ca0 2022-12-14 op memset(&u_path, 0, sizeof(u_path));
73 ed619ca0 2022-12-14 op u_path.index_page = -1;
74 ed619ca0 2022-12-14 op u_path.page = -1;
75 ed619ca0 2022-12-14 op u_path.action = SUMMARY;
76 ed619ca0 2022-12-14 op !}
77 ed619ca0 2022-12-14 op <!doctype html>
78 ed619ca0 2022-12-14 op <html>
79 ed619ca0 2022-12-14 op <head>
80 ed619ca0 2022-12-14 op <meta charset="utf-8" />
81 ed619ca0 2022-12-14 op <title>{{ srv->site_name }}</title>
82 ed619ca0 2022-12-14 op <meta name="viewport" content="initial-scale=.75" />
83 ed619ca0 2022-12-14 op <meta name="msapplication-TileColor" content="#da532c" />
84 ed619ca0 2022-12-14 op <meta name="theme-color" content="#ffffff"/>
85 ed619ca0 2022-12-14 op <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
86 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
87 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
88 ed619ca0 2022-12-14 op <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
89 ed619ca0 2022-12-14 op <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
90 ed619ca0 2022-12-14 op <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
91 ed619ca0 2022-12-14 op </head>
92 ed619ca0 2022-12-14 op <body>
93 ed619ca0 2022-12-14 op <div id="gw_body">
94 ed619ca0 2022-12-14 op <div id="header">
95 ed619ca0 2022-12-14 op <div id="got_link">
96 ed619ca0 2022-12-14 op <a href="{{ srv->logo_url }}" target="_blank">
97 ed619ca0 2022-12-14 op <img src="{{ prfx }}{{ srv->logo }}" />
98 ed619ca0 2022-12-14 op </a>
99 ed619ca0 2022-12-14 op </div>
100 ed619ca0 2022-12-14 op </div>
101 ed619ca0 2022-12-14 op <div id="site_path">
102 ed619ca0 2022-12-14 op <div id="site_link">
103 ed619ca0 2022-12-14 op <a href="?index_page={{ printf "%d", qs->index_page }}">
104 ed619ca0 2022-12-14 op {{ srv->site_link }}
105 ed619ca0 2022-12-14 op </a>
106 ed619ca0 2022-12-14 op {{ if qs->path }}
107 ed619ca0 2022-12-14 op {! u_path.path = qs->path; !}
108 ed619ca0 2022-12-14 op {{ " / " }}
109 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
110 ed619ca0 2022-12-14 op {{ qs->path }}
111 ed619ca0 2022-12-14 op </a>
112 ed619ca0 2022-12-14 op {{ end }}
113 ed619ca0 2022-12-14 op {{ if qs->action != INDEX }}
114 ed619ca0 2022-12-14 op {{ " / " }}{{ gotweb_action_name(qs->action) }}
115 ed619ca0 2022-12-14 op {{ end }}
116 ed619ca0 2022-12-14 op </div>
117 ed619ca0 2022-12-14 op </div>
118 ed619ca0 2022-12-14 op <div id="content">
119 ed619ca0 2022-12-14 op {{ end }}
120 ed619ca0 2022-12-14 op
121 ed619ca0 2022-12-14 op {{ define gotweb_render_footer(struct template *tp) }}
122 ed619ca0 2022-12-14 op {!
123 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
124 ed619ca0 2022-12-14 op struct server *srv = c->srv;
125 ed619ca0 2022-12-14 op !}
126 ed619ca0 2022-12-14 op <div id="site_owner_wrapper">
127 ed619ca0 2022-12-14 op <div id="site_owner">
128 ed619ca0 2022-12-14 op {{ if srv->show_site_owner }}
129 ed619ca0 2022-12-14 op {{ srv->site_owner }}
130 ed619ca0 2022-12-14 op {{ end }}
131 ed619ca0 2022-12-14 op </div>
132 ed619ca0 2022-12-14 op </div>
133 ed619ca0 2022-12-14 op </div>
134 ed619ca0 2022-12-14 op </div>
135 ed619ca0 2022-12-14 op </body>
136 ed619ca0 2022-12-14 op </html>
137 ed619ca0 2022-12-14 op {{ end }}
138 ed619ca0 2022-12-14 op
139 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
140 ed619ca0 2022-12-14 op {!
141 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
142 ed619ca0 2022-12-14 op struct server *srv = c->srv;
143 ed619ca0 2022-12-14 op !}
144 ed619ca0 2022-12-14 op <div id="index_header">
145 ed619ca0 2022-12-14 op <div id="index_header_project">
146 ed619ca0 2022-12-14 op Project
147 ed619ca0 2022-12-14 op </div>
148 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
149 ed619ca0 2022-12-14 op <div id="index_header_description">
150 ed619ca0 2022-12-14 op Description
151 ed619ca0 2022-12-14 op </div>
152 ed619ca0 2022-12-14 op {{ end }}
153 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
154 ed619ca0 2022-12-14 op <div id="index_header_owner">
155 ed619ca0 2022-12-14 op Owner
156 ed619ca0 2022-12-14 op </div>
157 ed619ca0 2022-12-14 op {{ end }}
158 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
159 ed619ca0 2022-12-14 op <div id="index_header_age">
160 ed619ca0 2022-12-14 op Last Change
161 ed619ca0 2022-12-14 op </div>
162 ed619ca0 2022-12-14 op {{ end }}
163 ed619ca0 2022-12-14 op </div>
164 ed619ca0 2022-12-14 op {{ end }}
165 ed619ca0 2022-12-14 op
166 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
167 ed619ca0 2022-12-14 op {!
168 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
169 ed619ca0 2022-12-14 op struct server *srv = c->srv;
170 ed619ca0 2022-12-14 op struct gotweb_url summary = {
171 ed619ca0 2022-12-14 op .action = SUMMARY,
172 ed619ca0 2022-12-14 op .index_page = -1,
173 ed619ca0 2022-12-14 op .page = -1,
174 ed619ca0 2022-12-14 op .path = repo_dir->name,
175 ed619ca0 2022-12-14 op }, briefs = {
176 ed619ca0 2022-12-14 op .action = BRIEFS,
177 ed619ca0 2022-12-14 op .index_page = -1,
178 ed619ca0 2022-12-14 op .page = -1,
179 ed619ca0 2022-12-14 op .path = repo_dir->name,
180 ed619ca0 2022-12-14 op }, commits = {
181 ed619ca0 2022-12-14 op .action = COMMITS,
182 ed619ca0 2022-12-14 op .index_page = -1,
183 ed619ca0 2022-12-14 op .page = -1,
184 ed619ca0 2022-12-14 op .path = repo_dir->name,
185 ed619ca0 2022-12-14 op }, tags = {
186 ed619ca0 2022-12-14 op .action = TAGS,
187 ed619ca0 2022-12-14 op .index_page = -1,
188 ed619ca0 2022-12-14 op .page = -1,
189 ed619ca0 2022-12-14 op .path = repo_dir->name,
190 ed619ca0 2022-12-14 op }, tree = {
191 ed619ca0 2022-12-14 op .action = TREE,
192 ed619ca0 2022-12-14 op .index_page = -1,
193 ed619ca0 2022-12-14 op .page = -1,
194 ed619ca0 2022-12-14 op .path = repo_dir->name,
195 1abb18e1 2022-12-20 op }, rss = {
196 1abb18e1 2022-12-20 op .action = RSS,
197 1abb18e1 2022-12-20 op .index_page = -1,
198 1abb18e1 2022-12-20 op .page = -1,
199 1abb18e1 2022-12-20 op .path = repo_dir->name,
200 ed619ca0 2022-12-14 op };
201 ed619ca0 2022-12-14 op !}
202 ed619ca0 2022-12-14 op <div class="index_wrapper">
203 ed619ca0 2022-12-14 op <div class="index_project">
204 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
205 ed619ca0 2022-12-14 op </div>
206 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
207 ed619ca0 2022-12-14 op <div class="index_project_description">
208 ed619ca0 2022-12-14 op {{ repo_dir->description }}
209 ed619ca0 2022-12-14 op </div>
210 ed619ca0 2022-12-14 op {{ end }}
211 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
212 ed619ca0 2022-12-14 op <div class="index_project_owner">
213 ed619ca0 2022-12-14 op {{ repo_dir->owner }}
214 ed619ca0 2022-12-14 op </div>
215 ed619ca0 2022-12-14 op {{ end }}
216 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
217 ed619ca0 2022-12-14 op <div class="index_project_age">
218 ed619ca0 2022-12-14 op {{ repo_dir->age }}
219 ed619ca0 2022-12-14 op </div>
220 ed619ca0 2022-12-14 op {{ end }}
221 ed619ca0 2022-12-14 op <div class="navs_wrapper">
222 ed619ca0 2022-12-14 op <div class="navs">
223 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
224 ed619ca0 2022-12-14 op {{ " | " }}
225 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
226 ed619ca0 2022-12-14 op {{ " | " }}
227 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
228 ed619ca0 2022-12-14 op {{ " | " }}
229 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
230 ed619ca0 2022-12-14 op {{ " | " }}
231 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
232 1abb18e1 2022-12-20 op {{ " | " }}
233 1abb18e1 2022-12-20 op <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
234 ed619ca0 2022-12-14 op </div>
235 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
236 ed619ca0 2022-12-14 op </div>
237 ed619ca0 2022-12-14 op </div>
238 ed619ca0 2022-12-14 op {{ end }}
239 ed619ca0 2022-12-14 op
240 ed619ca0 2022-12-14 op {{ define gotweb_render_briefs(struct template *tp) }}
241 ed619ca0 2022-12-14 op {!
242 ed619ca0 2022-12-14 op const struct got_error *error;
243 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
244 ed619ca0 2022-12-14 op struct server *srv = c->srv;
245 ed619ca0 2022-12-14 op struct transport *t = c->t;
246 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
247 ed619ca0 2022-12-14 op struct repo_commit *rc;
248 ed619ca0 2022-12-14 op struct repo_dir *repo_dir = t->repo_dir;
249 ed619ca0 2022-12-14 op struct gotweb_url diff_url, tree_url;
250 ed619ca0 2022-12-14 op char *tmp;
251 ed619ca0 2022-12-14 op
252 ed619ca0 2022-12-14 op diff_url = (struct gotweb_url){
253 ed619ca0 2022-12-14 op .action = DIFF,
254 ed619ca0 2022-12-14 op .index_page = -1,
255 ed619ca0 2022-12-14 op .page = -1,
256 ed619ca0 2022-12-14 op .path = repo_dir->name,
257 ed619ca0 2022-12-14 op .headref = qs->headref,
258 ed619ca0 2022-12-14 op };
259 ed619ca0 2022-12-14 op tree_url = (struct gotweb_url){
260 ed619ca0 2022-12-14 op .action = TREE,
261 ed619ca0 2022-12-14 op .index_page = -1,
262 ed619ca0 2022-12-14 op .page = -1,
263 ed619ca0 2022-12-14 op .path = repo_dir->name,
264 ed619ca0 2022-12-14 op .headref = qs->headref,
265 ed619ca0 2022-12-14 op };
266 ed619ca0 2022-12-14 op
267 ed619ca0 2022-12-14 op if (qs->action == SUMMARY) {
268 ed619ca0 2022-12-14 op qs->action = BRIEFS;
269 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
270 ed619ca0 2022-12-14 op } else
271 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, srv->max_commits_display);
272 ed619ca0 2022-12-14 op if (error)
273 ed619ca0 2022-12-14 op return -1;
274 ed619ca0 2022-12-14 op !}
275 ed619ca0 2022-12-14 op <div id="briefs_title_wrapper">
276 ed619ca0 2022-12-14 op <div id="briefs_title">Commit Briefs</div>
277 ed619ca0 2022-12-14 op </div>
278 ed619ca0 2022-12-14 op <div id="briefs_content">
279 ed619ca0 2022-12-14 op {{ tailq-foreach rc &t->repo_commits entry }}
280 ed619ca0 2022-12-14 op {!
281 ed619ca0 2022-12-14 op diff_url.commit = rc->commit_id;
282 ed619ca0 2022-12-14 op tree_url.commit = rc->commit_id;
283 ed619ca0 2022-12-14 op
284 ed619ca0 2022-12-14 op tmp = strchr(rc->author, '<');
285 ed619ca0 2022-12-14 op if (tmp)
286 ed619ca0 2022-12-14 op *tmp = '\0';
287 ed619ca0 2022-12-14 op
288 ed619ca0 2022-12-14 op tmp = strchr(rc->commit_msg, '\n');
289 ed619ca0 2022-12-14 op if (tmp)
290 ed619ca0 2022-12-14 op *tmp = '\0';
291 ed619ca0 2022-12-14 op !}
292 ed619ca0 2022-12-14 op <div class="briefs_age">
293 ed619ca0 2022-12-14 op {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
294 ed619ca0 2022-12-14 op </div>
295 ed619ca0 2022-12-14 op <div class="briefs_author">
296 ed619ca0 2022-12-14 op {{ rc->author }}
297 ed619ca0 2022-12-14 op </div>
298 ed619ca0 2022-12-14 op <div class="briefs_log">
299 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
300 ed619ca0 2022-12-14 op {{ rc->commit_msg }}
301 ed619ca0 2022-12-14 op </a>
302 ed619ca0 2022-12-14 op {{ if rc->refs_str }}
303 ed619ca0 2022-12-14 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
304 ed619ca0 2022-12-14 op {{ end }}
305 ed619ca0 2022-12-14 op </a>
306 ed619ca0 2022-12-14 op </div>
307 ed619ca0 2022-12-14 op <div class="navs_wrapper">
308 ed619ca0 2022-12-14 op <div class="navs">
309 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
310 ed619ca0 2022-12-14 op {{ " | " }}
311 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
312 ed619ca0 2022-12-14 op </div>
313 ed619ca0 2022-12-14 op </div>
314 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
315 ed619ca0 2022-12-14 op {{ end }}
316 ed619ca0 2022-12-14 op {{ if t->next_id || t->prev_id }}
317 b4c0bd72 2022-12-17 op {{ render gotweb_render_navs(tp) }}
318 ed619ca0 2022-12-14 op {{ end }}
319 b4c0bd72 2022-12-17 op </div>
320 b4c0bd72 2022-12-17 op {{ end }}
321 b4c0bd72 2022-12-17 op
322 b4c0bd72 2022-12-17 op {{ define gotweb_render_navs(struct template *tp) }}
323 b4c0bd72 2022-12-17 op {!
324 b4c0bd72 2022-12-17 op struct request *c = tp->tp_arg;
325 b4c0bd72 2022-12-17 op struct transport *t = c->t;
326 b4c0bd72 2022-12-17 op struct gotweb_url prev, next;
327 b4c0bd72 2022-12-17 op int have_prev, have_next;
328 b4c0bd72 2022-12-17 op
329 b4c0bd72 2022-12-17 op gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
330 b4c0bd72 2022-12-17 op !}
331 b4c0bd72 2022-12-17 op <div id="np_wrapper">
332 b4c0bd72 2022-12-17 op <div id="nav_prev">
333 b4c0bd72 2022-12-17 op {{ if have_prev }}
334 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &prev) }}">
335 b4c0bd72 2022-12-17 op Previous
336 b4c0bd72 2022-12-17 op </a>
337 b4c0bd72 2022-12-17 op {{ end }}
338 b4c0bd72 2022-12-17 op </div>
339 b4c0bd72 2022-12-17 op <div id="nav_next">
340 b4c0bd72 2022-12-17 op {{ if have_next }}
341 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &next) }}">
342 b4c0bd72 2022-12-17 op Next
343 b4c0bd72 2022-12-17 op </a>
344 b4c0bd72 2022-12-17 op {{ end }}
345 b4c0bd72 2022-12-17 op </div>
346 ed619ca0 2022-12-14 op </div>
347 b4c0bd72 2022-12-17 op {{ finally }}
348 b4c0bd72 2022-12-17 op {!
349 b4c0bd72 2022-12-17 op free(t->next_id);
350 b4c0bd72 2022-12-17 op t->next_id = NULL;
351 b4c0bd72 2022-12-17 op free(t->prev_id);
352 b4c0bd72 2022-12-17 op t->prev_id = NULL;
353 b4c0bd72 2022-12-17 op !}
354 ed619ca0 2022-12-14 op {{ end }}
355 156a1144 2022-12-17 op
356 156a1144 2022-12-17 op {{ define gotweb_render_commits(struct template *tp) }}
357 156a1144 2022-12-17 op {!
358 156a1144 2022-12-17 op struct request *c = tp->tp_arg;
359 156a1144 2022-12-17 op struct transport *t = c->t;
360 156a1144 2022-12-17 op struct repo_dir *repo_dir = t->repo_dir;
361 156a1144 2022-12-17 op struct repo_commit *rc;
362 156a1144 2022-12-17 op struct gotweb_url diff, tree;
363 156a1144 2022-12-17 op
364 156a1144 2022-12-17 op diff = (struct gotweb_url){
365 156a1144 2022-12-17 op .action = DIFF,
366 156a1144 2022-12-17 op .index_page = -1,
367 156a1144 2022-12-17 op .page = -1,
368 156a1144 2022-12-17 op .path = repo_dir->name,
369 156a1144 2022-12-17 op };
370 156a1144 2022-12-17 op tree = (struct gotweb_url){
371 156a1144 2022-12-17 op .action = TREE,
372 156a1144 2022-12-17 op .index_page = -1,
373 156a1144 2022-12-17 op .page = -1,
374 156a1144 2022-12-17 op .path = repo_dir->name,
375 156a1144 2022-12-17 op };
376 156a1144 2022-12-17 op !}
377 156a1144 2022-12-17 op <div class="commits_title_wrapper">
378 156a1144 2022-12-17 op <div class="commits_title">Commits</div>
379 156a1144 2022-12-17 op </div>
380 156a1144 2022-12-17 op <div class="commits_content">
381 156a1144 2022-12-17 op {{ tailq-foreach rc &t->repo_commits entry }}
382 156a1144 2022-12-17 op {!
383 156a1144 2022-12-17 op diff.commit = rc->commit_id;
384 156a1144 2022-12-17 op tree.commit = rc->commit_id;
385 156a1144 2022-12-17 op !}
386 156a1144 2022-12-17 op <div class="commits_header_wrapper">
387 156a1144 2022-12-17 op <div class="commits_header">
388 156a1144 2022-12-17 op <div class="header_commit_title">Commit:</div>
389 156a1144 2022-12-17 op <div class="header_commit">{{ rc->commit_id }}</div>
390 156a1144 2022-12-17 op <div class="header_author_title">Author:</div>
391 156a1144 2022-12-17 op <div class="header_author">{{ rc->author }}</div>
392 156a1144 2022-12-17 op <div class="header_age_title">Date:</div>
393 156a1144 2022-12-17 op <div class="header_age">
394 156a1144 2022-12-17 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
395 156a1144 2022-12-17 op </div>
396 156a1144 2022-12-17 op </div>
397 156a1144 2022-12-17 op </div>
398 cf536071 2022-12-31 op <div class="dotted_line"></div>
399 cf536071 2022-12-31 op <div class="commit">
400 cf536071 2022-12-31 op {{ "\n" }}
401 cf536071 2022-12-31 op {{ rc->commit_msg }}
402 cf536071 2022-12-31 op </div>
403 156a1144 2022-12-17 op <div class="navs_wrapper">
404 156a1144 2022-12-17 op <div class="navs">
405 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
406 156a1144 2022-12-17 op {{ " | " }}
407 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
408 156a1144 2022-12-17 op </div>
409 156a1144 2022-12-17 op </div>
410 156a1144 2022-12-17 op <div class="dotted_line"></div>
411 156a1144 2022-12-17 op {{ end }}
412 156a1144 2022-12-17 op {{ if t->next_id || t->prev_id }}
413 156a1144 2022-12-17 op {{ render gotweb_render_navs(tp) }}
414 156a1144 2022-12-17 op {{ end }}
415 298f95fb 2023-01-05 op </div>
416 298f95fb 2023-01-05 op {{ end }}
417 298f95fb 2023-01-05 op
418 298f95fb 2023-01-05 op {{ define gotweb_render_blob(struct template *tp,
419 298f95fb 2023-01-05 op struct got_blob_object *blob) }}
420 298f95fb 2023-01-05 op {!
421 298f95fb 2023-01-05 op struct request *c = tp->tp_arg;
422 298f95fb 2023-01-05 op struct transport *t = c->t;
423 298f95fb 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
424 298f95fb 2023-01-05 op !}
425 298f95fb 2023-01-05 op <div id="blob_title_wrapper">
426 298f95fb 2023-01-05 op <div id="blob_title">Blob</div>
427 298f95fb 2023-01-05 op </div>
428 298f95fb 2023-01-05 op <div id="blob_content">
429 298f95fb 2023-01-05 op <div id="blob_header_wrapper">
430 298f95fb 2023-01-05 op <div id="blob_header">
431 298f95fb 2023-01-05 op <div class="header_age_title">Date:</div>
432 298f95fb 2023-01-05 op <div class="header_age">
433 298f95fb 2023-01-05 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
434 298f95fb 2023-01-05 op </div>
435 298f95fb 2023-01-05 op <div id="header_commit_msg_title">Message:</div>
436 298f95fb 2023-01-05 op <div id="header_commit_msg">{{ rc->commit_msg }}</div>
437 298f95fb 2023-01-05 op </div>
438 298f95fb 2023-01-05 op </div>
439 298f95fb 2023-01-05 op <div class="dotted_line"></div>
440 298f95fb 2023-01-05 op <div id="blob">
441 298f95fb 2023-01-05 op <pre>
442 298f95fb 2023-01-05 op {{ render got_output_blob_by_lines(tp, blob, gotweb_render_blob_line) }}
443 298f95fb 2023-01-05 op </pre>
444 298f95fb 2023-01-05 op </div>
445 156a1144 2022-12-17 op </div>
446 1abb18e1 2022-12-20 op {{ end }}
447 1abb18e1 2022-12-20 op
448 298f95fb 2023-01-05 op {{ define gotweb_render_blob_line(struct template *tp, const char *line,
449 298f95fb 2023-01-05 op size_t no) }}
450 298f95fb 2023-01-05 op {!
451 298f95fb 2023-01-05 op char lineno[16];
452 298f95fb 2023-01-05 op int r;
453 298f95fb 2023-01-05 op
454 298f95fb 2023-01-05 op r = snprintf(lineno, sizeof(lineno), "%zu", no);
455 298f95fb 2023-01-05 op if (r < 0 || (size_t)r >= sizeof(lineno))
456 298f95fb 2023-01-05 op return -1;
457 298f95fb 2023-01-05 op !}
458 298f95fb 2023-01-05 op <div class="blob_line" id="line{{ lineno }}">
459 298f95fb 2023-01-05 op <div class="blob_number">
460 298f95fb 2023-01-05 op <a href="#line{{ lineno }}">{{ lineno }}</a>
461 298f95fb 2023-01-05 op </div>
462 298f95fb 2023-01-05 op <div class="blob_code">{{ line }}</div>
463 43d421de 2023-01-05 op </div>
464 43d421de 2023-01-05 op {{ end }}
465 43d421de 2023-01-05 op
466 43d421de 2023-01-05 op {{ define gotweb_render_tree(struct template *tp) }}
467 43d421de 2023-01-05 op {!
468 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
469 43d421de 2023-01-05 op struct transport *t = c->t;
470 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
471 43d421de 2023-01-05 op !}
472 43d421de 2023-01-05 op <div id="tree_title_wrapper">
473 43d421de 2023-01-05 op <div id="tree_title">Tree</div>
474 43d421de 2023-01-05 op </div>
475 43d421de 2023-01-05 op <div id="tree_content">
476 43d421de 2023-01-05 op <div id="tree_header_wrapper">
477 43d421de 2023-01-05 op <div id="tree_header">
478 43d421de 2023-01-05 op <div id="header_tree_title">Tree:</div>
479 43d421de 2023-01-05 op <div id="header_tree">{{ rc->tree_id }}</div>
480 43d421de 2023-01-05 op <div class="header_age_title">Date:</div>
481 43d421de 2023-01-05 op <div class="header_age">
482 43d421de 2023-01-05 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
483 43d421de 2023-01-05 op </div>
484 43d421de 2023-01-05 op <div id="header_commit_msg_title">Message:</div>
485 43d421de 2023-01-05 op <div id="header_commit_msg">{{ rc->commit_msg }}</div>
486 43d421de 2023-01-05 op </div>
487 43d421de 2023-01-05 op </div>
488 43d421de 2023-01-05 op <div class="dotted_line"></div>
489 43d421de 2023-01-05 op <div id="tree">
490 43d421de 2023-01-05 op {{ render got_output_repo_tree(c, gotweb_render_tree_item) }}
491 43d421de 2023-01-05 op </div>
492 43d421de 2023-01-05 op </div>
493 43d421de 2023-01-05 op {{ end }}
494 43d421de 2023-01-05 op
495 43d421de 2023-01-05 op {{ define gotweb_render_tree_item(struct template *tp,
496 43d421de 2023-01-05 op struct got_tree_entry *te) }}
497 43d421de 2023-01-05 op {!
498 43d421de 2023-01-05 op struct request *c = tp->tp_arg;
499 43d421de 2023-01-05 op struct transport *t = c->t;
500 43d421de 2023-01-05 op struct querystring *qs = t->qs;
501 43d421de 2023-01-05 op struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
502 43d421de 2023-01-05 op const char *modestr = "";
503 43d421de 2023-01-05 op const char *name;
504 43d421de 2023-01-05 op const char *folder;
505 43d421de 2023-01-05 op char *dir = NULL;
506 43d421de 2023-01-05 op mode_t mode;
507 43d421de 2023-01-05 op struct gotweb_url url = {
508 43d421de 2023-01-05 op .index_page = -1,
509 43d421de 2023-01-05 op .page = -1,
510 43d421de 2023-01-05 op .commit = rc->commit_id,
511 43d421de 2023-01-05 op .path = qs->path,
512 43d421de 2023-01-05 op };
513 43d421de 2023-01-05 op
514 43d421de 2023-01-05 op name = got_tree_entry_get_name(te);
515 43d421de 2023-01-05 op mode = got_tree_entry_get_mode(te);
516 43d421de 2023-01-05 op
517 43d421de 2023-01-05 op folder = qs->folder ? qs->folder : "";
518 43d421de 2023-01-05 op if (S_ISDIR(mode)) {
519 43d421de 2023-01-05 op if (asprintf(&dir, "%s/%s", folder, name) == -1)
520 43d421de 2023-01-05 op return (-1);
521 43d421de 2023-01-05 op
522 43d421de 2023-01-05 op url.action = TREE;
523 43d421de 2023-01-05 op url.folder = dir;
524 43d421de 2023-01-05 op } else {
525 43d421de 2023-01-05 op url.action = BLOB;
526 43d421de 2023-01-05 op url.folder = folder;
527 43d421de 2023-01-05 op url.file = name;
528 43d421de 2023-01-05 op }
529 43d421de 2023-01-05 op
530 43d421de 2023-01-05 op if (got_object_tree_entry_is_submodule(te))
531 43d421de 2023-01-05 op modestr = "$";
532 43d421de 2023-01-05 op else if (S_ISLNK(mode))
533 43d421de 2023-01-05 op modestr = "@";
534 43d421de 2023-01-05 op else if (S_ISDIR(mode))
535 43d421de 2023-01-05 op modestr = "/";
536 43d421de 2023-01-05 op else if (mode & S_IXUSR)
537 43d421de 2023-01-05 op modestr = "*";
538 43d421de 2023-01-05 op !}
539 43d421de 2023-01-05 op <div class="tree_wrapper">
540 43d421de 2023-01-05 op {{ if S_ISDIR(mode) }}
541 43d421de 2023-01-05 op <div class="tree_line">
542 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
543 43d421de 2023-01-05 op {{ name }}{{ modestr }}
544 43d421de 2023-01-05 op </a>
545 43d421de 2023-01-05 op </div>
546 43d421de 2023-01-05 op <div class="tree_line_blank">&nbsp;</div>
547 43d421de 2023-01-05 op {{ else }}
548 43d421de 2023-01-05 op <div class="tree_line">
549 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
550 43d421de 2023-01-05 op {{ name }}{{ modestr }}
551 43d421de 2023-01-05 op </a>
552 43d421de 2023-01-05 op </div>
553 43d421de 2023-01-05 op <div class="tree_line_blank">
554 43d421de 2023-01-05 op {! url.action = COMMITS; !}
555 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
556 43d421de 2023-01-05 op commits
557 43d421de 2023-01-05 op </a>
558 43d421de 2023-01-05 op {{ " | " }}
559 43d421de 2023-01-05 op {! url.action = BLAME; !}
560 43d421de 2023-01-05 op <a href="{{ render gotweb_render_url(c, &url) }}">
561 43d421de 2023-01-05 op blame
562 43d421de 2023-01-05 op </a>
563 43d421de 2023-01-05 op </div>
564 43d421de 2023-01-05 op {{ end }}
565 298f95fb 2023-01-05 op </div>
566 43d421de 2023-01-05 op {{ finally }}
567 43d421de 2023-01-05 op {!
568 43d421de 2023-01-05 op free(dir);
569 067396e6 2023-01-09 op !}
570 067396e6 2023-01-09 op {{ end }}
571 067396e6 2023-01-09 op
572 067396e6 2023-01-09 op {{ define gotweb_render_tags_tmpl(struct template *tp) }}
573 067396e6 2023-01-09 op {!
574 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
575 067396e6 2023-01-09 op struct transport *t = c->t;
576 067396e6 2023-01-09 op struct querystring *qs = t->qs;
577 067396e6 2023-01-09 op struct repo_tag *rt;
578 067396e6 2023-01-09 op int commit_found;
579 067396e6 2023-01-09 op
580 067396e6 2023-01-09 op commit_found = qs->commit == NULL;
581 43d421de 2023-01-05 op !}
582 067396e6 2023-01-09 op <div id="tags_title_wrapper">
583 067396e6 2023-01-09 op <div id="tags_title">Tags</div>
584 067396e6 2023-01-09 op </div>
585 067396e6 2023-01-09 op <div id="tags_content">
586 067396e6 2023-01-09 op {{ if t->tag_count == 0 }}
587 067396e6 2023-01-09 op <div id="err_content">
588 067396e6 2023-01-09 op This repository contains no tags
589 067396e6 2023-01-09 op </div>
590 067396e6 2023-01-09 op {{ else }}
591 067396e6 2023-01-09 op {{ tailq-foreach rt &t->repo_tags entry }}
592 067396e6 2023-01-09 op {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
593 067396e6 2023-01-09 op {! commit_found = 1; !}
594 067396e6 2023-01-09 op {{ render tag_item(tp, rt) }}
595 067396e6 2023-01-09 op {{ end }}
596 067396e6 2023-01-09 op {{ end }}
597 067396e6 2023-01-09 op {{ if t->next_id || t->prev_id }}
598 067396e6 2023-01-09 op {{ render gotweb_render_navs(tp) }}
599 067396e6 2023-01-09 op {{ end }}
600 067396e6 2023-01-09 op {{ end }}
601 067396e6 2023-01-09 op </div>
602 298f95fb 2023-01-05 op {{ end }}
603 298f95fb 2023-01-05 op
604 067396e6 2023-01-09 op {{ define tag_item(struct template *tp, struct repo_tag *rt) }}
605 067396e6 2023-01-09 op {!
606 067396e6 2023-01-09 op struct request *c = tp->tp_arg;
607 067396e6 2023-01-09 op struct transport *t = c->t;
608 067396e6 2023-01-09 op struct repo_dir *repo_dir = t->repo_dir;
609 067396e6 2023-01-09 op char *tag_name = rt->tag_name;
610 067396e6 2023-01-09 op char *msg = rt->tag_commit;
611 067396e6 2023-01-09 op char *nl;
612 067396e6 2023-01-09 op struct gotweb_url url = {
613 067396e6 2023-01-09 op .action = TAG,
614 067396e6 2023-01-09 op .index_page = -1,
615 067396e6 2023-01-09 op .page = -1,
616 067396e6 2023-01-09 op .path = repo_dir->name,
617 067396e6 2023-01-09 op .commit = rt->commit_id,
618 067396e6 2023-01-09 op };
619 067396e6 2023-01-09 op
620 067396e6 2023-01-09 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
621 067396e6 2023-01-09 op tag_name += 10;
622 067396e6 2023-01-09 op
623 067396e6 2023-01-09 op if (msg) {
624 067396e6 2023-01-09 op nl = strchr(msg, '\n');
625 067396e6 2023-01-09 op if (nl)
626 067396e6 2023-01-09 op *nl = '\0';
627 067396e6 2023-01-09 op }
628 067396e6 2023-01-09 op !}
629 067396e6 2023-01-09 op <div class="tag_age">
630 067396e6 2023-01-09 op {{ render gotweb_render_age(tp, rt->tagger_time, TM_DIFF) }}
631 067396e6 2023-01-09 op </div>
632 067396e6 2023-01-09 op <div class="tag">{{ tag_name }}</div>
633 067396e6 2023-01-09 op <div class="tag_log">
634 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">
635 067396e6 2023-01-09 op {{ msg }}
636 067396e6 2023-01-09 op </a>
637 067396e6 2023-01-09 op </div>
638 067396e6 2023-01-09 op <div class="navs_wrapper">
639 067396e6 2023-01-09 op <div class="navs">
640 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
641 067396e6 2023-01-09 op {{ " | " }}
642 067396e6 2023-01-09 op {! url.action = BRIEFS; !}
643 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
644 067396e6 2023-01-09 op {{ " | " }}
645 067396e6 2023-01-09 op {! url.action = COMMITS; !}
646 067396e6 2023-01-09 op <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
647 067396e6 2023-01-09 op </div>
648 067396e6 2023-01-09 op </div>
649 067396e6 2023-01-09 op <div class="dotted_line"></div>
650 067396e6 2023-01-09 op {{ end }}
651 dc07f76c 2023-01-09 op
652 dc07f76c 2023-01-09 op {{ define gotweb_render_tag(struct template *tp) }}
653 dc07f76c 2023-01-09 op {!
654 dc07f76c 2023-01-09 op struct request *c = tp->tp_arg;
655 dc07f76c 2023-01-09 op struct transport *t = c->t;
656 dc07f76c 2023-01-09 op struct repo_tag *rt;
657 dc07f76c 2023-01-09 op const char *tag_name;
658 067396e6 2023-01-09 op
659 dc07f76c 2023-01-09 op rt = TAILQ_LAST(&t->repo_tags, repo_tags_head);
660 dc07f76c 2023-01-09 op tag_name = rt->tag_name;
661 dc07f76c 2023-01-09 op
662 dc07f76c 2023-01-09 op if (strncmp(tag_name, "refs/", 5) == 0)
663 dc07f76c 2023-01-09 op tag_name += 5;
664 dc07f76c 2023-01-09 op !}
665 dc07f76c 2023-01-09 op <div id="tags_title_wrapper">
666 dc07f76c 2023-01-09 op <div id="tags_title">Tag</div>
667 dc07f76c 2023-01-09 op </div>
668 dc07f76c 2023-01-09 op <div id="tags_content">
669 dc07f76c 2023-01-09 op <div id="tag_header_wrapper">
670 dc07f76c 2023-01-09 op <div id="tag_header">
671 dc07f76c 2023-01-09 op <div class="header_commit_title">Commit:</div>
672 dc07f76c 2023-01-09 op <div class="header_commit">
673 dc07f76c 2023-01-09 op {{ rt->commit_id }}
674 dc07f76c 2023-01-09 op {{ " " }}
675 dc07f76c 2023-01-09 op <span class="refs_str">({{ tag_name }})</span>
676 dc07f76c 2023-01-09 op </div>
677 dc07f76c 2023-01-09 op <div class="header_author_title">Tagger:</div>
678 dc07f76c 2023-01-09 op <div class="header_author">{{ rt->tagger }}</div>
679 dc07f76c 2023-01-09 op <div class="header_age_title">Date:</div>
680 dc07f76c 2023-01-09 op <div class="header_age">
681 dc07f76c 2023-01-09 op {{ render gotweb_render_age(tp, rt->tagger_time, TM_LONG)}}
682 dc07f76c 2023-01-09 op </div>
683 dc07f76c 2023-01-09 op <div id="header_commit_msg_title">Message:</div>
684 dc07f76c 2023-01-09 op <div id="header_commit_msg">{{ rt->commit_msg }}</div>
685 dc07f76c 2023-01-09 op </div>
686 dc07f76c 2023-01-09 op <div class="dotted_line"></div>
687 dc07f76c 2023-01-09 op <div id="tag_commit">
688 dc07f76c 2023-01-09 op {{ "\n" }}
689 dc07f76c 2023-01-09 op {{ rt->tag_commit }}
690 dc07f76c 2023-01-09 op </div>
691 dc07f76c 2023-01-09 op </div>
692 dc07f76c 2023-01-09 op </div>
693 dc07f76c 2023-01-09 op {{ end }}
694 dc07f76c 2023-01-09 op
695 1abb18e1 2022-12-20 op {{ define gotweb_render_rss(struct template *tp) }}
696 1abb18e1 2022-12-20 op {!
697 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
698 1abb18e1 2022-12-20 op struct server *srv = c->srv;
699 1abb18e1 2022-12-20 op struct transport *t = c->t;
700 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
701 1abb18e1 2022-12-20 op struct repo_tag *rt;
702 1abb18e1 2022-12-20 op struct gotweb_url summary = {
703 1abb18e1 2022-12-20 op .action = SUMMARY,
704 1abb18e1 2022-12-20 op .index_page = -1,
705 1abb18e1 2022-12-20 op .page = -1,
706 1abb18e1 2022-12-20 op .path = repo_dir->name,
707 1abb18e1 2022-12-20 op };
708 1abb18e1 2022-12-20 op !}
709 1abb18e1 2022-12-20 op <?xml version="1.0" encoding="UTF-8"?>
710 1abb18e1 2022-12-20 op <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
711 1abb18e1 2022-12-20 op <channel>
712 1abb18e1 2022-12-20 op <title>Tags of {{ repo_dir->name }}</title>
713 1abb18e1 2022-12-20 op <link>
714 1abb18e1 2022-12-20 op <![CDATA[
715 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &summary) }}
716 1abb18e1 2022-12-20 op ]]>
717 1abb18e1 2022-12-20 op </link>
718 1abb18e1 2022-12-20 op {{ if srv->show_repo_description }}
719 1abb18e1 2022-12-20 op <description>{{ repo_dir->description }}</description>
720 1abb18e1 2022-12-20 op {{ end }}
721 1abb18e1 2022-12-20 op {{ tailq-foreach rt &t->repo_tags entry }}
722 1abb18e1 2022-12-20 op {{ render rss_tag_item(tp, rt) }}
723 1abb18e1 2022-12-20 op {{ end }}
724 1abb18e1 2022-12-20 op </channel>
725 1abb18e1 2022-12-20 op </rss>
726 1abb18e1 2022-12-20 op {{ end }}
727 1abb18e1 2022-12-20 op
728 1abb18e1 2022-12-20 op {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
729 1abb18e1 2022-12-20 op {!
730 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
731 1abb18e1 2022-12-20 op struct transport *t = c->t;
732 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
733 1abb18e1 2022-12-20 op char *tag_name = rt->tag_name;
734 1abb18e1 2022-12-20 op struct gotweb_url tag = {
735 1abb18e1 2022-12-20 op .action = TAG,
736 1abb18e1 2022-12-20 op .index_page = -1,
737 1abb18e1 2022-12-20 op .page = -1,
738 1abb18e1 2022-12-20 op .path = repo_dir->name,
739 1abb18e1 2022-12-20 op .commit = rt->commit_id,
740 1abb18e1 2022-12-20 op };
741 1abb18e1 2022-12-20 op
742 1abb18e1 2022-12-20 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
743 1abb18e1 2022-12-20 op tag_name += 10;
744 1abb18e1 2022-12-20 op !}
745 1abb18e1 2022-12-20 op <item>
746 1abb18e1 2022-12-20 op <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
747 1abb18e1 2022-12-20 op <link>
748 1abb18e1 2022-12-20 op <![CDATA[
749 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &tag) }}
750 1abb18e1 2022-12-20 op ]]>
751 1abb18e1 2022-12-20 op </link>
752 1abb18e1 2022-12-20 op <description>
753 1abb18e1 2022-12-20 op <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
754 1abb18e1 2022-12-20 op </description>
755 1abb18e1 2022-12-20 op {{ render rss_author(tp, rt->tagger) }}
756 1abb18e1 2022-12-20 op <guid isPermaLink="false">{{ rt->commit_id }}</guid>
757 1abb18e1 2022-12-20 op <pubDate>
758 1abb18e1 2022-12-20 op {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
759 1abb18e1 2022-12-20 op </pubDate>
760 1abb18e1 2022-12-20 op </item>
761 156a1144 2022-12-17 op {{ end }}
762 1abb18e1 2022-12-20 op
763 1abb18e1 2022-12-20 op {{ define rss_author(struct template *tp, char *author) }}
764 1abb18e1 2022-12-20 op {!
765 1abb18e1 2022-12-20 op char *t, *mail;
766 1abb18e1 2022-12-20 op
767 1abb18e1 2022-12-20 op /* what to do if the author name contains a paren? */
768 1abb18e1 2022-12-20 op if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
769 1abb18e1 2022-12-20 op return 0;
770 1abb18e1 2022-12-20 op
771 1abb18e1 2022-12-20 op t = strchr(author, '<');
772 1abb18e1 2022-12-20 op if (t == NULL)
773 1abb18e1 2022-12-20 op return 0;
774 1abb18e1 2022-12-20 op *t = '\0';
775 1abb18e1 2022-12-20 op mail = t+1;
776 1abb18e1 2022-12-20 op
777 1abb18e1 2022-12-20 op while (isspace((unsigned char)*--t))
778 1abb18e1 2022-12-20 op *t = '\0';
779 1abb18e1 2022-12-20 op
780 1abb18e1 2022-12-20 op t = strchr(mail, '>');
781 1abb18e1 2022-12-20 op if (t == NULL)
782 1abb18e1 2022-12-20 op return 0;
783 1abb18e1 2022-12-20 op *t = '\0';
784 1abb18e1 2022-12-20 op !}
785 1abb18e1 2022-12-20 op <author>
786 1abb18e1 2022-12-20 op {{ mail }} {{" "}} ({{ author }})
787 1abb18e1 2022-12-20 op </author>
788 1abb18e1 2022-12-20 op {{ end }}