about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorLukas Fleischer2015-03-05 20:41:45 +0100
committerJason A. Donenfeld2015-03-13 14:52:52 +0100
commitdb021a1989a52911557ce6b998c11fbe4a4bea9d (patch)
treeb92c3f017e657cf0ecb38f0259b2021a066a3dd8 /ui-shared.c
parentfilters: Add sample gentoo script (diff)
downloadcgit-db021a1989a52911557ce6b998c11fbe4a4bea9d.tar.gz
cgit-db021a1989a52911557ce6b998c11fbe4a4bea9d.zip
Remove no-op link from submodule entries
Instead of linking to the current page ("href='#'"), do not add a link
to a submodule entry at all if the module-link setting is not used.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/ui-shared.c b/ui-shared.c index 23a893b..1dd8722 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -559,25 +559,32 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
559 item = lookup_path(list, path); 559 item = lookup_path(list, path);
560 } 560 }
561 } 561 }
562 html("<a "); 562 if (item || ctx.repo->module_link) {
563 if (class) 563 html("<a ");
564 htmlf("class='%s' ", class); 564 if (class)
565 html("href='"); 565 htmlf("class='%s' ", class);
566 if (item) { 566 html("href='");
567 html_attrf(item->util, rev); 567 if (item) {
568 } else if (ctx.repo->module_link) { 568 html_attrf(item->util, rev);
569 dir = strrchr(path, '/'); 569 } else {
570 if (dir) 570 dir = strrchr(path, '/');
571 dir++; 571 if (dir)
572 else 572 dir++;
573 dir = path; 573 else
574 html_attrf(ctx.repo->module_link, dir, rev); 574 dir = path;
575 html_attrf(ctx.repo->module_link, dir, rev);
576 }
577 html("'>");
578 html_txt(path);
579 html("</a>");
575 } else { 580 } else {
576 html("#"); 581 html("<span");
582 if (class)
583 htmlf(" class='%s'", class);
584 html(">");
585 html_txt(path);
586 html("</span>");
577 } 587 }
578 html("'>");
579 html_txt(path);
580 html("</a>");
581 html_txtf(" @ %.7s", rev); 588 html_txtf(" @ %.7s", rev);
582 if (item && tail) 589 if (item && tail)
583 path[len - 1] = tail; 590 path[len - 1] = tail;