Commits

Anonymous committed 3004d9a

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

  • Participants
  • Parent commits f343128

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>'