List for cgit developers and users
 help / color / mirror / Atom feed
* readme & about-filter improvements: auto selection
@ 2013-05-25 15:21 Jason
  2013-05-26 10:09 ` john
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2013-05-25 15:21 UTC (permalink / raw)


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,
"master:README.md" makes the /about content show the README.md 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 "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
files.

  * 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
modified.

  * 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/about-selector.sh
    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

about-selector.sh reads:

    #!/bin/sh
    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; ;;
    esac

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 [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 git.zx2c4.com, 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.

Jason


[1] http://git.zx2c4.com/cgit/about/
[2] http://git.zx2c4.com/cgit/log/?h=jd/auto-about
[3] http://lists.zx2c4.com/pipermail/cgit/2013-May/001387.html
[4] http://git.zx2c4.com/cgit/tree/filters?h=jd/zx2c4-deployment
[5] http://git.zx2c4.com/cgit/plain/filters/syntaxhighlight?h=jd/zx2c4-deployment


^ permalink raw reply	[flat|nested] 3+ messages in thread

* readme & about-filter improvements: auto selection
  2013-05-25 15:21 readme & about-filter improvements: auto selection Jason
@ 2013-05-26 10:09 ` john
  2013-05-26 14:33   ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: john @ 2013-05-26 10:09 UTC (permalink / raw)


On Sat, May 25, 2013 at 05:21:05PM +0200, Jason A. Donenfeld wrote:
>   * 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.

Why not make this a multi-valued key instead?  That way we don't have to
worry about escaping for people who have whitespace in file names.

> Combined, they allow for the following setup. In cgitrc, I have these specified:
> 
>     about-filter=/var/www/uwsgi/cgit/filters/about-selector.sh
>     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

Then this becomes:

    about-filter=/var/www/uwsgi/cgit/filters/about-selector.sh
    readme=:README.md
    readme=:readme.md
    readme=:README.mkd
    ...

Which is also a lot more readable when there is a long lost of file
names.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* readme & about-filter improvements: auto selection
  2013-05-26 10:09 ` john
@ 2013-05-26 14:33   ` Jason
  0 siblings, 0 replies; 3+ messages in thread
From: Jason @ 2013-05-26 14:33 UTC (permalink / raw)


Great idea! Implemented using struct string_list in wip.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-26 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-25 15:21 readme & about-filter improvements: auto selection Jason
2013-05-26 10:09 ` john
2013-05-26 14:33   ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).