readme & about-filter improvements: auto selection

Jason A. Donenfeld Jason at
Sat May 25 17:21:05 CEST 2013

Hi guys,

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,
"" makes the /about content show the file
from the master branch. We use this on the cgit homepage [1] to show
the wiki using readme=wiki:index and about-filter=/path/to/markdown.

In the jd/auto-about branch [2], 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 "" may become "" 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 [3], 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:

    about-filter=/var/www/uwsgi/cgit/filters/ :README.mkd :readme.mkd :README.rst
:readme.rst :README.txt :readme.txt :README :readme :INSTALL.txt
:install.txt :INSTALL :install reads:

    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, if any repo contains, say, a 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 [1], 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 [4] for, and I may work to bring some of these,
especially the syntax highlighting [5], into the main repo.

Enjoy! And please do test this branch out.



More information about the CGit mailing list