comparison MoinMoin/script/migration/_conv160a_wiki.py @ 4489:a835ada897e0

1.6.0a mig script/converter: fix interwiki tests, cleanup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 16 Jan 2009 01:42:02 +0100
parents a2a05ae3e7ec
children b120d9978144
comparison
equal deleted inserted replaced
4488:a2a05ae3e7ec 4489:a835ada897e0
273 return self.interwiki("wiki:" + word) 273 return self.interwiki("wiki:" + word)
274 274
275 def interwiki(self, target_and_text, **kw): 275 def interwiki(self, target_and_text, **kw):
276 scheme, rest = target_and_text.split(':', 1) 276 scheme, rest = target_and_text.split(':', 1)
277 wikiname, pagename, text = wikiutil160a.split_wiki(rest) 277 wikiname, pagename, text = wikiutil160a.split_wiki(rest)
278 if text: 278
279 text = '|' + text 279 #if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
280 280 # Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text]
281 if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text] 281 # # XXX OtherWiki:FooPage markup -> checks for local FooPage -sense???
282 Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text] 282 # pagename = wikiutil.url_unquote(pagename)
283 pagename = wikiutil.url_unquote(pagename) 283 # pagename = self._replace_target(pagename)
284 pagename = self._replace_target(pagename) 284 # return '[[%s%s]]' % (pagename, text)
285 return '[[%s%s]]' % (pagename, text)
286 285
287 if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text] 286 if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
287 orig_pagename = pagename
288 pagename = wikiutil.url_unquote(pagename) 288 pagename = wikiutil.url_unquote(pagename)
289 pagename = self._replace_target(pagename) 289 pagename = self._replace_target(pagename)
290 camelcase = wikiutil.isStrictWikiname(pagename) 290 camelcase = wikiutil.isStrictWikiname(pagename)
291 if camelcase and text == pagename: 291 if camelcase and (not text or text == orig_pagename):
292 return '%s' % pagename # optimize special case 292 return pagename # optimize special case
293 else: 293 else:
294 if text:
295 text = '|' + text
294 return '[[%s%s]]' % (pagename, text) 296 return '[[%s%s]]' % (pagename, text)
295 297
296 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, wikiname+':') 298 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, wikiname+':')
297 if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that! 299 if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that!
298 pagename = wikiutil.url_unquote(pagename) 300 pagename = wikiutil.url_unquote(pagename)
306 return '{{%s:%s%s}}' % (wikitag, wikitail, text) 308 return '{{%s:%s%s}}' % (wikitag, wikitail, text)
307 else: 309 else:
308 if ' ' not in wikitail and not text: 310 if ' ' not in wikitail and not text:
309 return '%s:%s' % (wikitag, wikitail) 311 return '%s:%s' % (wikitag, wikitail)
310 else: 312 else:
313 if text:
314 text = '|' + text
311 return '[[%s:%s%s]]' % (wikitag, wikitail, text) 315 return '[[%s:%s%s]]' % (wikitag, wikitail, text)
312 316
313 def attachment(self, target_and_text, **kw): 317 def attachment(self, target_and_text, **kw):
314 """ This gets called on attachment URLs """ 318 """ This gets called on attachment URLs """
315 _ = self._ 319 _ = self._