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 e7e5fa49 2022-12-30 thomas
22 e7e5fa49 2022-12-30 thomas #include <event.h>
23 e7e5fa49 2022-12-30 thomas #include <stdint.h>
24 e7e5fa49 2022-12-30 thomas #include <stdlib.h>
25 e7e5fa49 2022-12-30 thomas #include <string.h>
26 e7e5fa49 2022-12-30 thomas #include <imsg.h>
27 e7e5fa49 2022-12-30 thomas
28 e7e5fa49 2022-12-30 thomas #include "proc.h"
29 e7e5fa49 2022-12-30 thomas
30 e7e5fa49 2022-12-30 thomas #include "gotwebd.h"
31 e7e5fa49 2022-12-30 thomas #include "tmpl.h"
32 e7e5fa49 2022-12-30 thomas
33 e7e5fa49 2022-12-30 thomas static int
34 e7e5fa49 2022-12-30 thomas gotweb_render_age(struct template *tp, time_t time, int ref_tm)
35 e7e5fa49 2022-12-30 thomas {
36 e7e5fa49 2022-12-30 thomas const struct got_error *err;
37 e7e5fa49 2022-12-30 thomas char *age;
38 e7e5fa49 2022-12-30 thomas int r;
39 e7e5fa49 2022-12-30 thomas
40 e7e5fa49 2022-12-30 thomas err = gotweb_get_time_str(&age, time, ref_tm);
41 e7e5fa49 2022-12-30 thomas if (err)
42 e7e5fa49 2022-12-30 thomas return 0;
43 e7e5fa49 2022-12-30 thomas r = tp->tp_puts(tp, age);
44 e7e5fa49 2022-12-30 thomas free(age);
45 e7e5fa49 2022-12-30 thomas return r;
46 e7e5fa49 2022-12-30 thomas }
47 e7e5fa49 2022-12-30 thomas
48 e7e5fa49 2022-12-30 thomas !}
49 e7e5fa49 2022-12-30 thomas
50 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_header(struct template *tp) }}
51 e7e5fa49 2022-12-30 thomas {!
52 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
53 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
54 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
55 e7e5fa49 2022-12-30 thomas struct gotweb_url u_path;
56 3191e256 2022-12-30 thomas const char *prfx = c->document_uri;
57 e7e5fa49 2022-12-30 thomas const char *css = srv->custom_css;
58 e7e5fa49 2022-12-30 thomas
59 e7e5fa49 2022-12-30 thomas memset(&u_path, 0, sizeof(u_path));
60 e7e5fa49 2022-12-30 thomas u_path.index_page = -1;
61 e7e5fa49 2022-12-30 thomas u_path.page = -1;
62 e7e5fa49 2022-12-30 thomas u_path.action = SUMMARY;
63 e7e5fa49 2022-12-30 thomas !}
64 e7e5fa49 2022-12-30 thomas <!doctype html>
65 e7e5fa49 2022-12-30 thomas <html>
66 e7e5fa49 2022-12-30 thomas <head>
67 e7e5fa49 2022-12-30 thomas <meta charset="utf-8" />
68 e7e5fa49 2022-12-30 thomas <title>{{ srv->site_name }}</title>
69 e7e5fa49 2022-12-30 thomas <meta name="viewport" content="initial-scale=.75" />
70 e7e5fa49 2022-12-30 thomas <meta name="msapplication-TileColor" content="#da532c" />
71 e7e5fa49 2022-12-30 thomas <meta name="theme-color" content="#ffffff"/>
72 e7e5fa49 2022-12-30 thomas <link rel="apple-touch-icon" sizes="180x180" href="{{ prfx }}apple-touch-icon.png" />
73 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="32x32" href="{{ prfx }}favicon-32x32.png" />
74 e7e5fa49 2022-12-30 thomas <link rel="icon" type="image/png" sizes="16x16" href="{{ prfx }}favicon-16x16.png" />
75 e7e5fa49 2022-12-30 thomas <link rel="manifest" href="{{ prfx }}site.webmanifest"/>
76 e7e5fa49 2022-12-30 thomas <link rel="mask-icon" href="{{ prfx }}safari-pinned-tab.svg" />
77 e7e5fa49 2022-12-30 thomas <link rel="stylesheet" type="text/css" href="{{ prfx }}{{ css }}" />
78 e7e5fa49 2022-12-30 thomas </head>
79 e7e5fa49 2022-12-30 thomas <body>
80 e7e5fa49 2022-12-30 thomas <div id="gw_body">
81 e7e5fa49 2022-12-30 thomas <div id="header">
82 e7e5fa49 2022-12-30 thomas <div id="got_link">
83 e7e5fa49 2022-12-30 thomas <a href="{{ srv->logo_url }}" target="_blank">
84 e7e5fa49 2022-12-30 thomas <img src="{{ prfx }}{{ srv->logo }}" />
85 e7e5fa49 2022-12-30 thomas </a>
86 e7e5fa49 2022-12-30 thomas </div>
87 e7e5fa49 2022-12-30 thomas </div>
88 e7e5fa49 2022-12-30 thomas <div id="site_path">
89 e7e5fa49 2022-12-30 thomas <div id="site_link">
90 e7e5fa49 2022-12-30 thomas <a href="?index_page={{ printf "%d", qs->index_page }}">
91 e7e5fa49 2022-12-30 thomas {{ srv->site_link }}
92 e7e5fa49 2022-12-30 thomas </a>
93 e7e5fa49 2022-12-30 thomas {{ if qs->path }}
94 e7e5fa49 2022-12-30 thomas {! u_path.path = qs->path; !}
95 e7e5fa49 2022-12-30 thomas {{ " / " }}
96 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &u_path)}}">
97 e7e5fa49 2022-12-30 thomas {{ qs->path }}
98 e7e5fa49 2022-12-30 thomas </a>
99 e7e5fa49 2022-12-30 thomas {{ end }}
100 e7e5fa49 2022-12-30 thomas {{ if qs->action != INDEX }}
101 e7e5fa49 2022-12-30 thomas {{ " / " }}{{ gotweb_action_name(qs->action) }}
102 e7e5fa49 2022-12-30 thomas {{ end }}
103 e7e5fa49 2022-12-30 thomas </div>
104 e7e5fa49 2022-12-30 thomas </div>
105 e7e5fa49 2022-12-30 thomas <div id="content">
106 e7e5fa49 2022-12-30 thomas {{ end }}
107 e7e5fa49 2022-12-30 thomas
108 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_footer(struct template *tp) }}
109 e7e5fa49 2022-12-30 thomas {!
110 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
111 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
112 e7e5fa49 2022-12-30 thomas !}
113 e7e5fa49 2022-12-30 thomas <div id="site_owner_wrapper">
114 e7e5fa49 2022-12-30 thomas <div id="site_owner">
115 e7e5fa49 2022-12-30 thomas {{ if srv->show_site_owner }}
116 e7e5fa49 2022-12-30 thomas {{ srv->site_owner }}
117 e7e5fa49 2022-12-30 thomas {{ end }}
118 e7e5fa49 2022-12-30 thomas </div>
119 e7e5fa49 2022-12-30 thomas </div>
120 e7e5fa49 2022-12-30 thomas </div>
121 e7e5fa49 2022-12-30 thomas </div>
122 e7e5fa49 2022-12-30 thomas </body>
123 e7e5fa49 2022-12-30 thomas </html>
124 e7e5fa49 2022-12-30 thomas {{ end }}
125 e7e5fa49 2022-12-30 thomas
126 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_table_hdr(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="index_header">
132 e7e5fa49 2022-12-30 thomas <div id="index_header_project">
133 e7e5fa49 2022-12-30 thomas Project
134 e7e5fa49 2022-12-30 thomas </div>
135 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
136 e7e5fa49 2022-12-30 thomas <div id="index_header_description">
137 e7e5fa49 2022-12-30 thomas Description
138 e7e5fa49 2022-12-30 thomas </div>
139 e7e5fa49 2022-12-30 thomas {{ end }}
140 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
141 e7e5fa49 2022-12-30 thomas <div id="index_header_owner">
142 e7e5fa49 2022-12-30 thomas Owner
143 e7e5fa49 2022-12-30 thomas </div>
144 e7e5fa49 2022-12-30 thomas {{ end }}
145 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
146 e7e5fa49 2022-12-30 thomas <div id="index_header_age">
147 e7e5fa49 2022-12-30 thomas Last Change
148 e7e5fa49 2022-12-30 thomas </div>
149 e7e5fa49 2022-12-30 thomas {{ end }}
150 e7e5fa49 2022-12-30 thomas </div>
151 e7e5fa49 2022-12-30 thomas {{ end }}
152 e7e5fa49 2022-12-30 thomas
153 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_repo_fragment(struct template *tp, struct repo_dir *repo_dir) }}
154 e7e5fa49 2022-12-30 thomas {!
155 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
156 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
157 e7e5fa49 2022-12-30 thomas struct gotweb_url summary = {
158 e7e5fa49 2022-12-30 thomas .action = SUMMARY,
159 e7e5fa49 2022-12-30 thomas .index_page = -1,
160 e7e5fa49 2022-12-30 thomas .page = -1,
161 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
162 e7e5fa49 2022-12-30 thomas }, briefs = {
163 e7e5fa49 2022-12-30 thomas .action = BRIEFS,
164 e7e5fa49 2022-12-30 thomas .index_page = -1,
165 e7e5fa49 2022-12-30 thomas .page = -1,
166 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
167 e7e5fa49 2022-12-30 thomas }, commits = {
168 e7e5fa49 2022-12-30 thomas .action = COMMITS,
169 e7e5fa49 2022-12-30 thomas .index_page = -1,
170 e7e5fa49 2022-12-30 thomas .page = -1,
171 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
172 e7e5fa49 2022-12-30 thomas }, tags = {
173 e7e5fa49 2022-12-30 thomas .action = TAGS,
174 e7e5fa49 2022-12-30 thomas .index_page = -1,
175 e7e5fa49 2022-12-30 thomas .page = -1,
176 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
177 e7e5fa49 2022-12-30 thomas }, tree = {
178 e7e5fa49 2022-12-30 thomas .action = TREE,
179 e7e5fa49 2022-12-30 thomas .index_page = -1,
180 e7e5fa49 2022-12-30 thomas .page = -1,
181 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
182 e7e5fa49 2022-12-30 thomas };
183 e7e5fa49 2022-12-30 thomas !}
184 e7e5fa49 2022-12-30 thomas <div class="index_wrapper">
185 e7e5fa49 2022-12-30 thomas <div class="index_project">
186 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">{{ repo_dir->name }}</a>
187 e7e5fa49 2022-12-30 thomas </div>
188 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_description }}
189 e7e5fa49 2022-12-30 thomas <div class="index_project_description">
190 e7e5fa49 2022-12-30 thomas {{ repo_dir->description }}
191 e7e5fa49 2022-12-30 thomas </div>
192 e7e5fa49 2022-12-30 thomas {{ end }}
193 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_owner }}
194 e7e5fa49 2022-12-30 thomas <div class="index_project_owner">
195 e7e5fa49 2022-12-30 thomas {{ repo_dir->owner }}
196 e7e5fa49 2022-12-30 thomas </div>
197 e7e5fa49 2022-12-30 thomas {{ end }}
198 e7e5fa49 2022-12-30 thomas {{ if srv->show_repo_age }}
199 e7e5fa49 2022-12-30 thomas <div class="index_project_age">
200 e7e5fa49 2022-12-30 thomas {{ repo_dir->age }}
201 e7e5fa49 2022-12-30 thomas </div>
202 e7e5fa49 2022-12-30 thomas {{ end }}
203 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
204 e7e5fa49 2022-12-30 thomas <div class="navs">
205 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &summary) }}">summary</a>
206 e7e5fa49 2022-12-30 thomas {{ " | " }}
207 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &briefs) }}">briefs</a>
208 e7e5fa49 2022-12-30 thomas {{ " | " }}
209 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &commits) }}">commits</a>
210 e7e5fa49 2022-12-30 thomas {{ " | " }}
211 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tags) }}">tags</a>
212 e7e5fa49 2022-12-30 thomas {{ " | " }}
213 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree) }}">tree</a>
214 e7e5fa49 2022-12-30 thomas </div>
215 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
216 e7e5fa49 2022-12-30 thomas </div>
217 e7e5fa49 2022-12-30 thomas </div>
218 e7e5fa49 2022-12-30 thomas {{ end }}
219 e7e5fa49 2022-12-30 thomas
220 e7e5fa49 2022-12-30 thomas {{ define gotweb_render_briefs(struct template *tp) }}
221 e7e5fa49 2022-12-30 thomas {!
222 e7e5fa49 2022-12-30 thomas const struct got_error *error;
223 e7e5fa49 2022-12-30 thomas struct request *c = tp->tp_arg;
224 e7e5fa49 2022-12-30 thomas struct server *srv = c->srv;
225 e7e5fa49 2022-12-30 thomas struct transport *t = c->t;
226 e7e5fa49 2022-12-30 thomas struct querystring *qs = c->t->qs;
227 e7e5fa49 2022-12-30 thomas struct repo_commit *rc;
228 e7e5fa49 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
229 e7e5fa49 2022-12-30 thomas struct gotweb_url diff_url, tree_url;
230 e7e5fa49 2022-12-30 thomas char *tmp;
231 e7e5fa49 2022-12-30 thomas
232 e7e5fa49 2022-12-30 thomas diff_url = (struct gotweb_url){
233 e7e5fa49 2022-12-30 thomas .action = DIFF,
234 e7e5fa49 2022-12-30 thomas .index_page = -1,
235 e7e5fa49 2022-12-30 thomas .page = -1,
236 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
237 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
238 e7e5fa49 2022-12-30 thomas };
239 e7e5fa49 2022-12-30 thomas tree_url = (struct gotweb_url){
240 e7e5fa49 2022-12-30 thomas .action = TREE,
241 e7e5fa49 2022-12-30 thomas .index_page = -1,
242 e7e5fa49 2022-12-30 thomas .page = -1,
243 e7e5fa49 2022-12-30 thomas .path = repo_dir->name,
244 e7e5fa49 2022-12-30 thomas .headref = qs->headref,
245 e7e5fa49 2022-12-30 thomas };
246 e7e5fa49 2022-12-30 thomas
247 e7e5fa49 2022-12-30 thomas if (qs->action == SUMMARY) {
248 e7e5fa49 2022-12-30 thomas qs->action = BRIEFS;
249 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, D_MAXSLCOMMDISP);
250 e7e5fa49 2022-12-30 thomas } else
251 e7e5fa49 2022-12-30 thomas error = got_get_repo_commits(c, srv->max_commits_display);
252 e7e5fa49 2022-12-30 thomas if (error)
253 e7e5fa49 2022-12-30 thomas return -1;
254 e7e5fa49 2022-12-30 thomas !}
255 e7e5fa49 2022-12-30 thomas <div id="briefs_title_wrapper">
256 e7e5fa49 2022-12-30 thomas <div id="briefs_title">Commit Briefs</div>
257 e7e5fa49 2022-12-30 thomas </div>
258 e7e5fa49 2022-12-30 thomas <div id="briefs_content">
259 e7e5fa49 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
260 e7e5fa49 2022-12-30 thomas {!
261 e7e5fa49 2022-12-30 thomas diff_url.commit = rc->commit_id;
262 e7e5fa49 2022-12-30 thomas tree_url.commit = rc->commit_id;
263 e7e5fa49 2022-12-30 thomas
264 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->author, '<');
265 e7e5fa49 2022-12-30 thomas if (tmp)
266 e7e5fa49 2022-12-30 thomas *tmp = '\0';
267 e7e5fa49 2022-12-30 thomas
268 e7e5fa49 2022-12-30 thomas tmp = strchr(rc->commit_msg, '\n');
269 e7e5fa49 2022-12-30 thomas if (tmp)
270 e7e5fa49 2022-12-30 thomas *tmp = '\0';
271 e7e5fa49 2022-12-30 thomas !}
272 e7e5fa49 2022-12-30 thomas <div class="briefs_age">
273 e7e5fa49 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_DIFF) }}
274 e7e5fa49 2022-12-30 thomas </div>
275 e7e5fa49 2022-12-30 thomas <div class="briefs_author">
276 e7e5fa49 2022-12-30 thomas {{ rc->author }}
277 e7e5fa49 2022-12-30 thomas </div>
278 e7e5fa49 2022-12-30 thomas <div class="briefs_log">
279 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
280 e7e5fa49 2022-12-30 thomas {{ rc->commit_msg }}
281 e7e5fa49 2022-12-30 thomas </a>
282 e7e5fa49 2022-12-30 thomas {{ if rc->refs_str }}
283 e7e5fa49 2022-12-30 thomas {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
284 e7e5fa49 2022-12-30 thomas {{ end }}
285 e7e5fa49 2022-12-30 thomas </a>
286 e7e5fa49 2022-12-30 thomas </div>
287 e7e5fa49 2022-12-30 thomas <div class="navs_wrapper">
288 e7e5fa49 2022-12-30 thomas <div class="navs">
289 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">diff</a>
290 e7e5fa49 2022-12-30 thomas {{ " | " }}
291 e7e5fa49 2022-12-30 thomas <a href="{{ render gotweb_render_url(tp->tp_arg, &tree_url) }}">tree</a>
292 e7e5fa49 2022-12-30 thomas </div>
293 e7e5fa49 2022-12-30 thomas </div>
294 e7e5fa49 2022-12-30 thomas <div class="dotted_line"></div>
295 e7e5fa49 2022-12-30 thomas {{ end }}
296 e7e5fa49 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
297 2f4f0731 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
298 e7e5fa49 2022-12-30 thomas {{ end }}
299 2f4f0731 2022-12-30 thomas </div>
300 2f4f0731 2022-12-30 thomas {{ end }}
301 2f4f0731 2022-12-30 thomas
302 2f4f0731 2022-12-30 thomas {{ define gotweb_render_navs(struct template *tp) }}
303 2f4f0731 2022-12-30 thomas {!
304 2f4f0731 2022-12-30 thomas struct request *c = tp->tp_arg;
305 2f4f0731 2022-12-30 thomas struct transport *t = c->t;
306 2f4f0731 2022-12-30 thomas struct gotweb_url prev, next;
307 2f4f0731 2022-12-30 thomas int have_prev, have_next;
308 2f4f0731 2022-12-30 thomas
309 2f4f0731 2022-12-30 thomas gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
310 2f4f0731 2022-12-30 thomas !}
311 2f4f0731 2022-12-30 thomas <div id="np_wrapper">
312 2f4f0731 2022-12-30 thomas <div id="nav_prev">
313 2f4f0731 2022-12-30 thomas {{ if have_prev }}
314 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &prev) }}">
315 2f4f0731 2022-12-30 thomas Previous
316 2f4f0731 2022-12-30 thomas </a>
317 2f4f0731 2022-12-30 thomas {{ end }}
318 2f4f0731 2022-12-30 thomas </div>
319 2f4f0731 2022-12-30 thomas <div id="nav_next">
320 2f4f0731 2022-12-30 thomas {{ if have_next }}
321 2f4f0731 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &next) }}">
322 2f4f0731 2022-12-30 thomas Next
323 2f4f0731 2022-12-30 thomas </a>
324 2f4f0731 2022-12-30 thomas {{ end }}
325 2f4f0731 2022-12-30 thomas </div>
326 e7e5fa49 2022-12-30 thomas </div>
327 2f4f0731 2022-12-30 thomas {{ finally }}
328 2f4f0731 2022-12-30 thomas {!
329 2f4f0731 2022-12-30 thomas free(t->next_id);
330 2f4f0731 2022-12-30 thomas t->next_id = NULL;
331 2f4f0731 2022-12-30 thomas free(t->prev_id);
332 2f4f0731 2022-12-30 thomas t->prev_id = NULL;
333 2f4f0731 2022-12-30 thomas !}
334 e7e5fa49 2022-12-30 thomas {{ end }}
335 7ade8b27 2022-12-30 thomas
336 7ade8b27 2022-12-30 thomas {{ define gotweb_render_commits(struct template *tp) }}
337 7ade8b27 2022-12-30 thomas {!
338 7ade8b27 2022-12-30 thomas struct request *c = tp->tp_arg;
339 7ade8b27 2022-12-30 thomas struct transport *t = c->t;
340 7ade8b27 2022-12-30 thomas struct repo_dir *repo_dir = t->repo_dir;
341 7ade8b27 2022-12-30 thomas struct repo_commit *rc;
342 7ade8b27 2022-12-30 thomas struct gotweb_url diff, tree;
343 7ade8b27 2022-12-30 thomas
344 7ade8b27 2022-12-30 thomas diff = (struct gotweb_url){
345 7ade8b27 2022-12-30 thomas .action = DIFF,
346 7ade8b27 2022-12-30 thomas .index_page = -1,
347 7ade8b27 2022-12-30 thomas .page = -1,
348 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
349 7ade8b27 2022-12-30 thomas };
350 7ade8b27 2022-12-30 thomas tree = (struct gotweb_url){
351 7ade8b27 2022-12-30 thomas .action = TREE,
352 7ade8b27 2022-12-30 thomas .index_page = -1,
353 7ade8b27 2022-12-30 thomas .page = -1,
354 7ade8b27 2022-12-30 thomas .path = repo_dir->name,
355 7ade8b27 2022-12-30 thomas };
356 7ade8b27 2022-12-30 thomas !}
357 7ade8b27 2022-12-30 thomas <div class="commits_title_wrapper">
358 7ade8b27 2022-12-30 thomas <div class="commits_title">Commits</div>
359 7ade8b27 2022-12-30 thomas </div>
360 7ade8b27 2022-12-30 thomas <div class="commits_content">
361 7ade8b27 2022-12-30 thomas {{ tailq-foreach rc &t->repo_commits entry }}
362 7ade8b27 2022-12-30 thomas {!
363 7ade8b27 2022-12-30 thomas diff.commit = rc->commit_id;
364 7ade8b27 2022-12-30 thomas tree.commit = rc->commit_id;
365 7ade8b27 2022-12-30 thomas !}
366 7ade8b27 2022-12-30 thomas <div class="commits_header_wrapper">
367 7ade8b27 2022-12-30 thomas <div class="commits_header">
368 7ade8b27 2022-12-30 thomas <div class="header_commit_title">Commit:</div>
369 7ade8b27 2022-12-30 thomas <div class="header_commit">{{ rc->commit_id }}</div>
370 7ade8b27 2022-12-30 thomas <div class="header_author_title">Author:</div>
371 7ade8b27 2022-12-30 thomas <div class="header_author">{{ rc->author }}</div>
372 7ade8b27 2022-12-30 thomas <div class="header_age_title">Date:</div>
373 7ade8b27 2022-12-30 thomas <div class="header_age">
374 7ade8b27 2022-12-30 thomas {{ render gotweb_render_age(tp, rc->committer_time, TM_LONG) }}
375 7ade8b27 2022-12-30 thomas </div>
376 7ade8b27 2022-12-30 thomas </div>
377 7ade8b27 2022-12-30 thomas </div>
378 7ade8b27 2022-12-30 thomas <div class="navs_wrapper">
379 7ade8b27 2022-12-30 thomas <div class="navs">
380 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &diff) }}">diff</a>
381 7ade8b27 2022-12-30 thomas {{ " | " }}
382 7ade8b27 2022-12-30 thomas <a href="{{ render gotweb_render_url(c, &tree) }}">tree</a>
383 7ade8b27 2022-12-30 thomas </div>
384 7ade8b27 2022-12-30 thomas </div>
385 7ade8b27 2022-12-30 thomas <div class="dotted_line"></div>
386 7ade8b27 2022-12-30 thomas {{ end }}
387 7ade8b27 2022-12-30 thomas {{ if t->next_id || t->prev_id }}
388 7ade8b27 2022-12-30 thomas {{ render gotweb_render_navs(tp) }}
389 7ade8b27 2022-12-30 thomas {{ end }}
390 7ade8b27 2022-12-30 thomas </div>
391 7ade8b27 2022-12-30 thomas {{ end }}