[Moin-user] I want a "changing logo" - browser cache problem

Henryk Gerlach hgerlach at gmx.de
Fri Jun 22 05:43:13 EDT 2007


Hi Sebastian,

Sorry for the PM again. ;(

> > So Thomas sugessts putting somethin like
> >
> >     import random
> >     pics=[u"http://xyz.de/a.png", u"http://xyz.de/b.png"]
> >     logo_string= u'<img src="' + random.choice(pics,1) + u'" />'
> >
> > in your wikiconfig instead of
> >     logo_string= u'<img src="fixed.png" />'

> Thanks - I tried something like this -- but it turns out that the
> wikiconfig is of course only evaluated once -- so I would have to
> restart the wiki-engine every time I change the logo ... don't like
> that ...

So change the function logo MoinMoin/theme/__init__.py:

    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".

        @param d: parameter dictionary
        @rtype: unicode
        @return: logo html
        """
        html = u''
#        if self.cfg.logo_string:
        if 1: 
            pagename = wikiutil.getFrontPage(self.request).page_name
            pagename = wikiutil.quoteWikinameURL(pagename)
            import random
            pics=[u"http://xyz.de/a.png", u"http://xyz.de/b.png"]
            logo_string= u'<img src="' + random.choice(pics) + u'" />'
            logo = wikiutil.link_tag(self.request, pagename, logo_string)
            html = u'''<div id="logo">%s</div>''' % logo
        return html

MoinMoin/theme/__init__.py seems to be reloaded for each page (even in the desktopedition).

instead of 
"if 1" you might want to introduce a configuration variable pics and check for "if self.cfg.pics" ...

Cheers,
  Henryk

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger




More information about the Moin-user mailing list