-rw-r--r-- | ui-shared.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c index e4bb98f..45105dc 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -324,116 +324,121 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
324 | } | 324 | } |
325 | if (secs < TM_MONTH * 2) { | 325 | if (secs < TM_MONTH * 2) { |
326 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 326 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
327 | secs * 1.0 / TM_WEEK); | 327 | secs * 1.0 / TM_WEEK); |
328 | return; | 328 | return; |
329 | } | 329 | } |
330 | if (secs < TM_YEAR * 2) { | 330 | if (secs < TM_YEAR * 2) { |
331 | htmlf("<span class='age-months'>%.0f months</span>", | 331 | htmlf("<span class='age-months'>%.0f months</span>", |
332 | secs * 1.0 / TM_MONTH); | 332 | secs * 1.0 / TM_MONTH); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | htmlf("<span class='age-years'>%.0f years</span>", | 335 | htmlf("<span class='age-years'>%.0f years</span>", |
336 | secs * 1.0 / TM_YEAR); | 336 | secs * 1.0 / TM_YEAR); |
337 | } | 337 | } |
338 | 338 | ||
339 | void cgit_print_docstart(char *title, struct cacheitem *item) | 339 | void cgit_print_docstart(char *title, struct cacheitem *item) |
340 | { | 340 | { |
341 | html("Content-Type: text/html; charset=utf-8\n"); | 341 | html("Content-Type: text/html; charset=utf-8\n"); |
342 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 342 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
343 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 343 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
344 | ttl_seconds(item->ttl))); | 344 | ttl_seconds(item->ttl))); |
345 | html("\n"); | 345 | html("\n"); |
346 | html(cgit_doctype); | 346 | html(cgit_doctype); |
347 | html("<html>\n"); | 347 | html("<html>\n"); |
348 | html("<head>\n"); | 348 | html("<head>\n"); |
349 | html("<title>"); | 349 | html("<title>"); |
350 | html_txt(title); | 350 | html_txt(title); |
351 | html("</title>\n"); | 351 | html("</title>\n"); |
352 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 352 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
353 | html("<link rel='stylesheet' type='text/css' href='"); | 353 | html("<link rel='stylesheet' type='text/css' href='"); |
354 | html_attr(cgit_css); | 354 | html_attr(cgit_css); |
355 | html("'/>\n"); | 355 | html("'/>\n"); |
356 | html("</head>\n"); | 356 | html("</head>\n"); |
357 | html("<body>\n"); | 357 | html("<body>\n"); |
358 | } | 358 | } |
359 | 359 | ||
360 | void cgit_print_docend() | 360 | void cgit_print_docend() |
361 | { | 361 | { |
362 | html("</td></tr></table>"); | 362 | html("</td></tr></table>"); |
363 | html("</body>\n</html>\n"); | 363 | html("</body>\n</html>\n"); |
364 | } | 364 | } |
365 | 365 | ||
366 | void cgit_print_pageheader(char *title, int show_search) | 366 | void cgit_print_pageheader(char *title, int show_search) |
367 | { | 367 | { |
368 | html("<table id='layout'>"); | 368 | html("<table id='layout'>"); |
369 | html("<tr><td id='header'><a href='"); | 369 | html("<tr><td id='header'><a href='"); |
370 | html_attr(cgit_rooturl()); | 370 | html_attr(cgit_rooturl()); |
371 | html("'>"); | 371 | html("'>"); |
372 | html_txt(cgit_root_title); | 372 | html_txt(cgit_root_title); |
373 | html("</a></td><td id='logo'>"); | 373 | html("</a></td><td id='logo'>"); |
374 | html("<a href='"); | 374 | html("<a href='"); |
375 | html_attr(cgit_logo_link); | 375 | html_attr(cgit_logo_link); |
376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
377 | html("</td></tr>"); | 377 | html("</td></tr>"); |
378 | html("<tr><td id='crumb'>"); | 378 | html("<tr><td id='crumb'>"); |
379 | if (cgit_query_repo) { | 379 | if (cgit_query_repo) { |
380 | html_txt(cgit_repo->name); | 380 | html_txt(cgit_repo->name); |
381 | html(" ("); | 381 | html(" ("); |
382 | html_txt(cgit_query_head); | 382 | html_txt(cgit_query_head); |
383 | html(") : "); | 383 | html(") : "); |
384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, | 384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, |
385 | NULL, NULL); | 385 | NULL, NULL); |
386 | html(" "); | 386 | html(" "); |
387 | cgit_log_link("log", NULL, NULL, cgit_query_head, | 387 | cgit_log_link("log", NULL, NULL, cgit_query_head, |
388 | cgit_query_sha1, cgit_query_path, 0); | 388 | cgit_query_sha1, cgit_query_path, 0); |
389 | html(" "); | 389 | html(" "); |
390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, | 390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, |
391 | cgit_query_sha1, NULL); | 391 | cgit_query_sha1, NULL); |
392 | html(" "); | 392 | html(" "); |
393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, | 393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, |
394 | cgit_query_sha1); | 394 | cgit_query_sha1); |
395 | html(" "); | 395 | html(" "); |
396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, | 396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, |
397 | cgit_query_sha1, cgit_query_sha2, | 397 | cgit_query_sha1, cgit_query_sha2, |
398 | cgit_query_path); | 398 | cgit_query_path); |
399 | } else { | 399 | } else { |
400 | html_txt("Index of repositories"); | 400 | html_txt("Index of repositories"); |
401 | } | 401 | } |
402 | html("</td>"); | 402 | html("</td>"); |
403 | html("<td id='search'>"); | 403 | html("<td id='search'>"); |
404 | if (show_search) { | 404 | if (show_search) { |
405 | html("<form method='get' action='"); | 405 | html("<form method='get' action='"); |
406 | html_attr(cgit_currurl()); | 406 | html_attr(cgit_currurl()); |
407 | html("'>"); | 407 | html("'>"); |
408 | if (!cgit_virtual_root) { | 408 | if (!cgit_virtual_root) { |
409 | if (cgit_query_repo) | 409 | if (cgit_query_repo) |
410 | html_hidden("r", cgit_query_repo); | 410 | html_hidden("r", cgit_query_repo); |
411 | if (cgit_query_page) | 411 | if (cgit_query_page) |
412 | html_hidden("p", cgit_query_page); | 412 | html_hidden("p", cgit_query_page); |
413 | } | 413 | } |
414 | if (cgit_query_head) | 414 | if (cgit_query_head) |
415 | html_hidden("h", cgit_query_head); | 415 | html_hidden("h", cgit_query_head); |
416 | if (cgit_query_sha1) | 416 | if (cgit_query_sha1) |
417 | html_hidden("id", cgit_query_sha1); | 417 | html_hidden("id", cgit_query_sha1); |
418 | if (cgit_query_sha2) | 418 | if (cgit_query_sha2) |
419 | html_hidden("id2", cgit_query_sha2); | 419 | html_hidden("id2", cgit_query_sha2); |
420 | html("<input type='text' name='q' value='"); | 420 | html("<select name='qt'>"); |
421 | html_option("grep", "log msg", cgit_query_grep); | ||
422 | html_option("author", "author", cgit_query_grep); | ||
423 | html_option("committer", "committer", cgit_query_grep); | ||
424 | html("</select>"); | ||
425 | html("<input class='txt' type='text' name='q' value='"); | ||
421 | html_attr(cgit_query_search); | 426 | html_attr(cgit_query_search); |
422 | html("'/></form>"); | 427 | html("'/><input class='btn' type='submit' value='...'/></form>"); |
423 | } | 428 | } |
424 | html("</td></tr>"); | 429 | html("</td></tr>"); |
425 | html("<tr><td id='content' colspan='2'>"); | 430 | html("<tr><td id='content' colspan='2'>"); |
426 | } | 431 | } |
427 | 432 | ||
428 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 433 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
429 | struct cacheitem *item) | 434 | struct cacheitem *item) |
430 | { | 435 | { |
431 | htmlf("Content-Type: %s\n", mimetype); | 436 | htmlf("Content-Type: %s\n", mimetype); |
432 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 437 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
433 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 438 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
434 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 439 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
435 | ttl_seconds(item->ttl))); | 440 | ttl_seconds(item->ttl))); |
436 | html("\n"); | 441 | html("\n"); |
437 | } | 442 | } |
438 | 443 | ||
439 | /* vim:set sw=8: */ | 444 | /* vim:set sw=8: */ |