wiki:Hacking/TracTitleIndexImproved

TitleIndex Improved

I wanted to have TitleIndex on the front page of my Trac but didn't want the clutter of listing all the pages that are shipped with Trac (Trac*, Wiki*, etc.).

I've created a patch for class TitleIndexMacro to achieve my aims. There's an additional parameter ignore. When set to 1 TitleIndex will not list the built-in pages. E.g.

[[TitleIndex(format=group,ignore=1)]]

If ignore=0 or is omitted then it lists all pages.

Reported to Trac as ticket:  Improved TitleIndex macro: optionally ignores pages shipped with Trac

Apply the patch to an existing install (patch saved in /tmp/).

First change to the directory where Trac is installed. If it is installed from my Debian package that is:

cd /usr/share/python-support/trac/trac

If it is installed directly into Python it will be something like:

cd /usr/lib/python2.5/site-packages/trac

or

cd /usr/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac

Now apply the patch:

sudo patch -p1 < /tmp/trac-0.11b-wiki-macros.diff 
patching file wiki/macros.py

or

sudo patch -p1 < /tmp/trac-0.12-wiki-macros.diff
patching file wiki/macros.py

Warning If patch fails it may be because the installed python scripts have DOS-style line endings (CR/LF) instead of Unix-style (LF). I've documented how to fix that in a related article, Trac 0.12 On Ubuntu Lucid. Restart apache2 and trac:

sudo apach2ctl restart

Attachments