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