On Tuesday, December 2, 2014 4:14:42 PM UTC-8, Kristen wrote: > > Hello, > > I'm fairly new to Trac and I was wondering if there is a way to display > the latest svn revision number on the WikiStart page. So, for example, > if the revision number changes from 354 to 355, then it automatically > updates the number on the wiki, similar to how the Revision Log updates on > the Browse Source page. > > Thanks for your help! > > Kristen > It doesn't take much code to write the macro you're looking for, just a bit of familiarity with the Trac API.
The LatestRevision macro will display the latest rev from an VCS that is supported by Trac or it's VCS plugins. The latest rev will be displayed as a link to the repository's changelog. I tested with Trac 1.0-stable, but it should work with 0.12 and later. Just drop a file in your environment plugins dir with the following content: # -*- coding: utf-8 -*- # # Copyright (C) 2014 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://trac.edgewall.org/wiki/TracLicense. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://trac.edgewall.org/log/. from genshi.builder import tag from trac.util.translation import _ from trac.versioncontrol.api import RepositoryManager, Repository from trac.wiki.macros import WikiMacroBase class LatestRevisionMacro(WikiMacroBase): def expand_macro(self, formatter, name, content, args=None): name = content repos = RepositoryManager(self.env).get_repository(name) if repos is not None: rev = repos.get_youngest_rev() drev = repos.display_rev(rev) title = _("Changeset %(rev)s in repository %(name)s", rev=rev, name=name or "(default)") return tag.a(drev, title=title, href=formatter.href.log(name)) else: return tag.em(_("(Error: repository '%(name)s' not found)", name=name)) Here are some examples: <https://lh6.googleusercontent.com/-Ahm9GLIfTp8/VH5sONLfD1I/AAAAAAAAB6o/LqlWUKj6yx0/s1600/LatestRevisionMacro.png> -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.
