comparison examples/trac/wiki-macros/TracGuideToc.py @ 39:93b4dcbafd7b trunk

Copy Trac to main branch.
author cmlenz
date Mon, 03 Jul 2006 18:53:27 +0000
parents
children
comparison
equal deleted inserted replaced
38:ee669cb9cccc 39:93b4dcbafd7b
1 # -*- coding: utf-8 -*-
2 """
3 This macro shows a quick and dirty way to make a table-of-contents for a set
4 of wiki pages.
5 """
6
7 TOC = [('TracGuide', 'Index'),
8 ('TracInstall', 'Installation'),
9 ('TracUpgrade', 'Upgrading'),
10 ('TracIni', 'Configuration'),
11 ('TracAdmin', 'Administration'),
12 ('TracBackup', 'Backup'),
13 ('TracLogging', 'Logging'),
14 ('TracPermissions' , 'Permissions'),
15 ('TracWiki', 'The Wiki'),
16 ('WikiFormatting', 'Wiki Formatting'),
17 ('TracTimeline', 'Timeline'),
18 ('TracBrowser', 'Repository Browser'),
19 ('TracChangeset', 'Changesets'),
20 ('TracRoadmap', 'Roadmap'),
21 ('TracTickets', 'Tickets'),
22 ('TracQuery', 'Ticket Queries'),
23 ('TracReports', 'Reports'),
24 ('TracRss', 'RSS Support'),
25 ('TracNotification', 'Notification'),
26 ('TracInterfaceCustomization', 'Customization'),
27 ('TracPlugins', 'Plugins'),
28 ]
29
30 def execute(hdf, args, env):
31 html = '<div class="wiki-toc">' \
32 '<h4>Table of Contents</h4>' \
33 '<ul>'
34 curpage = '%s' % hdf.getValue('wiki.page_name', '')
35 lang, page = '/' in curpage and curpage.split('/', 1) or ('', curpage)
36 for ref, title in TOC:
37 if page == ref:
38 cls = ' class="active"'
39 else:
40 cls = ''
41 html += '<li%s><a href="%s">%s</a></li>' \
42 % (cls, env.href.wiki(lang+ref), title)
43 return html + '</ul></div>'
Copyright (C) 2012-2017 Edgewall Software