get repolink from http://zoo.weinigel.se/trac/public/browser/trac/repolink/trunk/repolink
This commit is contained in:
commit
5229866cde
4 changed files with 61 additions and 0 deletions
0
repolink/__init__.py
Normal file
0
repolink/__init__.py
Normal file
26
repolink/repolink.py
Normal file
26
repolink/repolink.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#! /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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue