Here is an idea of IncludeSourceMacro porting to 0.12 :

from genshi.core import Markup

from import WikiMacroBase
from trac.versioncontrol import RepositoryManager

class IncludeSourceMacro(WikiMacroBase):
    """Include source from mean SVN repository.

    Syntaxe :

    Supports formatings :
     * Textile

    TODO :
     * Supports HTML
     * Supports repository specification
     * Supports revision giving

    revision = "$Rev$"
    url = "$URL$"

    def expand_macro(self, formatter, name, text, args):
        """Return some output that will be displayed in the Wiki content.
    if text == None:
        return "No source provided"

    repo = RepositoryManager(self.env).get_repository(None)
    node = repo.get_node(text)
    content = node.get_content().read()
    mime = node.get_content_type()
    if mime == "text/textile" or".textile"):
        import textile
        content = textile.textile(content.encode('utf-8'), encoding='utf-8')

        return content

Last modified 5 years ago Last modified on Oct 3, 2011, 8:19:16 PM