From 5784efc9de06731cda916dd4575b43b93871dda3 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 9 Jun 2022 17:40:38 -0500 Subject: Apply default-tab patch --- ui-shared.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 72a1505..0b7937c 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -203,6 +203,9 @@ static void site_url(const char *page, const char *search, const char *sort, int { char *delim = "?"; + if (!strcmp(page ? page : "", ctx.cfg.root_default_tab)) + page = NULL; + if (always_root || page) html_attr(cgit_rooturl()); else { @@ -257,7 +260,7 @@ static void site_link(const char *page, const char *name, const char *title, void cgit_index_link(const char *name, const char *title, const char *class, const char *pattern, const char *sort, int ofs, int always_root) { - site_link(NULL, name, title, class, pattern, sort, ofs, always_root); + site_link("repolist", name, title, class, pattern, sort, ofs, always_root); } static char *repolink(const char *title, const char *class, const char *page, @@ -317,6 +320,14 @@ static void reporevlink(const char *page, const char *name, const char *title, { char *delim; + if (!strcmp(page + ? page + : "", + ctx.repo + ? ctx.repo->default_tab + : ctx.cfg.root_default_tab)) + page = NULL; + delim = repolink(title, class, page, head, path); if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { html(delim); @@ -328,10 +339,17 @@ static void reporevlink(const char *page, const char *name, const char *title, html(""); } +void cgit_repo_link(const char *name, const char *title, const char *class, + const char *head) +{ + reporevlink(NULL, name, title, class, head, NULL, NULL); +} + + void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { - reporevlink(NULL, name, title, class, head, NULL, NULL); + reporevlink("summary", name, title, class, head, NULL, NULL); } void cgit_tag_link(const char *name, const char *title, const char *class, @@ -1111,7 +1129,7 @@ void cgit_print_pageheader(void) html("\n"); } else if (ctx.env.authenticated) { char *currenturl = cgit_currenturl(); - site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); + site_link("repolist", "index", NULL, hc("repolist"), NULL, NULL, 0, 1); if (ctx.cfg.root_readme) site_link("about", "about", NULL, hc("about"), NULL, NULL, 0, 1); -- cgit 1.4.1-21-gabe81