summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorJohan Herland <johan@herland.net>2010-06-09 23:09:35 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-19 08:40:24 (UTC)
commit685872b770be2af643d00365d5358e46687f7385 (patch) (unidiff)
tree279a8399c3e9b189a7171df6ca009a58bf1bb8c7 /ui-shared.c
parent34c2331d2c33ea28743a2ee3e62f7337ae9887f6 (diff)
downloadcgit-685872b770be2af643d00365d5358e46687f7385.zip
cgit-685872b770be2af643d00365d5358e46687f7385.tar.gz
cgit-685872b770be2af643d00365d5358e46687f7385.tar.bz2
ui-commit: Preserve path limit in links to commit page
This includes adding a path argument to cgit_commit_link() and updating all its callers. The callers from within the commit page (i.e. the "commit", "unidiff"/"side-by-side diff" and "parent" links) all preserve the path limit of the current commit page. All other callers pass NULL (i.e. no path limit). Signed-off-by: Johan Herland <johan@herland.net> 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.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c
index d5c4c10..372b9e7 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -306,44 +306,45 @@ void cgit_log_link(const char *name, const char *title, const char *class,
306 if (ofs > 0) { 306 if (ofs > 0) {
307 html(delim); 307 html(delim);
308 html("ofs="); 308 html("ofs=");
309 htmlf("%d", ofs); 309 htmlf("%d", ofs);
310 delim = "&"; 310 delim = "&";
311 } 311 }
312 if (showmsg) { 312 if (showmsg) {
313 html(delim); 313 html(delim);
314 html("showmsg=1"); 314 html("showmsg=1");
315 } 315 }
316 html("'>"); 316 html("'>");
317 html_txt(name); 317 html_txt(name);
318 html("</a>"); 318 html("</a>");
319} 319}
320 320
321void cgit_commit_link(char *name, const char *title, const char *class, 321void cgit_commit_link(char *name, const char *title, const char *class,
322 const char *head, const char *rev, int toggle_ssdiff) 322 const char *head, const char *rev, const char *path,
323 int toggle_ssdiff)
323{ 324{
324 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { 325 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
325 name[ctx.cfg.max_msg_len] = '\0'; 326 name[ctx.cfg.max_msg_len] = '\0';
326 name[ctx.cfg.max_msg_len - 1] = '.'; 327 name[ctx.cfg.max_msg_len - 1] = '.';
327 name[ctx.cfg.max_msg_len - 2] = '.'; 328 name[ctx.cfg.max_msg_len - 2] = '.';
328 name[ctx.cfg.max_msg_len - 3] = '.'; 329 name[ctx.cfg.max_msg_len - 3] = '.';
329 } 330 }
330 331
331 char *delim; 332 char *delim;
332 333
333 delim = repolink(title, class, "commit", head, NULL); 334 delim = repolink(title, class, "commit", head, path);
334 if (rev && strcmp(rev, ctx.qry.head)) { 335 if (rev && strcmp(rev, ctx.qry.head)) {
335 html(delim); 336 html(delim);
336 html("id="); 337 html("id=");
337 html_url_arg(rev); 338 html_url_arg(rev);
338 delim = "&amp;"; 339 delim = "&amp;";
339 } 340 }
340 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 341 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
341 html(delim); 342 html(delim);
342 html("ss=1"); 343 html("ss=1");
343 } 344 }
344 html("'>"); 345 html("'>");
345 html_txt(name); 346 html_txt(name);
346 html("</a>"); 347 html("</a>");
347} 348}
348 349
349void cgit_refs_link(const char *name, const char *title, const char *class, 350void cgit_refs_link(const char *name, const char *title, const char *class,
@@ -453,33 +454,33 @@ void cgit_self_link(char *name, const char *title, const char *class,
453 html("><!-- cgit_self_link() doesn't know how to make link for page '"); 454 html("><!-- cgit_self_link() doesn't know how to make link for page '");
454 html_txt(ctx->qry.page); 455 html_txt(ctx->qry.page);
455 html("' -->"); 456 html("' -->");
456 html_txt(name); 457 html_txt(name);
457 html("</a>"); 458 html("</a>");
458} 459}
459 460
460void cgit_object_link(struct object *obj) 461void cgit_object_link(struct object *obj)
461{ 462{
462 char *page, *shortrev, *fullrev, *name; 463 char *page, *shortrev, *fullrev, *name;
463 464
464 fullrev = sha1_to_hex(obj->sha1); 465 fullrev = sha1_to_hex(obj->sha1);
465 shortrev = xstrdup(fullrev); 466 shortrev = xstrdup(fullrev);
466 shortrev[10] = '\0'; 467 shortrev[10] = '\0';
467 if (obj->type == OBJ_COMMIT) { 468 if (obj->type == OBJ_COMMIT) {
468 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, 469 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
469 ctx.qry.head, fullrev, 0); 470 ctx.qry.head, fullrev, NULL, 0);
470 return; 471 return;
471 } else if (obj->type == OBJ_TREE) 472 } else if (obj->type == OBJ_TREE)
472 page = "tree"; 473 page = "tree";
473 else if (obj->type == OBJ_TAG) 474 else if (obj->type == OBJ_TAG)
474 page = "tag"; 475 page = "tag";
475 else 476 else
476 page = "blob"; 477 page = "blob";
477 name = fmt("%s %s...", typename(obj->type), shortrev); 478 name = fmt("%s %s...", typename(obj->type), shortrev);
478 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); 479 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
479} 480}
480 481
481void cgit_print_date(time_t secs, const char *format, int local_time) 482void cgit_print_date(time_t secs, const char *format, int local_time)
482{ 483{
483 char buf[64]; 484 char buf[64];
484 struct tm *time; 485 struct tm *time;
485 486
@@ -780,33 +781,33 @@ void cgit_print_pageheader(struct cgit_context *ctx)
780{ 781{
781 html("<div id='cgit'>"); 782 html("<div id='cgit'>");
782 if (!ctx->cfg.noheader) 783 if (!ctx->cfg.noheader)
783 print_header(ctx); 784 print_header(ctx);
784 785
785 html("<table class='tabs'><tr><td>\n"); 786 html("<table class='tabs'><tr><td>\n");
786 if (ctx->repo) { 787 if (ctx->repo) {
787 cgit_summary_link("summary", NULL, hc(ctx, "summary"), 788 cgit_summary_link("summary", NULL, hc(ctx, "summary"),
788 ctx->qry.head); 789 ctx->qry.head);
789 cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head, 790 cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head,
790 ctx->qry.sha1, NULL); 791 ctx->qry.sha1, NULL);
791 cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, 792 cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
792 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg); 793 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
793 cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, 794 cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
794 ctx->qry.sha1, NULL); 795 ctx->qry.sha1, NULL);
795 cgit_commit_link("commit", NULL, hc(ctx, "commit"), 796 cgit_commit_link("commit", NULL, hc(ctx, "commit"),
796 ctx->qry.head, ctx->qry.sha1, 0); 797 ctx->qry.head, ctx->qry.sha1, NULL, 0);
797 cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, 798 cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
798 ctx->qry.sha1, ctx->qry.sha2, NULL, 0); 799 ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
799 if (ctx->repo->max_stats) 800 if (ctx->repo->max_stats)
800 cgit_stats_link("stats", NULL, hc(ctx, "stats"), 801 cgit_stats_link("stats", NULL, hc(ctx, "stats"),
801 ctx->qry.head, NULL); 802 ctx->qry.head, NULL);
802 if (ctx->repo->readme) 803 if (ctx->repo->readme)
803 reporevlink("about", "about", NULL, 804 reporevlink("about", "about", NULL,
804 hc(ctx, "about"), ctx->qry.head, NULL, 805 hc(ctx, "about"), ctx->qry.head, NULL,
805 NULL); 806 NULL);
806 html("</td><td class='form'>"); 807 html("</td><td class='form'>");
807 html("<form class='right' method='get' action='"); 808 html("<form class='right' method='get' action='");
808 if (ctx->cfg.virtual_root) 809 if (ctx->cfg.virtual_root)
809 html_url_path(cgit_fileurl(ctx->qry.repo, "log", 810 html_url_path(cgit_fileurl(ctx->qry.repo, "log",
810 ctx->qry.vpath, NULL)); 811 ctx->qry.vpath, NULL));
811 html("'>\n"); 812 html("'>\n");
812 cgit_add_hidden_formfields(1, 0, "log"); 813 cgit_add_hidden_formfields(1, 0, "log");