开发者

adding "last edit time" to trac wiki pages

My organization has a sprawling wiki that isn't kept up to date very well. To reduce the danger of new people reading a page and not realizing how outdated it is, I'd like to modify the page header so that instead of

Page Name

at the top, it says something like

Page Name - last mo开发者_Go百科dified 5/8/10 by Joe

I see that Trac allows page templates, but if we haven't used those before, is there a 'blank' template I could alter to change all existing pages?


Unless you have changed something, Trac wiki pages should have a "Last Modified" entry in the top right-hand corner of each page. Hovering the mouse over different parts of the text will show you more details, like the user name of the last person to edit the page and a detailed timestamp of when the last edit was made. Is this different from the functionality that you are asking about?


You can put the following in site.html in the templates directory of your project directory:

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="">
  <!--!
    This file allows customizing the appearance of the Trac installation.
    Add your customizations here and rename the file to site.html. Note that
    it will take precedence over a global site.html placed in the directory
    specified by [inherit] templates_dir.

    More information about site appearance customization can be found here:

      http://trac.edgewall.org/wiki/TracInterfaceCustomization#SiteAppearance
  -->

  <div py:match="div[@id='wikipage']" py:attrs="select('@*')" once="true">
    <h1>Last modified ${format_date(page.time)} by ${authorinfo(page.author)}</h1>
    ${select('*|text()|comment()')}
  </div>
</html>

It doesn't add the last modified info into the title, but displays it before rendering the rest of the page. I don't think you can add it to the title without changing the code of how wiki formatting is rendered.


If you want the last modified date to be more visible, you can use the LastModifiedMacro. I'm fairly sure you could insert it into all existing pages with a simple script that read/writes to wiki table in the database, but I've never done anything like that myself. Take a look at the Database Schema, though keep in mind there may be a better way to do this through the Trac API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜