contributing to moin - a shy developer story

getting set up

weechat and screen

linode weechat doc

libera IRC chat server home page

github

setup: fork, set up github auth & clone

development process: branch, code, test, commit, push, create pull request

diving into the code

understanding moin.utils.tree

QName

svg namespace crash course

from moin.converters._tests import serialize
from emeraldtree import ElementTree as ET
from moin.utils.tree import moin_page, html, dc, mathml, svg, xinclude, xlink, docbook, xml
from xml.etree import ElementTree

def dump(el):
  namespaces = {
    moin_page : 'moin_page',
    html: 'xhtml',
    dc : 'dc',
    mathml: 'mathml',
    svg: 'svg',
    xinclude: 'xinclude',
    xlink: 'xlink',
    docbook: 'docbook',
    xml: 'xml',
  }
  root=ElementTree.fromstring(serialize(el, namespaces=namespaces))
  ElementTree.indent(root, space='    ', level=0)
  ElementTree.dump(root)

html.p == ET.QName('p', 'http://www.w3.org/1999/xhtml')

n = html.p
n.name
n.uri

el1 = ET.Element(html.p)
el2 = html.p()
el1 == el2
el1.tag == el2.tag

elp = html.p()
elp.append('hello world ')
elp.text
dump(elp)

ela = html.a()
ela.set(html.href, 'page.html')
dump(ela)

elp.append(ela)
elp.append(' more text')
dump(elp)

image src atttribute

starting with this moinwiki on /my_page:

moinwiki_in.Converter.call ->

  •    <moin_page:page>
         <moin_page:body>
           <moin_page:p>
             <xinclude:include xhtml:alt="photo" xhtml:width="80%" xinclude:href="wiki.local:/photo.jpg?" />
           </moin_page:p>
         </moin_page:body>
       </moin_page:page>

content.Content.internal_representation adds page_href to the top level element:

  •    <moin_page:page moin_page:page-href="wiki:///my_page">
         <moin_page:body>
           <moin_page:p>
             <xinclude:include xhtml:alt="photo" xhtml:width="80%" xinclude:href="wiki.local:/photo.jpg?" />
           </moin_page:p>
         </moin_page:body>
       </moin_page:page>

content._expand_document

  • \_include.Converter.call converts xinclude:include to moin_page.object with moin_page.type and xlink:href, retaining the xinclude:href
    • \_ mark_item_as_transclusion adds data_href and xhtml:class to the moin_page
  •    <moin_page:page moin_page:page-href="wiki:///my_page">
         <moin_page:p>
           <moin_page:page moin_page:page-href="wiki:///my_page/photo.jpg" xhtml:class="moin-transclusion" xhtml:data-href="/my_page/photo.jpg">
             <moin_page:body>
               <moin_page:object moin_page:type="image/jpeg" xhtml:alt="photo" xhtml:width="80%" xlink:href="wiki:///my_page/photo.jpg?do=get&amp;rev=521f309c038c4ce7b8670371ac60335b" xinclude:href="wiki.local:/photo.jpg?">my_page/photo.jpg</moin_page:object>
             </moin_page:body>
           </moin_page:page>

content._expand_document

  • \_ link.ConverterExternOutput.Converter.call
  •    <moin_page:page moin_page:page-href="wiki:///my_page" xmlns:moin_page="http://moinmo.in/namespaces/page" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xinclude="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink">
         <moin_page:body>
           <moin_page:p><moin_page:page moin_page:page-href="wiki:///my_page/photo.jpg" xhtml:class="moin-transclusion" xhtml:data-href="/my_page/photo.jpg"><moin_page:body><moin_page:object moin_page:type="image/jpeg" xhtml:alt="photo" xhtml:width="80%" xlink:href="/+get/+521f309c038c4ce7b8670371ac60335b/my_page/photo.jpg" xinclude:href="wiki.local:/photo.jpg?">my_page/photo.jpg</moin_page:object></moin_page:body></moin_page:page></moin_page:p><moin_page:div xhtml:class="moin-transclusion" xhtml:data-href="/my_page/a.tar"><moin_page:table moin_page:class="zebra"><moin_page:table-header><moin_page:table-row><moin_page:table-cell moin_page:class="moin-integer">Size</moin_page:table-cell><moin_page:table-cell>Timestamp</moin_page:table-cell><moin_page:table-cell>Name</moin_page:table-cell></moin_page:table-row></moin_page:table-header><moin_page:table-body><moin_page:table-row><moin_page:table-cell moin_page:class="moin-integer">538397</moin_page:table-cell><moin_page:table-cell>2023-01-31 13:30:25</moin_page:table-cell><moin_page:table-cell><moin_page:a xlink:href="/+get/my_page/a.tar?member=pps/GPS_Visualizer_Atlas.mhtml">pps/GPS_Visualizer_Atlas.mhtml</moin_page:a></moin_page:table-cell></moin_page:table-row><moin_page:table-row><moin_page:table-cell moin_page:class="moin-integer">23270</moin_page:table-cell><moin_page:table-cell>2023-01-31 13:43:39</moin_page:table-cell><moin_page:table-cell><moin_page:a xlink:href="/+get/my_page/a.tar?member=pps/map">pps/map</moin_page:a></moin_page:table-cell></moin_page:table-row></moin_page:table-body></moin_page:table></moin_page:div></moin_page:body></moin_page:page>