Description

There are multiple places to specify the alternate texts for the images of the icon bar. The provided alt-texts / title-texts for the icons are ignored. In any case, the alt-text from icons in theme/_init_.py is taken.

The task is to reproduce the problem, review and apply the patch (and generate a new one like described on MoinDev/MercurialGuide), check if it fixes the problem (and does not cause other problems), cleanup the code, close bug.

This task is expected to take to 10h. You will have to complete it in 7 days.

Steps to reproduce

  1. Change classic theme iconbar like this:

    def iconbar(self, d):
        """
        Assemble the iconbar

        @param d: parameter dictionary
        @rtype: string
        @return: iconbar html
        """
        iconbar = []
        if self.cfg.page_iconbar and self.request.user.show_toolbar and d['page_name']:
            iconbar.append('<ul id="iconbar">\n')
            icons = self.cfg.page_iconbar[:]
            for icon in icons:
                # Using icon "up" is depreciated. Moin now uses breadcrumb navigation
                if icon == "up":
                    if d['page_parent_page']:
                        iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
                elif icon == "subscribe" and self.cfg.mail_enabled:
                    iconbar.append('<li>%s</li>\n' % self.make_iconlink(
                        ["subscribe", "unsubscribe"][self.request.user.isSubscribedTo([d['page_name']])], d))
                elif icon == "quicklink":
                    iconbar.append('<li>%s</li>\n' % self.make_iconlink(
                        ["addquicklink", "delquicklink"][self.request.user.isQuickLinkedTo([d['page_name']])], d))
                else:
                    iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
            iconbar.append('</ul>\n')
        return ''.join(iconbar)
  1. Customize the iconbar in wikiconfig.py as described below (see Details)
  2. Look at the provided tool-tip.

Example

screenshot.jpg

Text should be "Show latest changes" (like set in wikiconfig.py) and not "Diffs" (like set in theme/_init_.py)...( Sorry mousepointer was lost in screenshot, instead of that I have put the grey line there. But the tool tip is the original one)

Component selection

Details

Some issue for classic like themes:

If you try customize the iconbar in wikiconfig.py as follows

# -*- coding: iso-8859-1 -*-
"""

MoinMoin - Configuration


"""
import sys, os
from MoinMoin.config.multiconfig import DefaultConfig

def _(text): return text

class Config(DefaultConfig):


    # standard buttons in the iconbar for classic theme
    page_iconbar = ["edit", "view", "diff", "info", "subscribe", "quicklink", "attach", "print", ]
    # classic theme big icons
    page_icons_table = {
        # key           querystr dict             alt-text                        icon-key
        'edit':         ({'action': 'edit'},      _("Edit"),                      "edit-big"),
        'view':         ({'action': 'refresh'},   _("View / Refresh"),            "view-big"),
        'diff':         ({'action': 'diff'},      _("Show lastest changes"),      "diff-big"),
        'info':         ({'action': 'info'},      _("History / Page properties"), "info-big"),
        'unsubscribe':  ({'action': 'subscribe'}, _("UnSubscribe"),               "unsubscribe-big"),
        'subscribe':    ({'action': 'subscribe'}, _("Subscribe"),                 "subscribe-big"),
        'delquicklink': ({'action': 'quicklink'}, _("Delete quicklink"),          "delquicklink-big"),
        'addquicklink': ({'action': 'quicklink'}, _("Add quicklink"),             "addquicklink-big"),
        'attach':       ({'action': 'AttachFile'},_("Add/Manage files"),          "attach-big"),
        'print':        ({'action': 'print'},     _("Print"),                     "print-big"),
        }

all newly provided alt-texts /title-texts for the icons are ignored. Always the alt-text from icons in theme/_init_.py is taken.

However, I find this a very useful and important feature for theme customization.

Note to get the above sample to work: the icon-keys ("edit-big" etc.) had been added to "icons" dict in ThemeBase by changing theme/_init_.py or by overiding "icons" in the theme's py file (e.g. classic.py). Don't forget the def _(text): return text

MoinMoin Version

1.6dev

OS and Version

Python Version

Server Setup

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

Discussion

Looked at the code (make_icon_link, make_icon and get_icon), but could not fix that.. I also asked myself why always gettext is used there. In the icon dicts the alttext is always provided as follows  _("Edit") ... -- OliverSiemoneit 2007-01-06 15:40:58

The problem is maybe we have "alt" attr at the <img> and "title" at the <a>. Your browser seems to display the alt.

I have found the bug: matching a newly given alt tag with the standard alt tag by using alt = alt % vars (in make_icon) and d['title'] = title % d in make_iconlink seems not to work. Here's a patch for Moin 1.6dev (moin-1-6-main-7c58e8af1a97):

   1 --- __init__old.py	2006-12-09 13:32:00.000000000 +0100
   2 +++ __init__new.py	2007-01-16 00:04:20.000000000 +0100
   3 @@ -478,7 +478,7 @@
   4  
   5      def make_icon(self, icon, vars=None):
   6          """
   7 -        This is the central routine for making <img> tags for icons!
   8 +        Central routine for making <img> tags for icons
   9          All icons stuff except the top left logo and search field icons are
  10          handled here.
  11          
  12 @@ -490,12 +490,18 @@
  13          if vars is None:
  14              vars = {}
  15          alt, img, w, h = self.get_icon(icon)
  16 -        try:
  17 -            alt = alt % vars
  18 -        except KeyError, err:
  19 -            alt = 'KeyError: %s' % str(err)
  20 +        if vars:
  21 +            try:
  22 +                alt = vars['alt']
  23 +            except KeyError, err:
  24 +                try:
  25 +                    alt = alt % vars
  26 +                except KeyError, err:
  27 +                    alt = 'KeyError: %s' % str(err)
  28 +
  29          if self.request:
  30              alt = self.request.getText(alt, formatted=False)
  31 +
  32          try:
  33              tag = self.request.formatter.image(src=img, alt=alt, width=w, height=h)
  34          except AttributeError: # XXX FIXME if we have no formatter or no request 
  35 @@ -515,16 +521,16 @@
  36          @return: html link tag
  37          """
  38          querystr, title, icon = self.cfg.page_icons_table[which]
  39 -        d['title'] = title % d
  40 +        d['alt'] = d['title'] = title
  41          d['i18ntitle'] = self.request.getText(d['title'], formatted=False)
  42          img_src = self.make_icon(icon, d)
  43          rev = d['rev']
  44          if rev and which in ['raw', 'print', ]:
  45              querystr['rev'] = str(rev)
  46 -        attrs = {'rel': 'nofollow', 'title': d['i18ntitle'], }
  47 +        attrs = {'rel': 'nofollow', 'title': d['i18ntitle'], 'alt': d['i18ntitle'],}
  48          page = d['page']
  49          return page.link_to_raw(self.request, text=img_src, querystr=querystr, **attrs)
  50 -
  51 +    
  52      def msg(self, d):
  53          """ Assemble the msg display
  54  

_init_.diff

-- OliverSiemoneit 2007-01-13 18:59:30

Hi Oliver, is this patch for 1.5 or 1.6 and for which changeset? -- ReimarBauer 2007-01-13 20:12:12

That patch just creates another problem, it doesn't expand the variables in the alt texts any more, see icons definition in theme/init.py.

Tried to change that now in the newly given patch above. Code looks horrible, but behaviour seems to be correct now.. -- OliverSiemoneit 2007-01-15 23:08:56

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/MakeIconLinkLosesAltTitle (last edited 2008-05-01 20:29:31 by ThomasWaldmann)