fix repo link and add notice

This commit is contained in:
j 2012-02-02 10:34:56 +01:00
parent 5229866cde
commit 7f6a1d67df
1 changed files with 7 additions and 4 deletions

View File

@ -2,7 +2,7 @@
from trac.core import * from trac.core import *
from trac.web.api import IRequestFilter from trac.web.api import IRequestFilter
from trac.web.chrome import add_ctxtnav from trac.web.chrome import add_ctxtnav, add_notice
class RepoLinkModule(Component): class RepoLinkModule(Component):
"""Show a link to the repository in the source browser.""" """Show a link to the repository in the source browser."""
@ -19,8 +19,11 @@ class RepoLinkModule(Component):
return (handler) return (handler)
def post_process_request(self, req, template, data, content_type): def post_process_request(self, req, template, data, content_type):
if self.base and req.path_info.startswith('/browser'): if self.base and req.path_info.startswith('/browser/'):
href = self.base + req.path_info[8:] name = req.path_info[9:].split('/')[0]
add_ctxtnav(req, "Repo", href = href) if name:
href = self.base + '/' + name
add_ctxtnav(req, "Repo", href = href)
add_notice(req, "checkout %s with: bzr branch %s"%(name, href))
return (template, data, content_type) return (template, data, content_type)