Commits

Anonymous committed 3004d9a

Added a wikimacro to present table of contents for a set of wiki pages
(TracGuide in particular).

Comments (0)

Files changed (2)

htdocs/css/wiki.css

 }
 #wikihist td.version { text-align: center }
 #wikihist td.comment { width: 100% }
+
+/* Styles for the TracGuideToc wikimacro */
+.wiki-toc {
+ padding: .5em 0;
+ margin: 0 1em 0 1em;
+ float: right;
+ border: 1px solid #ddc;
+ background: #ffd;
+ font-size: 85%;
+}
+.wiki-toc h4 { margin: 0 1em; }
+.wiki-toc ul { list-style: none; padding: 0; margin: 0; }
+.wiki-toc li { margin: 0; padding: 0 1em; }
+.wiki-toc .active { background: #ff9; }

trac/wikimacros/TracGuideToc.py

+# -*- coding: iso8859-1 -*-
+"""
+This macro shows a quick and dirty way to make a table-of-contents for a set
+of wiki pages.
+"""
+
+TOC = [('TracGuide',        'Index'),
+       ('TracInstall',      'Installation'),
+       ('TracUpgrade',      'Upgrading'),
+       ('TracIni',          'Configuration'),
+       ('TracAdmin',        'Administration'),
+       ('TracLogging',      'Logging'),
+       ('TracPermissions' , 'Permissions'),
+       ('TracWiki',         'The Wiki'),
+       ('TracBrowser',      'The Browser'),
+       ('TracRoadmap',      'The Roadmap'),
+       ('TracChangeset',    'Changesets'),
+       ('TracTickets',      'Tickets'),
+       ('TracReports',      'Reports'),
+       ('TracQuery',        'Custom Queries'),
+       ('TracTimeline',     'Timeline'),
+       ('TracRss',          'RSS Support'),
+       ('TracNotification', 'Notification'),
+       ]
+
+def execute(hdf, args, env):
+    html = '<div class="wiki-toc">' \
+           '<h4>Table of Contents</h4>' \
+           '<ul>'
+    curpage =  '%s' % hdf.getValue('args.page', '')
+    for ref,title in TOC:
+        if curpage == ref:
+            cls =  'class="active"'
+        else:
+            cls = ''
+        html += '<li %s><a href="%s">%s</a></li>' % (cls, ref, title)
+    return html + '</ul></div>'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.