What I want to do:
I want to change the standard Trac layout using a custom CSS file from my plugin. More specifically, I want to change the appearance of the navigation bar link of my plugin.
What I have so far:
I know that the navigation bar items automatically get a CSS class assigned to them. This looks like class="iconPluginname"
. I created a new HTML file in my templates folder called site.html
, which looks like this:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<!--! Add site-specific style sheet -->
<head py:match="head" py:attrs="select('@*')">
${select('*')}
<link rel="stylesheet" type="text/css"
href="${href.chrome('/mypluginname/css/mainnav_icon.css')}" />
</head>
<body py:match="body" py:attrs="select('@*')">
${select('*|text()')}
</body>
</html>
As far as I know, Trac searches in the plugin files for a file called site.html
, and if it doesn't find one it searches in the shared resources and finally in the Trac folder. The latter case is the default case. By my understanding, if I create a file site.html
in my templates folder and the plugin is loaded correctly, it should automatically use the linked stylesheet and also add any changes done in the template. However, when I add a title tag to it, the title of my Trac page is not changed, so I assume the layout is not even loaded.
What do I have to do to make changes to the layout or add a custom stylesheet to my Trac, apart from adding site.html
in my templates folder and linking to the stylesheet?
If you want to provide custom site styling, put the site.html
shown on the TracInterfaceCustomization page in your environment templates
directory and put the custom site styling in style.css
in your environment htdocs
directory.
If you'd like to add a stylesheet through a plugin you are developing, use add_stylesheet.