Edgewall Software

source: trunk/svntrac/Toolbar.py@ 1

Last change on this file since 1 was 1, checked in by Jonas Borgström, 20 years ago

Initial import

File size: 3.3 KB
Line 
1# svntrac
2#
3# Copyright (C) 2003 Xyche Software
4#
5# svntrac is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2 of the
8# License, or (at your option) any later version.
9#
10# svntrac is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18#
19# Author: Jonas Borgström <jonas@xyche.com>
20
21import StringIO
22from util import *
23from auth import get_authname
24import perm
25
26class Toolbar:
27 def __init__(self):
28 self.log = 0
29 self.browser = 1
30 self.timeline = 1
31 self.changeset = 0
32 self.log_path = '/'
33 self.browser_path = '/'
34
35 def enable_log (self, path = '/', enable=1):
36 self.log = enable
37 self.log_path = path
38
39 def enable_browser(self, path = '/', enable=1):
40 self.browser = enable
41 self.browser_path = path
42
43 def enable_timeline (self, enable=1):
44 self.timeline = enable
45
46 def enable_changeset (self, rev, enable=1):
47 self.changeset = enable
48 self.changeset_rev = rev
49
50 def enable_timeline (self, enable=1):
51 self.timeline = enable
52
53 def render (self):
54 out = StringIO.StringIO()
55 out.write ('<table width="100%" cellspacing="0" cellpadding="0"><tr><td class="navbar" bgcolor="black">')
56
57 out.write ('<a href="%s" class="navbar-link">menu</a> |' % menu_href ())
58
59 if perm.has_permission (perm.BROWSER_VIEW):
60 out.write ('<a href="%s" class="navbar-link">browse</a> |'
61 % browser_href (self.browser_path))
62 if perm.has_permission (perm.TIMELINE_VIEW):
63 out.write ('<a href="%s" class="navbar-link">timeline</a> | '
64 % timeline_href ())
65
66 if perm.has_permission (perm.REPORT_VIEW):
67 out.write ('<a href="%s" class="navbar-link">reports</a> |' % report_href ())
68
69 if perm.has_permission (perm.WIKI_VIEW):
70 out.write ('<a href="%s" class="navbar-link">wiki</a> |' % wiki_href ())
71
72 if perm.has_permission (perm.TICKET_CREATE):
73 out.write ('<a href="%s" class="navbar-link">new ticket</a> |' % newticket_href ())
74
75 if self.log:
76 out.write ('<a href="%s" class="navbar-link">log</a> |'
77 % log_href (self.log_path))
78 if self.changeset:
79 out.write ('<a href="%s" class="navbar-link">change set</a> |'
80 % changeset_href (self.changeset_rev))
81
82 out.write ('</td><td align="right" class="navbar" bgcolor="black">')
83 authname = get_authname ()
84 if authname == 'anonymous':
85 out.write ('<a href="%s" class="navbar-link">login</a>' % login_href())
86 else:
87 out.write ('logged in as %s | <a href="svntrac.cgi?logout=now" class="navbar-link">logout</a>' % authname)
88 out.write ('</td>')
89 out.write ('</td></tr></table>')
90 return out.getvalue()
Note: See TracBrowser for help on using the repository browser.