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
- 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)
- Customize the iconbar in wikiconfig.py as described below (see Details)
- Look at the provided tool-tip.
Example
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
- classic.py: iconbar
- theme/_init_.py: make_iconlink, make_icon, get_icon
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
It is because _ is faked some lines above the icons dict definition to do nothing - see comment there
Thanks for that tip! Right def _(text): return text is indeed a fake! It returns only "text" without translation. Sorry, did not understand this first...
The problem is maybe we have "alt" attr at the <img> and "title" at the <a>. Your browser seems to display the alt.
It works neither correctly on IE7, Firefox 2.001 and Opera 9.10 on WinXP. But you are right: I haven't noticed in the html source, that the new tool-tip-text "show latest changes" is there. It really seems to be a problem of mixing various alt and title text in <img> and <a>. Here is a copy of the html-source which shows this:
<a href="/FrontPage?action=diff" rel="nofollow" title="Show lastest changes"><img alt="Diffs" height="25" src="/moin_static160/cleanorange/img/moin-diff-big.png" title="Diffs" width="31" /></a></li>
However the title/alt provided in <img> seems to have always higher priority than the title/alt in <a>, i.e. the nested code seems to be processed first. -- OliverSiemoneit 2007-01-13 16:22:01
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
-- 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
- Sorry. Forget that. It's for 1.6 (moin-1-6-main-7c58e8af1a97).
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.
Yes. Right, just saw that the icons in e.g. TitleIndex don't work anymore. Shit.. -- OliverSiemoneit 2007-01-15 22:47:07
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
- Priority:
- Assigned to:
Status: Fixed in 6342dc571d59 on 1.6, and 1.7: http://hg.moinmo.in/moin/1.7/rev/1e9444f35a22