summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMehmet Samet Duman <froster12@naver.com>2026-02-13 15:14:11 +0300
committerMehmet Samet Duman <froster12@naver.com>2026-02-13 15:14:11 +0300
commitbcd195b23999d238298140a2e76d5e3062d17b38 (patch)
tree8b9939a96e0aa244917162d22384a87db0a6b575
parent03d3fbba855583d8928f2ebd98487db14e69ae5d (diff)
downloadProject-Tick-bcd195b23999d238298140a2e76d5e3062d17b38.tar.gz
Project-Tick-bcd195b23999d238298140a2e76d5e3062d17b38.zip
feat: add support for root homepage configuration and display in UI
Signed-off-by: Mehmet Samet Duman <froster12@naver.com>
-rw-r--r--cgit.c4
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt10
-rwxr-xr-xtests/setup.sh2
-rw-r--r--tests/t0114-root-homepage.sh18
-rw-r--r--ui-shared.c8
6 files changed, 44 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index c3ddfaba1c..4479adcb78 100644
--- a/cgit.c
+++ b/cgit.c
@@ -163,6 +163,10 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.root_coc = xstrdup(value);
else if (!strcmp(name, "root-cla"))
ctx.cfg.root_cla = xstrdup(value);
+ else if (!strcmp(name, "root-homepage"))
+ ctx.cfg.root_homepage = xstrdup(value);
+ else if (!strcmp(name, "root-homepage-title"))
+ ctx.cfg.root_homepage_title = xstrdup(value);
else if (!strcmp(name, "css"))
string_list_append(&ctx.cfg.css, xstrdup(value));
else if (!strcmp(name, "js"))
diff --git a/cgit.h b/cgit.h
index 194e45ec9a..8d20e24880 100644
--- a/cgit.h
+++ b/cgit.h
@@ -221,6 +221,8 @@ struct cgit_config {
char *root_readme;
char *root_coc;
char *root_cla;
+ char *root_homepage;
+ char *root_homepage_title;
char *script_name;
char *section;
char *repository_sort;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index c541f9f319..53bba3e3ff 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -390,6 +390,14 @@ root-cla::
verbatim below the "Contributor License Agreement" link on the
repository index page. Default value: none.
+root-homepage::
+ Specifies an external URL to be shown as a link on the repository
+ index page tabs (next to "index", "about", etc). Default value: none.
+
+root-homepage-title::
+ Text to use for the root-homepage link label. Default value:
+ "homepage".
+
root-title::
Text printed as heading on the repository index page. Default value:
"Git Repository Browser".
@@ -922,6 +930,8 @@ root-desc=tracking the foobar development
root-readme=/var/www/htdocs/about.html
root-coc=/var/www/htdocs/coc.html
root-cla=/var/www/htdocs/cla.html
+root-homepage=https://github.com/example
+root-homepage-title=GitHub
# Allow download of tar.gz, tar.bz2 and zip-files
diff --git a/tests/setup.sh b/tests/setup.sh
index 7b8777379a..54ac2bf5cc 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -120,6 +120,8 @@ clone-url=git://example.org/\$CGIT_REPO_URL.git
enable-filter-overrides=1
root-coc=$PWD/site-coc.txt
root-cla=$PWD/site-cla.txt
+root-homepage=https://github.com/example
+root-homepage-title=GitHub
repo.url=foo
repo.path=$PWD/repos/foo/.git
diff --git a/tests/t0114-root-homepage.sh b/tests/t0114-root-homepage.sh
new file mode 100644
index 0000000000..932d443b4f
--- /dev/null
+++ b/tests/t0114-root-homepage.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+test_description='Check root homepage link'
+. ./setup.sh
+
+test_expect_success 'index has configured root homepage link' '
+ cgit_url "" >tmp &&
+ grep "https://github.com/example" tmp &&
+ grep ">GitHub<" tmp
+'
+
+test_expect_success 'root pages keep root homepage link' '
+ cgit_query "p=coc" >tmp &&
+ grep "https://github.com/example" tmp &&
+ grep ">GitHub<" tmp
+'
+
+test_done
diff --git a/ui-shared.c b/ui-shared.c
index 3aa1bbc01e..2d857c56d8 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1145,6 +1145,14 @@ void cgit_print_pageheader(void)
if (ctx.cfg.root_cla)
site_link("cla", "Contributor License Agreement", NULL,
hc("cla"), NULL, NULL, 0, 1);
+ if (ctx.cfg.root_homepage) {
+ html("<a href='");
+ html_attr(ctx.cfg.root_homepage);
+ html("'>");
+ html_txt(ctx.cfg.root_homepage_title ?
+ ctx.cfg.root_homepage_title : "homepage");
+ html("</a>");
+ }
html("</td><td class='form'>");
html("<form method='get' action='");
html_attr(currenturl);