aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 1bb30c2..4f28512 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -281,7 +281,8 @@ void cgit_plain_link(char *name, char *title, char *class, char *head,
281} 281}
282 282
283void cgit_log_link(char *name, char *title, char *class, char *head, 283void cgit_log_link(char *name, char *title, char *class, char *head,
284 char *rev, char *path, int ofs, char *grep, char *pattern) 284 char *rev, char *path, int ofs, char *grep, char *pattern,
285 int showmsg)
285{ 286{
286 char *delim; 287 char *delim;
287 288
@@ -305,6 +306,11 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
305 html(delim); 306 html(delim);
306 html("ofs="); 307 html("ofs=");
307 htmlf("%d", ofs); 308 htmlf("%d", ofs);
309 delim = "&";
310 }
311 if (showmsg) {
312 html(delim);
313 html("showmsg=1");
308 } 314 }
309 html("'>"); 315 html("'>");
310 html_txt(name); 316 html_txt(name);
@@ -371,11 +377,14 @@ void cgit_stats_link(char *name, char *title, char *class, char *head,
371 377
372void cgit_object_link(struct object *obj) 378void cgit_object_link(struct object *obj)
373{ 379{
374 char *page, *rev, *name; 380 char *page, *shortrev, *fullrev, *name;
375 381
382 fullrev = sha1_to_hex(obj->sha1);
383 shortrev = xstrdup(fullrev);
384 shortrev[10] = '\0';
376 if (obj->type == OBJ_COMMIT) { 385 if (obj->type == OBJ_COMMIT) {
377 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 386 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
378 ctx.qry.head, sha1_to_hex(obj->sha1)); 387 ctx.qry.head, fullrev);
379 return; 388 return;
380 } else if (obj->type == OBJ_TREE) 389 } else if (obj->type == OBJ_TREE)
381 page = "tree"; 390 page = "tree";
@@ -383,9 +392,8 @@ void cgit_object_link(struct object *obj)
383 page = "tag"; 392 page = "tag";
384 else 393 else
385 page = "blob"; 394 page = "blob";
386 rev = sha1_to_hex(obj->sha1); 395 name = fmt("%s %s...", typename(obj->type), shortrev);
387 name = fmt("%s %s", typename(obj->type), rev); 396 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
388 reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL);
389} 397}
390 398
391void cgit_print_date(time_t secs, char *format, int local_time) 399void cgit_print_date(time_t secs, char *format, int local_time)
@@ -574,6 +582,8 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
574 html_hidden("id", ctx.qry.sha1); 582 html_hidden("id", ctx.qry.sha1);
575 if (ctx.qry.sha2) 583 if (ctx.qry.sha2)
576 html_hidden("id2", ctx.qry.sha2); 584 html_hidden("id2", ctx.qry.sha2);
585 if (ctx.qry.showmsg)
586 html_hidden("showmsg", "1");
577 587
578 if (incl_search) { 588 if (incl_search) {
579 if (ctx.qry.grep) 589 if (ctx.qry.grep)
@@ -583,15 +593,20 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
583 } 593 }
584} 594}
585 595
596const char *fallback_cmd = "repolist";
597
586char *hc(struct cgit_cmd *cmd, const char *page) 598char *hc(struct cgit_cmd *cmd, const char *page)
587{ 599{
588 return (strcmp(cmd->name, page) ? NULL : "active"); 600 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active");
589} 601}
590 602
591void cgit_print_pageheader(struct cgit_context *ctx) 603void cgit_print_pageheader(struct cgit_context *ctx)
592{ 604{
593 struct cgit_cmd *cmd = cgit_get_cmd(ctx); 605 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
594 606
607 if (!cmd && ctx->repo)
608 fallback_cmd = "summary";
609
595 html("<table id='header'>\n"); 610 html("<table id='header'>\n");
596 html("<tr>\n"); 611 html("<tr>\n");
597 html("<td class='logo' rowspan='2'><a href='"); 612 html("<td class='logo' rowspan='2'><a href='");
@@ -640,7 +655,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
640 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 655 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
641 ctx->qry.sha1, NULL); 656 ctx->qry.sha1, NULL);
642 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, 657 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
643 NULL, NULL, 0, NULL, NULL); 658 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
644 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, 659 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
645 ctx->qry.sha1, NULL); 660 ctx->qry.sha1, NULL);
646 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 661 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
@@ -716,8 +731,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
716 continue; 731 continue;
717 filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, 732 filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
718 f->suffix); 733 f->suffix);
719 cgit_snapshot_link(filename, NULL, NULL, (char *)head, 734 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
720 (char *)hex, filename);
721 html("<br/>"); 735 html("<br/>");
722 } 736 }
723} 737}