summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt10
-rw-r--r--cmd.c2
-rw-r--r--shared.c1
-rw-r--r--ui-repolist.c7
-rw-r--r--ui-summary.c24
-rw-r--r--ui-summary.h2
8 files changed, 45 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index dbec196..7b228af 100644
--- a/cgit.c
+++ b/cgit.c
@@ -102,2 +102,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.cache_dynamic_ttl = atoi(value);
+ else if (!strcmp(name, "about-filter"))
+ ctx.cfg.about_filter = new_filter(value, 0);
else if (!strcmp(name, "commit-filter"))
@@ -160,2 +162,4 @@ void config_cb(const char *name, const char *value)
ctx.repo->module_link= xstrdup(value);
+ else if (ctx.repo && !strcmp(name, "repo.about-filter"))
+ ctx.repo->about_filter = new_filter(value, 0);
else if (ctx.repo && !strcmp(name, "repo.commit-filter"))
diff --git a/cgit.h b/cgit.h
index b8557ac..4c854ea 100644
--- a/cgit.h
+++ b/cgit.h
@@ -76,2 +76,3 @@ struct cgit_repo {
time_t mtime;
+ struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
@@ -190,2 +191,3 @@ struct cgit_config {
struct string_list mimetypes;
+ struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index dc63637..4d656fe 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -18,2 +18,9 @@ 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). The command will
+ get the content of the about-file on its STDIN, and the STDOUT from the
+ command will be included verbatim on the about page. Default value:
+ none.
+
agefile::
@@ -244,2 +251,5 @@ REPOSITORY SETTINGS
-------------------
+repo.about-filter::
+ Override the default about-filter. Default value: <about-filter>.
+
repo.clone-url::
diff --git a/cmd.c b/cmd.c
index cf97da7..766f903 100644
--- a/cmd.c
+++ b/cmd.c
@@ -41,3 +41,3 @@ static void about_fn(struct cgit_context *ctx)
if (ctx->repo)
- cgit_print_repo_readme();
+ cgit_print_repo_readme(ctx->qry.path);
else
diff --git a/shared.c b/shared.c
index 783604b..911a55a 100644
--- a/shared.c
+++ b/shared.c
@@ -64,2 +64,3 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->mtime = -1;
+ ret->about_filter = ctx.cfg.about_filter;
ret->commit_filter = ctx.cfg.commit_filter;
diff --git a/ui-repolist.c b/ui-repolist.c
index 2c13d50..25f076f 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -275,4 +275,9 @@ void cgit_print_site_readme()
{
- if (ctx.cfg.root_readme)
+ if (!ctx.cfg.root_readme)
+ return;
+ if (ctx.cfg.about_filter)
+ cgit_open_filter(ctx.cfg.about_filter);
html_include(ctx.cfg.root_readme);
+ if (ctx.cfg.about_filter)
+ cgit_close_filter(ctx.cfg.about_filter);
}
diff --git a/ui-summary.c b/ui-summary.c
index ede4a62..a2c018e 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -68,9 +68,25 @@ void cgit_print_summary()
-void cgit_print_repo_readme()
+void cgit_print_repo_readme(char *path)
{
- if (ctx.repo->readme) {
+ char *slash, *tmp;
+
+ if (!ctx.repo->readme)
+ return;
+
+ if (path) {
+ slash = strrchr(ctx.repo->readme, '/');
+ if (!slash)
+ return;
+ tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1);
+ strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1);
+ strcpy(tmp + (slash - ctx.repo->readme + 1), path);
+ } else
+ tmp = ctx.repo->readme;
html("<div id='summary'>");
- html_include(ctx.repo->readme);
+ if (ctx.repo->about_filter)
+ cgit_open_filter(ctx.repo->about_filter);
+ html_include(tmp);
+ if (ctx.repo->about_filter)
+ cgit_close_filter(ctx.repo->about_filter);
html("</div>");
}
-}
diff --git a/ui-summary.h b/ui-summary.h
index 3e13039..c01f560 100644
--- a/ui-summary.h
+++ b/ui-summary.h
@@ -4,3 +4,3 @@
extern void cgit_print_summary();
-extern void cgit_print_repo_readme();
+extern void cgit_print_repo_readme(char *path);