27 lines
804 B
Python
27 lines
804 B
Python
#! /usr/bin/python
|
|
from trac.core import *
|
|
from trac.web.api import IRequestFilter
|
|
|
|
from trac.web.chrome import add_ctxtnav
|
|
|
|
class RepoLinkModule(Component):
|
|
"""Show a link to the repository in the source browser."""
|
|
|
|
implements(IRequestFilter)
|
|
|
|
def __init__(self):
|
|
Component.__init__(self)
|
|
self.base = self.config.get('trac', 'repository_url')
|
|
if self.base.endswith('/'):
|
|
self.base = self.base[:-1]
|
|
|
|
def pre_process_request(self, req, handler):
|
|
return (handler)
|
|
|
|
def post_process_request(self, req, template, data, content_type):
|
|
if self.base and req.path_info.startswith('/browser'):
|
|
href = self.base + req.path_info[8:]
|
|
add_ctxtnav(req, "Repo", href = href)
|
|
|
|
return (template, data, content_type)
|