|
Revision 25, 0.8 KB
(checked in by wingel, 4 years ago)
|
|
added a README
|
| Line | |
|---|
| 1 | #! /usr/bin/python |
|---|
| 2 | from trac.core import * |
|---|
| 3 | from trac.web.api import IRequestFilter |
|---|
| 4 | |
|---|
| 5 | from trac.web.chrome import add_ctxtnav |
|---|
| 6 | |
|---|
| 7 | class RepoLinkModule(Component): |
|---|
| 8 | """Show a link to the repository in the source browser.""" |
|---|
| 9 | |
|---|
| 10 | implements(IRequestFilter) |
|---|
| 11 | |
|---|
| 12 | def __init__(self): |
|---|
| 13 | Component.__init__(self) |
|---|
| 14 | self.base = self.config.get('trac', 'repository_url') |
|---|
| 15 | if self.base.endswith('/'): |
|---|
| 16 | self.base = self.base[:-1] |
|---|
| 17 | |
|---|
| 18 | def pre_process_request(self, req, handler): |
|---|
| 19 | return (handler) |
|---|
| 20 | |
|---|
| 21 | def post_process_request(self, req, template, data, content_type): |
|---|
| 22 | if self.base and req.path_info.startswith('/browser'): |
|---|
| 23 | href = self.base + req.path_info[8:] |
|---|
| 24 | add_ctxtnav(req, "Repo", href = href) |
|---|
| 25 | |
|---|
| 26 | return (template, data, content_type) |
|---|