# HG changeset patch # User Paul Boddie # Date 1368824911 -7200 # Node ID 8bf0bbc9c1790be45472d1c9d73b42744a7933ec # Parent d3c11f5d39523abcc644a04106009082603c5b88 Removed the specific MoinShare parser: the "moinshare" attribute is supposed to be used on generic regions instead. diff -r d3c11f5d3952 -r 8bf0bbc9c179 parsers/MoinShare.py --- a/parsers/MoinShare.py Fri May 17 23:07:09 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -# -*- coding: iso-8859-1 -*- -""" - MoinMoin - MoinShare fragment parser - - @copyright: 2011, 2012, 2013 by Paul Boddie - @license: GNU GPL (v2 or later), see COPYING.txt for details. -""" - -from MoinSupport import parseAttributes, getParserClass, formatText -from MoinMoin import wikiutil - -try: - from hashlib import sha1 -except ImportError: - from sha import new as sha1 - -Dependencies = ["pages"] - -# Parser support. - -class Parser: - - """ - Format shared content fragments of the form... - - {{{#!MoinShare fragment=fragment-id ref=ref-fragment-id format=content-format - - Content... - }}} - """ - - def __init__(self, raw, request, **kw): - - """ - Initialise the parser with the given 'raw' data, 'request' and any - keyword arguments that may have been supplied. - """ - - self.raw = raw - self.request = request - - attrs = parseAttributes(request, False) - - # Get any reference to this fragment, another fragment and the content - # format. - - self.fragment = attrs.get("fragment", '') - self.ref = attrs.get("ref", '') - self.format_type = attrs.get("format", '') - - def getDigest(self): - - "Make a message digest for the fragment's content." - - return sha1(self.raw).hexdigest() - - def format(self, fmt): - - "Format a fragment using the given formatter 'fmt'." - - request = self.request - - if self.fragment: - request.write(fmt.anchordef(self.fragment)) - - request.write(fmt.div(1, css_class="moinsharefragment")) - request.write(self.formatText(self.raw, fmt)) - request.write(fmt.div(0)) - - def getFormat(self): - - "Get the format used on this page." - - return self.format_type - - def formatText(self, text, fmt): - - """ - Format the given 'text' using the specified formatter 'fmt'. - """ - - request = self.request - format = self.getFormat() - - return formatText(text, request, fmt, inhibit_p=True, parser_cls=getParserClass(request, format)) - -# vim: tabstop=4 expandtab shiftwidth=4