Short description
- It should be possible to setup different logos with different urls
Sometimes I want to have the possibility to use the logo of a wiki to link to a main page of the webserver. I would like to use this page element because sometimes it is used to show in addition to the wiki logo the company logo. People don't understand by clicking on the company logo that they got the FrontPage. I have included a patch to show the simple changes. (changed to the whole logo routine)
If you like to have logos directed to urls add e.g. the following entry.
logo_string = [u'<img src="/wiki/mywiki.png">',u'<img src="/wiki/mycompany.png">'] logo_url = [u'http://mywiki.domain.de',u'http://mycompany.domain.de']
def logo(self): """ Assemble logo with link to front page The logo contain an image and or text or any html markup the admin inserted in the config file. Everything it enclosed inside a div with id="logo". ReimarBauer 2005-11-15,16 optionaly a logo_url could be used to link to a different page as the wiki front_page if different logos are used you could setup different urls too @param d: parameter dictionary @rtype: unicode @return: logo html """ html = u'' if self.cfg.logo_string: pagename = wikiutil.getFrontPage(self.request).page_name pagename = wikiutil.quoteWikinameURL(pagename) #ReimarBauer 2005-11-15 logo = u'' i = 0 if hasattr(self.cfg,'logo_url'): from MoinMoin.formatter.text_html import Formatter formatter = Formatter(self.request) for txt in self.cfg.logo_string: if txt == "" : logo += wikiutil.link_tag(self.request, pagename, self.cfg.logo_string[i]) else: kw ={} kw['src']=self.cfg.logo_url[i] image_link=self.cfg.logo_string[i] logo += formatter.url(1,kw['src'] )+image_link +formatter.url(0) i += 1 else: for txt in self.cfg.logo_string: logo += wikiutil.link_tag(self.request, pagename, self.cfg.logo_string[i]) i += 1 html = u'''<div id="logo">%s</div>''' % logo return html
I think this would be a simple extension to the current configurations. -- ReimarBauer 2005-11-15 07:21:37
This is very bad for usability - most users expect to see a logo which leads to the home page in the top left corner. Different location or logo that leads to a another page will confuse users.
They don't need to change anything in the configuration. But if you use a wiki in corporation with other web tools it is useful to have. In this case we have setup the wikis frontpage in the navibar. In our case the logo is not exclusive the wiki logo. -- ReimarBauer 2005-11-15 12:23:20
Changed the routine again to an hasattr test of logo_url. By this the changed code do not affect existing wiki setups. -- ReimarBauer 2005-11-16 19:40:15
what if we simply allow variable substitution in the logo URL (I do not understand the Python code)?
You need to have an additional parameter (logo_url) for setting the url because on default the logo links to the wiki's frontpage. Then you need some code to not break the existing default definition and to add the feature.
Ok, yes. I would simply put something like if %p ( this value should be changed here if it exists but is named different) would be the page name:
logo_string = [u'<img src="/wiki/%p.png">']
That would mean you could not choose the name of the logo. The logo would have to be named by the pagename. The default definition does not have a variable, so this will not be a problem for most sites. One might also want to have a setting where you could choose that %p will always be the default logo_url. So maybe it rather would be good to have settings logo_string_default and logo_string_pagelogo or something like that? Understand what I mean? -- ThiloPfennig 2006-02-11 10:07:46 Ok, logo_string is the default var for this. We should not change this var and it's behaviour or type otherwise all users have to change their wikiconfig.py or their wikis are broken. So we need to think on a differnt solution. One could be this hasattr(self.cfg,'logo_url'). This means one who has set this config var logo_url in addition to logo_string gets another behaviour of the logo code. If as you suggested the logo has to be named to pagename then you will have for each page a logo, this is mostly unwanted. And if the logo isn't there it probably gives an error. I have needed this patch for two things at first to get the logo of the project linked to the project homepage and not to the wiki's frontpage and second to get the company logo and link to the company added. An other wiki on the same server could use it's logo linked to it's frontpage.
The script should look if a logo by the pagename does exists and if not, it takes the default logo. This could be cached. BTW: this also could be made with CSS if CSS rewritten. As CSS is cascading you also can have default values for a logo and rewrite it. This would mean that the CSS is only added (on the page) if there is a logo by the name of the page. So this could go into <style></style> in the header section of the html page. Example:
<style> div#MoinMoinWiki { height:64px; width:64px; background: url("MoinMoinWiki.png") no-repeat } </style>
and the logo itself:<div name="MoinMoinWiki" alt="MoinMoin Logo" id="MoinMoinWiki"></div>
The problem with that solution is, that the logo is not clickable any more. This is because the logo is in the background. I think the only other option in CSS2 currently is to use the "list-style-image" argument? -- ThiloPfennig 2006-02-12 12:40:16
patches for 1.8
logo_string = [u'<img src="/wiki/mywiki.png">',u'<img src="/wiki/mycompany.png">'] logo_url = [u'http://mywiki.domain.de',u'http://mycompany.domain.de']
patch -p1 < logo_rss_rc_patch.patch
diff -r 550373665133 MoinMoin/action/rss_rc.py --- a/MoinMoin/action/rss_rc.py Sun Apr 20 21:39:50 2008 +0200 +++ b/MoinMoin/action/rss_rc.py Fri Apr 25 09:16:27 2008 +0200 @@ -112,7 +112,7 @@ if not baseurl.endswith('/'): baseurl += '/' - logo = re.search(r'src="([^"]*)"', cfg.logo_string) + logo = re.search(r'src="([^"]*)"', cfg.logo_string[0]) if logo: logo = request.getQualifiedURL(logo.group(1))
patch -p1 < logo_theme_patch.patch
diff -r 550373665133 MoinMoin/theme/__init__.py --- a/MoinMoin/theme/__init__.py Sun Apr 20 21:39:50 2008 +0200 +++ b/MoinMoin/theme/__init__.py Fri Apr 25 09:24:31 2008 +0200 @@ -181,6 +181,51 @@ return html def logo(self): + """ Assemble logo with link to front page + + The logo contain an image and or text or any html markup the + admin inserted in the config file. Everything it enclosed inside + a div with id="logo". + + ReimarBauer 2005-11-15,16 + optionaly a logo_url could be used to link to a different page as the wiki front_page + if different logos are used you could setup different urls too + + @param d: parameter dictionary + @rtype: unicode + @return: logo html + """ + html = u'' + if self.cfg.logo_string: + pagename = wikiutil.getFrontPage(self.request).page_name + pagename = wikiutil.quoteWikinameURL(pagename) + #ReimarBauer 2005-11-15 + logo = u'' + i = 0 + if hasattr(self.cfg, 'logo_url'): + from MoinMoin.formatter.text_html import Formatter + formatter = Formatter(self.request) + + for txt in self.cfg.logo_string: + if txt == "": + logo += wikiutil.link_tag(self.request, pagename, self.cfg.logo_string[i]) + + else: + kw = {} + kw['src'] = self.cfg.logo_url[i] + image_link = self.cfg.logo_string[i] + logo += formatter.url(1, kw['src'] )+image_link +formatter.url(0) + + i += 1 + else: + for txt in self.cfg.logo_string: + logo += wikiutil.link_tag(self.request, pagename, self.cfg.logo_string[i]) + i += 1 + + html = u'''<div id="logo">%s</div>''' % logo + return html + + def logo_old(self): """ Assemble logo with link to front page The logo contain an image and or text or any html markup the