summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-30 12:16:17 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-30 12:19:57 +0100
commitb9ea7e737d37df6eb01d0bd2790044cb5cef0c3d (patch)
tree9d4413a640696bbeb9c4cb973ce4553dee54c42f
parent24b90aff29724fdc0481bca3103e05899a7a486b (diff)
downloadcgit_EL6-b9ea7e737d37df6eb01d0bd2790044cb5cef0c3d.tar.gz
Add default-pages.patch to make default pages configurable
Discussion on https://lists.zx2c4.com/pipermail/cgit/2024-January/004869.html
-rw-r--r--cgit.spec12
-rw-r--r--default-pages.patch246
2 files changed, 257 insertions, 1 deletions
diff --git a/cgit.spec b/cgit.spec
index c93d2d5..f3f5cb5 100644
--- a/cgit.spec
+++ b/cgit.spec
@@ -31,7 +31,7 @@
Name: cgit
Version: 1.2.3
-Release: 8%{?dist}
+Release: 9%{?dist}
Summary: A fast web interface for git
License: GPLv2
@@ -80,6 +80,13 @@ Patch1: https://git.zx2c4.com/cgit/patch/?id=bd6f5683f#/0001-t0107-suppo
# done >~/src/dist/fedora/cgit/cgit-1.2.3-update-to-git-2.34.1.patch
Patch2: cgit-1.2.3-update-to-git-2.34.1.patch
+# Make default pages configurable
+#
+# PATCH-FEATURE-UPSTREAM default-pages.patch mcepl@suse.com
+# Discussion on https://lists.zx2c4.com/pipermail/cgit/2024-January/004869.html
+# Make default pages configurable
+Patch3: default-pages.patch
+
# Note the bundled git, per the packaging guidelines
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#bundling
Provides: bundled(git) = %gitver
@@ -227,6 +234,9 @@ install -Dp -m0644 httpd.conf %{buildroot}%{httpdconfd}/%{name}.conf
%changelog
+* Tue Jan 30 2024 Matěj Cepl <mcepl@cepl.eu> - 1.2.3-9
+- Add default-pages.patch to make default pages configurable
+
* Sun Jan 02 2022 Todd Zullinger <tmz@pobox.com> - 1.2.3-8
- update to git-2.34.1
- use %%__make to run tests in %%check
diff --git a/default-pages.patch b/default-pages.patch
new file mode 100644
index 0000000..d36af74
--- /dev/null
+++ b/default-pages.patch
@@ -0,0 +1,246 @@
+From d9f3d6fb1817fd22512ac62e8d7c36c67dc5584a Mon Sep 17 00:00:00 2001
+From: Naïm Favier <fnaim42@gmail.com>
+Date: Mon, 9 Dec 2019 19:38:14 +0100
+Subject: Make default pages configurable
+
+Signed-off-by: Christian Hesse <mail@eworm.de>
+---
+ cgit.c | 10 ++++++++++
+ cgit.h | 3 +++
+ cgitrc.5.txt | 14 ++++++++++++++
+ cmd.c | 18 +++++++++---------
+ ui-repolist.c | 2 +-
+ ui-shared.c | 12 +++++++++---
+ ui-shared.h | 2 ++
+ 7 files changed, 48 insertions(+), 13 deletions(-)
+
+diff --git a/cgit.c b/cgit.c
+index 57d7097..e7c0172 100644
+--- a/cgit.c
++++ b/cgit.c
+@@ -56,6 +56,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
+ repo->homepage = xstrdup(value);
+ else if (!strcmp(name, "defbranch"))
+ repo->defbranch = xstrdup(value);
++ else if (!strcmp(name, "default-page"))
++ repo->default_page = xstrdup(value);
+ else if (!strcmp(name, "extra-head-content"))
+ repo->extra_head_content = xstrdup(value);
+ else if (!strcmp(name, "snapshots"))
+@@ -141,6 +143,8 @@ static void config_cb(const char *name, const char *value)
+ ctx.cfg.root_desc = xstrdup(value);
+ else if (!strcmp(name, "root-readme"))
+ ctx.cfg.root_readme = xstrdup(value);
++ else if (!strcmp(name, "root-default-page"))
++ ctx.cfg.root_default_page = xstrdup(value);
+ else if (!strcmp(name, "css"))
+ string_list_append(&ctx.cfg.css, xstrdup(value));
+ else if (!strcmp(name, "js"))
+@@ -157,6 +161,8 @@ static void config_cb(const char *name, const char *value)
+ ctx.cfg.logo = xstrdup(value);
+ else if (!strcmp(name, "logo-link"))
+ ctx.cfg.logo_link = xstrdup(value);
++ else if (!strcmp(name, "default-page"))
++ ctx.cfg.default_page = xstrdup(value);
+ else if (!strcmp(name, "module-link"))
+ ctx.cfg.module_link = xstrdup(value);
+ else if (!strcmp(name, "strict-export"))
+@@ -380,6 +386,7 @@ static void prepare_context(void)
+ ctx.cfg.case_sensitive_sort = 1;
+ ctx.cfg.branch_sort = 0;
+ ctx.cfg.commit_sort = 0;
++ ctx.cfg.default_page= "summary";
+ ctx.cfg.logo = "/cgit.png";
+ ctx.cfg.favicon = "/favicon.ico";
+ ctx.cfg.local_time = 0;
+@@ -400,6 +407,7 @@ static void prepare_context(void)
+ ctx.cfg.robots = "index, nofollow";
+ ctx.cfg.root_title = "Git repository browser";
+ ctx.cfg.root_desc = "a fast webinterface for the git dscm";
++ ctx.cfg.root_default_page = "repolist";
+ ctx.cfg.scan_hidden_path = 0;
+ ctx.cfg.script_name = CGIT_SCRIPT_NAME;
+ ctx.cfg.section = "";
+@@ -811,6 +819,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
+ }
+ if (repo->defbranch)
+ fprintf(f, "repo.defbranch=%s\n", repo->defbranch);
++ if (repo->default_page)
++ fprintf(f, "repo.default-page=%s\n", repo->default_page);
+ if (repo->extra_head_content)
+ fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
+ if (repo->module_link)
+diff --git a/cgit.h b/cgit.h
+index ddd2ccb..9f9daac 100644
+--- a/cgit.h
++++ b/cgit.h
+@@ -87,6 +87,7 @@ struct cgit_repo {
+ char *owner;
+ char *homepage;
+ char *defbranch;
++ char *default_page;
+ char *module_link;
+ struct string_list readme;
+ char *section;
+@@ -196,6 +197,7 @@ struct cgit_config {
+ char *cache_root;
+ char *clone_prefix;
+ char *clone_url;
++ char *default_page;
+ char *favicon;
+ char *footer;
+ char *head_include;
+@@ -211,6 +213,7 @@ struct cgit_config {
+ char *root_title;
+ char *root_desc;
+ char *root_readme;
++ char *root_default_page;
+ char *script_name;
+ char *section;
+ char *repository_sort;
+diff --git a/cgitrc.5.txt b/cgitrc.5.txt
+index 6f3e952..ac86864 100644
+--- a/cgitrc.5.txt
++++ b/cgitrc.5.txt
+@@ -129,6 +129,12 @@ css::
+ Default value: "/cgit.css". May be given multiple times, each
+ css URL path is added in the head section of the document in turn.
+
++default-page::
++ Specifies the default page for repositories. This setting is only used
++ if `repo.default-page` is unspecified. Possible values: "about",
++ "summary", "refs", "log", "tree", "commit", "diff", "stats". Default
++ value: "summary".
++
+ email-filter::
+ Specifies a command which will be invoked to format names and email
+ address of committers, authors, and taggers, as represented in various
+@@ -359,6 +365,10 @@ robots::
+ Text used as content for the "robots" meta-tag. Default value:
+ "index, nofollow".
+
++root-default-page::
++ Specifies the default root page. Possible values are "repolist" and
++ "about". Default value: "repolist".
++
+ root-desc::
+ Text printed below the heading on the repository index page. Default
+ value: "a fast webinterface for the git dscm".
+@@ -482,6 +492,10 @@ repo.commit-sort::
+ ordering. If unset, the default ordering of "git log" is used. Default
+ value: unset.
+
++repo.default-page::
++ Specifies the default page for the repository. Default value: global
++ default-page.
++
+ repo.defbranch::
+ The name of the default branch for this repository. If no such branch
+ exists in the repository, the first branch name (when sorted) is used
+diff --git a/cmd.c b/cmd.c
+index 0eb75b1..669c345 100644
+--- a/cmd.c
++++ b/cmd.c
+@@ -51,13 +51,10 @@ static void about_fn(void)
+ free(redirect);
+ } else if (ctx.repo->readme.nr)
+ cgit_print_repo_readme(ctx.qry.path);
+- else if (ctx.repo->homepage)
+- cgit_redirect(ctx.repo->homepage, false);
+ else {
+- char *currenturl = cgit_currenturl();
+- char *redirect = fmtalloc("%s../", currenturl);
++ char *redirect = fmtalloc("%s%s/summary/",
++ ctx.cfg.virtual_root, ctx.repo->url);
+ cgit_redirect(redirect, false);
+- free(currenturl);
+ free(redirect);
+ }
+ } else
+@@ -195,10 +192,13 @@ struct cgit_cmd *cgit_get_cmd(void)
+ int i;
+
+ if (ctx.qry.page == NULL) {
+- if (ctx.repo)
+- ctx.qry.page = "summary";
+- else
+- ctx.qry.page = "repolist";
++ if (ctx.repo) {
++ if (ctx.repo->default_page && *ctx.repo->default_page)
++ ctx.qry.page = ctx.repo->default_page;
++ else
++ ctx.qry.page = ctx.cfg.default_page;
++ } else
++ ctx.qry.page = ctx.cfg.root_default_page;
+ }
+
+ for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
+diff --git a/ui-repolist.c b/ui-repolist.c
+index d12e3dd..2390eae 100644
+--- a/ui-repolist.c
++++ b/ui-repolist.c
+@@ -321,7 +321,7 @@ void cgit_print_repolist(void)
+ }
+ htmlf("<tr><td class='%s'>",
+ !sorted && section ? "sublevel-repo" : "toplevel-repo");
+- cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
++ cgit_repo_link(ctx.repo->name, NULL, NULL, NULL);
+ html("</td><td>");
+ repourl = cgit_repourl(ctx.repo->url);
+ html_link_open(repourl, NULL, NULL);
+diff --git a/ui-shared.c b/ui-shared.c
+index baea6f2..81e1f46 100644
+--- a/ui-shared.c
++++ b/ui-shared.c
+@@ -328,10 +328,16 @@ static void reporevlink(const char *page, const char *name, const char *title,
+ html("</a>");
+ }
+
++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,
+@@ -1035,7 +1041,7 @@ static void print_header(void)
+ if (ctx.repo) {
+ cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1);
+ html(" : ");
+- cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
++ cgit_repo_link(ctx.repo->name, NULL, NULL, NULL);
+ if (ctx.env.authenticated) {
+ html("</td><td class='form'>");
+ html("<form method='get'>\n");
+@@ -1130,7 +1136,7 @@ void cgit_print_pageheader(void)
+ html("</form>\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);
+diff --git a/ui-shared.h b/ui-shared.h
+index 6964873..4d14858 100644
+--- a/ui-shared.h
++++ b/ui-shared.h
+@@ -17,6 +17,8 @@ extern void cgit_add_clone_urls(void (*fn)(const char *));
+
+ extern void cgit_index_link(const char *name, const char *title,
+ const char *class, const char *pattern, const char *sort, int ofs, int always_root);
++extern void cgit_repo_link(const char *name, const char *title,
++ const char *class, const char *head);
+ extern void cgit_summary_link(const char *name, const char *title,
+ const char *class, const char *head);
+ extern void cgit_tag_link(const char *name, const char *title,
+--
+cgit v1.2.3-59-g8ed1b
+