mitar avatar mitar committed 6fc038f

Added initial r9850 SVN version.

Comments (0)

Files changed (3)

navadd/__init__.py

+from navadd import *
+from trac.core import *
+from trac.web.chrome import INavigationContributor, ITemplateProvider
+from trac.util import Markup
+
+class NavAdd(Component):
+    """ Allows to add items to main and meta navigation bar"""
+    implements(INavigationContributor)
+
+    nav_contributors = ExtensionPoint(INavigationContributor)
+
+    # INavigationContributor methods
+    def get_active_navigation_item(self, req):
+        return ''
+                
+    def get_navigation_items(self, req):
+	add = self.env.config.get('navadd', 'add_items', ''). \
+		replace(',', ' ').split()
+	
+	items = []
+	for a in add:
+	    title = self.env.config.get('navadd', '%s.title' % a)
+	    url = self.env.config.get('navadd', '%s.url' % a)
+	    perm = self.env.config.get('navadd', '%s.perm' % a)
+	    target = self.env.config.get('navadd', '%s.target' % a)
+
+	    if perm and not req.perm.has_permission(perm):
+		continue
+
+	    if target not in ('mainnav', 'metanav'):
+		target = 'mainnav'
+
+	    items.append((target, a, Markup('<a href="%s">%s</a>' % (url, title))))
+	
+	return items
+from setuptools import setup
+
+setup(name='NavAdd',
+      version='0.1',
+      packages=['navadd'],
+      entry_points = {'trac.plugins': ['navadd = navadd']},
+      package_data={'navadd' : ['templates/*.cs', 'htdocs/js/*.js', 'htdocs/css/*.css']},
+      author = 'Michael Renzmann',
+      author_email = 'mrenzmann@otaku42.de',
+      description = 'A plugin for adding navigation items into one of the navigation bars.',
+      license = 'BSD',
+      keywords = 'trac navigation main meta',
+      url = 'http://trac-hacks.org/wiki/NavAddPlugin')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.