]> git.cameronkatri.com Git - cgit.git/commitdiff
Add 'about-filter' and 'repo.about-filter' options
authorLars Hjemli <hjemli@gmail.com>
Sun, 9 Aug 2009 11:27:21 +0000 (13:27 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sun, 9 Aug 2009 11:41:54 +0000 (13:41 +0200)
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>
cgit.c
cgit.h
cgitrc.5.txt
shared.c
ui-repolist.c
ui-summary.c

diff --git a/cgit.c b/cgit.c
index b3a98c1599ff8971d9af03a0ca8ea1a1b6d8abb0..cb1149d44189d17a13bbec97f8aa4f28c84c7f91 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -90,6 +90,8 @@ void config_cb(const char *name, const char *value)
                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"))
@@ -146,6 +148,8 @@ void config_cb(const char *name, const char *value)
                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"))
diff --git a/cgit.h b/cgit.h
index f10ba054bc1a7b0d0e728e10983490347a9d9713..b8f485047e48d49f1c3fbdd0fe84a6aac6c6b355 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -73,6 +73,7 @@ struct cgit_repo {
        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;
 };
@@ -185,6 +186,7 @@ struct cgit_config {
        int summary_branches;
        int summary_log;
        int summary_tags;
+       struct cgit_filter *about_filter;
        struct cgit_filter *commit_filter;
        struct cgit_filter *source_filter;
 };
index ffb3e0f4bf6d2abc5fefe5192c07cb7bf31688e3..d8e4b97b18f80e4ef50fff0b551b2257e8773eb7 100644 (file)
@@ -16,6 +16,13 @@ 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.
@@ -234,6 +241,9 @@ virtual-root::
 
 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.
index 783604beba81510f4e155c6de8edced39c8ac3df..911a55a9a4476482b6333bd82d9abb515787021c 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -62,6 +62,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
        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;
index 2c13d5041b2a4931358b241b6316db3d96a9a6b5..25f076fd3198cac33bca32dcceea423e4d9af30c 100644 (file)
@@ -273,6 +273,11 @@ void cgit_print_repolist()
 
 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);
 }
index f2a9b4626058b0caa50b70d1971954ebf9002135..a2c018e3087b8b70866a55f2de4a110a81dddc90 100644 (file)
@@ -83,6 +83,10 @@ void cgit_print_repo_readme(char *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>");
 }