| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | """ |
|---|
| 3 | = Watchlist Plugin for Trac = |
|---|
| 4 | Plugin Website: http://trac-hacks.org/wiki/WatchlistPlugin |
|---|
| 5 | Trac website: http://trac.edgewall.org/ |
|---|
| 6 | |
|---|
| 7 | Copyright (c) 2008-2010 by Martin Scharrer <martin@scharrer-online.de> |
|---|
| 8 | All rights reserved. |
|---|
| 9 | |
|---|
| 10 | The i18n support was added by Steffen Hoffmann <hoff.st@web.de>. |
|---|
| 11 | |
|---|
| 12 | This program is free software: you can redistribute it and/or modify |
|---|
| 13 | it under the terms of the GNU General Public License as published by |
|---|
| 14 | the Free Software Foundation, either version 3 of the License, or |
|---|
| 15 | (at your option) any later version. |
|---|
| 16 | |
|---|
| 17 | This program is distributed in the hope that it will be useful, |
|---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | GNU General Public License for more details. |
|---|
| 21 | |
|---|
| 22 | For a copy of the GNU General Public License see |
|---|
| 23 | <http://www.gnu.org/licenses/>. |
|---|
| 24 | |
|---|
| 25 | $Id: nav.py 15264 2016-02-11 04:22:34Z rjollos $ |
|---|
| 26 | """ |
|---|
| 27 | |
|---|
| 28 | __url__ = ur"$URL: //trac-hacks.org/svn/watchlistplugin/0.12/tracwatchlist/nav.py $"[6:-2] |
|---|
| 29 | __author__ = ur"$Author: rjollos $"[9:-2] |
|---|
| 30 | __revision__ = int("0" + ur"$Rev: 15264 $"[6:-2].strip('M')) |
|---|
| 31 | __date__ = ur"$Date: 2016-02-11 04:22:34 +0000 (Thu, 11 Feb 2016) $"[7:-2] |
|---|
| 32 | |
|---|
| 33 | from genshi.builder import tag |
|---|
| 34 | from trac.core import * |
|---|
| 35 | from trac.web.chrome import INavigationContributor |
|---|
| 36 | from tracwatchlist.translation import _ |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | class WatchlistNavigation(Component): |
|---|
| 40 | """Navigation entries for the Trac WatchlistPlugin.""" |
|---|
| 41 | implements( INavigationContributor ) |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | ### methods for INavigationContributor |
|---|
| 45 | def get_active_navigation_item(self, req): |
|---|
| 46 | if req.path_info.startswith("/watchlist"): |
|---|
| 47 | return 'watchlist' |
|---|
| 48 | return '' |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | def get_navigation_items(self, req): |
|---|
| 52 | user = req.authname |
|---|
| 53 | if user and user != 'anonymous': |
|---|
| 54 | yield ('mainnav', 'watchlist', tag.a(_("Watchlist"), |
|---|
| 55 | href=req.href("watchlist"))) |
|---|
| 56 | |
|---|
| 57 | # EOF |
|---|