summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-08-09 11:27:21 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-08-09 11:41:54 (UTC)
commit537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4 (patch) (side-by-side diff)
tree73b1d25a96dd171c5503fae1fefc6a27a7d58683
parente1782fff8a78b7f265432603351281ad2988bb40 (diff)
downloadcgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.zip
cgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.tar.gz
cgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.tar.bz2
Add 'about-filter' and 'repo.about-filter' options
These options can be used to execute a filter command on each about-page, both top-level and for each repository (repo.about-filter can be used to override the current about-filter). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt10
-rw-r--r--shared.c1
-rw-r--r--ui-repolist.c9
-rw-r--r--ui-summary.c4
6 files changed, 28 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index b3a98c1..cb1149d 100644
--- a/cgit.c
+++ b/cgit.c
@@ -87,12 +87,14 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "cache-repo-ttl"))
ctx.cfg.cache_repo_ttl = atoi(value);
else if (!strcmp(name, "cache-static-ttl"))
ctx.cfg.cache_static_ttl = atoi(value);
else if (!strcmp(name, "cache-dynamic-ttl"))
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"))
ctx.cfg.commit_filter = new_filter(value, 0);
else if (!strcmp(name, "embedded"))
ctx.cfg.embedded = atoi(value);
else if (!strcmp(name, "max-message-length"))
ctx.cfg.max_msg_len = atoi(value);
@@ -143,12 +145,14 @@ void config_cb(const char *name, const char *value)
else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
else if (ctx.repo && !strcmp(name, "repo.max-stats"))
ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
else if (ctx.repo && !strcmp(name, "repo.module-link"))
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"))
ctx.repo->commit_filter = new_filter(value, 0);
else if (ctx.repo && !strcmp(name, "repo.source-filter"))
ctx.repo->source_filter = new_filter(value, 1);
else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
if (*value == '/')
diff --git a/cgit.h b/cgit.h
index f10ba05..b8f4850 100644
--- a/cgit.h
+++ b/cgit.h
@@ -70,12 +70,13 @@ struct cgit_repo {
char *clone_url;
int snapshots;
int enable_log_filecount;
int enable_log_linecount;
int max_stats;
time_t mtime;
+ struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
};
struct cgit_repolist {
int length;
@@ -182,12 +183,13 @@ struct cgit_config {
int noheader;
int renamelimit;
int snapshots;
int summary_branches;
int summary_log;
int summary_tags;
+ struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
};
struct cgit_page {
time_t modified;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index ffb3e0f..d8e4b97 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -13,12 +13,19 @@ Cgitrc contains all runtime settings for cgit, including the list of git
repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank
lines, and lines starting with '#', are ignored.
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::
Specifies a path, relative to each repository path, which can be used
to specify the date and time of the youngest commit in the repository.
The first line in the file is used as input to the "parse_date"
function in libgit. Recommended timestamp-format is "yyyy-mm-dd
hh:mm:ss". Default value: "info/web/last-modified".
@@ -231,12 +238,15 @@ virtual-root::
value: none.
NOTE: cgit has recently learned how to use PATH_INFO to achieve the
same kind of virtual urls, so this option will probably be deprecated.
REPOSITORY SETTINGS
-------------------
+repo.about-filter::
+ Override the default about-filter. Default value: <about-filter>.
+
repo.clone-url::
A list of space-separated urls which can be used to clone this repo.
Default value: none.
repo.commit-filter::
Override the default commit-filter. Default value: <commit-filter>.
diff --git a/shared.c b/shared.c
index 783604b..911a55a 100644
--- a/shared.c
+++ b/shared.c
@@ -59,12 +59,13 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
ret->max_stats = ctx.cfg.max_stats;
ret->module_link = ctx.cfg.module_link;
ret->readme = NULL;
ret->mtime = -1;
+ ret->about_filter = ctx.cfg.about_filter;
ret->commit_filter = ctx.cfg.commit_filter;
ret->source_filter = ctx.cfg.source_filter;
return ret;
}
struct cgit_repo *cgit_get_repoinfo(const char *url)
diff --git a/ui-repolist.c b/ui-repolist.c
index 2c13d50..25f076f 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -270,9 +270,14 @@ void cgit_print_repolist()
print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search);
cgit_print_docend();
}
void cgit_print_site_readme()
{
- if (ctx.cfg.root_readme)
- html_include(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 f2a9b46..a2c018e 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -80,9 +80,13 @@ void cgit_print_repo_readme(char *path)
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'>");
+ 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>");
}