Short description

Support image map links in AnyWikiDraw and TWikiDraw which work the same way as MoinMoin links.

Detailed description

You maybe know that AnyWikiDraw (and TWikiDraw) supports automatically generation of image maps. Image maps can enrich the style users can navigate in your wikis.

Look at this example:

http://www.google.detest.adraw

Hover your mousepointer over the circle and you will see a link to Google.

You also can provide links which direct to a different page in your wiki:

/MoinMoinBugsbugs.adraw

A klick to the "bug" graphics will bring you to the bug list page of this MoinMoin wiki.

You can create image map links directly in AnyWikiDraw in a very easy way. Inside of AnyWikiDraw you can select any graphical object and connect a html link to it by entering the url in this field:

link.adraw

To get your image map links working for wiki pages don't forget the slash before the page name!

If you want to link to a page in a wikifarm, you have to use this syntax:

/<name of the wiki>/<name of the page>

Example: A link to page "HelpMe" in the wiki "SupportWiki" inside of a wikifarm would look like this:

/SupportWiki/HelpMe

!!! Problem with "offline wikis" aka standalone server

As described before you have to put the name of the wiki into your url. If you want to drive your wiki offline through the standalone wiki feature of MoinMoin (by starting wikiserver.py in a shell) you will propably make a local copy of your wiki's data. Everything will work as expected but your image maps won't do it anymore cause wikiserver doesn't know anything about your wikifarm - I'll take the example from above - "SupportWiki" so the link will lead you to the missing page "/SupportWiki/HelpMe".

Solution

A solution to this problem could be that we use the same syntax for page links in AnyWikiDraw as for page links on wiki pages.

Instead of

/SupportWiki/HelpMe

we could use MoinMoin's interwiki link syntax

SupportWiki:HelpMe

or if we want to link to a page inside of the same wiki

HelpMe

After saving the AnyWikiDraw drawing a image map will be created with href statements containing the link information. If the page with the drawing is viewed after that, the MoinMoin system should translate the image map links containing Moin style links to valid html url links.

Patch

This patch will add the wiki name of your farmwiki before each image map link in your drawing before it's sent to the browser by Moin. If you are working with an offline wiki, the wiki's name (automatically derived from the script_root variable) is only "/".

This patch doesn't support the interwiki link syntax for the moment. But after applying this patch you can create image map links to pages for the current wikifarm wiki and the links will also work in an offline wiki. I'll provide support for page linking to different wikis soon.

   1 diff -r 8f2446858dd3 MoinMoin/action/anywikidraw.py
   2 --- a/MoinMoin/action/anywikidraw.py	Mon Mar 01 00:23:21 2010 +0100
   3 +++ b/MoinMoin/action/anywikidraw.py	Thu Apr 15 11:54:50 2010 +0200
   4 @@ -63,6 +63,21 @@
   5          map = map.replace(u'name="%s.svg"' % drawing, u'name="%s"' % mapid)
   6          # unxml, because 4.01 concrete will not validate />
   7          map = map.replace(u'/>', u'>')
   8 +
   9 +        # Add script_root to image map links which direct to wiki pages.
  10 +        script = self.request.script_root
  11 +        regexes = re.compile('(?:href=")+(?P<url>[^"]+)"+')
  12 +        def correct_map_match( match):
  13 +            url = match.group("url")
  14 +
  15 +            if not url.startswith("http://"):
  16 +                return r'href="' + script + "/" + url + '"'
  17 +            else:
  18 +                return r'href="' + url + '"'
  19 +        map = regexes.sub(correct_map_match, map)
  20 +      
  21 +      
  22 +        
  23          title = _('Clickable drawing: %(filename)s') % {'filename': self.text(containername)}
  24          if 'title' not in kw:
  25              kw['title'] = title
imagemap.patch


CategoryFeatureRequest