contributing to moin - a shy developer story
getting set up
weechat and screen
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
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:
{{../my_page/photo.jpg|photo|width=80%}}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:../my_page/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_simple_page">
<moin_page:body>
<moin_page:p>
<xinclude:include xhtml:alt="photo" xhtml:width="80%" xinclude:href="wiki.local:../my_page/photo.jpg?" />
</moin_page:p>
</moin_page:body>
</moin_page:page>content._expand_document -> include.Converter.call
first it converts xinclude:include to:
<moin_page:page moin_page:page-href="wiki:///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&rev=521f309c038c4ce7b8670371ac60335b" xinclude:href="wiki.local:../my_page/photo.jpg?">my_page/photo.jpg</moin_page:object>
</moin_page:body>
</moin_page:page>then it calls mark_item_as_transclusion adding the data-href
<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&rev=521f309c038c4ce7b8670371ac60335b" xinclude:href="wiki.local:../my_page/photo.jpg?">my_page/photo.jpg</moin_page:object>
</moin_page:body>
</moin_page:page>after this the full xml is
<moin_page:page moin_page:page-href="wiki:///my_simple_page">
<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="wiki:///my_page/photo.jpg?do=get&rev=521f309c038c4ce7b8670371ac60335b" xinclude:href="wiki.local:../my_page/photo.jpg?">my_page/photo.jpg</moin_page:object>
</moin_page:body>
</moin_page:page>
</moin_page:p>
</moin_page:body>
</moin_page:page>content._expand_document
- \_ link.ConverterExternOutput.Converter.call
link.ConverterExternOutput.Converter._get_do_rev coverts the wiki:///my_page/photo.jpg?do=get&rev=521f309c038c4ce7b8670371ac60335b to (endpoint, rev, query) = ('frontend.get_item', '521f309c038c4ce7b8670371ac60335b', None)
then moin.utils.interwiki.url_for_item calls flask.helpers.url_for which generates the external url (presumably the wiki_root is added here)
<moin_page:page moin_page:page-href="wiki:///my_simple_page">
<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:../my_page/photo.jpg?">my_page/photo.jpg</moin_page:object>
</moin_page:body>
</moin_page:page>
</moin_page:p>
</moin_page:body>
</moin_page:page>then html_out.ConverterPage.call transforms to html
<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:p>
<xhtml:span xhtml:class="moin-transclusion" xhtml:data-href="/my_page/photo.jpg">
<xhtml:img xhtml:alt="photo" xhtml:src="/+get/+521f309c038c4ce7b8670371ac60335b/my_page/photo.jpg" xhtml:width="80%" />
</xhtml:span>
</xhtml:p>
</xhtml:div>