views:

60

answers:

2

Hi All, I want to customize the project page (trac/templates/index.html).

I want to use a table to show more project-specific information. For instance the admin list of each project, the build status of each project. These information are stored in trac's database.

I am afraid that the default template engine is not able to give me there information. At least I have found nothing valuable from its documentaton.

So I decided to write a python script (on the server side) to generate these information as a JSON string. I injected also a chunk javascript to fetch the JSON from this python script by using Ajax.

But I do not know how to make my python script interpreted by trac.

Can anyone help me?

A: 

I've customized trac in a more simple way by adding an iframe to the top of all trac project pages. You can do this by going to templates directory in the trac environment directory, and adding a site.html file.

I have something like:

 <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:py="http://genshi.edgewall.org/" py:strip="">
  <!--! Custom match templates go here -->
  <head py:match="head" py:attrs="select('@*')">
      ${select('*|comment()|text()[local-name()!="script"]')}
      <link rel="stylesheet" type="text/css" href="http://mysite.com/nav.css" />
  </head>

<body py:match="body" py:attrs="select('@*')">
     <iframe src ="http://mysite.com/nav.html"
                 width="100%"
                 id="navbar-iframe"
                 height="30px"
                 frameborder="0"
                 marginheight="0"
                 scrolling="no"
                 marginwidth="0">
             </iframe>
    <div id="tdtracbody">
        ${select('*|text()')}
    </div>
    </body>
</html>
rlotun
+1  A: 

The Trac extension API allows you to intercept arbitrary pages and insert new data. For example, the BatchModifyPlugin intercepts requests and adds content to the custom query page. See the ITemplateStreamFilter methods at http://trac-hacks.org/browser/batchmodifyplugin/0.11/trunk/batchmod/web_ui.py Take a look at the Trac Hacks website for more examples.

CuriousCurmudgeon