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 ed619ca0 2022-12-14 op
22 1abb18e1 2022-12-20 op #include <ctype.h>
23 ed619ca0 2022-12-14 op #include <event.h>
24 ed619ca0 2022-12-14 op #include <stdint.h>
25 ed619ca0 2022-12-14 op #include <stdlib.h>
26 ed619ca0 2022-12-14 op #include <string.h>
27 ed619ca0 2022-12-14 op #include <imsg.h>
28 ed619ca0 2022-12-14 op
29 ed619ca0 2022-12-14 op #include "proc.h"
30 ed619ca0 2022-12-14 op
31 ed619ca0 2022-12-14 op #include "gotwebd.h"
32 ed619ca0 2022-12-14 op #include "tmpl.h"
33 ed619ca0 2022-12-14 op
34 1abb18e1 2022-12-20 op static inline int rss_tag_item(struct template *, struct repo_tag *);
35 1abb18e1 2022-12-20 op static inline int rss_author(struct template *, char *);
36 1abb18e1 2022-12-20 op
37 ed619ca0 2022-12-14 op static int
38 ed619ca0 2022-12-14 op gotweb_render_age(struct template *tp, time_t time, int ref_tm)
39 ed619ca0 2022-12-14 op {
40 ed619ca0 2022-12-14 op const struct got_error *err;
41 ed619ca0 2022-12-14 op char *age;
42 ed619ca0 2022-12-14 op int r;
43 ed619ca0 2022-12-14 op
44 ed619ca0 2022-12-14 op err = gotweb_get_time_str(&age, time, ref_tm);
45 ed619ca0 2022-12-14 op if (err)
46 ed619ca0 2022-12-14 op return 0;
47 ed619ca0 2022-12-14 op r = tp->tp_puts(tp, age);
48 ed619ca0 2022-12-14 op free(age);
49 ed619ca0 2022-12-14 op return r;
50 ed619ca0 2022-12-14 op }
51 ed619ca0 2022-12-14 op
52 ed619ca0 2022-12-14 op !}
53 ed619ca0 2022-12-14 op
54 ed619ca0 2022-12-14 op {{ define gotweb_render_header(struct template *tp) }}
55 ed619ca0 2022-12-14 op {!
56 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
57 ed619ca0 2022-12-14 op struct server *srv = c->srv;
58 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
59 ed619ca0 2022-12-14 op struct gotweb_url u_path;
60 d19d9fce 2022-12-20 op const char *prfx = c->document_uri;
61 ed619ca0 2022-12-14 op const char *css = srv->custom_css;
62 ed619ca0 2022-12-14 op
63 ed619ca0 2022-12-14 op memset(&u_path, 0, sizeof(u_path));
64 ed619ca0 2022-12-14 op u_path.index_page = -1;
65 ed619ca0 2022-12-14 op u_path.page = -1;
66 ed619ca0 2022-12-14 op u_path.action = SUMMARY;
67 ed619ca0 2022-12-14 op !}
68 ed619ca0 2022-12-14 op <!doctype html>
69 ed619ca0 2022-12-14 op <html>
70 ed619ca0 2022-12-14 op <head>
71 ed619ca0 2022-12-14 op <meta charset="utf-8" />
72 ed619ca0 2022-12-14 op <title>{{ srv->site_name }}</title>
73 ed619ca0 2022-12-14 op <meta name="viewport" content="initial-scale=.75" />
74 ed619ca0 2022-12-14 op <meta name="msapplication-TileColor" content="#da532c" />
75 ed619ca0 2022-12-14 op <meta name="theme-color" content="#ffffff"/>
76 ed619ca0 2022-12-14 op <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
77 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
78 ed619ca0 2022-12-14 op <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
79 ed619ca0 2022-12-14 op <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
80 ed619ca0 2022-12-14 op <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
81 ed619ca0 2022-12-14 op <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
82 ed619ca0 2022-12-14 op </head>
83 ed619ca0 2022-12-14 op <body>
84 ed619ca0 2022-12-14 op <div id="gw_body">
85 ed619ca0 2022-12-14 op <div id="header">
86 ed619ca0 2022-12-14 op <div id="got_link">
87 ed619ca0 2022-12-14 op <a href="{{ srv->logo_url }}" target="_blank">
88 ed619ca0 2022-12-14 op <img src="{{ prfx }}{{ srv->logo }}" />
89 ed619ca0 2022-12-14 op </a>
90 ed619ca0 2022-12-14 op </div>
91 ed619ca0 2022-12-14 op </div>
92 ed619ca0 2022-12-14 op <div id="site_path">
93 ed619ca0 2022-12-14 op <div id="site_link">
94 ed619ca0 2022-12-14 op <a href="?index_page={{ printf "%d", qs->index_page }}">
95 ed619ca0 2022-12-14 op {{ srv->site_link }}
96 ed619ca0 2022-12-14 op </a>
97 ed619ca0 2022-12-14 op {{ if qs->path }}
98 ed619ca0 2022-12-14 op {! u_path.path = qs->path; !}
99 ed619ca0 2022-12-14 op {{ " / " }}
100 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
101 ed619ca0 2022-12-14 op {{ qs->path }}
102 ed619ca0 2022-12-14 op </a>
103 ed619ca0 2022-12-14 op {{ end }}
104 ed619ca0 2022-12-14 op {{ if qs->action != INDEX }}
105 ed619ca0 2022-12-14 op {{ " / " }}{{ gotweb_action_name(qs->action) }}
106 ed619ca0 2022-12-14 op {{ end }}
107 ed619ca0 2022-12-14 op </div>
108 ed619ca0 2022-12-14 op </div>
109 ed619ca0 2022-12-14 op <div id="content">
110 ed619ca0 2022-12-14 op {{ end }}
111 ed619ca0 2022-12-14 op
112 ed619ca0 2022-12-14 op {{ define gotweb_render_footer(struct template *tp) }}
113 ed619ca0 2022-12-14 op {!
114 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
115 ed619ca0 2022-12-14 op struct server *srv = c->srv;
116 ed619ca0 2022-12-14 op !}
117 ed619ca0 2022-12-14 op <div id="site_owner_wrapper">
118 ed619ca0 2022-12-14 op <div id="site_owner">
119 ed619ca0 2022-12-14 op {{ if srv->show_site_owner }}
120 ed619ca0 2022-12-14 op {{ srv->site_owner }}
121 ed619ca0 2022-12-14 op {{ end }}
122 ed619ca0 2022-12-14 op </div>
123 ed619ca0 2022-12-14 op </div>
124 ed619ca0 2022-12-14 op </div>
125 ed619ca0 2022-12-14 op </div>
126 ed619ca0 2022-12-14 op </body>
127 ed619ca0 2022-12-14 op </html>
128 ed619ca0 2022-12-14 op {{ end }}
129 ed619ca0 2022-12-14 op
130 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_table_hdr(struct template *tp) }}
131 ed619ca0 2022-12-14 op {!
132 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
133 ed619ca0 2022-12-14 op struct server *srv = c->srv;
134 ed619ca0 2022-12-14 op !}
135 ed619ca0 2022-12-14 op <div id="index_header">
136 ed619ca0 2022-12-14 op <div id="index_header_project">
137 ed619ca0 2022-12-14 op Project
138 ed619ca0 2022-12-14 op </div>
139 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
140 ed619ca0 2022-12-14 op <div id="index_header_description">
141 ed619ca0 2022-12-14 op Description
142 ed619ca0 2022-12-14 op </div>
143 ed619ca0 2022-12-14 op {{ end }}
144 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
145 ed619ca0 2022-12-14 op <div id="index_header_owner">
146 ed619ca0 2022-12-14 op Owner
147 ed619ca0 2022-12-14 op </div>
148 ed619ca0 2022-12-14 op {{ end }}
149 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
150 ed619ca0 2022-12-14 op <div id="index_header_age">
151 ed619ca0 2022-12-14 op Last Change
152 ed619ca0 2022-12-14 op </div>
153 ed619ca0 2022-12-14 op {{ end }}
154 ed619ca0 2022-12-14 op </div>
155 ed619ca0 2022-12-14 op {{ end }}
156 ed619ca0 2022-12-14 op
157 ed619ca0 2022-12-14 op {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
158 ed619ca0 2022-12-14 op {!
159 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
160 ed619ca0 2022-12-14 op struct server *srv = c->srv;
161 ed619ca0 2022-12-14 op struct gotweb_url summary = {
162 ed619ca0 2022-12-14 op .action = SUMMARY,
163 ed619ca0 2022-12-14 op .index_page = -1,
164 ed619ca0 2022-12-14 op .page = -1,
165 ed619ca0 2022-12-14 op .path = repo_dir->name,
166 ed619ca0 2022-12-14 op }, briefs = {
167 ed619ca0 2022-12-14 op .action = BRIEFS,
168 ed619ca0 2022-12-14 op .index_page = -1,
169 ed619ca0 2022-12-14 op .page = -1,
170 ed619ca0 2022-12-14 op .path = repo_dir->name,
171 ed619ca0 2022-12-14 op }, commits = {
172 ed619ca0 2022-12-14 op .action = COMMITS,
173 ed619ca0 2022-12-14 op .index_page = -1,
174 ed619ca0 2022-12-14 op .page = -1,
175 ed619ca0 2022-12-14 op .path = repo_dir->name,
176 ed619ca0 2022-12-14 op }, tags = {
177 ed619ca0 2022-12-14 op .action = TAGS,
178 ed619ca0 2022-12-14 op .index_page = -1,
179 ed619ca0 2022-12-14 op .page = -1,
180 ed619ca0 2022-12-14 op .path = repo_dir->name,
181 ed619ca0 2022-12-14 op }, tree = {
182 ed619ca0 2022-12-14 op .action = TREE,
183 ed619ca0 2022-12-14 op .index_page = -1,
184 ed619ca0 2022-12-14 op .page = -1,
185 ed619ca0 2022-12-14 op .path = repo_dir->name,
186 1abb18e1 2022-12-20 op }, rss = {
187 1abb18e1 2022-12-20 op .action = RSS,
188 1abb18e1 2022-12-20 op .index_page = -1,
189 1abb18e1 2022-12-20 op .page = -1,
190 1abb18e1 2022-12-20 op .path = repo_dir->name,
191 ed619ca0 2022-12-14 op };
192 ed619ca0 2022-12-14 op !}
193 ed619ca0 2022-12-14 op <div class="index_wrapper">
194 ed619ca0 2022-12-14 op <div class="index_project">
195 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
196 ed619ca0 2022-12-14 op </div>
197 ed619ca0 2022-12-14 op {{ if srv->show_repo_description }}
198 ed619ca0 2022-12-14 op <div class="index_project_description">
199 ed619ca0 2022-12-14 op {{ repo_dir->description }}
200 ed619ca0 2022-12-14 op </div>
201 ed619ca0 2022-12-14 op {{ end }}
202 ed619ca0 2022-12-14 op {{ if srv->show_repo_owner }}
203 ed619ca0 2022-12-14 op <div class="index_project_owner">
204 ed619ca0 2022-12-14 op {{ repo_dir->owner }}
205 ed619ca0 2022-12-14 op </div>
206 ed619ca0 2022-12-14 op {{ end }}
207 ed619ca0 2022-12-14 op {{ if srv->show_repo_age }}
208 ed619ca0 2022-12-14 op <div class="index_project_age">
209 ed619ca0 2022-12-14 op {{ repo_dir->age }}
210 ed619ca0 2022-12-14 op </div>
211 ed619ca0 2022-12-14 op {{ end }}
212 ed619ca0 2022-12-14 op <div class="navs_wrapper">
213 ed619ca0 2022-12-14 op <div class="navs">
214 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
215 ed619ca0 2022-12-14 op {{ " | " }}
216 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
217 ed619ca0 2022-12-14 op {{ " | " }}
218 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
219 ed619ca0 2022-12-14 op {{ " | " }}
220 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
221 ed619ca0 2022-12-14 op {{ " | " }}
222 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
223 1abb18e1 2022-12-20 op {{ " | " }}
224 1abb18e1 2022-12-20 op <a href="{{ render gotweb_render_url(tp->tp_arg, &rss) }}">rss</a>
225 ed619ca0 2022-12-14 op </div>
226 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
227 ed619ca0 2022-12-14 op </div>
228 ed619ca0 2022-12-14 op </div>
229 ed619ca0 2022-12-14 op {{ end }}
230 ed619ca0 2022-12-14 op
231 ed619ca0 2022-12-14 op {{ define gotweb_render_briefs(struct template *tp) }}
232 ed619ca0 2022-12-14 op {!
233 ed619ca0 2022-12-14 op const struct got_error *error;
234 ed619ca0 2022-12-14 op struct request *c = tp->tp_arg;
235 ed619ca0 2022-12-14 op struct server *srv = c->srv;
236 ed619ca0 2022-12-14 op struct transport *t = c->t;
237 ed619ca0 2022-12-14 op struct querystring *qs = c->t->qs;
238 ed619ca0 2022-12-14 op struct repo_commit *rc;
239 ed619ca0 2022-12-14 op struct repo_dir *repo_dir = t->repo_dir;
240 ed619ca0 2022-12-14 op struct gotweb_url diff_url, tree_url;
241 ed619ca0 2022-12-14 op char *tmp;
242 ed619ca0 2022-12-14 op
243 ed619ca0 2022-12-14 op diff_url = (struct gotweb_url){
244 ed619ca0 2022-12-14 op .action = DIFF,
245 ed619ca0 2022-12-14 op .index_page = -1,
246 ed619ca0 2022-12-14 op .page = -1,
247 ed619ca0 2022-12-14 op .path = repo_dir->name,
248 ed619ca0 2022-12-14 op .headref = qs->headref,
249 ed619ca0 2022-12-14 op };
250 ed619ca0 2022-12-14 op tree_url = (struct gotweb_url){
251 ed619ca0 2022-12-14 op .action = TREE,
252 ed619ca0 2022-12-14 op .index_page = -1,
253 ed619ca0 2022-12-14 op .page = -1,
254 ed619ca0 2022-12-14 op .path = repo_dir->name,
255 ed619ca0 2022-12-14 op .headref = qs->headref,
256 ed619ca0 2022-12-14 op };
257 ed619ca0 2022-12-14 op
258 ed619ca0 2022-12-14 op if (qs->action == SUMMARY) {
259 ed619ca0 2022-12-14 op qs->action = BRIEFS;
260 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
261 ed619ca0 2022-12-14 op } else
262 ed619ca0 2022-12-14 op error = got_get_repo_commits(c, srv->max_commits_display);
263 ed619ca0 2022-12-14 op if (error)
264 ed619ca0 2022-12-14 op return -1;
265 ed619ca0 2022-12-14 op !}
266 ed619ca0 2022-12-14 op <div id="briefs_title_wrapper">
267 ed619ca0 2022-12-14 op <div id="briefs_title">Commit Briefs</div>
268 ed619ca0 2022-12-14 op </div>
269 ed619ca0 2022-12-14 op <div id="briefs_content">
270 ed619ca0 2022-12-14 op {{ tailq-foreach rc &t->repo_commits entry }}
271 ed619ca0 2022-12-14 op {!
272 ed619ca0 2022-12-14 op diff_url.commit = rc->commit_id;
273 ed619ca0 2022-12-14 op tree_url.commit = rc->commit_id;
274 ed619ca0 2022-12-14 op
275 ed619ca0 2022-12-14 op tmp = strchr(rc->author, '<');
276 ed619ca0 2022-12-14 op if (tmp)
277 ed619ca0 2022-12-14 op *tmp = '\0';
278 ed619ca0 2022-12-14 op
279 ed619ca0 2022-12-14 op tmp = strchr(rc->commit_msg, '\n');
280 ed619ca0 2022-12-14 op if (tmp)
281 ed619ca0 2022-12-14 op *tmp = '\0';
282 ed619ca0 2022-12-14 op !}
283 ed619ca0 2022-12-14 op <div class="briefs_age">
284 ed619ca0 2022-12-14 op {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
285 ed619ca0 2022-12-14 op </div>
286 ed619ca0 2022-12-14 op <div class="briefs_author">
287 ed619ca0 2022-12-14 op {{ rc->author }}
288 ed619ca0 2022-12-14 op </div>
289 ed619ca0 2022-12-14 op <div class="briefs_log">
290 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
291 ed619ca0 2022-12-14 op {{ rc->commit_msg }}
292 ed619ca0 2022-12-14 op </a>
293 ed619ca0 2022-12-14 op {{ if rc->refs_str }}
294 ed619ca0 2022-12-14 op {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
295 ed619ca0 2022-12-14 op {{ end }}
296 ed619ca0 2022-12-14 op </a>
297 ed619ca0 2022-12-14 op </div>
298 ed619ca0 2022-12-14 op <div class="navs_wrapper">
299 ed619ca0 2022-12-14 op <div class="navs">
300 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
301 ed619ca0 2022-12-14 op {{ " | " }}
302 ed619ca0 2022-12-14 op <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
303 ed619ca0 2022-12-14 op </div>
304 ed619ca0 2022-12-14 op </div>
305 ed619ca0 2022-12-14 op <div class="dotted_line"></div>
306 ed619ca0 2022-12-14 op {{ end }}
307 ed619ca0 2022-12-14 op {{ if t->next_id || t->prev_id }}
308 b4c0bd72 2022-12-17 op {{ render gotweb_render_navs(tp) }}
309 ed619ca0 2022-12-14 op {{ end }}
310 b4c0bd72 2022-12-17 op </div>
311 b4c0bd72 2022-12-17 op {{ end }}
312 b4c0bd72 2022-12-17 op
313 b4c0bd72 2022-12-17 op {{ define gotweb_render_navs(struct template *tp) }}
314 b4c0bd72 2022-12-17 op {!
315 b4c0bd72 2022-12-17 op struct request *c = tp->tp_arg;
316 b4c0bd72 2022-12-17 op struct transport *t = c->t;
317 b4c0bd72 2022-12-17 op struct gotweb_url prev, next;
318 b4c0bd72 2022-12-17 op int have_prev, have_next;
319 b4c0bd72 2022-12-17 op
320 b4c0bd72 2022-12-17 op gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
321 b4c0bd72 2022-12-17 op !}
322 b4c0bd72 2022-12-17 op <div id="np_wrapper">
323 b4c0bd72 2022-12-17 op <div id="nav_prev">
324 b4c0bd72 2022-12-17 op {{ if have_prev }}
325 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &prev) }}">
326 b4c0bd72 2022-12-17 op Previous
327 b4c0bd72 2022-12-17 op </a>
328 b4c0bd72 2022-12-17 op {{ end }}
329 b4c0bd72 2022-12-17 op </div>
330 b4c0bd72 2022-12-17 op <div id="nav_next">
331 b4c0bd72 2022-12-17 op {{ if have_next }}
332 b4c0bd72 2022-12-17 op <a href="{{ render gotweb_render_url(c, &next) }}">
333 b4c0bd72 2022-12-17 op Next
334 b4c0bd72 2022-12-17 op </a>
335 b4c0bd72 2022-12-17 op {{ end }}
336 b4c0bd72 2022-12-17 op </div>
337 ed619ca0 2022-12-14 op </div>
338 b4c0bd72 2022-12-17 op {{ finally }}
339 b4c0bd72 2022-12-17 op {!
340 b4c0bd72 2022-12-17 op free(t->next_id);
341 b4c0bd72 2022-12-17 op t->next_id = NULL;
342 b4c0bd72 2022-12-17 op free(t->prev_id);
343 b4c0bd72 2022-12-17 op t->prev_id = NULL;
344 b4c0bd72 2022-12-17 op !}
345 ed619ca0 2022-12-14 op {{ end }}
346 156a1144 2022-12-17 op
347 156a1144 2022-12-17 op {{ define gotweb_render_commits(struct template *tp) }}
348 156a1144 2022-12-17 op {!
349 156a1144 2022-12-17 op struct request *c = tp->tp_arg;
350 156a1144 2022-12-17 op struct transport *t = c->t;
351 156a1144 2022-12-17 op struct repo_dir *repo_dir = t->repo_dir;
352 156a1144 2022-12-17 op struct repo_commit *rc;
353 156a1144 2022-12-17 op struct gotweb_url diff, tree;
354 156a1144 2022-12-17 op
355 156a1144 2022-12-17 op diff = (struct gotweb_url){
356 156a1144 2022-12-17 op .action = DIFF,
357 156a1144 2022-12-17 op .index_page = -1,
358 156a1144 2022-12-17 op .page = -1,
359 156a1144 2022-12-17 op .path = repo_dir->name,
360 156a1144 2022-12-17 op };
361 156a1144 2022-12-17 op tree = (struct gotweb_url){
362 156a1144 2022-12-17 op .action = TREE,
363 156a1144 2022-12-17 op .index_page = -1,
364 156a1144 2022-12-17 op .page = -1,
365 156a1144 2022-12-17 op .path = repo_dir->name,
366 156a1144 2022-12-17 op };
367 156a1144 2022-12-17 op !}
368 156a1144 2022-12-17 op <div class="commits_title_wrapper">
369 156a1144 2022-12-17 op <div class="commits_title">Commits</div>
370 156a1144 2022-12-17 op </div>
371 156a1144 2022-12-17 op <div class="commits_content">
372 156a1144 2022-12-17 op {{ tailq-foreach rc &t->repo_commits entry }}
373 156a1144 2022-12-17 op {!
374 156a1144 2022-12-17 op diff.commit = rc->commit_id;
375 156a1144 2022-12-17 op tree.commit = rc->commit_id;
376 156a1144 2022-12-17 op !}
377 156a1144 2022-12-17 op <div class="commits_header_wrapper">
378 156a1144 2022-12-17 op <div class="commits_header">
379 156a1144 2022-12-17 op <div class="header_commit_title">Commit:</div>
380 156a1144 2022-12-17 op <div class="header_commit">{{ rc->commit_id }}</div>
381 156a1144 2022-12-17 op <div class="header_author_title">Author:</div>
382 156a1144 2022-12-17 op <div class="header_author">{{ rc->author }}</div>
383 156a1144 2022-12-17 op <div class="header_age_title">Date:</div>
384 156a1144 2022-12-17 op <div class="header_age">
385 156a1144 2022-12-17 op {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
386 156a1144 2022-12-17 op </div>
387 156a1144 2022-12-17 op </div>
388 156a1144 2022-12-17 op </div>
389 156a1144 2022-12-17 op <div class="navs_wrapper">
390 156a1144 2022-12-17 op <div class="navs">
391 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
392 156a1144 2022-12-17 op {{ " | " }}
393 156a1144 2022-12-17 op <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
394 156a1144 2022-12-17 op </div>
395 156a1144 2022-12-17 op </div>
396 156a1144 2022-12-17 op <div class="dotted_line"></div>
397 156a1144 2022-12-17 op {{ end }}
398 156a1144 2022-12-17 op {{ if t->next_id || t->prev_id }}
399 156a1144 2022-12-17 op {{ render gotweb_render_navs(tp) }}
400 156a1144 2022-12-17 op {{ end }}
401 156a1144 2022-12-17 op </div>
402 1abb18e1 2022-12-20 op {{ end }}
403 1abb18e1 2022-12-20 op
404 1abb18e1 2022-12-20 op {{ define gotweb_render_rss(struct template *tp) }}
405 1abb18e1 2022-12-20 op {!
406 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
407 1abb18e1 2022-12-20 op struct server *srv = c->srv;
408 1abb18e1 2022-12-20 op struct transport *t = c->t;
409 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
410 1abb18e1 2022-12-20 op struct repo_tag *rt;
411 1abb18e1 2022-12-20 op struct gotweb_url summary = {
412 1abb18e1 2022-12-20 op .action = SUMMARY,
413 1abb18e1 2022-12-20 op .index_page = -1,
414 1abb18e1 2022-12-20 op .page = -1,
415 1abb18e1 2022-12-20 op .path = repo_dir->name,
416 1abb18e1 2022-12-20 op };
417 1abb18e1 2022-12-20 op !}
418 1abb18e1 2022-12-20 op <?xml version="1.0" encoding="UTF-8"?>
419 1abb18e1 2022-12-20 op <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
420 1abb18e1 2022-12-20 op <channel>
421 1abb18e1 2022-12-20 op <title>Tags of {{ repo_dir->name }}</title>
422 1abb18e1 2022-12-20 op <link>
423 1abb18e1 2022-12-20 op <![CDATA[
424 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &summary) }}
425 1abb18e1 2022-12-20 op ]]>
426 1abb18e1 2022-12-20 op </link>
427 1abb18e1 2022-12-20 op {{ if srv->show_repo_description }}
428 1abb18e1 2022-12-20 op <description>{{ repo_dir->description }}</description>
429 1abb18e1 2022-12-20 op {{ end }}
430 1abb18e1 2022-12-20 op {{ tailq-foreach rt &t->repo_tags entry }}
431 1abb18e1 2022-12-20 op {{ render rss_tag_item(tp, rt) }}
432 1abb18e1 2022-12-20 op {{ end }}
433 1abb18e1 2022-12-20 op </channel>
434 1abb18e1 2022-12-20 op </rss>
435 1abb18e1 2022-12-20 op {{ end }}
436 1abb18e1 2022-12-20 op
437 1abb18e1 2022-12-20 op {{ define rss_tag_item(struct template *tp, struct repo_tag *rt) }}
438 1abb18e1 2022-12-20 op {!
439 1abb18e1 2022-12-20 op struct request *c = tp->tp_arg;
440 1abb18e1 2022-12-20 op struct transport *t = c->t;
441 1abb18e1 2022-12-20 op struct repo_dir *repo_dir = t->repo_dir;
442 1abb18e1 2022-12-20 op char *tag_name = rt->tag_name;
443 1abb18e1 2022-12-20 op struct gotweb_url tag = {
444 1abb18e1 2022-12-20 op .action = TAG,
445 1abb18e1 2022-12-20 op .index_page = -1,
446 1abb18e1 2022-12-20 op .page = -1,
447 1abb18e1 2022-12-20 op .path = repo_dir->name,
448 1abb18e1 2022-12-20 op .commit = rt->commit_id,
449 1abb18e1 2022-12-20 op };
450 1abb18e1 2022-12-20 op
451 1abb18e1 2022-12-20 op if (strncmp(tag_name, "refs/tags/", 10) == 0)
452 1abb18e1 2022-12-20 op tag_name += 10;
453 1abb18e1 2022-12-20 op !}
454 1abb18e1 2022-12-20 op <item>
455 1abb18e1 2022-12-20 op <title>{{ repo_dir->name }} {{" "}} {{ tag_name }}</title>
456 1abb18e1 2022-12-20 op <link>
457 1abb18e1 2022-12-20 op <![CDATA[
458 1abb18e1 2022-12-20 op {{ render gotweb_render_absolute_url(c, &tag) }}
459 1abb18e1 2022-12-20 op ]]>
460 1abb18e1 2022-12-20 op </link>
461 1abb18e1 2022-12-20 op <description>
462 1abb18e1 2022-12-20 op <![CDATA[<pre>{{ rt->tag_commit }}</pre>]]>
463 1abb18e1 2022-12-20 op </description>
464 1abb18e1 2022-12-20 op {{ render rss_author(tp, rt->tagger) }}
465 1abb18e1 2022-12-20 op <guid isPermaLink="false">{{ rt->commit_id }}</guid>
466 1abb18e1 2022-12-20 op <pubDate>
467 1abb18e1 2022-12-20 op {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }}
468 1abb18e1 2022-12-20 op </pubDate>
469 1abb18e1 2022-12-20 op </item>
470 156a1144 2022-12-17 op {{ end }}
471 1abb18e1 2022-12-20 op
472 1abb18e1 2022-12-20 op {{ define rss_author(struct template *tp, char *author) }}
473 1abb18e1 2022-12-20 op {!
474 1abb18e1 2022-12-20 op char *t, *mail;
475 1abb18e1 2022-12-20 op
476 1abb18e1 2022-12-20 op /* what to do if the author name contains a paren? */
477 1abb18e1 2022-12-20 op if (strchr(author, '(') != NULL || strchr(author, ')') != NULL)
478 1abb18e1 2022-12-20 op return 0;
479 1abb18e1 2022-12-20 op
480 1abb18e1 2022-12-20 op t = strchr(author, '<');
481 1abb18e1 2022-12-20 op if (t == NULL)
482 1abb18e1 2022-12-20 op return 0;
483 1abb18e1 2022-12-20 op *t = '\0';
484 1abb18e1 2022-12-20 op mail = t+1;
485 1abb18e1 2022-12-20 op
486 1abb18e1 2022-12-20 op while (isspace((unsigned char)*--t))
487 1abb18e1 2022-12-20 op *t = '\0';
488 1abb18e1 2022-12-20 op
489 1abb18e1 2022-12-20 op t = strchr(mail, '>');
490 1abb18e1 2022-12-20 op if (t == NULL)
491 1abb18e1 2022-12-20 op return 0;
492 1abb18e1 2022-12-20 op *t = '\0';
493 1abb18e1 2022-12-20 op !}
494 1abb18e1 2022-12-20 op <author>
495 1abb18e1 2022-12-20 op {{ mail }} {{" "}} ({{ author }})
496 1abb18e1 2022-12-20 op </author>
497 1abb18e1 2022-12-20 op {{ end }}