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