filters: document environment variables in filter scripts

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
Ferry Huberts 2011-03-23 11:57:44 +01:00 committed by Lars Hjemli
parent 14f28923a2
commit b2cf630a4b
3 changed files with 64 additions and 5 deletions

View File

@ -31,7 +31,7 @@ about-filter::
about pages (both top-level and for each repository). The command will 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 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: command will be included verbatim on the about page. Default value:
none. none. See also: "FILTER API".
agefile:: agefile::
Specifies a path, relative to each repository path, which can be used Specifies a path, relative to each repository path, which can be used
@ -81,6 +81,7 @@ commit-filter::
The command will get the message on its STDIN, and the STDOUT from the The command will get the message on its STDIN, and the STDOUT from the
command will be included verbatim as the commit message, i.e. this can command will be included verbatim as the commit message, i.e. this can
be used to implement bugtracker integration. Default value: none. be used to implement bugtracker integration. Default value: none.
See also: "FILTER API".
css:: css::
Url which specifies the css document to include in all cgit pages. Url which specifies the css document to include in all cgit pages.
@ -316,7 +317,7 @@ source-filter::
and the name of the blob as its only command line argument. The STDOUT and the name of the blob as its only command line argument. The STDOUT
from the command will be included verbatim as the blob contents, i.e. from the command will be included verbatim as the blob contents, i.e.
this can be used to implement e.g. syntax highlighting. Default value: this can be used to implement e.g. syntax highlighting. Default value:
none. none. See also: "FILTER API".
summary-branches:: summary-branches::
Specifies the number of branches to display in the repository "summary" Specifies the number of branches to display in the repository "summary"
@ -349,7 +350,7 @@ REPOSITORY SETTINGS
------------------- -------------------
repo.about-filter:: repo.about-filter::
Override the default about-filter. Default value: none. See also: Override the default about-filter. Default value: none. See also:
"enable-filter-overrides". "enable-filter-overrides". See also: "FILTER API".
repo.clone-url:: repo.clone-url::
A list of space-separated urls which can be used to clone this repo. A list of space-separated urls which can be used to clone this repo.
@ -357,7 +358,7 @@ repo.clone-url::
repo.commit-filter:: repo.commit-filter::
Override the default commit-filter. Default value: none. See also: Override the default commit-filter. Default value: none. See also:
"enable-filter-overrides". "enable-filter-overrides". See also: "FILTER API".
repo.defbranch:: repo.defbranch::
The name of the default branch for this repository. If no such branch The name of the default branch for this repository. If no such branch
@ -428,7 +429,7 @@ repo.section::
repo.source-filter:: repo.source-filter::
Override the default source-filter. Default value: none. See also: Override the default source-filter. Default value: none. See also:
"enable-filter-overrides". "enable-filter-overrides". See also: "FILTER API".
repo.url:: repo.url::
The relative url used to access the repository. This must be the first The relative url used to access the repository. This must be the first
@ -448,6 +449,42 @@ Note: the "repo." prefix is dropped from the option names in repo-specific
config files, e.g. "repo.desc" becomes "desc". config files, e.g. "repo.desc" becomes "desc".
FILTER API
----------
- about filter::
This filter is given no arguments.
The about text that is to be filtered is available on standard input and the
filtered text is expected on standard output.
- commit filter::
This filter is given no arguments.
The commit message text that is to be filtered is available on standard input
and the filtered text is expected on standard output.
- source 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 syntax
highlighting mode.
The contents of the source file that is to be filtered is available on
standard input and the filtered contents is expected on standard output.
Also, all filters are handed the following environment variables:
- CGIT_REPO_URL ( = repo.url setting )
- CGIT_REPO_NAME ( = repo.name setting )
- CGIT_REPO_PATH ( = repo.path setting )
- CGIT_REPO_OWNER ( = repo.owner setting )
- CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
- CGIT_REPO_SECTION ( = section setting )
- CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
If a setting is not defined for a repository and the corresponding global
setting is also not defined (if applicable), then the corresponding
environment variable will be an empty string.
Note that under normal circumstance all these environment variables are
defined. If however the total size of the defined settings exceed the
allocated buffer within cgit then only the environment variables that fit
in the allocated buffer are handed to the filter.
EXAMPLE CGITRC FILE EXAMPLE CGITRC FILE
------------------- -------------------

View File

@ -3,6 +3,17 @@
# #
# To use this script, refer to this file with either the commit-filter or the # To use this script, refer to this file with either the commit-filter or the
# repo.commit-filter options in cgitrc. # repo.commit-filter options in cgitrc.
#
# The following environment variables can be used to retrieve the configuration
# of the repository for which this script is called:
# CGIT_REPO_URL ( = repo.url setting )
# CGIT_REPO_NAME ( = repo.name setting )
# CGIT_REPO_PATH ( = repo.path setting )
# CGIT_REPO_OWNER ( = repo.owner setting )
# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
# CGIT_REPO_SECTION ( = section setting )
# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
#
# This expression generates links to commits referenced by their SHA1. # This expression generates links to commits referenced by their SHA1.
regex=$regex' regex=$regex'

View File

@ -23,6 +23,17 @@
# table.blob .kwb { color:#830000; } # table.blob .kwb { color:#830000; }
# table.blob .kwc { color:#000000; font-weight:bold; } # table.blob .kwc { color:#000000; font-weight:bold; }
# table.blob .kwd { color:#010181; } # table.blob .kwd { color:#010181; }
#
# The following environment variables can be used to retrieve the configuration
# of the repository for which this script is called:
# CGIT_REPO_URL ( = repo.url setting )
# CGIT_REPO_NAME ( = repo.name setting )
# CGIT_REPO_PATH ( = repo.path setting )
# CGIT_REPO_OWNER ( = repo.owner setting )
# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
# CGIT_REPO_SECTION ( = section setting )
# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
#
# store filename and extension in local vars # store filename and extension in local vars
BASENAME="$1" BASENAME="$1"