Edgewall Software

Changes between Version 7 and Version 8 of TracInterfaceCustomization


Ignore:
Timestamp:
Oct 31, 2005, 11:42:17 AM (18 years ago)
Author:
Christopher Lenz
Comment:

Cleanup, additions

Legend:

Unmodified
Added
Removed
Modified
  • TracInterfaceCustomization

    v7 v8  
    22
    33== Introduction ==
    4 This page is meant to give users suggestions on how they can customize the look of Trac.  Topics on this page should cover editing the HTML templates and CSS files, but not the program code itself.  The topics are intended to show users how they can modify the look of Trac to meet their specific needs.  Suggestions for changes to Trac's interface applicable to all users should be filed as tickets, not listed on this page.
     4This page is meant to give users suggestions on how they can customize the look of Trac.  Topics on this page cover editing the HTML templates and CSS files, but not the program code itself.  The topics are intended to show users how they can modify the look of Trac to meet their specific needs.  Suggestions for changes to Trac's interface applicable to all users should be filed as tickets, not listed on this page.
    55
    66== Project Logo and Icon ==
    7 
    87The easiest parts of the Trac interface to customize are the logo and the site icon.  Both of these can be configured with settings in [wiki:TracIni trac.ini].
    98
    10 The logo or icon image should be put in a folder named "htdocs" in your project's environment folder.  (''note: in projects created before 0.9 you will need to create this folder'')
     9The logo or icon image should be put in a folder named "htdocs" in your project's environment folder.  (''Note: in projects created with a Trac version prior to 0.9 you will need to create this folder'')
    1110
    1211Now configure the appropriate section of your [wiki:TracIni trac.ini]:
    1312
    1413=== Logo ===
    15 
    1614Change the `src` setting to `site/` followed by the name of your image file.  The `width` and `height` settings should be modified to match your image's dimensions.
    1715
     
    3230}}}
    3331
     32Note though that this icon is ignored by Internet Explorer, which only accepts a file named ``favicon.ico`` at the root of the host. To make the project icon work in both IE and other browsers, you can store the icon in the document root of the host, and reference it from ``trac.ini`` as follows:
     33
     34{{{
     35[project]
     36icon = /favicon.ico
     37}}}
     38
    3439== Site Header & Footer ==
    35 In the environment folder for each Trac project there should be a directory called {{{templates}}}.  This folder contains files {{{site_header.cs}}} and {{{site_footer.cs}}}.  Users can customize their Trac site by placing HTML in these files.  The content of these two files will be placed immediately following the opening {{{<body>}}} tag and immediately preceding the closing {{{</body>}}} tag of each page in the site.
     40In the environment folder for each Trac project there should be a directory called {{{templates}}}.  This folder contains files {{{site_header.cs}}} and {{{site_footer.cs}}}.  Users can customize their Trac site by adding the required HTML markup to these files.  The content of these two files will be placed immediately following the opening {{{<body>}}} tag and immediately preceding the closing {{{</body>}}} tag of each page in the site, respectively.
    3641
    37 These files may contain static HTML, though if users desire to have dynamically generated content they can make use of the ClearSilver templating language from within the pages as well.
    38 
    39 Users can see ticket #332 and changeset [522] for more details.
     42These files may contain static HTML, though if users desire to have dynamically generated content they can make use of the [http://www.clearsilver.net/ ClearSilver] templating language from within the pages as well. When you need to see what variables are available to the template, append the query string `?hdfdump=1` to the URL of your Trac site. This will display a structured view of the template data.
    4043
    4144== Site CSS ==
    42 Also in the enviroment's {{{templates}}} directory is the file {{{site_css.cs}}}.  This file can contain [http://www.w3.org/TR/REC-CSS2/ Cascading Style Sheet] rules that can override or extend the standard stylesheets.
     45The primary means to adjust the layout of a Trac site is by add [http://www.w3.org/TR/REC-CSS2/ CSS] style rules that overlay the default rules. This is best done by editing the `site_css.cs` file in the enviroment's `templates` directory. The content of that template gets inserted into a `<style type="text/css></style>` element on every HTML page generated by Trac.
    4346
    44 == Examples ==
    45 Users can post code samples for how they have customized Trac's interface.
     47While you can add your custom style rules directory to the `site_css.cs` file, it is recommended that you simply reference an external style sheet, thereby enabling browsers to cache the CSS file instead of transmitting the rules with every response.
     48
     49The following example would import a style sheet located in the `style` root directory of your host:
     50{{{
     51@import url(/style/mytrac.css);
     52}}}
     53
     54You can use a !ClearSilver variable to reference a style sheet stored in the project environment's `htdocs` directory:
     55{{{
     56@import url(<?cs var:chrome.href ?>/site/style.css);
     57}}}
     58
     59== Main Templates ==
     60
     61It is also possible to use your own modified versions of the Trac [http://www.clearsilver.net/ ClearSilver] templates. Note though that this technique is not recommended because it makes upgrading Trac rather problematic: there are unfortunately several dependencies between the templates and the application code, such as the name of form fields and the structure of the template data, and these are likely to change between different versions of Trac.
     62
     63If you absolutely need to use modified templates, copy the template files from the default templates directory (usually in found in `$prefix/share/trac/templates`) into the `templates` directory of the project environment. Then modify those copies to get the desired results.
     64
     65
     66----
     67See also TracGuide, TracIni