Edgewall Software

Interface Customization using site_*.html files

This page collects useful snippets for inclusion in a project site_head.html, site_header.html and site_footer.html files.

Quicksearch for tickets only

When no search filters are provided, Trac searches using all filters. This snippets adds a filter to the quicksearch that restricts searches to tickets only by default using site_header.html. More can of course be added by user after initial search:

<input type="hidden" name="ticket" value="on" form="search" />

Add licensing information when adding attachments

If adding attachments to your Trac site requires people to agree to some licensing terms, you can add the terms of the license on the "Add attachments" page using site_head.html as follows:

{% raw %}<script>
jQuery(function($) {
    var terms = $('<p>').text('By submitting a file here, you accept that we can do whatever we want with it...');
    $('form#attachment .buttons').before(terms);
});
</script>{% endraw %}

Another approach is inserting content to the buttons of the attachment form using CSS:

{% raw %}<style>
form#attachment .buttons::before {
 display: block;
 margin: .5em 0;
 content: "By submitting a file here, you accept that we can do whatever we want with it...";
}
</style>{% endraw %}

Rename Roadmap header

If your team would prefer to see a different title instead of Roadmap, add the following code to your site_head.html and restart the server. Don't forget to edit trac.ini to change the link title.

# if req.path_info == '/roadmap':
<script>
jQuery(function($) {
    $('h1').text('Open Milestones');
});
</script>
# endif

Replace footer

If you want to change the default footer, add the following code to your site_head.html. This snippet strips out the current one and puts in my own.

{% raw %}<script>
jQuery(function($) {
    $('#footer').html(`
        <hr />
        <a id="tracpowered" href="http://www.tnky.ca/">
          <img src="http://www.tnky.ca/TAI_tag.jpg"
                   style="border: none; height: 98px; width: 185px;" alt="TAI Powered" /></a>
        <p class="left">Base Software is <a href="/about"><strong>Trac 1.4.3</strong></a>
          <br />
           By Edgewall Software.</p>
        <p class="right">Visit Turnkey Automation at<br /><a href="http://www.tnky.ca/">
             http://www.tnky.ca/</a></p>
    `);
});
</script>{% endraw %}
Last modified 9 months ago Last modified on Feb 24, 2024, 4:35:47 AM
Note: See TracWiki for help on using the wiki.