aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 76cd00d..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);
@@ -363,13 +369,22 @@ void cgit_patch_link(char *name, char *title, char *class, char *head,
363 reporevlink("patch", name, title, class, head, rev, NULL); 369 reporevlink("patch", name, title, class, head, rev, NULL);
364} 370}
365 371
372void cgit_stats_link(char *name, char *title, char *class, char *head,
373 char *path)
374{
375 reporevlink("stats", name, title, class, head, NULL, path);
376}
377
366void cgit_object_link(struct object *obj) 378void cgit_object_link(struct object *obj)
367{ 379{
368 char *page, *rev, *name; 380 char *page, *shortrev, *fullrev, *name;
369 381
382 fullrev = sha1_to_hex(obj->sha1);
383 shortrev = xstrdup(fullrev);
384 shortrev[10] = '\0';
370 if (obj->type == OBJ_COMMIT) { 385 if (obj->type == OBJ_COMMIT) {
371 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 386 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
372 ctx.qry.head, sha1_to_hex(obj->sha1)); 387 ctx.qry.head, fullrev);
373 return; 388 return;
374 } else if (obj->type == OBJ_TREE) 389 } else if (obj->type == OBJ_TREE)
375 page = "tree"; 390 page = "tree";
@@ -377,9 +392,8 @@ void cgit_object_link(struct object *obj)
377 page = "tag"; 392 page = "tag";
378 else 393 else
379 page = "blob"; 394 page = "blob";
380 rev = sha1_to_hex(obj->sha1); 395 name = fmt("%s %s...", typename(obj->type), shortrev);
381 name = fmt("%s %s", typename(obj->type), rev); 396 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
382 reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL);
383} 397}
384 398
385void cgit_print_date(time_t secs, char *format, int local_time) 399void cgit_print_date(time_t secs, char *format, int local_time)
@@ -549,7 +563,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
549 return 0; 563 return 0;
550} 564}
551 565
552void add_hidden_formfields(int incl_head, int incl_search, char *page) 566void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
553{ 567{
554 char *url; 568 char *url;
555 569
@@ -568,6 +582,8 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
568 html_hidden("id", ctx.qry.sha1); 582 html_hidden("id", ctx.qry.sha1);
569 if (ctx.qry.sha2) 583 if (ctx.qry.sha2)
570 html_hidden("id2", ctx.qry.sha2); 584 html_hidden("id2", ctx.qry.sha2);
585 if (ctx.qry.showmsg)
586 html_hidden("showmsg", "1");
571 587
572 if (incl_search) { 588 if (incl_search) {
573 if (ctx.qry.grep) 589 if (ctx.qry.grep)
@@ -609,7 +625,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
609 cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); 625 cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL);
610 html("</td><td class='form'>"); 626 html("</td><td class='form'>");
611 html("<form method='get' action=''>\n"); 627 html("<form method='get' action=''>\n");
612 add_hidden_formfields(0, 1, ctx->qry.page); 628 cgit_add_hidden_formfields(0, 1, ctx->qry.page);
613 html("<select name='h' onchange='this.form.submit();'>\n"); 629 html("<select name='h' onchange='this.form.submit();'>\n");
614 for_each_branch_ref(print_branch_option, ctx->qry.head); 630 for_each_branch_ref(print_branch_option, ctx->qry.head);
615 html("</select> "); 631 html("</select> ");
@@ -639,13 +655,16 @@ void cgit_print_pageheader(struct cgit_context *ctx)
639 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 655 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
640 ctx->qry.sha1, NULL); 656 ctx->qry.sha1, NULL);
641 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, 657 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
642 NULL, NULL, 0, NULL, NULL); 658 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
643 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, 659 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
644 ctx->qry.sha1, NULL); 660 ctx->qry.sha1, NULL);
645 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 661 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
646 ctx->qry.head, ctx->qry.sha1); 662 ctx->qry.head, ctx->qry.sha1);
647 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, 663 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
648 ctx->qry.sha1, ctx->qry.sha2, NULL); 664 ctx->qry.sha1, ctx->qry.sha2, NULL);
665 if (ctx->repo->max_stats)
666 cgit_stats_link("stats", NULL, hc(cmd, "stats"),
667 ctx->qry.head, NULL);
649 if (ctx->repo->readme) 668 if (ctx->repo->readme)
650 reporevlink("about", "about", NULL, 669 reporevlink("about", "about", NULL,
651 hc(cmd, "about"), ctx->qry.head, NULL, 670 hc(cmd, "about"), ctx->qry.head, NULL,
@@ -656,7 +675,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
656 html_url_path(cgit_fileurl(ctx->qry.repo, "log", 675 html_url_path(cgit_fileurl(ctx->qry.repo, "log",
657 ctx->qry.path, NULL)); 676 ctx->qry.path, NULL));
658 html("'>\n"); 677 html("'>\n");
659 add_hidden_formfields(1, 0, "log"); 678 cgit_add_hidden_formfields(1, 0, "log");
660 html("<select name='qt'>\n"); 679 html("<select name='qt'>\n");
661 html_option("grep", "log msg", ctx->qry.grep); 680 html_option("grep", "log msg", ctx->qry.grep);
662 html_option("author", "author", ctx->qry.grep); 681 html_option("author", "author", ctx->qry.grep);
@@ -712,8 +731,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
712 continue; 731 continue;
713 filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, 732 filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
714 f->suffix); 733 f->suffix);
715 cgit_snapshot_link(filename, NULL, NULL, (char *)head, 734 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
716 (char *)hex, filename);
717 html("<br/>"); 735 html("<br/>");
718 } 736 }
719} 737}