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