Changes between Version 82 and Version 83 of TracInterfaceCustomization
- Timestamp:
- Apr 15, 2015, 1:35:22 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracInterfaceCustomization
v82 v83 1 = Customizing the Trac Interface = 1 = Customizing the Trac Interface 2 2 3 [[TracGuideToc]] 3 4 [[PageOutline]] 4 5 5 == Introduction == 6 == Introduction 7 6 8 This page gives suggestions on how to customize the look of Trac. Topics include editing the HTML templates and CSS files, but not the program code itself. The topics 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. 7 9 8 == Project Logo and Icon == 10 == Project Logo and Icon 11 9 12 The 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]. 10 13 11 14 The 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''. 12 15 13 '' Note: you can actually put the logo and icon anywhere on your server (as long as it's accessible through the web server), and use their absolute or server-relative URLs in the configuration.''16 '''Note''': you can actually put the logo and icon anywhere on your server (as long as it's accessible through the web server), and use their absolute or server-relative URLs in the configuration. 14 17 15 18 Now configure the appropriate section of your [wiki:TracIni trac.ini]: 16 19 17 === Logo === 20 === Logo 21 18 22 Change 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. The Trac chrome handler uses "`site/`" for files within the project directory `htdocs`, and "`common/`" for the common `htdocs` directory belonging to a Trac installation. Note that 'site/' is not a placeholder for your project name, it is the literal prefix that should be used. For example, if your project is named 'sandbox', and the image file is 'red_logo.gif' then the 'src' setting would be 'site/red_logo.gif', not 'sandbox/red_logo.gif'. 19 23 20 {{{ 24 {{{#!ini 21 25 [header_logo] 22 26 src = site/my_logo.gif … … 26 30 }}} 27 31 28 === Icon === 32 === Icon 33 29 34 Icons are small images displayed by your web browser next to the site's URL and in the `Bookmarks` menu. Icons should be a 32x32 image in `.gif` or `.ico` format. Change the `icon` setting to `site/` followed by the name of your icon file: 30 35 31 {{{ 36 {{{#!ini 32 37 [project] 33 38 icon = site/my_icon.ico … … 36 41 Note 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 IE as well as other browsers, you can store the icon in the document root of the host and then reference it from `trac.ini` as follows: 37 42 38 {{{ 43 {{{#!ini 39 44 [project] 40 45 icon = /favicon.ico … … 43 48 If your browser does not show your favicon in the address bar, append a "?" to the file extension: 44 49 45 {{{ 50 {{{#!ini 46 51 [project] 47 52 icon = /favicon.ico? 48 53 }}} 49 54 50 == Custom Navigation Entries == 55 == Custom Navigation Entries 56 51 57 The new [mainnav] and [metanav] can now be used to customize the text and link used for the navigation items, or even to disable them, but not for adding new ones. 52 58 53 59 In the following example, we rename the link to the Wiki start "Home", and hide the "!Help/Guide". We also make the "View Tickets" entry link to a specific report: 54 {{{ 60 {{{#!ini 55 61 [mainnav] 56 62 wiki.label = Home … … 65 71 == Site Appearance == #SiteAppearance 66 72 67 Trac is using [http://genshi.edgewall.org Genshi] as the templating engine. Say you want to add a link to a custom stylesheet, and then your own header and footer. Save the following content as `site.html` inside your projects `templates/` directory (each Trac project can have their own `site.html`), eg {{{/path/to/env/templates/site.html}}}:73 Trac is using [http://genshi.edgewall.org Genshi] as the templating engine. Say you want to add a link to a custom stylesheet, and then your own header and footer. Save the following content as `site.html` inside your projects `templates/` directory (each Trac project can have their own `site.html`), eg `/path/to/env/templates/site.html`: 68 74 69 75 {{{ … … 200 206 }}} 201 207 202 == Project Templates ==208 == Project Templates 203 209 204 210 The appearance of each individual Trac environment, ie instance of a project, can be customized independently of other projects, even those hosted on the same server. The recommended way is to use a `site.html` template (see [#SiteAppearance]) whenever possible. Using `site.html` means changes are made to the original templates as they are rendered, and you should not normally need to redo modifications whenever Trac is upgraded. If you do make a copy of `theme.html` or any other Trac template, you need to migrate your modifiations to the newer version. If not, new Trac features or bug fixes may not work as expected. … … 212 218 Trac resolves requests for a template by first looking inside the project, then in any inherited templates location, and finally inside the Trac egg. 213 219 214 Trac caches templates in memory by default to improve performance. To apply a template you need to restart the server.220 Trac caches templates in memory by default to improve performance. To apply a template you need to restart the web server. 215 221 216 222 ----