comparison MoinMoin/formatter/text_html.py @ 101:2202f548cbb0

use own urllib wrapper, see wikiutil imported from: moin--main--1.5--patch-103
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 15 Oct 2005 16:56:39 +0000
parents 1cfa2e49377e
children 67f71c7a8c43
comparison
equal deleted inserted replaced
100:9aa2836c997b 101:2202f548cbb0
3 MoinMoin - "text/html+css" Formatter 3 MoinMoin - "text/html+css" Formatter
4 4
5 @copyright: 2000 - 2004 by Jürgen Hermann <jh@web.de> 5 @copyright: 2000 - 2004 by Jürgen Hermann <jh@web.de>
6 @license: GNU GPL, see COPYING for details. 6 @license: GNU GPL, see COPYING for details.
7 """ 7 """
8 import os.path, urllib, re 8 import os.path, re
9 from MoinMoin.formatter.base import FormatterBase 9 from MoinMoin.formatter.base import FormatterBase
10 from MoinMoin import wikiutil, i18n, config 10 from MoinMoin import wikiutil, i18n, config
11 from MoinMoin.Page import Page 11 from MoinMoin.Page import Page
12 from MoinMoin.action import AttachFile 12 from MoinMoin.action import AttachFile
13 13
240 if not on: 240 if not on:
241 return '</a>' 241 return '</a>'
242 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:%s' % (interwiki, pagename)) 242 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:%s' % (interwiki, pagename))
243 wikiurl = wikiutil.mapURL(self.request, wikiurl) 243 wikiurl = wikiutil.mapURL(self.request, wikiurl)
244 if wikitag == 'Self': # for own wiki, do simple links 244 if wikitag == 'Self': # for own wiki, do simple links
245 import urllib
246 if wikitail.find('#') > -1: 245 if wikitail.find('#') > -1:
247 wikitail, kw['anchor'] = wikitail.split('#', 1) 246 wikitail, kw['anchor'] = wikitail.split('#', 1)
248 wikitail = urllib.unquote(wikitail) 247 wikitail = wikiutil.url_unquote(wikitail, want_unicode=False)
249 try: # XXX this is the only place where we access self.page - do we need it? Crashes silently on actions! 248 try: # XXX this is the only place where we access self.page - do we need it? Crashes silently on actions!
250 return apply(self.pagelink, (on, wikiutil.AbsPageName(self.request, self.page.page_name, wikitail)), kw) 249 return apply(self.pagelink, (on, wikiutil.AbsPageName(self.request, self.page.page_name, wikitail)), kw)
251 except: 250 except:
252 return apply(self.pagelink, (on, wikitail), kw) 251 return apply(self.pagelink, (on, wikitail), kw)
253 else: # return InterWiki hyperlink 252 else: # return InterWiki hyperlink
309 linktext = _('Upload new attachment "%(filename)s"') 308 linktext = _('Upload new attachment "%(filename)s"')
310 return wikiutil.link_tag( 309 return wikiutil.link_tag(
311 self.request, 310 self.request,
312 self.text('%s?action=AttachFile&rename=%s' % 311 self.text('%s?action=AttachFile&rename=%s' %
313 (wikiutil.quoteWikinameURL(pagename), 312 (wikiutil.quoteWikinameURL(pagename),
314 urllib.quote_plus(fname.encode(config.charset)))), 313 wikiutil.url_quote_plus(fname))),
315 linktext % {'filename': self.text(fname)}) 314 linktext % {'filename': self.text(fname)})
316 target = AttachFile.getAttachUrl(pagename, url, self.request) 315 target = AttachFile.getAttachUrl(pagename, url, self.request)
317 return (self.url(1, target, title="attachment:%s" % url) + 316 return (self.url(1, target, title="attachment:%s" % url) +
318 self.text(text) + 317 self.text(text) +
319 self.url(0)) 318 self.url(0))
327 linktext = _('Upload new attachment "%(filename)s"') 326 linktext = _('Upload new attachment "%(filename)s"')
328 return wikiutil.link_tag( 327 return wikiutil.link_tag(
329 self.request, 328 self.request,
330 self.text('%s?action=AttachFile&rename=%s' % 329 self.text('%s?action=AttachFile&rename=%s' %
331 (wikiutil.quoteWikinameURL(pagename), 330 (wikiutil.quoteWikinameURL(pagename),
332 urllib.quote_plus(fname.encode(config.charset)))), 331 wikiutil.url_quote_plus(fname))),
333 linktext % {'filename': self.text(fname)}) 332 linktext % {'filename': self.text(fname)})
334 return self.image( 333 return self.image(
335 title="attachment:%s" % url, 334 title="attachment:%s" % url,
336 src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1)) 335 src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1))
337 336
355 if not os.path.exists(fpath): 354 if not os.path.exists(fpath):
356 linktext = _('Create new drawing "%(filename)s"') 355 linktext = _('Create new drawing "%(filename)s"')
357 return wikiutil.link_tag(self.request, 356 return wikiutil.link_tag(self.request,
358 self.text('%s?action=AttachFile&rename=%s%s' % ( 357 self.text('%s?action=AttachFile&rename=%s%s' % (
359 wikiutil.quoteWikinameURL(pagename), 358 wikiutil.quoteWikinameURL(pagename),
360 urllib.quote_plus(fname.encode(config.charset)), 359 wikiutil.url_quote_plus(fname),
361 drawing and ('&drawing=%s' % urllib.quote(drawing.encode(config.charset))) or '')), 360 drawing and ('&drawing=%s' % wikiutil.url_quote(drawing)) or '')),
362 linktext % {'filename': self.text(fname)}) 361 linktext % {'filename': self.text(fname)})
363 362
364 mappath = AttachFile.getFilename(self.request, pagename, drawing + '.map') 363 mappath = AttachFile.getFilename(self.request, pagename, drawing + '.map')
365 edit_link = self.text('%s?action=AttachFile&rename=%s&drawing=%s' % (wikiutil.quoteWikinameURL(pagename), urllib.quote_plus(fname.encode(config.charset)), urllib.quote(drawing.encode(config.charset)))) 364 edit_link = self.text('%s?action=AttachFile&rename=%s&drawing=%s' % (
365 wikiutil.quoteWikinameURL(pagename),
366 wikiutil.url_quote_plus(fname),
367 wikiutil.url_quote(drawing)))
366 368
367 # check for map file 369 # check for map file
368 if os.path.exists(mappath): 370 if os.path.exists(mappath):
369 # we have a image map. inline it and add a map ref 371 # we have a image map. inline it and add a map ref
370 # to the img tag 372 # to the img tag