-rw-r--r-- | ui-shared.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index ece041c..60aa2e3 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -179,192 +179,198 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
179 | char *delim; | 179 | char *delim; |
180 | 180 | ||
181 | delim = repolink(title, class, page, head, path); | 181 | delim = repolink(title, class, page, head, path); |
182 | if (rev && strcmp(rev, cgit_query_head)) { | 182 | if (rev && strcmp(rev, cgit_query_head)) { |
183 | html(delim); | 183 | html(delim); |
184 | html("id="); | 184 | html("id="); |
185 | html_attr(rev); | 185 | html_attr(rev); |
186 | } | 186 | } |
187 | html("'>"); | 187 | html("'>"); |
188 | html_txt(name); | 188 | html_txt(name); |
189 | html("</a>"); | 189 | html("</a>"); |
190 | } | 190 | } |
191 | 191 | ||
192 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 192 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
193 | char *rev, char *path) | 193 | char *rev, char *path) |
194 | { | 194 | { |
195 | reporevlink("tree", name, title, class, head, rev, path); | 195 | reporevlink("tree", name, title, class, head, rev, path); |
196 | } | 196 | } |
197 | 197 | ||
198 | void cgit_log_link(char *name, char *title, char *class, char *head, | 198 | void cgit_log_link(char *name, char *title, char *class, char *head, |
199 | char *rev, char *path, int ofs, char *grep, char *pattern) | 199 | char *rev, char *path, int ofs, char *grep, char *pattern) |
200 | { | 200 | { |
201 | char *delim; | 201 | char *delim; |
202 | 202 | ||
203 | delim = repolink(title, class, "log", head, path); | 203 | delim = repolink(title, class, "log", head, path); |
204 | if (rev && strcmp(rev, cgit_query_head)) { | 204 | if (rev && strcmp(rev, cgit_query_head)) { |
205 | html(delim); | 205 | html(delim); |
206 | html("id="); | 206 | html("id="); |
207 | html_attr(rev); | 207 | html_attr(rev); |
208 | delim = "&"; | 208 | delim = "&"; |
209 | } | 209 | } |
210 | if (grep && pattern) { | 210 | if (grep && pattern) { |
211 | html(delim); | 211 | html(delim); |
212 | html("qt="); | 212 | html("qt="); |
213 | html_attr(grep); | 213 | html_attr(grep); |
214 | delim = "&"; | 214 | delim = "&"; |
215 | html(delim); | 215 | html(delim); |
216 | html("q="); | 216 | html("q="); |
217 | html_attr(pattern); | 217 | html_attr(pattern); |
218 | } | 218 | } |
219 | if (ofs > 0) { | 219 | if (ofs > 0) { |
220 | html(delim); | 220 | html(delim); |
221 | html("ofs="); | 221 | html("ofs="); |
222 | htmlf("%d", ofs); | 222 | htmlf("%d", ofs); |
223 | } | 223 | } |
224 | html("'>"); | 224 | html("'>"); |
225 | html_txt(name); | 225 | html_txt(name); |
226 | html("</a>"); | 226 | html("</a>"); |
227 | } | 227 | } |
228 | 228 | ||
229 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 229 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
230 | char *rev) | 230 | char *rev) |
231 | { | 231 | { |
232 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | 232 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { |
233 | name[cgit_max_msg_len] = '\0'; | 233 | name[cgit_max_msg_len] = '\0'; |
234 | name[cgit_max_msg_len - 1] = '.'; | 234 | name[cgit_max_msg_len - 1] = '.'; |
235 | name[cgit_max_msg_len - 2] = '.'; | 235 | name[cgit_max_msg_len - 2] = '.'; |
236 | name[cgit_max_msg_len - 3] = '.'; | 236 | name[cgit_max_msg_len - 3] = '.'; |
237 | } | 237 | } |
238 | reporevlink("commit", name, title, class, head, rev, NULL); | 238 | reporevlink("commit", name, title, class, head, rev, NULL); |
239 | } | 239 | } |
240 | 240 | ||
241 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 241 | void cgit_refs_link(char *name, char *title, char *class, char *head, |
242 | char *rev, char *path) | 242 | char *rev, char *path) |
243 | { | 243 | { |
244 | reporevlink("refs", name, title, class, head, rev, path); | 244 | reporevlink("refs", name, title, class, head, rev, path); |
245 | } | 245 | } |
246 | 246 | ||
247 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | 247 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, |
248 | char *rev, char *archivename) | 248 | char *rev, char *archivename) |
249 | { | 249 | { |
250 | reporevlink("snapshot", name, title, class, head, rev, archivename); | 250 | reporevlink("snapshot", name, title, class, head, rev, archivename); |
251 | } | 251 | } |
252 | 252 | ||
253 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 253 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
254 | char *new_rev, char *old_rev, char *path) | 254 | char *new_rev, char *old_rev, char *path) |
255 | { | 255 | { |
256 | char *delim; | 256 | char *delim; |
257 | 257 | ||
258 | delim = repolink(title, class, "diff", head, path); | 258 | delim = repolink(title, class, "diff", head, path); |
259 | if (new_rev && strcmp(new_rev, cgit_query_head)) { | 259 | if (new_rev && strcmp(new_rev, cgit_query_head)) { |
260 | html(delim); | 260 | html(delim); |
261 | html("id="); | 261 | html("id="); |
262 | html_attr(new_rev); | 262 | html_attr(new_rev); |
263 | delim = "&"; | 263 | delim = "&"; |
264 | } | 264 | } |
265 | if (old_rev) { | 265 | if (old_rev) { |
266 | html(delim); | 266 | html(delim); |
267 | html("id2="); | 267 | html("id2="); |
268 | html_attr(old_rev); | 268 | html_attr(old_rev); |
269 | } | 269 | } |
270 | html("'>"); | 270 | html("'>"); |
271 | html_txt(name); | 271 | html_txt(name); |
272 | html("</a>"); | 272 | html("</a>"); |
273 | } | 273 | } |
274 | 274 | ||
275 | void cgit_patch_link(char *name, char *title, char *class, char *head, | ||
276 | char *rev) | ||
277 | { | ||
278 | reporevlink("patch", name, title, class, head, rev, NULL); | ||
279 | } | ||
280 | |||
275 | void cgit_object_link(struct object *obj) | 281 | void cgit_object_link(struct object *obj) |
276 | { | 282 | { |
277 | char *page, *arg, *url; | 283 | char *page, *arg, *url; |
278 | 284 | ||
279 | if (obj->type == OBJ_COMMIT) { | 285 | if (obj->type == OBJ_COMMIT) { |
280 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 286 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
281 | cgit_query_head, sha1_to_hex(obj->sha1)); | 287 | cgit_query_head, sha1_to_hex(obj->sha1)); |
282 | return; | 288 | return; |
283 | } else if (obj->type == OBJ_TREE) { | 289 | } else if (obj->type == OBJ_TREE) { |
284 | page = "tree"; | 290 | page = "tree"; |
285 | arg = "id"; | 291 | arg = "id"; |
286 | } else if (obj->type == OBJ_TAG) { | 292 | } else if (obj->type == OBJ_TAG) { |
287 | page = "tag"; | 293 | page = "tag"; |
288 | arg = "id"; | 294 | arg = "id"; |
289 | } else { | 295 | } else { |
290 | page = "blob"; | 296 | page = "blob"; |
291 | arg = "id"; | 297 | arg = "id"; |
292 | } | 298 | } |
293 | 299 | ||
294 | url = cgit_pageurl(cgit_query_repo, page, | 300 | url = cgit_pageurl(cgit_query_repo, page, |
295 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 301 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
296 | html_link_open(url, NULL, NULL); | 302 | html_link_open(url, NULL, NULL); |
297 | htmlf("%s %s", typename(obj->type), | 303 | htmlf("%s %s", typename(obj->type), |
298 | sha1_to_hex(obj->sha1)); | 304 | sha1_to_hex(obj->sha1)); |
299 | html_link_close(); | 305 | html_link_close(); |
300 | } | 306 | } |
301 | 307 | ||
302 | void cgit_print_date(time_t secs, char *format) | 308 | void cgit_print_date(time_t secs, char *format) |
303 | { | 309 | { |
304 | char buf[64]; | 310 | char buf[64]; |
305 | struct tm *time; | 311 | struct tm *time; |
306 | 312 | ||
307 | if (!secs) | 313 | if (!secs) |
308 | return; | 314 | return; |
309 | time = gmtime(&secs); | 315 | time = gmtime(&secs); |
310 | strftime(buf, sizeof(buf)-1, format, time); | 316 | strftime(buf, sizeof(buf)-1, format, time); |
311 | html_txt(buf); | 317 | html_txt(buf); |
312 | } | 318 | } |
313 | 319 | ||
314 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 320 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
315 | { | 321 | { |
316 | time_t now, secs; | 322 | time_t now, secs; |
317 | 323 | ||
318 | if (!t) | 324 | if (!t) |
319 | return; | 325 | return; |
320 | time(&now); | 326 | time(&now); |
321 | secs = now - t; | 327 | secs = now - t; |
322 | 328 | ||
323 | if (secs > max_relative && max_relative >= 0) { | 329 | if (secs > max_relative && max_relative >= 0) { |
324 | cgit_print_date(t, format); | 330 | cgit_print_date(t, format); |
325 | return; | 331 | return; |
326 | } | 332 | } |
327 | 333 | ||
328 | if (secs < TM_HOUR * 2) { | 334 | if (secs < TM_HOUR * 2) { |
329 | htmlf("<span class='age-mins'>%.0f min.</span>", | 335 | htmlf("<span class='age-mins'>%.0f min.</span>", |
330 | secs * 1.0 / TM_MIN); | 336 | secs * 1.0 / TM_MIN); |
331 | return; | 337 | return; |
332 | } | 338 | } |
333 | if (secs < TM_DAY * 2) { | 339 | if (secs < TM_DAY * 2) { |
334 | htmlf("<span class='age-hours'>%.0f hours</span>", | 340 | htmlf("<span class='age-hours'>%.0f hours</span>", |
335 | secs * 1.0 / TM_HOUR); | 341 | secs * 1.0 / TM_HOUR); |
336 | return; | 342 | return; |
337 | } | 343 | } |
338 | if (secs < TM_WEEK * 2) { | 344 | if (secs < TM_WEEK * 2) { |
339 | htmlf("<span class='age-days'>%.0f days</span>", | 345 | htmlf("<span class='age-days'>%.0f days</span>", |
340 | secs * 1.0 / TM_DAY); | 346 | secs * 1.0 / TM_DAY); |
341 | return; | 347 | return; |
342 | } | 348 | } |
343 | if (secs < TM_MONTH * 2) { | 349 | if (secs < TM_MONTH * 2) { |
344 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 350 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
345 | secs * 1.0 / TM_WEEK); | 351 | secs * 1.0 / TM_WEEK); |
346 | return; | 352 | return; |
347 | } | 353 | } |
348 | if (secs < TM_YEAR * 2) { | 354 | if (secs < TM_YEAR * 2) { |
349 | htmlf("<span class='age-months'>%.0f months</span>", | 355 | htmlf("<span class='age-months'>%.0f months</span>", |
350 | secs * 1.0 / TM_MONTH); | 356 | secs * 1.0 / TM_MONTH); |
351 | return; | 357 | return; |
352 | } | 358 | } |
353 | htmlf("<span class='age-years'>%.0f years</span>", | 359 | htmlf("<span class='age-years'>%.0f years</span>", |
354 | secs * 1.0 / TM_YEAR); | 360 | secs * 1.0 / TM_YEAR); |
355 | } | 361 | } |
356 | 362 | ||
357 | void cgit_print_docstart(char *title, struct cacheitem *item) | 363 | void cgit_print_docstart(char *title, struct cacheitem *item) |
358 | { | 364 | { |
359 | html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); | 365 | html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); |
360 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 366 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
361 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 367 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
362 | ttl_seconds(item->ttl))); | 368 | ttl_seconds(item->ttl))); |
363 | html("\n"); | 369 | html("\n"); |
364 | html(cgit_doctype); | 370 | html(cgit_doctype); |
365 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 371 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
366 | html("<head>\n"); | 372 | html("<head>\n"); |
367 | html("<title>"); | 373 | html("<title>"); |
368 | html_txt(title); | 374 | html_txt(title); |
369 | html("</title>\n"); | 375 | html("</title>\n"); |
370 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 376 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
@@ -397,166 +403,168 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
397 | struct taginfo *info; | 403 | struct taginfo *info; |
398 | struct object *obj; | 404 | struct object *obj; |
399 | char buf[256], *url; | 405 | char buf[256], *url; |
400 | unsigned char fileid[20]; | 406 | unsigned char fileid[20]; |
401 | int *header = (int *)cb_data; | 407 | int *header = (int *)cb_data; |
402 | 408 | ||
403 | if (prefixcmp(refname, "refs/archives")) | 409 | if (prefixcmp(refname, "refs/archives")) |
404 | return 0; | 410 | return 0; |
405 | strncpy(buf, refname+14, sizeof(buf)); | 411 | strncpy(buf, refname+14, sizeof(buf)); |
406 | obj = parse_object(sha1); | 412 | obj = parse_object(sha1); |
407 | if (!obj) | 413 | if (!obj) |
408 | return 1; | 414 | return 1; |
409 | if (obj->type == OBJ_TAG) { | 415 | if (obj->type == OBJ_TAG) { |
410 | tag = lookup_tag(sha1); | 416 | tag = lookup_tag(sha1); |
411 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 417 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
412 | return 0; | 418 | return 0; |
413 | hashcpy(fileid, tag->tagged->sha1); | 419 | hashcpy(fileid, tag->tagged->sha1); |
414 | } else if (obj->type != OBJ_BLOB) { | 420 | } else if (obj->type != OBJ_BLOB) { |
415 | return 0; | 421 | return 0; |
416 | } else { | 422 | } else { |
417 | hashcpy(fileid, sha1); | 423 | hashcpy(fileid, sha1); |
418 | } | 424 | } |
419 | if (!*header) { | 425 | if (!*header) { |
420 | html("<h1>download</h1>\n"); | 426 | html("<h1>download</h1>\n"); |
421 | *header = 1; | 427 | *header = 1; |
422 | } | 428 | } |
423 | url = cgit_pageurl(cgit_query_repo, "blob", | 429 | url = cgit_pageurl(cgit_query_repo, "blob", |
424 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 430 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
425 | buf)); | 431 | buf)); |
426 | html_link_open(url, NULL, "menu"); | 432 | html_link_open(url, NULL, "menu"); |
427 | html_txt(strlpart(buf, 20)); | 433 | html_txt(strlpart(buf, 20)); |
428 | html_link_close(); | 434 | html_link_close(); |
429 | return 0; | 435 | return 0; |
430 | } | 436 | } |
431 | 437 | ||
432 | void add_hidden_formfields(int incl_head, int incl_search, char *page) | 438 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
433 | { | 439 | { |
434 | char *url; | 440 | char *url; |
435 | 441 | ||
436 | if (!cgit_virtual_root) { | 442 | if (!cgit_virtual_root) { |
437 | url = fmt("%s/%s", cgit_query_repo, page); | 443 | url = fmt("%s/%s", cgit_query_repo, page); |
438 | if (cgit_query_path) | 444 | if (cgit_query_path) |
439 | url = fmt("%s/%s", url, cgit_query_path); | 445 | url = fmt("%s/%s", url, cgit_query_path); |
440 | html_hidden("url", url); | 446 | html_hidden("url", url); |
441 | } | 447 | } |
442 | 448 | ||
443 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | 449 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) |
444 | html_hidden("h", cgit_query_head); | 450 | html_hidden("h", cgit_query_head); |
445 | 451 | ||
446 | if (cgit_query_sha1) | 452 | if (cgit_query_sha1) |
447 | html_hidden("id", cgit_query_sha1); | 453 | html_hidden("id", cgit_query_sha1); |
448 | if (cgit_query_sha2) | 454 | if (cgit_query_sha2) |
449 | html_hidden("id2", cgit_query_sha2); | 455 | html_hidden("id2", cgit_query_sha2); |
450 | 456 | ||
451 | if (incl_search) { | 457 | if (incl_search) { |
452 | if (cgit_query_grep) | 458 | if (cgit_query_grep) |
453 | html_hidden("qt", cgit_query_grep); | 459 | html_hidden("qt", cgit_query_grep); |
454 | if (cgit_query_search) | 460 | if (cgit_query_search) |
455 | html_hidden("q", cgit_query_search); | 461 | html_hidden("q", cgit_query_search); |
456 | } | 462 | } |
457 | } | 463 | } |
458 | 464 | ||
459 | void cgit_print_pageheader(char *title, int show_search) | 465 | void cgit_print_pageheader(char *title, int show_search) |
460 | { | 466 | { |
461 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; | 467 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
462 | int header = 0; | 468 | int header = 0; |
463 | char *url; | 469 | char *url; |
464 | 470 | ||
465 | html("<table id='layout' summary=''>\n"); | 471 | html("<table id='layout' summary=''>\n"); |
466 | html("<tr><td id='sidebar'>\n"); | 472 | html("<tr><td id='sidebar'>\n"); |
467 | html("<table class='sidebar' cellspacing='0' summary=''>\n"); | 473 | html("<table class='sidebar' cellspacing='0' summary=''>\n"); |
468 | html("<tr><td class='sidebar'>\n<a href='"); | 474 | html("<tr><td class='sidebar'>\n<a href='"); |
469 | html_attr(cgit_rooturl()); | 475 | html_attr(cgit_rooturl()); |
470 | htmlf("'><img src='%s' alt='cgit'/></a>\n", | 476 | htmlf("'><img src='%s' alt='cgit'/></a>\n", |
471 | cgit_logo); | 477 | cgit_logo); |
472 | html("</td></tr>\n<tr><td class='sidebar'>\n"); | 478 | html("</td></tr>\n<tr><td class='sidebar'>\n"); |
473 | if (cgit_query_repo) { | 479 | if (cgit_query_repo) { |
474 | html("<h1 class='first'>"); | 480 | html("<h1 class='first'>"); |
475 | html_txt(strrpart(cgit_repo->name, 20)); | 481 | html_txt(strrpart(cgit_repo->name, 20)); |
476 | html("</h1>\n"); | 482 | html("</h1>\n"); |
477 | html_txt(cgit_repo->desc); | 483 | html_txt(cgit_repo->desc); |
478 | if (cgit_repo->owner) { | 484 | if (cgit_repo->owner) { |
479 | html("<h1>owner</h1>\n"); | 485 | html("<h1>owner</h1>\n"); |
480 | html_txt(cgit_repo->owner); | 486 | html_txt(cgit_repo->owner); |
481 | } | 487 | } |
482 | html("<h1>navigate</h1>\n"); | 488 | html("<h1>navigate</h1>\n"); |
483 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 489 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, |
484 | NULL, NULL); | 490 | NULL, NULL); |
485 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, | 491 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, |
486 | 0, NULL, NULL); | 492 | 0, NULL, NULL); |
487 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, | 493 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, |
488 | cgit_query_sha1, NULL); | 494 | cgit_query_sha1, NULL); |
489 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, | 495 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, |
490 | cgit_query_sha1); | 496 | cgit_query_sha1); |
491 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 497 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
492 | cgit_query_sha1, cgit_query_sha2, NULL); | 498 | cgit_query_sha1, cgit_query_sha2, NULL); |
499 | cgit_patch_link("patch", NULL, "menu", cgit_query_head, | ||
500 | cgit_query_sha1); | ||
493 | 501 | ||
494 | for_each_ref(print_archive_ref, &header); | 502 | for_each_ref(print_archive_ref, &header); |
495 | 503 | ||
496 | if (cgit_repo->clone_url || cgit_clone_prefix) { | 504 | if (cgit_repo->clone_url || cgit_clone_prefix) { |
497 | html("<h1>clone</h1>\n"); | 505 | html("<h1>clone</h1>\n"); |
498 | if (cgit_repo->clone_url) | 506 | if (cgit_repo->clone_url) |
499 | url = cgit_repo->clone_url; | 507 | url = cgit_repo->clone_url; |
500 | else | 508 | else |
501 | url = fmt("%s%s", cgit_clone_prefix, | 509 | url = fmt("%s%s", cgit_clone_prefix, |
502 | cgit_repo->url); | 510 | cgit_repo->url); |
503 | html("<a class='menu' href='"); | 511 | html("<a class='menu' href='"); |
504 | html_attr(url); | 512 | html_attr(url); |
505 | html("' title='"); | 513 | html("' title='"); |
506 | html_attr(url); | 514 | html_attr(url); |
507 | html("'>\n"); | 515 | html("'>\n"); |
508 | html_txt(strrpart(url, 20)); | 516 | html_txt(strrpart(url, 20)); |
509 | html("</a>\n"); | 517 | html("</a>\n"); |
510 | } | 518 | } |
511 | 519 | ||
512 | html("<h1>branch</h1>\n"); | 520 | html("<h1>branch</h1>\n"); |
513 | html("<form method='get' action=''>\n"); | 521 | html("<form method='get' action=''>\n"); |
514 | add_hidden_formfields(0, 1, cgit_query_page); | 522 | add_hidden_formfields(0, 1, cgit_query_page); |
515 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); | 523 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); |
516 | html("<select name='h' onchange='this.form.submit();'>\n"); | 524 | html("<select name='h' onchange='this.form.submit();'>\n"); |
517 | for_each_branch_ref(print_branch_option, cgit_query_head); | 525 | for_each_branch_ref(print_branch_option, cgit_query_head); |
518 | html("</select>\n"); | 526 | html("</select>\n"); |
519 | // html("</td><td>"); | 527 | // html("</td><td>"); |
520 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); | 528 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); |
521 | // html("</td></tr></table>"); | 529 | // html("</td></tr></table>"); |
522 | html("</form>\n"); | 530 | html("</form>\n"); |
523 | 531 | ||
524 | html("<h1>search</h1>\n"); | 532 | html("<h1>search</h1>\n"); |
525 | html("<form method='get' action='"); | 533 | html("<form method='get' action='"); |
526 | if (cgit_virtual_root) | 534 | if (cgit_virtual_root) |
527 | html_attr(cgit_fileurl(cgit_query_repo, "log", | 535 | html_attr(cgit_fileurl(cgit_query_repo, "log", |
528 | cgit_query_path, NULL)); | 536 | cgit_query_path, NULL)); |
529 | html("'>\n"); | 537 | html("'>\n"); |
530 | add_hidden_formfields(1, 0, "log"); | 538 | add_hidden_formfields(1, 0, "log"); |
531 | html("<select name='qt'>\n"); | 539 | html("<select name='qt'>\n"); |
532 | html_option("grep", "log msg", cgit_query_grep); | 540 | html_option("grep", "log msg", cgit_query_grep); |
533 | html_option("author", "author", cgit_query_grep); | 541 | html_option("author", "author", cgit_query_grep); |
534 | html_option("committer", "committer", cgit_query_grep); | 542 | html_option("committer", "committer", cgit_query_grep); |
535 | html("</select>\n"); | 543 | html("</select>\n"); |
536 | html("<input class='txt' type='text' name='q' value='"); | 544 | html("<input class='txt' type='text' name='q' value='"); |
537 | html_attr(cgit_query_search); | 545 | html_attr(cgit_query_search); |
538 | html("'/>\n"); | 546 | html("'/>\n"); |
539 | html("</form>\n"); | 547 | html("</form>\n"); |
540 | } else { | 548 | } else { |
541 | if (!cgit_index_info || html_include(cgit_index_info)) | 549 | if (!cgit_index_info || html_include(cgit_index_info)) |
542 | html(default_info); | 550 | html(default_info); |
543 | } | 551 | } |
544 | 552 | ||
545 | html("</td></tr></table></td>\n"); | 553 | html("</td></tr></table></td>\n"); |
546 | 554 | ||
547 | html("<td id='content'>\n"); | 555 | html("<td id='content'>\n"); |
548 | } | 556 | } |
549 | 557 | ||
550 | 558 | ||
551 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 559 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
552 | struct cacheitem *item) | 560 | struct cacheitem *item) |
553 | { | 561 | { |
554 | htmlf("Content-Type: %s\n", mimetype); | 562 | htmlf("Content-Type: %s\n", mimetype); |
555 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 563 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
556 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 564 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
557 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 565 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
558 | ttl_seconds(item->ttl))); | 566 | ttl_seconds(item->ttl))); |
559 | html("\n"); | 567 | html("\n"); |
560 | } | 568 | } |
561 | 569 | ||
562 | /* vim:set sw=8: */ | 570 | /* vim:set sw=8: */ |