Changeset 3145 for trac/plugins


Ignore:
Timestamp:
01/12/07 15:44:56 (6 years ago)
Author:
moschny
Message:
  • Make the plugin compatible with Trac's current trunk (i.e. the upcoming 0.11 version):
    • IWikiMacroProvider interface change: The render_macro() method now gets a Formatter object instead of a Request.
    • Objects of type Formatter (or descendants thereof) are constructed with a single argument of type Context.
  • Update the copyright notices.
  • Bump the revision number to 4.0preX.
Location:
trac/plugins/tracnav-0.11
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trac/plugins/tracnav-0.11/README

    r3090 r3145  
    6666------------------- 
    6767 
    68 Copyright 2005, 2006 
    69 - Bernhard Haumacher (haui at haumacher.de) 
    70 - Thomas Moschny (moschny at ipd.uni-karlsruhe.de) 
     68Copyright 2005-2006, Bernhard Haumacher (haui at haumacher.de) 
     69Copyright 2005-2007, Thomas Moschny (moschny at ipd.uni-karlsruhe.de) 
    7170 
    7271This program is free software; you can redistribute it and/or modify 
  • trac/plugins/tracnav-0.11/tracnav/__init__.py

    r3142 r3145  
    1 __version__ = '3.92pre7' 
     1__version__ = '4.0pre1' 
  • trac/plugins/tracnav-0.11/tracnav/tracnav.py

    r3142 r3145  
    3434== Author and License == 
    3535 
    36 Copyright 2005, 2006 
    37  *  Bernhard Haumacher (haui at haumacher.de) 
    38  *  Thomas Moschny (moschny at ipd.uni-karlsruhe.de) 
     36 * Copyright 2005-2006, Bernhard Haumacher (haui at haumacher.de) 
     37 * Copyright 2005-2007, Thomas Moschny (moschny at ipd.uni-karlsruhe.de) 
    3938 
    4039{{{ 
     
    7776    last wiki link. 
    7877    """ 
     78    def __init__(self, context): 
     79        OneLinerFormatter.__init__(self, context) 
     80        self.lastlink = None 
     81 
    7982    def format_toc(self, wikitext): 
    80         self.link = None 
     83        self.lastlink = None 
    8184        out = StringIO() 
    8285        OneLinerFormatter.format(self, wikitext, out) 
    83         return out.getvalue(), self.link 
    84  
    85     def __init__(self, env, req = None): 
    86         OneLinerFormatter.__init__(self, env) 
    87         # OneLinerFormatter sets req to None 
    88         self.req = req 
    89         self.link = None 
     86        return out.getvalue(), self.lastlink 
    9087 
    9188    def _make_link(self, namespace, target, match, label): 
    9289        if namespace == 'wiki': 
    93             self.link = target 
     90            self.lastlink = target 
    9491        return OneLinerFormatter._make_link( 
    9592            self, namespace, target, match, label) 
     
    9794    def _macro_formatter(self, match, fullmatch): 
    9895        name = fullmatch.group('macroname').lower() 
    99         if name == 'br': 
    100             return ' ' 
    101         elif name in ALLOWED_MACROS: 
     96        if name in ALLOWED_MACROS: 
    10297            # leapfrog the OneLinerFormatter 
    10398            return Formatter._macro_formatter(self, match, fullmatch) 
    10499        else: 
    105             return '' 
     100            # use the OneLinerFormatter 
     101            return OneLinerFormatter._macro_formatter(self, match, fullmatch) 
    106102 
    107103    # FIXME: what about _make_relative_link() ? 
     
    111107class Invocation(object): 
    112108 
    113     def __init__(self, env, req, args, out): 
    114  
    115         #save for later use 
    116         self.env = env 
    117         self.req = req 
     109    def __init__(self, formatter, args, out): 
     110 
     111        # save for later use 
     112        self.formatter = formatter 
     113 
     114        # shortcuts 
     115        self.env = formatter.env 
     116        self.req = formatter.req 
     117 
     118        # output 
    118119        self.out = out 
    119120        self.col = 0 
    120121         
    121         #needed several times 
    122         self.preview = req.args.get('preview', '') 
    123         self.curpage = req.args.get('page', 'WikiStart') 
    124         self.modify = req.perm.has_permission('WIKI_MODIFY') 
     122        # needed several times 
     123        self.preview = self.req.args.get('preview', '') 
     124        self.curpage = self.req.args.get('page', 'WikiStart') 
     125        self.modify = self.req.perm.has_permission('WIKI_MODIFY') 
    125126 
    126127        # parse arguments 
     
    149150        Parse and format the entries in toc_text. 
    150151        """ 
    151         formatter = TocFormatter(self.env, self.req) 
     152        formatter = TocFormatter(self.formatter.context) 
    152153        for match in LISTRULE.finditer(toc_text): 
    153154            indent = len(match.group('indent')) 
     
    298299        yield 'JPNav' # legacy 
    299300 
    300     def render_macro(self, req, name, args): 
     301    def render_macro(self, formatter, name, args): 
    301302        out = StringIO() 
    302         Invocation(self.env, req, args, out).run() 
     303        Invocation(formatter, args, out).run() 
    303304        return out.getvalue() 
    304305 
Note: See TracChangeset for help on using the changeset viewer.