diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/ui-shared.c b/ui-shared.c index 4944dfd..60aa2e3 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -272,6 +272,12 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
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; |
@@ -356,18 +362,20 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
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=utf-8\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>\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); |
377 | if (cgit_robots && *cgit_robots) | ||
378 | htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); | ||
371 | html("<link rel='stylesheet' type='text/css' href='"); | 379 | html("<link rel='stylesheet' type='text/css' href='"); |
372 | html_attr(cgit_css); | 380 | html_attr(cgit_css); |
373 | html("'/>\n"); | 381 | html("'/>\n"); |
@@ -377,7 +385,7 @@ void cgit_print_docstart(char *title, struct cacheitem *item) | |||
377 | 385 | ||
378 | void cgit_print_docend() | 386 | void cgit_print_docend() |
379 | { | 387 | { |
380 | html("</td>\n</tr>\n<table>\n</body>\n</html>\n"); | 388 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); |
381 | } | 389 | } |
382 | 390 | ||
383 | int print_branch_option(const char *refname, const unsigned char *sha1, | 391 | int print_branch_option(const char *refname, const unsigned char *sha1, |
@@ -415,7 +423,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
415 | hashcpy(fileid, sha1); | 423 | hashcpy(fileid, sha1); |
416 | } | 424 | } |
417 | if (!*header) { | 425 | if (!*header) { |
418 | html("<p><h1>download</h1>"); | 426 | html("<h1>download</h1>\n"); |
419 | *header = 1; | 427 | *header = 1; |
420 | } | 428 | } |
421 | url = cgit_pageurl(cgit_query_repo, "blob", | 429 | url = cgit_pageurl(cgit_query_repo, "blob", |
@@ -458,23 +466,26 @@ void cgit_print_pageheader(char *title, int show_search) | |||
458 | { | 466 | { |
459 | 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"; |
460 | int header = 0; | 468 | int header = 0; |
469 | char *url; | ||
461 | 470 | ||
462 | html("<div id='sidebar'>\n"); | 471 | html("<table id='layout' summary=''>\n"); |
463 | html("<a href='"); | 472 | html("<tr><td id='sidebar'>\n"); |
473 | html("<table class='sidebar' cellspacing='0' summary=''>\n"); | ||
474 | html("<tr><td class='sidebar'>\n<a href='"); | ||
464 | html_attr(cgit_rooturl()); | 475 | html_attr(cgit_rooturl()); |
465 | htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", | 476 | htmlf("'><img src='%s' alt='cgit'/></a>\n", |
466 | cgit_logo); | 477 | cgit_logo); |
467 | html("<div class='infobox'>"); | 478 | html("</td></tr>\n<tr><td class='sidebar'>\n"); |
468 | if (cgit_query_repo) { | 479 | if (cgit_query_repo) { |
469 | html("<h1>"); | 480 | html("<h1 class='first'>"); |
470 | html_txt(strrpart(cgit_repo->name, 20)); | 481 | html_txt(strrpart(cgit_repo->name, 20)); |
471 | html("</h1>\n"); | 482 | html("</h1>\n"); |
472 | html_txt(cgit_repo->desc); | 483 | html_txt(cgit_repo->desc); |
473 | if (cgit_repo->owner) { | 484 | if (cgit_repo->owner) { |
474 | html("<p>\n<h1>owner</h1>\n"); | 485 | html("<h1>owner</h1>\n"); |
475 | html_txt(cgit_repo->owner); | 486 | html_txt(cgit_repo->owner); |
476 | } | 487 | } |
477 | html("<p>\n<h1>navigate</h1>\n"); | 488 | html("<h1>navigate</h1>\n"); |
478 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 489 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, |
479 | NULL, NULL); | 490 | NULL, NULL); |
480 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, | 491 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, |
@@ -485,22 +496,40 @@ void cgit_print_pageheader(char *title, int show_search) | |||
485 | cgit_query_sha1); | 496 | cgit_query_sha1); |
486 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 497 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
487 | 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); | ||
488 | 501 | ||
489 | for_each_ref(print_archive_ref, &header); | 502 | for_each_ref(print_archive_ref, &header); |
490 | 503 | ||
491 | html("<p>\n<h1>branch</h1>\n"); | 504 | if (cgit_repo->clone_url || cgit_clone_prefix) { |
505 | html("<h1>clone</h1>\n"); | ||
506 | if (cgit_repo->clone_url) | ||
507 | url = cgit_repo->clone_url; | ||
508 | else | ||
509 | url = fmt("%s%s", cgit_clone_prefix, | ||
510 | cgit_repo->url); | ||
511 | html("<a class='menu' href='"); | ||
512 | html_attr(url); | ||
513 | html("' title='"); | ||
514 | html_attr(url); | ||
515 | html("'>\n"); | ||
516 | html_txt(strrpart(url, 20)); | ||
517 | html("</a>\n"); | ||
518 | } | ||
519 | |||
520 | html("<h1>branch</h1>\n"); | ||
492 | html("<form method='get' action=''>\n"); | 521 | html("<form method='get' action=''>\n"); |
493 | add_hidden_formfields(0, 1, cgit_query_page); | 522 | add_hidden_formfields(0, 1, cgit_query_page); |
494 | html("<table class='grid'><tr><td id='branch-dropdown-cell'>"); | 523 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); |
495 | html("<select name='h' onchange='this.form.submit();'>\n"); | 524 | html("<select name='h' onchange='this.form.submit();'>\n"); |
496 | for_each_branch_ref(print_branch_option, cgit_query_head); | 525 | for_each_branch_ref(print_branch_option, cgit_query_head); |
497 | html("</select>\n"); | 526 | html("</select>\n"); |
498 | html("</td><td>"); | 527 | // html("</td><td>"); |
499 | html("<noscript><input type='submit' id='switch-btn' value='..'></noscript>\n"); | 528 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); |
500 | html("</td></tr></table>"); | 529 | // html("</td></tr></table>"); |
501 | html("</form>\n"); | 530 | html("</form>\n"); |
502 | 531 | ||
503 | html("<p>\n<h1>search</h1>\n"); | 532 | html("<h1>search</h1>\n"); |
504 | html("<form method='get' action='"); | 533 | html("<form method='get' action='"); |
505 | if (cgit_virtual_root) | 534 | if (cgit_virtual_root) |
506 | html_attr(cgit_fileurl(cgit_query_repo, "log", | 535 | html_attr(cgit_fileurl(cgit_query_repo, "log", |
@@ -521,9 +550,9 @@ void cgit_print_pageheader(char *title, int show_search) | |||
521 | html(default_info); | 550 | html(default_info); |
522 | } | 551 | } |
523 | 552 | ||
524 | html("</div>\n"); | 553 | html("</td></tr></table></td>\n"); |
525 | 554 | ||
526 | html("</div>\n<table class='grid'><tr><td id='content'>\n"); | 555 | html("<td id='content'>\n"); |
527 | } | 556 | } |
528 | 557 | ||
529 | 558 | ||