| 1 | [[PageOutline(2-5,Contents,pullout)]] |
| 2 | |
| 3 | = WikiSyntax for multiple repository revision = |
| 4 | |
| 5 | == Description == |
| 6 | |
| 7 | When multiple repositories are configured, the 'r123' syntax doesn't enable you to specify the repository and the ![changeset:123:repo] or ![123/repo] syntax must be used instead. As I do find the 'r123' syntax more readable, I wrote this small plugin that lets you use 'r123repo' (simply add the repository name right after the changeset number). |
| 8 | |
| 9 | This is displayed as 'repo/!r123' with a link to the changeset. Parsing 'repo/!r123' syntax isn't possible (AFAIK) as the built-in parser parses the '!r123' part, so the syntax is 'r123repo' but it displayed as 'repo/!r123'. |
| 10 | |
| 11 | |
| 12 | This is the quick solution I came up with. Simply drop this as a .py file directly in your plugins directory: |
| 13 | |
| 14 | {{{ |
| 15 | from trac.core import * |
| 16 | from trac.wiki import IWikiSyntaxProvider |
| 17 | from genshi.builder import tag |
| 18 | |
| 19 | class RepoRevisionSyntax(Component): |
| 20 | implements(IWikiSyntaxProvider) |
| 21 | # -- IWikiSyntaxProvider |
| 22 | def get_wiki_syntax(self): |
| 23 | yield ( r'[r#](?P<rev_id>\d+)(?:\/|@)?(?P<repo>[a-zA-Z0-9_\/]+)', self._format_regex_link) |
| 24 | def _format_regex_link(self, formatter, ns, match): |
| 25 | return tag.a('%s/r%s' % (match.group('repo'), match.group('rev_id')), |
| 26 | href=formatter.href.changeset('%s/%s'%(match.group('rev_id'), match.group('repo')))) |
| 27 | }}} |
| 28 | |
| 29 | == Bugs/Feature Requests == |
| 30 | |
| 31 | Existing bugs and feature requests for RepoRevisionSyntaxPlugin are |
| 32 | [report:9?COMPONENT=RepoRevisionSyntaxPlugin here]. |
| 33 | |
| 34 | If you have any issues, create a |
| 35 | [http://trac-hacks.org/newticket?component=RepoRevisionSyntaxPlugin&owner=shesek new ticket]. |
| 36 | |
| 37 | == Download == |
| 38 | |
| 39 | Download the zipped source from [download:reporevisionsyntaxplugin here]. |
| 40 | |
| 41 | == Source == |
| 42 | |
| 43 | You can check out RepoRevisionSyntaxPlugin from [http://trac-hacks.org/svn/reporevisionsyntaxplugin here] using Subversion, or [source:reporevisionsyntaxplugin browse the source] with Trac. |
| 44 | |
| 45 | == Example == |
| 46 | |
| 47 | For example, 'Fixed by r78trac' (as a ticket comment) would be get displayed as 'Fixed by trac/!r78' with a link. |
| 48 | |
| 49 | == Recent Changes == |
| 50 | |
| 51 | [[ChangeLog(reporevisionsyntaxplugin, 3)]] |
| 52 | |
| 53 | == Author/Contributors == |
| 54 | |
| 55 | '''Author:''' [wiki:shesek] [[BR]] |
| 56 | '''Maintainer:''' [wiki:shesek] [[BR]] |
| 57 | '''Contributors:''' |