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