# HG changeset patch # User Paul Boddie # Date 1370864729 -7200 # Node ID 4a10cbd14a491bc903e2e3607f004067acc1a931 # Parent 589001c9539edb37d32f29c16c708a160735f3eb Introduced page title truncation in links in order to find translated pages. diff -r 589001c9539e -r 4a10cbd14a49 TO_DO.txt --- a/TO_DO.txt Mon Jun 10 13:20:27 2013 +0200 +++ b/TO_DO.txt Mon Jun 10 13:45:29 2013 +0200 @@ -4,15 +4,6 @@ that would cause conflicts in the generated Moin markup should be translated with spaces separating them -DOC/How do I turn off HTML messages/attachments? (4030675) - - Link targets need shortening for long page names: - 4.22 Messages that are translated from HTML to plain text are empty or have a body like ""-root-8e8Ta4- Permission denied" - -DOC/Where do I go for help? (4816921) - - XHTML: need to combine ac:anchor with ri:content-title to produce a complete link - Handle page renaming (add redirects, perhaps support comments on old revisions): DOC/Making Sure Your Lists Are Private (10715350) renamed from diff -r 589001c9539e -r 4a10cbd14a49 wikiparser.py --- a/wikiparser.py Mon Jun 10 13:20:27 2013 +0200 +++ b/wikiparser.py Mon Jun 10 13:45:29 2013 +0200 @@ -430,6 +430,7 @@ prefix = "" space, rest = target.split(":", 1) if space not in URL_SCHEMES: + rest = get_page_title(rest) target = "%s/%s" % (space, rest) # Detect anchors. @@ -452,6 +453,8 @@ if not label: label = target + target = get_page_title(target) + if not label and not title: return "[[%s%s]]" % (prefix, target) elif not title: diff -r 589001c9539e -r 4a10cbd14a49 xmlparser.py --- a/xmlparser.py Mon Jun 10 13:20:27 2013 +0200 +++ b/xmlparser.py Mon Jun 10 13:45:29 2013 +0200 @@ -282,12 +282,23 @@ for attrname in link_target_tags[name]: attrvalue = self.attributes[-1].get(attrname) if attrvalue: + + # Obtain a link label. + + if attrname in link_label_attributes and not self.label: + self.label = attrvalue + + # Validate any page title. + + if attrname == "ri:content-title": + attrvalue = get_page_title(attrvalue) target_details.append(attrvalue) + + # Insert any prefix required for the link. + prefix = link_target_prefixes.get(attrname) if prefix: target_details.insert(0, prefix) - if attrname in link_label_attributes and not self.label: - self.label = attrvalue # Make a link based on the details.