Changes between Version 3 and Version 4 of TracInterfaceCustomization


Ignore:
Timestamp:
May 24, 2018, 4:29:30 PM (6 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracInterfaceCustomization

    v3 v4  
    11= Customizing the Trac Interface
    2 
    32[[TracGuideToc]]
    43[[PageOutline(2-5,Contents,pullout)]]
     
    76
    87== Project Logo and Icon
    9 
    108The 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].
    119
     
    1715
    1816=== Logo
    19 
    2017Change 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'.
    2118
     
    2926
    3027=== Icon
    31 
    3228Icons 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:
    3329
     
    3834
    3935== Custom Navigation Entries
    40 
    4136The 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.
    4237
     
    9489{{{#!xml
    9590<form py:match="div[@id='content' and @class='ticket']/form" py:attrs="select('@*')">
    96   <py:if test="req.environ['PATH_INFO'] == '/newticket' and (not 'preview' in req.args)">
     91  <py:if test="req.path_info == '/newticket' and (not 'preview' in req.args)">
    9792    <p>Please make sure to search for existing tickets before reporting a new one!</p>
    9893  </py:if>
     
    10196}}}
    10297
    103 This example illustrates a technique of using `req.environ['PATH_INFO']` to limit scope of changes to one view only. For instance, to make changes in `site.html` only for timeline and avoid modifying other sections - use `req.environ['PATH_INFO'] == '/timeline'` condition in `<py:if>` test.
     98This example illustrates a technique of using `req.path_info` to limit scope of changes to one view only. For instance, to make changes in `site.html` only for timeline and avoid modifying other sections - use `req.path_info == '/timeline'` condition in `<py:if>` test.
    10499
    105100More examples snippets for `site.html` can be found at [trac:wiki:CookBook/SiteHtml CookBook/SiteHtml].
     
    107102Example snippets for `style.css` can be found at [trac:wiki:CookBook/SiteStyleCss CookBook/SiteStyleCss].
    108103
    109 If the environment is upgraded from 0.10 and a `site_newticket.cs` file already exists, it can be loaded using a workaround, provided it contains no [trac:ClearSilver] processing. In addition, as only one element can be imported, the content needs a wrapper, such as a `<div>` block or other similar parent container. The XInclude namespace must be specified to allow includes, but that can be moved to document root along with the others:
    110 {{{#!xml
    111 <form py:match="div[@id='content' and @class='ticket']/form" py:attrs="select('@*')"
    112         xmlns:xi="http://www.w3.org/2001/XInclude">
    113   <py:if test="req.environ['PATH_INFO'] == '/newticket' and (not 'preview' in req.args)">
    114     <xi:include href="site_newticket.cs"><xi:fallback /></xi:include>
    115   </py:if>
    116   ${select('*')}
    117 </form>
    118 }}}
    119 
    120 Also note that the `site.html`, despite its name, can be put in a shared templates directory, see the [[TracIni#inherit-section|[inherit] templates_dir]] option. This could provide easier maintenance (and a migration path from 0.10 for larger installations) as one new global `site.html` file can be made to include any existing header, footer and newticket snippets.
     104Note that the `site.html`, despite its name, can be put in a shared templates directory, see the [[TracIni#inherit-section|[inherit] templates_dir]] option. This could provide easier maintainence as one new global `site.html` file can be made to include any existing header, footer and newticket snippets.
    121105
    122106== Project List #ProjectList