PKÈ„4tractoc/__init__.pyPK…68êô£˜„„tractoc/__init__.pyo;ò yô1Dc@sdS(N((((s4build/bdist.darwin-8.0.1-x86/egg/tractoc/__init__.pys?sPKw¢4èm$ß33tractoc/macro.py# vim: expandtab tabstop=4 from trac.core import * from trac.util import escape from trac.wiki.formatter import Formatter, OutlineFormatter, wiki_to_oneliner, wiki_to_outline from trac.wiki.api import IWikiMacroProvider, WikiSystem from trac.wiki.model import WikiPage from StringIO import StringIO import os, re, string, inspect __all__ = ['TracTocMacro'] class NullOut(object): def write(self, *args): pass class MyOutlineFormatter(OutlineFormatter): def format(self, active_page, page, text, out, min_depth, max_depth): self.__page = page # XXX Code copied straight out of OutlineFormatter self.outline = [] class NullOut(object): def write(self, data): pass Formatter.format(self, text, NullOut()) if min_depth > max_depth: min_depth, max_depth = max_depth, min_depth max_depth = min(6, max_depth) min_depth = max(1, min_depth) curr_depth = min_depth - 1 for depth, link in self.outline: active = '' if '/%s' % active_page in link: active = ' class="active"' if depth < min_depth or depth > max_depth: continue if depth < curr_depth: out.write('' % active * (curr_depth - depth)) elif depth > curr_depth: out.write('
    ' % active * (depth - curr_depth)) else: out.write("\n" % active) curr_depth = depth out.write(link) out.write('
' * curr_depth) def _heading_formatter(self, match, fullmatch): Formatter._heading_formatter(self, match, fullmatch) depth = min(len(fullmatch.group('hdepth')), 5) heading = match[depth + 1:len(match) - depth - 1] anchor = self._anchors[-1] text = wiki_to_oneliner(heading, self.env, self.db, self._absurls) text = re.sub(r'', '', text) # Strip out link tags self.outline.append((depth, '%s' % (self.env.href.wiki(self.__page), anchor, text))) class TracTocMacro(Component): """ Generate a table of contents for the current page or a set of pages. If no arguments are given, a table of contents is generated for the current page, with the top-level title stripped: {{{ [[TOC]] }}} To generate a table of contents for a set of pages, simply pass them as comma separated arguments to the TOC macro, e.g. as in {{{ [[TOC(TracGuide, TracInstall, TracUpgrade, TracIni, TracAdmin, TracBackup, TracLogging, TracPermissions, TracWiki, WikiFormatting, TracBrowser, TracRoadmap, TracChangeset, TracTickets, TracReports, TracQuery, TracTimeline, TracRss, TracNotification)]] }}} The following ''control'' arguments change the default behaviour of the TOC macro: || '''Argument''' || '''Meaning''' || || {{{heading=}}} || Override the default heading of "Table of Contents" || || {{{noheading}}} || Suppress display of the heading. || || {{{depth=}}} || Display headings of ''subsequent'' pages to a maximum depth of ''''''. || || {{{inline}}} || Display TOC inline rather than as a side-bar. || || {{{titleindex}}} || Only display the page name and title of each page, similar to TitleIndex. || Note that the current page must also be specified if individual wiki pages are given in the argument list. """ implements(IWikiMacroProvider) def get_macros(self): yield 'TOC' def get_macro_description(self, name): return inspect.getdoc(self.__class__) def render_macro(self, req, name, args): db = self.env.get_db_cnx() formatter = MyOutlineFormatter(self.env) # Bail out if we are in a no-float zone if 'macro_no_float' in req.hdf: return '' # If this is a page preview, try to figure out where its from current_page = req.hdf.getValue('wiki.page_name','WikiStart') in_preview = False if not req.hdf.has_key('wiki.page_name'): if req.path_info.startswith('/wiki/'): current_page = req.path_info[6:] in_preview = True else: return '' def get_page_text(pagename): """Return a tuple of (text, exists) for a page, taking into account previews.""" if in_preview and pagename == current_page: return (req.args.get('text',''), True) else: page = WikiPage(self.env,pagename) return (page.text, page.exists) # Split the args if not args: args = '' args = [x.strip() for x in args.split(',')] # Options inline = False heading = 'Table of Contents' pagenames = [] root = '' params = { 'title_index': False, 'min_depth': 1, 'max_depth': 6 } # Global options for arg in args: if arg == 'inline': inline = True elif arg == 'noheading': heading = '' elif arg == 'notitle': params['min_depth'] = 2 # Skip page title elif arg == 'titleindex': params['title_index'] = True heading = '' elif arg == 'nofloat': return '' elif arg.startswith('heading='): heading = arg[8:] elif arg.startswith('depth='): params['max_depth'] = int(arg[6:]) elif arg.startswith('root='): root = arg[5:] elif arg != '': pagenames.append(arg) # Has the user supplied a list of pages? if not pagenames: pagenames.append(current_page) root = '' params['min_depth'] = 2 # Skip page title out = StringIO() if not inline: out.write("
\n") if heading: out.write("

%s

\n" % heading) for pagename in pagenames: if params['title_index']: li_class = pagename.startswith(current_page) and ' class="active"' or '' prefix = (pagename.split('/'))[0] prefix = prefix.replace('\'', '\'\'') all_pages = list(WikiSystem(self.env).get_pages(prefix)) if all_pages: all_pages.sort() out.write('
    ') for page in all_pages: page_text, _ = get_page_text(page) formatter.format(current_page, page, page_text, NullOut(), 1, 1) header = '' if formatter.outline: title = formatter.outline[0][1] title = re.sub('<[^>]*>','', title) # Strip all tags header = ': ' + wiki_to_oneliner(title, self.env) out.write(' %s %s\n' % (li_class, self.env.href.wiki(page), page, header)) out.write('
') else : out.write('
Error: No page matching %s found
' % prefix) else: page = root + pagename page_text, page_exists = get_page_text(page) if page_exists: formatter.format(current_page, page, page_text, out, params['min_depth'], params['max_depth']) else: out.write('
Error: Page %s does not exist
' % pagename) if not inline: out.write("
\n") return out.getvalue() PK…68cF¿õ†%†%tractoc/macro.pyo;ò "øVDc@sÓdkTdklZdklZlZlZlZdkl Z l Z dk l Z dk l Z dkZdkZdkZdkZdgZdefd „ƒYZd efd „ƒYZdefd „ƒYZdS( (s*(sescape(s FormattersOutlineFormatterswiki_to_onelinerswiki_to_outline(sIWikiMacroProviders WikiSystem(sWikiPage(sStringIONs TracTocMacrosNullOutcBstZd„ZRS(NcGsdS(N((sselfsargs((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pyswrites(s__name__s __module__swrite(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysNullOut ssMyOutlineFormattercBstZd„Zd„ZRS(Nc Csr||_g|_dtfd„ƒY} ti||| ƒƒ||jo||f\}}nt d|ƒ}t d|ƒ}|d}xÑ|iD]Æ\}} d} d|| jo d} n||jp ||joq“n||jo|id| ||ƒn<||jo|id | ||ƒn|id | ƒ|}|i| ƒq“W|id |ƒdS( NsNullOutcBstZd„ZRS(NcCsdS(N((sselfsdata((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pyswrites(s__name__s __module__swrite(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysNullOutsiiss/%ss class="active"ss
    s s
(spagesselfs_MyOutlineFormatter__pagesoutlinesobjectsNullOuts Formattersformatstexts min_depths max_depthsminsmaxs curr_depthsdepthslinksactives active_pagesoutswrite( sselfs active_pagespagestextsouts min_depths max_depths curr_depthsdepthslinksactivesNullOut((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysformats0        cCsÉti|||ƒtt|idƒƒdƒ}||dt|ƒ|d!}|i d}t ||i |i|iƒ}tidd|ƒ}|ii|d|i ii|iƒ||ffƒdS(Nshdepthiiiÿÿÿÿsss%s(s Formatters_heading_formattersselfsmatchs fullmatchsminslensgroupsdepthsheadings_anchorssanchorswiki_to_onelinersenvsdbs_absurlsstextsressubsoutlinesappendshrefswikis_MyOutlineFormatter__page(sselfsmatchs fullmatchstextsanchorsdepthsheading((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys_heading_formatter1s (s__name__s __module__sformats_heading_formatter(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysMyOutlineFormatters cBs3tZdZeeƒd„Zd„Zd„ZRS(sK Generate a table of contents for the current page or a set of pages. If no arguments are given, a table of contents is generated for the current page, with the top-level title stripped: {{{ [[TOC]] }}} To generate a table of contents for a set of pages, simply pass them as comma separated arguments to the TOC macro, e.g. as in {{{ [[TOC(TracGuide, TracInstall, TracUpgrade, TracIni, TracAdmin, TracBackup, TracLogging, TracPermissions, TracWiki, WikiFormatting, TracBrowser, TracRoadmap, TracChangeset, TracTickets, TracReports, TracQuery, TracTimeline, TracRss, TracNotification)]] }}} The following ''control'' arguments change the default behaviour of the TOC macro: || '''Argument''' || '''Meaning''' || || {{{heading=}}} || Override the default heading of "Table of Contents" || || {{{noheading}}} || Suppress display of the heading. || || {{{depth=}}} || Display headings of ''subsequent'' pages to a maximum depth of ''''''. || || {{{inline}}} || Display TOC inline rather than as a side-bar. || || {{{titleindex}}} || Only display the page name and title of each page, similar to TitleIndex. || Note that the current page must also be specified if individual wiki pages are given in the argument list. ccsdVdS(NsTOC((sself((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys get_macrosXscCsti|iƒSdS(N(sinspectsgetdocsselfs __class__(sselfsname((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysget_macro_description[sc s§ˆiiƒ}tˆiƒ}dˆijodSnˆiiddƒ‰t ‰ˆii dƒ o2ˆi idƒoˆi d‰t‰q—dSn‡‡‡‡d†}| o d}ngi}|idƒD]}||iƒƒqÕ~}t }d }g}d}hd t <d d <d d<} x|D]}|djo t}q4|djo d}q4|djod| d s

%s

s class="active"s/is's''s
    s<[^>]*>s: s# %s %s s
sS
Error: No page matching %s found
sP
Error: Page %s does not exist
s (9sselfsenvs get_db_cnxsdbsMyOutlineFormatters formattersreqshdfsgetValues current_pagesFalses in_previewshas_keys path_infos startswithsTrues get_page_textsargssappends_[1]ssplitsxsstripsinlinesheadings pagenamessrootsparamssargsintsStringIOsoutswritespagenamesli_classsprefixsreplaceslists WikiSystems get_pagess all_pagesssortspages page_texts_sformatsNullOutsheadersoutlinestitlesressubswiki_to_onelinershrefswikis page_existssgetvalue(sselfsreqsnamesargss pagenamessheadersprefixs all_pagessargsouts page_textstitlesparamssli_classs formattersdbs page_existss get_page_texts in_previewsxspagenames_s current_pagespages_[1]sinlinesrootsheading((sselfsreqs in_previews current_pages1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys render_macro^s     6!                0 ((s__name__s __module__s__doc__s implementssIWikiMacroProviders get_macrossget_macro_descriptions render_macro(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys TracTocMacro;s    (s trac.cores trac.utilsescapestrac.wiki.formatters FormattersOutlineFormatterswiki_to_onelinerswiki_to_outlines trac.wiki.apisIWikiMacroProviders WikiSystemstrac.wiki.modelsWikiPagesStringIOsossresstringsinspects__all__sobjectsNullOutsMyOutlineFormatters Components TracTocMacro(swiki_to_outlinesWikiPagesIWikiMacroProvidersStringIOs TracTocMacrosinspects__all__swiki_to_onelinersOutlineFormattersresMyOutlineFormattersescapesNullOuts Formattersoss WikiSystemsstring((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys?s   $ *PK…68êô£˜„„tractoc/__init__.pyc;ò yô1Dc@sdS(N((((s4build/bdist.darwin-8.0.1-x86/egg/tractoc/__init__.pys?sPK…68cF¿õ†%†%tractoc/macro.pyc;ò "øVDc@sÓdkTdklZdklZlZlZlZdkl Z l Z dk l Z dk l Z dkZdkZdkZdkZdgZdefd „ƒYZd efd „ƒYZdefd „ƒYZdS( (s*(sescape(s FormattersOutlineFormatterswiki_to_onelinerswiki_to_outline(sIWikiMacroProviders WikiSystem(sWikiPage(sStringIONs TracTocMacrosNullOutcBstZd„ZRS(NcGsdS(N((sselfsargs((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pyswrites(s__name__s __module__swrite(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysNullOut ssMyOutlineFormattercBstZd„Zd„ZRS(Nc Csr||_g|_dtfd„ƒY} ti||| ƒƒ||jo||f\}}nt d|ƒ}t d|ƒ}|d}xÑ|iD]Æ\}} d} d|| jo d} n||jp ||joq“n||jo|id| ||ƒn<||jo|id | ||ƒn|id | ƒ|}|i| ƒq“W|id |ƒdS( NsNullOutcBstZd„ZRS(NcCsdS(N((sselfsdata((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pyswrites(s__name__s __module__swrite(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysNullOutsiiss/%ss class="active"ss
    s s
(spagesselfs_MyOutlineFormatter__pagesoutlinesobjectsNullOuts Formattersformatstexts min_depths max_depthsminsmaxs curr_depthsdepthslinksactives active_pagesoutswrite( sselfs active_pagespagestextsouts min_depths max_depths curr_depthsdepthslinksactivesNullOut((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysformats0        cCsÉti|||ƒtt|idƒƒdƒ}||dt|ƒ|d!}|i d}t ||i |i|iƒ}tidd|ƒ}|ii|d|i ii|iƒ||ffƒdS(Nshdepthiiiÿÿÿÿsss%s(s Formatters_heading_formattersselfsmatchs fullmatchsminslensgroupsdepthsheadings_anchorssanchorswiki_to_onelinersenvsdbs_absurlsstextsressubsoutlinesappendshrefswikis_MyOutlineFormatter__page(sselfsmatchs fullmatchstextsanchorsdepthsheading((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys_heading_formatter1s (s__name__s __module__sformats_heading_formatter(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysMyOutlineFormatters cBs3tZdZeeƒd„Zd„Zd„ZRS(sK Generate a table of contents for the current page or a set of pages. If no arguments are given, a table of contents is generated for the current page, with the top-level title stripped: {{{ [[TOC]] }}} To generate a table of contents for a set of pages, simply pass them as comma separated arguments to the TOC macro, e.g. as in {{{ [[TOC(TracGuide, TracInstall, TracUpgrade, TracIni, TracAdmin, TracBackup, TracLogging, TracPermissions, TracWiki, WikiFormatting, TracBrowser, TracRoadmap, TracChangeset, TracTickets, TracReports, TracQuery, TracTimeline, TracRss, TracNotification)]] }}} The following ''control'' arguments change the default behaviour of the TOC macro: || '''Argument''' || '''Meaning''' || || {{{heading=}}} || Override the default heading of "Table of Contents" || || {{{noheading}}} || Suppress display of the heading. || || {{{depth=}}} || Display headings of ''subsequent'' pages to a maximum depth of ''''''. || || {{{inline}}} || Display TOC inline rather than as a side-bar. || || {{{titleindex}}} || Only display the page name and title of each page, similar to TitleIndex. || Note that the current page must also be specified if individual wiki pages are given in the argument list. ccsdVdS(NsTOC((sself((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys get_macrosXscCsti|iƒSdS(N(sinspectsgetdocsselfs __class__(sselfsname((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pysget_macro_description[sc s§ˆiiƒ}tˆiƒ}dˆijodSnˆiiddƒ‰t ‰ˆii dƒ o2ˆi idƒoˆi d‰t‰q—dSn‡‡‡‡d†}| o d}ngi}|idƒD]}||iƒƒqÕ~}t }d }g}d}hd t <d d <d d<} x|D]}|djo t}q4|djo d}q4|djod| d s

%s

s class="active"s/is's''s
    s<[^>]*>s: s# %s %s s
sS
Error: No page matching %s found
sP
Error: Page %s does not exist
s (9sselfsenvs get_db_cnxsdbsMyOutlineFormatters formattersreqshdfsgetValues current_pagesFalses in_previewshas_keys path_infos startswithsTrues get_page_textsargssappends_[1]ssplitsxsstripsinlinesheadings pagenamessrootsparamssargsintsStringIOsoutswritespagenamesli_classsprefixsreplaceslists WikiSystems get_pagess all_pagesssortspages page_texts_sformatsNullOutsheadersoutlinestitlesressubswiki_to_onelinershrefswikis page_existssgetvalue(sselfsreqsnamesargss pagenamessheadersprefixs all_pagessargsouts page_textstitlesparamssli_classs formattersdbs page_existss get_page_texts in_previewsxspagenames_s current_pagespages_[1]sinlinesrootsheading((sselfsreqs in_previews current_pages1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys render_macro^s     6!                0 ((s__name__s __module__s__doc__s implementssIWikiMacroProviders get_macrossget_macro_descriptions render_macro(((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys TracTocMacro;s    (s trac.cores trac.utilsescapestrac.wiki.formatters FormattersOutlineFormatterswiki_to_onelinerswiki_to_outlines trac.wiki.apisIWikiMacroProviders WikiSystemstrac.wiki.modelsWikiPagesStringIOsossresstringsinspects__all__sobjectsNullOutsMyOutlineFormatters Components TracTocMacro(swiki_to_outlinesWikiPagesIWikiMacroProvidersStringIOs TracTocMacrosinspects__all__swiki_to_onelinersOutlineFormattersresMyOutlineFormattersescapesNullOuts Formattersoss WikiSystemsstring((s1build/bdist.darwin-8.0.1-x86/egg/tractoc/macro.pys?s   $ *PK…68“×2EGG-INFO/zip-safe PK…68´MK⸸EGG-INFO/SOURCES.txtsetup.py Toc.egg-info/PKG-INFO Toc.egg-info/SOURCES.txt Toc.egg-info/dependency_links.txt Toc.egg-info/entry_points.txt Toc.egg-info/top_level.txt tractoc/__init__.py tractoc/macro.py PK…68â¿L..EGG-INFO/entry_points.txt[trac.plugins] tractoc.macro = tractoc.macro PK…68“×2EGG-INFO/dependency_links.txt PK …68¦-„ŸEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: Toc Version: 1.0 Summary: A macro to create tables of contents. Home-page: http://trac-hacks.org/ Author: Alec Thomas Author-email: UNKNOWN License: BSD Description: UNKNOWN Keywords: trac table of content macro Platform: UNKNOWN PK…68Ï:&"EGG-INFO/top_level.txttractoc PKÈ„4¤tractoc/__init__.pyPK…68êô£˜„„¤1tractoc/__init__.pyoPKw¢4èm$ß33¤çtractoc/macro.pyPK…68cF¿õ†%†%¤H tractoc/macro.pyoPK…68êô£˜„„¤ýEtractoc/__init__.pycPK…68cF¿õ†%†%¤³Ftractoc/macro.pycPK…68“×2¤hlEGG-INFO/zip-safePK…68´MK⸸¤˜lEGG-INFO/SOURCES.txtPK…68â¿L..¤‚mEGG-INFO/entry_points.txtPK…68“×2¤çmEGG-INFO/dependency_links.txtPK …68¦-„Ÿ¤#nEGG-INFO/PKG-INFOPK…68Ï:&"¤ToEGG-INFO/top_level.txtPK o