wiki:NavAddPlugin

Version 23 (modified by rjollos, 14 months ago) (diff)

Mention proposed integration to the Trac core.

Add custom items to main and meta navigation bar

There is an open ticket for integrating the functionality provided by this plugin into the Trac core. See trac:#11317.

Description

Starting with release 0.11, Trac allows existing items in the main and meta navigation bar menu items to be customized, however it does not allow custom items to be added. This plugin allows you to add custom items ("buttons") to both the main and the meta navigation bar. Item name, title and URL can be specified in trac.ini, as well as an optional permission the user is required to have to see the item.

The plugin was inspired by and derived from NavMoverPlugin. In contrast to NavMoverPlugin this plugin does not hide navigation bars, which was my main motivation for creating this "fork".

Note: The 0.9 branch of this plugin works without modification for 0.10, 0.11 and 0.12.

See also: MenusPlugin, TracTabPlugin.

Fork: I have made a small fork on GitHub with some improvements/fixes. Feel free to suggest new. For example, It supports TracLinks syntax for url, so if a link works in the wiki page itself, it should also in the menu. Install with pip install NavAdd.

Configuration

Enable with:

[components]
navadd.* = enabled

All configuration settings are to be kept in a section called [navadd] in TracIni. The basic syntax is:

add_items = <item>,<item>,...
comma-separated list of items that will be added; only items that are listed here will be processed.

Note: all items need to be in lowercase. If you use any uppercase character it will not work.

And then for each item:

<item>.title = <title>
the name (title) of the button
<item>.url = <url>
the URL the button should link to; please note that TracLinks syntax is not supported here yet
<item>.perm = <permission>
an optional permission that a user needs to have in order to see the button. If unspecified, then all users will see the button.
<item>.target = <navbar_name>
the name of the navigation bar the button should be added to; only mainnav and metanav have been tested so far, others names probably work as well

Example

This is the configuration I use on madwifi-project.org to add a link to the imprint in the meta navigation bar, and a link to our download section on sf.net in the main navigation bar.

[navadd]
add_items = imprint,download
imprint.title = Impressum/Imprint
imprint.url = /wiki/Impressum
#imprint.perm = WIKI_VIEW
imprint.target = metanav
download.title = Download
download.url = http://sourceforge.net/project/showfiles.php?group_id=82936&amp;package_id=85233
#download.perm = WIKI_VIEW
download.target = mainnav

Ordering of buttons

It might be worth to note that buttons which are added with this plugin can be ordered in the usual way, i.e. by specifying the actual order in section [trac], keywords mainnav and metanav in TracIni.

Example

Let's assume that you add a button Download to your main navigation bar (same as in the configuration example above), and you want it to appear right after the Wiki button. The configuration then looks like:

[trac]
...
mainnav = wiki,download,timeline,roadmap,browser,tickets,newticket
...

Bugs/Feature Requests

Existing bugs and feature requests for NavAddPlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out NavAddPlugin from here using Subversion, or browse the source with Trac.

Recent Changes

[13554] by rjollos on 2014-01-08 17:46:30
0.3: An href starting with a / is relative to the base URL, and absolute URLs are treated as such. Fixes #11443.

Removed some unused code. Thanks to ryank-inovonics for the patch.

[13385] by rjollos on 2013-09-10 10:46:37
Refs #940: Refactor code to use a ListOption and add doc. Bumped version to 0.2.
[13384] by rjollos on 2013-09-10 10:46:25
Renamed 0.9 directory to trunk`.

Author/Contributors

Author: otaku42
Maintainer: otaku42
Contributors: