Short description

This feature request is mainly done for AccessibleMoin since it is an often mentioned criteria that

This means in detail:

Test.py

Test.py (4.3KB)

This seems to be a rediculous detail, however this is one accessibility criteria (especially for people using screenreaders). It's not enough to have file size information only in the filelist of AttachFile.

So I did some changes to MoinMoin.formatter.text_html (moin-1-6-main-7c58e8af1a97):

   1 --- text_html_old.py	2007-02-18 15:42:50.000000000 +0100
   2 +++ text_html.py	2007-02-18 16:56:40.000000000 +0100
   3 @@ -642,9 +642,13 @@
   4                    wikiutil.url_quote_plus(fname))),
   5                  linktext % {'filename': self.text(fname)})
   6          target = AttachFile.getAttachUrl(pagename, filename, self.request)
   7 -        return (self.url(1, target, css='attachment', title="attachment:%s" % url) +
   8 +        fsize = float(os.stat(fpath)[6]) # in byte
   9 +        fsize = "%.1f" % (fsize / 1024)
  10 +        title = _('Attachment: %(url)s')
  11 +        return (self.url(1, target, css='attachment', title=title % {'url': self.text(url)}) +
  12                  self.text(text) +
  13 -                self.url(0))
  14 +                self.url(0) +
  15 +                self.text(' (%(fsize)s KB)' % {'fsize': fsize}))
  16  
  17      def attachment_image(self, url, **kw):
  18          _ = self.request.getText
  19 @@ -659,8 +663,12 @@
  20                   (wikiutil.quoteWikinameURL(pagename),
  21                    wikiutil.url_quote_plus(fname))),
  22                  linktext % {'filename': self.text(fname)})
  23 +        title = _('Attachment: %(url)s') % {'url': self.text(url)}
  24 +        if not 'alt' in kw:
  25 +            kw['alt'] = _('Inlined image: %(url)s') % {'url': self.text(url)}
  26          return self.image(
  27 -            title="attachment:%s" % url,
  28 +            title=title,
  29 +            alt=kw['alt'],
  30              src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1),
  31              css="attachment")
  32  

text_html.diff

Further I want to suggest to change parser standard behaviour for AccessibleMoin: attachment: should not longer be confused with inline:. With attachment you do reference attachments of a page. You use inline to inline an attachment in a page. It's semantically wrong to inline a picture if you write attachment:pic.png!! That's like Internet Explorer always confusing title with alt. Therefore in AccessibleMoin with

Here's the patch for MoinMoin.parser.text_moin_wiki (moin-1-6-main-7c58e8af1a97):

   1 --- text_moin_wiki_old.py	2007-02-18 17:00:12.000000000 +0100
   2 +++ text_moin_wiki.py	2007-02-18 21:05:12.000000000 +0100
   3 @@ -209,12 +209,27 @@
   4          if scheme == 'drawing':
   5              return self.formatter.attachment_drawing(fname, text)
   6  
   7 -        # check for image, and possibly return IMG tag (images are always inlined)
   8 -        if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
   9 -            return self.formatter.attachment_image(fname)
  10 +        # check if AccessibleMoin is wanted. In AccessibleMoin we don't want to confuse
  11 +        # attachment of images with inline of images anymore. It's like IE confusing alt
  12 +        # with title.
  13 +        accessible_moin = False
  14 +        if hasattr(self.request.cfg, 'accessible_moin'):
  15 +            accessible_moin = self.request.cfg.accessible_moin
  16 +        if not accessible_moin:
  17 +            # check for image, and possibly return IMG tag (images are always inlined)
  18 +            if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
  19 +                return self.formatter.attachment_image(fname)
  20  
  21          # inline the attachment
  22          if scheme == 'inline':
  23 +            # in AccessibleMoin pictures are inlined as other stuff is inlined. For proper
  24 +            # picture display use ImageLink or Image macro
  25 +            if accessible_moin:
  26 +                if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
  27 +                    return (self.formatter.preformatted(1) +
  28 +                            self.formatter.attachment_image(fname) +
  29 +                            self.formatter.preformatted(0) +
  30 +                            self.formatter.attachment_link(fname, text))
  31              return self.formatter.attachment_inlined(fname, text)
  32  
  33          return self.formatter.attachment_link(fname, text)

text_moin_wiki.diff

-- OliverSiemoneit 2007-02-18 20:50:34


CategoryFeaturePatched

MoinMoin: FeatureRequests/ShowFilesizeForAttachmentsAndAltForImages (last edited 2007-10-29 19:20:23 by localhost)