You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2012/06/27 19:24:36 UTC

svn commit: r1354639 - /incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Author: gjm
Date: Wed Jun 27 17:24:35 2012
New Revision: 1354639

URL: http://svn.apache.org/viewvc?rev=1354639&view=rev
Log:
theme: show source tab to admins to give a link to documentation when no source is defined - #20 (based on antony's patch)

Modified:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1354639&r1=1354638&r2=1354639&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Wed Jun 27 17:24:35 2012
@@ -16,6 +16,7 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+from genshi.builder import tag
 from genshi.filters.transform import Transformer
 
 from trac.core import *
@@ -25,8 +26,10 @@ from trac.ticket.model import Ticket
 from trac.ticket.web_ui import TicketModule
 from trac.util.compat import set
 from trac.util.translation import _
+from trac.versioncontrol.web_ui.browser import BrowserModule
 from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
-from trac.web.chrome import add_stylesheet, ITemplateProvider, prevnext_nav
+from trac.web.chrome import (add_stylesheet, INavigationContributor, 
+                             ITemplateProvider, prevnext_nav)
 
 from themeengine.api import ThemeBase, ThemeEngineSystem
 
@@ -105,7 +108,8 @@ class BloodhoundTheme(ThemeBase):
                 ['table', 'table-condensed']),
     )
 
-    implements(IRequestFilter, ITemplateProvider, ITemplateStreamFilter)
+    implements(IRequestFilter, INavigationContributor, ITemplateProvider,
+               ITemplateStreamFilter)
 
     # ITemplateStreamFilter methods
 
@@ -219,6 +223,19 @@ class BloodhoundTheme(ThemeBase):
         """
         add_stylesheet(req, 'dashboard/css/roadmap.css')
 
+    # INavigationContributor methods
+
+    def get_active_navigation_item(self, req):
+        return
+
+    def get_navigation_items(self, req):
+        if 'BROWSER_VIEW' in req.perm and 'VERSIONCONTROL_ADMIN' in req.perm:
+            bm = self.env[BrowserModule]
+            if bm and not list(bm.get_navigation_items(req)):
+                yield ('mainnav', 'browser', 
+                       tag.a(_('Browse Source'),
+                             href=req.href.wiki('TracRepositoryAdmin')))
+
 class QuickCreateTicketDialog(Component):
     implements(IRequestFilter, IRequestHandler)