Mercurial > moin > 1.9
changeset 3054:d2e9afd64276
get formatters in sync with 1.6 cs 2558:3e3a549b49f0, add attachimg icon (needed by html formatter)
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 20 Feb 2008 10:23:56 +0100 |
parents | 067a87029064 |
children | 29d236eb2ab7 |
files | MoinMoin/formatter/__init__.py MoinMoin/formatter/text_html.py MoinMoin/formatter/text_python.py MoinMoin/theme/__init__.py wiki/htdocs/classic/img/attach.png wiki/htdocs/modern/img/attach.png wiki/htdocs/rightsidebar/img/attach.png |
diffstat | 7 files changed, 44 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/formatter/__init__.py Wed Feb 20 01:14:06 2008 +0100 +++ b/MoinMoin/formatter/__init__.py Wed Feb 20 10:23:56 2008 +0100 @@ -8,6 +8,7 @@ @license: GNU GPL, see COPYING for details. """ import re +import logging from MoinMoin.util import pysupport from MoinMoin import wikiutil @@ -333,10 +334,16 @@ """ # attention: this is copied into text_python! parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", parser_name) - - args = self._get_bang_args(lines[0]) - if args is not None: + args = None + if lines: + args = self._get_bang_args(lines[0]) + #logging.debug("formatter.parser: parser args %r" % args) + if args is not None: + lines = lines[1:] + if lines and not lines[0]: lines = lines[1:] + if lines and not lines[-1].strip(): + lines = lines[:-1] p = parser('\n'.join(lines), self.request, format_args=args) p.format(self) del p
--- a/MoinMoin/formatter/text_html.py Wed Feb 20 01:14:06 2008 +0100 +++ b/MoinMoin/formatter/text_html.py Wed Feb 20 10:23:56 2008 +0100 @@ -481,6 +481,7 @@ """ @keyword title: override using the interwiki wikiname as title """ + querystr = kw.get('querystr', {}) wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwiki, pagename) wikiurl = wikiutil.mapURL(self.request, wikiurl) if wikitag == 'Self': # for own wiki, do simple links @@ -495,6 +496,8 @@ else: # return InterWiki hyperlink if on: href = wikiutil.join_wiki(wikiurl, wikitail) + if querystr: + href += '?%s' % wikiutil.makeQueryString(querystr) if wikitag_bad: html_class = 'badinterwiki' else: @@ -609,17 +612,21 @@ """ assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was _ = self.request.getText + querystr = kw.get('querystr', {}) + assert isinstance(querystr, dict) # new in 1.6, only support dicts + if 'do' not in querystr: + querystr['do'] = 'view' if on: pagename, filename = AttachFile.absoluteName(url, self.page.page_name) #self.request.log("attachment_link: url %s pagename %s filename %s" % (url, pagename, filename)) fname = wikiutil.taintfilename(filename) if AttachFile.exists(self.request, pagename, fname): - target = AttachFile.getAttachUrl(pagename, fname, self.request, do='view') + target = AttachFile.getAttachUrl(pagename, fname, self.request, do=querystr['do']) title = "attachment:%s" % url css = 'attachment' else: target = AttachFile.getAttachUploadUrl(pagename, fname, self.request) - title = _('Upload new attachment "%(filename)s"') % {'filename': wikiutil.escape(fname)} + title = _('Upload new attachment "%(filename)s"', formatted=False) % {'filename': wikiutil.escape(fname)} css = 'attachment nonexistent' return self.url(on, target, css=css, title=title) else: @@ -629,24 +636,30 @@ _ = self.request.getText pagename, filename = AttachFile.absoluteName(url, self.page.page_name) fname = wikiutil.taintfilename(filename) - if not AttachFile.exists(self.request, pagename, fname): - linktext = _('Upload new attachment "%(filename)s"') + exists = AttachFile.exists(self.request, pagename, fname) + if exists: + kw['css'] = 'attachment' + kw['src'] = AttachFile.getAttachUrl(pagename, filename, self.request, addts=1) + title = _('Inlined image: %(url)s', formatted=False) % {'url': self.text(url)} + if not 'title' in kw: + kw['title'] = title + # alt is required for images: + if not 'alt' in kw: + kw['alt'] = kw['title'] + return self.image(**kw) + else: + title = _('Upload new attachment "%(filename)s"', formatted=False) % { + 'filename': wikiutil.escape(fname)} + img = self.icon('attachimg') + css = 'nonexistent' return wikiutil.link_tag( self.request, ('%s?action=AttachFile&rename=%s' % (wikiutil.quoteWikinameURL(pagename), wikiutil.url_quote_plus(fname))), - linktext % {'filename': self.text(fname)}) - if not 'title' in kw: - kw['title'] = _('Inlined image: %(url)s') % {'url': self.text(url)} - # alt is required for images: - if not 'alt' in kw: - kw['alt'] = kw['title'] - return self.image( - title=kw['title'], - alt=kw['alt'], - src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1), - css="attachment") + img, + title=title, + css_class=css) def attachment_drawing(self, url, text, **kw): _ = self.request.getText @@ -666,7 +679,7 @@ # check whether attachment exists, possibly point to upload form if not exists: - linktext = _('Create new drawing "%(filename)s (opens in new window)"') + linktext = _('Create new drawing "%(filename)s (opens in new window)"', formatted=False) return wikiutil.link_tag( self.request, ('%s?action=AttachFile&rename=%s%s' % @@ -697,18 +710,18 @@ # add alt and title tags to areas map = re.sub('href\s*=\s*"((?!%TWIKIDRAW%).+?)"', r'href="\1" alt="\1" title="\1"', map) # add in edit links plus alt and title attributes - alt = title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(fname)} + alt = title = _('Edit drawing %(filename)s (opens in new window)', formatted=False) % {'filename': self.text(fname)} map = map.replace('%TWIKIDRAW%"', '%s" alt="%s" title="%s"' % (edit_link, alt, title)) # unxml, because 4.01 concrete will not validate /> map = map.replace('/>', '>') - alt = title = _('Clickable drawing: %(filename)s') % {'filename': self.text(fname)} + alt = title = _('Clickable drawing: %(filename)s', formatted=False) % {'filename': self.text(fname)} return (map + self.image( alt=alt, title=title, src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1), usemap='#'+mapid, css="drawing")) else: - alt = title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(fname)} + alt = title = _('Edit drawing %(filename)s (opens in new window)', formatted=False) % {'filename': self.text(fname)} return wikiutil.link_tag(self.request, edit_link, self.image(alt=alt,
--- a/MoinMoin/formatter/text_python.py Wed Feb 20 01:14:06 2008 +0100 +++ b/MoinMoin/formatter/text_python.py Wed Feb 20 10:23:56 2008 +0100 @@ -206,16 +206,7 @@ Dependencies = self.defaultDependencies if self.__is_static(Dependencies): - # XXX: copied from FormatterBase because we can't inherit from it - parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", parser_name) - - args = self._get_bang_args(lines[0]) - if args is not None: - lines = lines[1:] - p = parser('\n'.join(lines), self.request, format_args=args) - p.format(self) - del p - return '' + return self.formatter.parser(parser_name, lines) else: return self.__insert_code('%s%s.parser(%r, %r)' % (self.__adjust_formatter_state(),
--- a/MoinMoin/theme/__init__.py Wed Feb 20 01:14:06 2008 +0100 +++ b/MoinMoin/theme/__init__.py Wed Feb 20 10:23:56 2008 +0100 @@ -51,6 +51,7 @@ 'up': (_("Up"), "moin-parent.png", 15, 13), # FileAttach 'attach': ("%(attach_count)s", "moin-attach.png", 7, 15), + 'attachimg': ("", "attach.png", 32, 32), # RecentChanges 'rss': (_("[RSS]"), "moin-rss.png", 24, 24), 'deleted': (_("[DELETED]"), "moin-deleted.png", 60, 12),