Skip to content

Commit 125e6f9

Browse files
authored
Fixed login/logout/logged as items in metanav.
Most of the issues were caused by Trac's clever plugin system where classes implementing INavigationContributor all contribute to the metanav. Plugins can then override existing links by making sure they pass the same name (second element in the yielded tuple in get_navigation_items()). On top of that, trac.ini can override any item by specifying a <item name>.label configuration. Rather than trying to figure this all out, I've opted to hardcode the navigation menu in the HTML. This has the nice side-effect of removing the dependency on the forked trac-github. This commit therefore includes a revert of d8760ad. Fixes django#51
1 parent 5dc9fba commit 125e6f9

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

requirements.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ https://trac-hacks.org/browser/xmlrpcplugin/trunk?rev=18591&format=zip
1616
oauthlib==2.1.0
1717
requests==2.20.1
1818
requests-oauthlib==1.0.0
19-
# trac-github is unmaintained at this time and not compatible with Trac 1.4
20-
# See issue https://github.com/trac-hacks/trac-github/issues/136 for example
21-
# So obviously the solution is a fork, this one will surely never go unmaintained
22-
trac-github @ git+https://github.com/bmispelon/[email protected]
19+
trac-github==2.3
2320

2421
gunicorn==19.10.0
2522
sentry-sdk==1.11.0

trac-env/conf/trac.ini

+2-7
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,8 @@ timeline.order = 4.0
9292
wiki.order = 5.0
9393

9494
[metanav]
95-
about = disabled
96-
github_login.order = 1.0
97-
help = disabled
98-
login.label = DjangoProject Login
99-
login.order = 2.0
100-
logout.order = 3.0
101-
prefs.order = 4.0
95+
; The metanav is hardcoded in templates/django_theme.html
96+
; because it was too hard to make the login plugins play nice with each other
10297

10398
[mimeviewer]
10499
enscript_modes = text/x-dylan:dylan:4

trac-env/templates/django_theme.html

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,26 @@
1717

1818
# macro main()
1919
<div role="main">
20-
${navigation('metanav')}
20+
<div id="metanav" class="nav">
21+
<ul>
22+
# if req.is_authenticated:
23+
<li>Logged in as ${req.authname}</li>
24+
<li>
25+
<form action="/github/logout" method="post" id="logout" class="trac-logout">
26+
<button type="submit">Logout</button>
27+
<input type="hidden" name="__FORM_TOKEN" value="${req.form_token}">
28+
</form>
29+
</li>
30+
# else
31+
<li><a href="/github/login">GitHub Login</a></li>
32+
<li><a href="/login">DjangoProject Login</a></li>
33+
# endif
34+
<li><a href="${req.href.prefs()}">Preferences</a></li>
35+
# if req.perm.has_permission('XML_RPC'):
36+
<li><a href="${req.href.rpc()}">API</a></li>
37+
# endif
38+
</ul>
39+
</div>
2140
${navigation('mainnav')}
2241
<div id="main" ${{'class': {
2342
'uisymbols': req.session.get('ui.use_symbols'),

0 commit comments

Comments
 (0)