readme & about-filter improvements: auto selection
Jason A. Donenfeld
Jason at zx2c4.com
Sat May 25 17:21:05 CEST 2013
Cgit has for a long time had the ability to show the /about content
from the git repo itself by specifying branch:file, for example,
"master:README.md" makes the /about content show the README.md file
from the master branch. We use this on the cgit homepage  to show
the wiki using readme=wiki:index and about-filter=/path/to/markdown.
In the jd/auto-about branch , I have a few commits that make readme
and about-filter much more dynamic.
* On readme=, if the branch is not specified, the default branch is
used. Thus "master:README.md" may become ":README.md" in many cases.
If defbranch= is specified, it will pick up the defbranch setting. Of
course, the case without the prepended colon is still used for actual
* On about-filter=, depending on the discussion in , we now pass
the filename (the part after the colon) to the filter program, so that
the program may use that information to infer how the file should be
* On readme=, multiple items may be specified, separated by a space,
and if multiple items exist, cgit will display the first one that it's
able to find.
Combined, they allow for the following setup. In cgitrc, I have these specified:
readme=:README.md :readme.md :README.mkd :readme.mkd :README.rst
:readme.rst :README.txt :readme.txt :README :readme :INSTALL.txt
:install.txt :INSTALL :install
cd "$(dirname $(readlink -f "$0"))"
case "$(tr '[:upper:]' '[:lower:]' <<<"$1")" in
*.md|*.mkd) exec ./markdown; ;;
*.rst) exec ./rst2html; ;;
*.[1-9]) exec ./man2html; ;;
*.txt|*) exec ./txt2html; ;;
Now, on git.zx2c4.com, if any repo contains, say, a README.md file in
the default branch, it will automatically receive an about page, and
likewise for the other possibilities, each one correctly filtered. For
the cgit homepage , I of course still provide a repo-specific
cgitrc pointing to wiki:index.
As well, at some point, I'd like to revamp the /filters directory we
ship with releases. I've got a number of filters in my own personal
branch  for git.zx2c4.com, and I may work to bring some of these,
especially the syntax highlighting , into the main repo.
Enjoy! And please do test this branch out.
More information about the CGit