changeset 2713:ddb2d19684d7

add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 23 Aug 2007 10:29:42 +0200
parents 92fdea43e06e
children eb37036e3350 907b9e60c232 3d776db594ed
files MoinMoin/formatter/__init__.py MoinMoin/formatter/dom_xml.py MoinMoin/formatter/pagelinks.py MoinMoin/formatter/text_docbook.py MoinMoin/formatter/text_html.py MoinMoin/formatter/text_plain.py MoinMoin/formatter/text_xml.py
diffstat 7 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/formatter/__init__.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/__init__.py	Thu Aug 23 10:29:42 2007 +0200
@@ -171,6 +171,12 @@
             return '[Image:%s]' % title
         return '[Image]'
 
+    # generic transclude/include:
+    def transclusion(self, on, **kw):
+        raise NotImplementedError
+    def transclusion_param(self, **kw):
+        raise NotImplementedError
+
     def smiley(self, text):
         return text
 
--- a/MoinMoin/formatter/dom_xml.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/dom_xml.py	Thu Aug 23 10:29:42 2007 +0200
@@ -357,6 +357,12 @@
             kw['src'] = src
         return self._add_tag('img', **kw)
 
+    def transclusion(self, on, **kw):
+        return self._set_tag('object', on, **kw)
+
+    def transclusion_param(self, **kw):
+        return self._add_tag('param', **kw)
+
     def escapedText(self, text, **kw):
         return wikiutil.escape(text)
 
--- a/MoinMoin/formatter/pagelinks.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/pagelinks.py	Thu Aug 23 10:29:42 2007 +0200
@@ -27,4 +27,5 @@
     number_list = bullet_list = listitem = definition_list = null
     definition_term = definition_desc = heading = table = null
     table_row = table_cell = attachment_link = attachment_image = attachment_drawing = null
+    transclusion = transclusion_param = null
 
--- a/MoinMoin/formatter/text_docbook.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/text_docbook.py	Thu Aug 23 10:29:42 2007 +0200
@@ -470,6 +470,14 @@
         self.cur.appendChild(media)
         return ""
 
+    def transclusion(self, on, **kw):
+        # TODO, see text_html formatter
+        return ""
+
+    def transclusion_param(self, **kw):
+        # TODO, see text_html formatter
+        return ""
+
     def smiley(self, text):
         return self.request.theme.make_icon(text)
 
--- a/MoinMoin/formatter/text_html.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/text_html.py	Thu Aug 23 10:29:42 2007 +0200
@@ -1042,6 +1042,8 @@
             return self._open('hr', newline=1, attr={'class': 'hr%d' % size}, **kw)
         return self._open('hr', newline=1, **kw)
 
+    # Images / Transclusion ##############################################
+
     def icon(self, type):
         return self.request.theme.make_icon(type)
 
@@ -1056,6 +1058,24 @@
             kw['src'] = src
         return self._open('img', **kw)
 
+    def transclusion(self, on, **kw):
+        """Transcludes (includes/embeds) another object."""
+        if on:
+            return self._open('object',
+                              allowed_attrs=['archive', 'classid', 'codebase',
+                                             'codetype', 'data', 'declare',
+                                             'height', 'name', 'standby',
+                                             'type', 'width', ],
+                              **kw)
+        else:
+            return self._close('object')
+
+    def transclusion_param(self, **kw):
+        """Give a parameter to a transcluded object."""
+        return self._open('param',
+                          allowed_attrs=['name', 'type', 'value', 'valuetype', ],
+                          **kw)
+
     # Lists ##############################################################
 
     def number_list(self, on, type=None, start=None, **kw):
--- a/MoinMoin/formatter/text_plain.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/text_plain.py	Thu Aug 23 10:29:42 2007 +0200
@@ -250,6 +250,12 @@
                 return kw[a]
         return u''
 
+    def transclusion(self, on, **kw):
+        return u''
+
+    def transclusion_param(self, **kw):
+        return u''
+
     def lang(self, on, lang_name):
         return ''
 
--- a/MoinMoin/formatter/text_xml.py	Wed Aug 22 12:38:14 2007 +0200
+++ b/MoinMoin/formatter/text_xml.py	Thu Aug 23 10:29:42 2007 +0200
@@ -213,6 +213,14 @@
                 attrs[key] = value
         return FormatterBase.image(self, **attrs) + '</img>'
 
+    def transclusion(self, on, **kw):
+        # TODO, see text_html formatter
+        return ''
+
+    def transclusion_param(self, **kw):
+        # TODO, see text_html formatter
+        return ''
+
     def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1):
         return ('<codearea id="%s">' % code_id, '</codearea')[not on]