From 5229866cde3c3040a5ed60459949e9f8d1e52400 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 2 Feb 2012 14:35:19 +0530 Subject: [PATCH] get repolink from http://zoo.weinigel.se/trac/public/browser/trac/repolink/trunk/repolink --- README.txt | 12 ++++++++++++ repolink/__init__.py | 0 repolink/repolink.py | 26 ++++++++++++++++++++++++++ setup.py | 23 +++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 README.txt create mode 100644 repolink/__init__.py create mode 100644 repolink/repolink.py create mode 100755 setup.py diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..bc9e62d --- /dev/null +++ b/README.txt @@ -0,0 +1,12 @@ +This trac plugin adds a link to the repository in the source browser. + +For an example of how it works, go to the following link and then +click on "Repo" in the context navigation: + +http://zoo.weinigel.se/trac/public/browser/trac/repolink/trunk + +To activate the link you have to tell the plugin where the repository +resides, for example, if the repository is reachable via http: + +[trac] +repository_url=http://svn.edgewall.com/repos/trac/ diff --git a/repolink/__init__.py b/repolink/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/repolink/repolink.py b/repolink/repolink.py new file mode 100644 index 0000000..89b2c6c --- /dev/null +++ b/repolink/repolink.py @@ -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) diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..fad29cf --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: iso-8859-1 -*- + +from setuptools import setup + +setup( + name = 'RepoLink', + version = '0.1', + packages = ['repolink'], + + author = "Christer Weinigel", + author_email = "christer@weinigel.se", + description = "Show a link to the repository in the source browser", + license = "BSD", + keywords = "trac repolink", + url = "http://zoo.weinigel.se/", + + entry_points = { + 'trac.plugins': [ + 'repolink.repolink = repolink.repolink' + ] + } +)