changeset 1318:013de4f3dc4b

transclusion cleanup - change html.div > moin_page.div; remove unused import html; delete unwanted comment
author Roger Haase <crosseyedpenguin@yahoo.com>
date Fri, 30 Mar 2012 12:16:17 -0700
parents 7ca1cab62e38
children 97398f9a6324
files MoinMoin/converter/_tests/test_include.py MoinMoin/converter/include.py MoinMoin/converter/link.py
diffstat 3 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/_tests/test_include.py	Mon Mar 26 21:22:52 2012 +0200
+++ b/MoinMoin/converter/_tests/test_include.py	Fri Mar 30 12:16:17 2012 -0700
@@ -101,7 +101,6 @@
         update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki'}, u"Single Line")
         rendered = MoinWiki.create(u'page1')._render_data()
         assert '<p>Content of page2 is</p><p><span class="moin-transclusion" data-href="/page2">Single Line</span></p>' in rendered
-        #           '<p>Content of page2 is</p><p><span class="moin-transclusion" data-href="http://127.0.0.1:8080/page2">Single Line</span></p>'
 
         update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'Content of page2 is "{{page2}}"')
         update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki'}, u"|| table || cell ||")
--- a/MoinMoin/converter/include.py	Mon Mar 26 21:22:52 2012 +0200
+++ b/MoinMoin/converter/include.py	Fri Mar 30 12:16:17 2012 -0700
@@ -29,7 +29,7 @@
 from MoinMoin.items import Item
 from MoinMoin.util.mime import type_moin_document
 from MoinMoin.util.iri import Iri, IriPath
-from MoinMoin.util.tree import html, moin_page, xinclude, xlink
+from MoinMoin.util.tree import moin_page, xinclude, xlink
 
 from MoinMoin.converter.html_out import mark_item_as_transclusion, Attributes
 
@@ -233,8 +233,8 @@
                         loop = self.stack[self.stack.index(p_href):]
                         loop = [u'{0}'.format(ref.path[1:]) for ref in loop if ref is not None] + [page.name]
                         msg = u'Error: Transclusion loop via: ' + u', '.join(loop)
-                        attrib = {getattr(html, 'class'): 'moin-error'}
-                        strong = ET.Element(html.strong, attrib, (msg, ))
+                        attrib = {getattr(moin_page, 'class'): 'moin-error'}
+                        strong = ET.Element(moin_page.strong, attrib, (msg, ))
                         included_elements.append(strong)
                         continue
                     # TODO: Is this correct?
@@ -302,7 +302,7 @@
                                 # get attributes from page node; we expect {class: "moin-transclusion"; data-href: "http://some.org/somepage"}
                                 attrib = Attributes(ret).convert()
                                 # make new span node and "convert" p to span by copying all of p's children
-                                span = ET.Element(html.span, attrib=attrib, children=p[:])
+                                span = ET.Element(moin_page.span, attrib=attrib, children=p[:])
                                 # insert the new span into the DOM replacing old include, page, body, and p elements
                                 elem[i] = span
                             elif not isinstance(body, unicode) and ret.tag.name == 'page' and body.tag.name == 'body':
@@ -310,19 +310,19 @@
                                 # note: ancestor P may have text before or after include
                                 if i > 0:
                                     # there is text before transclude, make new p node to hold text before include and save in container
-                                    pa = ET.Element(html.p)
+                                    pa = ET.Element(moin_page.p)
                                     pa[:] = elem[0:i]
                                     container.append(pa)
                                 # get attributes from page node; we expect {class: "moin-transclusion"; data-href: "http://some.org/somepage"}
                                 attrib = Attributes(ret).convert()
                                 # make new div node, copy all of body's children, and save in container
-                                div = ET.Element(html.div, attrib=attrib, children=body[:])
+                                div = ET.Element(moin_page.div, attrib=attrib, children=body[:])
                                 container.append(div)
                                  # empty elem of siblings that were just placed in container
                                 elem[0:i+1] = []
                                 if len(elem) > 0:
                                     # there is text after transclude, make new p node to hold text, copy siblings, save in container
-                                    pa = ET.Element(html.p)
+                                    pa = ET.Element(moin_page.p)
                                     pa[:] = elem[:]
                                     container.append(pa)
                                     elem[:] = []
--- a/MoinMoin/converter/link.py	Mon Mar 26 21:22:52 2012 +0200
+++ b/MoinMoin/converter/link.py	Fri Mar 30 12:16:17 2012 -0700
@@ -16,7 +16,7 @@
 from MoinMoin.util.interwiki import is_known_wiki, url_for_item
 from MoinMoin.util.iri import Iri, IriPath
 from MoinMoin.util.mime import Type, type_moin_document
-from MoinMoin.util.tree import html, moin_page, xlink, xinclude
+from MoinMoin.util.tree import moin_page, xlink, xinclude
 from MoinMoin.wikiutil import AbsItemName
 
 
@@ -63,7 +63,7 @@
             elif xlink_href.scheme == 'wiki':
                 self.handle_wiki_links(elem, xlink_href)
             elif xlink_href.scheme:
-                elem.set(html.class_, 'moin-' + xlink_href.scheme)
+                elem.set(moin_page.class_, 'moin-' + xlink_href.scheme)
 
         elif xinclude_href:
             xinclude_href = Iri(xinclude_href)
@@ -152,7 +152,7 @@
             wn = unicode(input.authority.host)
             if is_known_wiki(wn):
                 # interwiki link
-                elem.set(html.class_, 'moin-interwiki')
+                elem.set(moin_page.class_, 'moin-interwiki')
                 wiki_name = wn
         item_name = unicode(input.path[1:])
         endpoint, rev, query = self._get_do_rev(input.query)
@@ -167,7 +167,7 @@
             path = self.absolute_path(path, page.path)
             item_name = unicode(path)
             if not flaskg.storage.has_item(item_name):
-                elem.set(html.class_, 'moin-nonexistent')
+                elem.set(moin_page.class_, 'moin-nonexistent')
         else:
             item_name = unicode(page.path[1:])
         endpoint, rev, query = self._get_do_rev(input.query)