summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2008-04-12 13:53:31 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-04-12 18:00:27 (UTC)
commitf135569b2be3fb1816f802f9a162b3743b735d1c (patch) (unidiff)
tree240917f3d213ea255c34db77af4e1cdfec950264 /ui-shared.c
parent4a842288260a0b0c4a3d4032d441f7fd2afee699 (diff)
downloadcgit-f135569b2be3fb1816f802f9a162b3743b735d1c.zip
cgit-f135569b2be3fb1816f802f9a162b3743b735d1c.tar.gz
cgit-f135569b2be3fb1816f802f9a162b3743b735d1c.tar.bz2
Replace sidebar/logo
This replaces the sidebar with a more 'common' header layout and also updates the logo. Not quite finished yet, though. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c125
1 files changed, 44 insertions, 81 deletions
diff --git a/ui-shared.c b/ui-shared.c
index aa65988..7287956 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "cmd.h"
10#include "html.h" 11#include "html.h"
11 12
12const char cgit_doctype[] = 13const char cgit_doctype[] =
@@ -465,97 +466,59 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
465 } 466 }
466} 467}
467 468
469char *hc(struct cgit_cmd *cmd, const char *page)
470{
471 return (strcmp(cmd->name, page) ? NULL : "active");
472}
473
468void cgit_print_pageheader(struct cgit_context *ctx) 474void cgit_print_pageheader(struct cgit_context *ctx)
469{ 475{
470 static const char *default_info = "This is cgit, a fast webinterface for git repositories"; 476 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
471 int header = 0;
472 char *url;
473 477
474 html("<table id='layout' summary=''>\n"); 478 html("<table id='header'>\n");
475 html("<tr><td id='sidebar'>\n"); 479 html("<tr>\n");
476 html("<table class='sidebar' cellspacing='0' summary=''>\n"); 480 html("<td class='logo' rowspan='2'><a href='");
477 html("<tr><td class='sidebar'>\n<a href='");
478 html_attr(cgit_rooturl()); 481 html_attr(cgit_rooturl());
479 htmlf("'><img src='%s' alt='cgit'/></a>\n", 482 html("'><img src='");
480 ctx->cfg.logo); 483 html_attr(ctx->cfg.logo);
481 html("</td></tr>\n<tr><td class='sidebar'>\n"); 484 html("'/></a></td>\n");
482 if (ctx->repo) { 485 html("<td class='main'>");
483 html("<h1 class='first'>"); 486 if (ctx->repo)
484 html_txt(strrpart(ctx->repo->name, 20)); 487 html_txt(ctx->repo->name);
485 html("</h1>\n"); 488 else
489 html_txt(ctx->cfg.root_title);
490 html("</td></tr>\n");
491 html("<tr><td class='sub'>");
492 if (ctx->repo)
486 html_txt(ctx->repo->desc); 493 html_txt(ctx->repo->desc);
487 if (ctx->repo->owner) { 494 else
488 html("<h1>owner</h1>\n"); 495 html_txt(ctx->cfg.index_info);
489 html_txt(ctx->repo->owner); 496 html("</td></tr>\n");
490 } 497 html("</table>\n");
491 html("<h1>navigate</h1>\n"); 498
492 reporevlink(NULL, "summary", NULL, "menu", ctx->qry.head, 499 html("<table class='tabs'><tr><td>\n");
493 NULL, NULL); 500 if (ctx->repo) {
494 cgit_log_link("log", NULL, "menu", ctx->qry.head, NULL, NULL, 501 reporevlink(NULL, "summary", NULL, hc(cmd, "summary"),
495 0, NULL, NULL); 502 ctx->qry.head, NULL, NULL);
496 cgit_tree_link("tree", NULL, "menu", ctx->qry.head, 503 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
497 ctx->qry.sha1, NULL); 504 ctx->qry.sha1, NULL);
498 cgit_commit_link("commit", NULL, "menu", ctx->qry.head, 505 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
499 ctx->qry.sha1); 506 NULL, NULL, 0, NULL, NULL);
500 cgit_diff_link("diff", NULL, "menu", ctx->qry.head, 507 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
508 ctx->qry.sha1, NULL);
509 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
510 ctx->qry.head, ctx->qry.sha1);
511 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
501 ctx->qry.sha1, ctx->qry.sha2, NULL); 512 ctx->qry.sha1, ctx->qry.sha2, NULL);
502 cgit_patch_link("patch", NULL, "menu", ctx->qry.head, 513 cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head,
503 ctx->qry.sha1); 514 ctx->qry.sha1);
504
505 for_each_ref(print_archive_ref, &header);
506
507 if (ctx->repo->clone_url || ctx->cfg.clone_prefix) {
508 html("<h1>clone</h1>\n");
509 if (ctx->repo->clone_url)
510 url = ctx->repo->clone_url;
511 else
512 url = fmt("%s%s", ctx->cfg.clone_prefix,
513 ctx->repo->url);
514 html("<a class='menu' href='");
515 html_attr(url);
516 html("' title='");
517 html_attr(url);
518 html("'>\n");
519 html_txt(strrpart(url, 20));
520 html("</a>\n");
521 }
522
523 html("<h1>branch</h1>\n");
524 html("<form method='get' action=''>\n");
525 add_hidden_formfields(0, 1, ctx->qry.page);
526 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
527 html("<select name='h' onchange='this.form.submit();'>\n");
528 for_each_branch_ref(print_branch_option, ctx->qry.head);
529 html("</select>\n");
530 // html("</td><td>");
531 html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n");
532 // html("</td></tr></table>");
533 html("</form>\n");
534
535 html("<h1>search</h1>\n");
536 html("<form method='get' action='");
537 if (ctx->cfg.virtual_root)
538 html_attr(cgit_fileurl(ctx->qry.repo, "log",
539 ctx->qry.path, NULL));
540 html("'>\n");
541 add_hidden_formfields(1, 0, "log");
542 html("<select name='qt'>\n");
543 html_option("grep", "log msg", ctx->qry.grep);
544 html_option("author", "author", ctx->qry.grep);
545 html_option("committer", "committer", ctx->qry.grep);
546 html("</select>\n");
547 html("<input class='txt' type='text' name='q' value='");
548 html_attr(ctx->qry.search);
549 html("'/>\n");
550 html("</form>\n");
551 } else { 515 } else {
552 if (!ctx->cfg.index_info || html_include(ctx->cfg.index_info)) 516 html("<a class='active' href='");
553 html(default_info); 517 html_attr(cgit_rooturl());
518 html("'>index</a>\n");
554 } 519 }
555 520 html("</td></tr></table>\n");
556 html("</td></tr></table></td>\n"); 521 html("<div class='content'>");
557
558 html("<td id='content'>\n");
559} 522}
560 523
561void cgit_print_filemode(unsigned short mode) 524void cgit_print_filemode(unsigned short mode)