Hacking Trac

On this page I document my efforts to customise the Trac sites I manage.

WARNING: The recipes work for me but please do not blame me if something goes wrong. You can use the on your own risk.

Hacking Trac templates

Configuring site header

As suggested here I try to keep all the template changes inside site.html in the project's templates directory. Below is sample site.html that overrides specification of the site header. Comparing to the original Trac template this one adds some text before logo.

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/" py:strip="">
  <!--! Custom match templates go here -->
 <body py:match="body" py:attrs="select('@*')">
    <!--! Override specification of the header -->
    <py:match path="//div[@id='header']" once="true"><div id="header">
        Here is some text before logo image
        ${select('*|text()')}
    </div></py:match>
    <!--! Add site-specific header -->
    <div id="siteheader">
      <!--! Place your header content here... -->
    </div>
 
    ${select('*|text()')}
 
    <!--! Add site-specific footer -->
    <div id="sitefooter">
      <!--! Place your footer content here... -->
    </div>
  </body>
</html>
  • en/projects/mytools/hackingtrac.txt
  • Last modified: 2017/10/02 15:54
  • (external edit)