From d6f6072560c963065b13c704fa1fa6f8950e4bac Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 31 Jul 2009 17:38:38 +0200 Subject: Add generic filter/plugin infrastructure The functions cgit_open_filter() and cgit_close_filter() can be used to execute filters on the output stream from cgit. Signed-off-by: Lars Hjemli --- cgit.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cgit.h') diff --git a/cgit.h b/cgit.h index 8c64efe..d0fff1f 100644 --- a/cgit.h +++ b/cgit.h @@ -129,6 +129,15 @@ struct cgit_query { int showmsg; }; +struct cgit_filter { + char *cmd; + char **argv; + int old_stdout; + int pipe_fh[2]; + int pid; + int exitstatus; +}; + struct cgit_config { char *agefile; char *cache_root; @@ -248,5 +257,8 @@ extern const char *cgit_repobasename(const char *reponame); extern int cgit_parse_snapshots_mask(const char *str); +extern int cgit_open_filter(struct cgit_filter *filter); +extern int cgit_close_filter(struct cgit_filter *filter); + #endif /* CGIT_H */ -- cgit v1.2.1 From 46b7abed99e957008c01c02cf612aa526ba92f04 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 31 Jul 2009 16:55:27 +0200 Subject: ui-tree: add support for source-filter option This new option is used to specify an external command which will be executed when displaying blob content in the tree view. Blob content will be written to STDIN of the filter and STDOUT from the filter will be included verbatim in the html output from cgit. The file name of the blob will be passed as the only argument to the filter command. Signed-off-by: Lars Hjemli --- cgit.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cgit.h') diff --git a/cgit.h b/cgit.h index d0fff1f..f9cf0df 100644 --- a/cgit.h +++ b/cgit.h @@ -183,6 +183,7 @@ struct cgit_config { int summary_branches; int summary_log; int summary_tags; + struct cgit_filter *source_filter; }; struct cgit_page { -- cgit v1.2.1 From f35db1cd2b75aac6952aa07713e44ca01fd89727 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 31 Jul 2009 17:42:57 +0200 Subject: ui-commit: add support for 'commit-filter' option This new option specifies a filter which is executed on the commit message, i.e. the commit message is written to the filters STDIN and the filters STDOUT is included verbatim as the commit message. This can be used to implement commit linking by creating a simple shell script in e.g. /usr/bin/cgit-commit-filter.sh like this: #/bin/sh sed -re 's|\b([0-9a-fA-F]{6,40})\b|\1|g' Signed-off-by: Lars Hjemli --- cgit.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cgit.h') diff --git a/cgit.h b/cgit.h index f9cf0df..438301d 100644 --- a/cgit.h +++ b/cgit.h @@ -183,6 +183,7 @@ struct cgit_config { int summary_branches; int summary_log; int summary_tags; + struct cgit_filter *commit_filter; struct cgit_filter *source_filter; }; -- cgit v1.2.1 From e976df27952ca1e450c1c3d420532ac9f5e3036b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 9 Aug 2009 13:22:00 +0200 Subject: Add support for repo.commit-filter and repo.source-filter These options can be used to override the default commit- and source- filter settings per repository. Signed-off-by: Lars Hjemli --- cgit.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'cgit.h') diff --git a/cgit.h b/cgit.h index 438301d..f10ba05 100644 --- a/cgit.h +++ b/cgit.h @@ -48,6 +48,15 @@ typedef void (*configfn)(const char *name, const char *value); typedef void (*filepair_fn)(struct diff_filepair *pair); typedef void (*linediff_fn)(char *line, int len); +struct cgit_filter { + char *cmd; + char **argv; + int old_stdout; + int pipe_fh[2]; + int pid; + int exitstatus; +}; + struct cgit_repo { char *url; char *name; @@ -64,6 +73,8 @@ struct cgit_repo { int enable_log_linecount; int max_stats; time_t mtime; + struct cgit_filter *commit_filter; + struct cgit_filter *source_filter; }; struct cgit_repolist { @@ -129,15 +140,6 @@ struct cgit_query { int showmsg; }; -struct cgit_filter { - char *cmd; - char **argv; - int old_stdout; - int pipe_fh[2]; - int pid; - int exitstatus; -}; - struct cgit_config { char *agefile; char *cache_root; -- cgit v1.2.1