summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgit.c5
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt24
-rw-r--r--cmd.c20
-rwxr-xr-xtests/setup.sh2
-rw-r--r--tests/t0113-cla.sh25
-rw-r--r--ui-repolist.c5
-rw-r--r--ui-repolist.h1
-rw-r--r--ui-shared.c3
9 files changed, 76 insertions, 10 deletions
diff --git a/cgit.c b/cgit.c
index 2479986998..c3ddfaba1c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -161,6 +161,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "root-coc"))
ctx.cfg.root_coc = xstrdup(value);
+ else if (!strcmp(name, "root-cla"))
+ ctx.cfg.root_cla = xstrdup(value);
else if (!strcmp(name, "css"))
string_list_append(&ctx.cfg.css, xstrdup(value));
else if (!strcmp(name, "js"))
@@ -1075,7 +1077,8 @@ static int calc_ttl(void)
if (!ctx.qry.page)
return ctx.cfg.cache_repo_ttl;
- if (!strcmp(ctx.qry.page, "about") || !strcmp(ctx.qry.page, "coc"))
+ if (!strcmp(ctx.qry.page, "about") || !strcmp(ctx.qry.page, "coc") ||
+ !strcmp(ctx.qry.page, "cla"))
return ctx.cfg.cache_about_ttl;
if (!strcmp(ctx.qry.page, "snapshot"))
diff --git a/cgit.h b/cgit.h
index 553aa7dd41..194e45ec9a 100644
--- a/cgit.h
+++ b/cgit.h
@@ -220,6 +220,7 @@ struct cgit_config {
char *root_desc;
char *root_readme;
char *root_coc;
+ char *root_cla;
char *script_name;
char *section;
char *repository_sort;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 671a8c303e..c541f9f319 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -29,10 +29,10 @@ GLOBAL SETTINGS
about-filter::
Specifies a command which will be invoked to format the content of
about pages (both top-level and for each repository), as well as the
- top-level coc page. The command will get the content of the source
- file on its STDIN, the name of the file as the first argument, and
- the STDOUT from the command will be included verbatim on the target
- page. Default value: none. See also: "FILTER API".
+ top-level coc and cla pages. The command will get the content of the
+ source file on its STDIN, the name of the file as the first argument,
+ and the STDOUT from the command will be included verbatim on the
+ target page. Default value: none. See also: "FILTER API".
agefile::
Specifies a path, relative to each repository path, which can be used
@@ -56,8 +56,8 @@ branch-sort::
cache-about-ttl::
Number which specifies the time-to-live, in minutes, for the cached
- version of the about and coc pages. See also: "CACHE". Default value:
- "15".
+ version of the about, coc, and cla pages. See also: "CACHE". Default
+ value: "15".
cache-dynamic-ttl::
Number which specifies the time-to-live, in minutes, for the cached
@@ -385,6 +385,11 @@ root-coc::
verbatim below the "Code of Conduct" link on the repository index page.
Default value: none.
+root-cla::
+ The content of the file specified with this option will be included
+ verbatim below the "Contributor License Agreement" link on the
+ repository index page. Default value: none.
+
root-title::
Text printed as heading on the repository index page. Default value:
"Git Repository Browser".
@@ -712,9 +717,9 @@ Parameters are provided to filters as follows.
about filter::
This filter is given a single parameter: the filename of the source
file to filter. The filter can use the filename to determine (for
- example) the type of syntax to follow when formatting readme or coc
- text. The input text is available on standard input and the filtered
- text is expected on standard output.
+ example) the type of syntax to follow when formatting readme, coc, or
+ cla text. The input text is available on standard input and the
+ filtered text is expected on standard output.
auth filter::
The authentication filter receives 12 parameters:
@@ -916,6 +921,7 @@ root-desc=tracking the foobar development
# Include some more info about example.com on the index page
root-readme=/var/www/htdocs/about.html
root-coc=/var/www/htdocs/coc.html
+root-cla=/var/www/htdocs/cla.html
# Allow download of tar.gz, tar.bz2 and zip-files
diff --git a/cmd.c b/cmd.c
index 91701d1a8c..729f25f9a4 100644
--- a/cmd.c
+++ b/cmd.c
@@ -102,6 +102,25 @@ static void coc_fn(void)
}
}
+static void cla_fn(void)
+{
+ if (ctx.repo) {
+ struct cgit_repo *old_repo = ctx.repo;
+ char *old_repo_qry = ctx.qry.repo;
+ char *old_url = ctx.qry.url;
+
+ ctx.repo = NULL;
+ ctx.qry.repo = NULL;
+ ctx.qry.url = NULL;
+ cgit_print_site_cla();
+ ctx.qry.url = old_url;
+ ctx.qry.repo = old_repo_qry;
+ ctx.repo = old_repo;
+ } else {
+ cgit_print_site_cla();
+ }
+}
+
static void diff_fn(void)
{
cgit_print_diff(ctx.qry.oid, ctx.qry.oid2, ctx.qry.path, 1, 0);
@@ -195,6 +214,7 @@ struct cgit_cmd *cgit_get_cmd(void)
def_cmd(about, 0, 0, 0),
def_cmd(blame, 1, 1, 0),
def_cmd(blob, 1, 0, 0),
+ def_cmd(cla, 0, 0, 0),
def_cmd(commit, 1, 1, 0),
def_cmd(coc, 0, 0, 0),
def_cmd(diff, 1, 1, 0),
diff --git a/tests/setup.sh b/tests/setup.sh
index ea973584b4..7b8777379a 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -104,6 +104,7 @@ setup_repos()
mkrepo "repos/with space" 2 >/dev/null
mkrepo repos/filter 5 testplus >/dev/null
echo "site code of conduct" >site-coc.txt
+ echo "site contributor license agreement" >site-cla.txt
cat >cgitrc <<EOF
virtual-root=/
cache-root=$PWD/cache
@@ -118,6 +119,7 @@ summary-tags=5
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
repo.url=foo
repo.path=$PWD/repos/foo/.git
diff --git a/tests/t0113-cla.sh b/tests/t0113-cla.sh
new file mode 100644
index 0000000000..085e65ea9c
--- /dev/null
+++ b/tests/t0113-cla.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+test_description='Check top-level CLA page'
+. ./setup.sh
+
+test_expect_success 'index has cla tab' '
+ cgit_url "" >tmp &&
+ grep "p=cla" tmp &&
+ grep "Contributor License Agreement" tmp
+'
+
+test_expect_success 'generate top-level cla page' '
+ cgit_query "p=cla" >tmp
+'
+
+test_expect_success 'find cla content' '
+ grep "site contributor license agreement" tmp
+'
+
+test_expect_success 'repo cla renders top-level cla page' '
+ cgit_url "foo/cla" >tmp &&
+ grep "site contributor license agreement" tmp
+'
+
+test_done
diff --git a/ui-repolist.c b/ui-repolist.c
index 618f32b0a9..ac01724d8b 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -388,3 +388,8 @@ void cgit_print_site_coc(void)
{
cgit_print_site_page(ctx.cfg.root_coc);
}
+
+void cgit_print_site_cla(void)
+{
+ cgit_print_site_page(ctx.cfg.root_cla);
+}
diff --git a/ui-repolist.h b/ui-repolist.h
index 65a442aaa5..9b49d9b869 100644
--- a/ui-repolist.h
+++ b/ui-repolist.h
@@ -4,5 +4,6 @@
extern void cgit_print_repolist(void);
extern void cgit_print_site_readme(void);
extern void cgit_print_site_coc(void);
+extern void cgit_print_site_cla(void);
#endif /* UI_REPOLIST_H */
diff --git a/ui-shared.c b/ui-shared.c
index 281a22f5b6..3aa1bbc01e 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1142,6 +1142,9 @@ void cgit_print_pageheader(void)
if (ctx.cfg.root_coc)
site_link("coc", "Code of Conduct", NULL, hc("coc"),
NULL, NULL, 0, 1);
+ if (ctx.cfg.root_cla)
+ site_link("cla", "Contributor License Agreement", NULL,
+ hc("cla"), NULL, NULL, 0, 1);
html("</td><td class='form'>");
html("<form method='get' action='");
html_attr(currenturl);