svg

PURPOSE

This macro is used to enable an attached SVG image to be displayed in a browser. Optionally, the size of the image can be adjusted.

Download & Release Notes

Download

Release Version

Moin Version

Release Notes

svg.py

1.3

CALLING SEQUENCE

<<svg(attachment[,width=width,[height=height]])>>

INPUTS

attachment:name of SVG attachment

KEYWORD PARAMETERS

width: width of the embedded image (default is 100%)
height: height of the embedded image (default is 100%)

OUTPUT

The svg macro will output an <object> tag as follows:

<object type="image/svg+xml" data="...url-of-attachment..." width="..." height="...">Your browser cannot display SVG</object>

WARNING

You will need Internet Explorer and the Adobe SvgViewer plugin before SVG content can be seen. Mozilla and Firefox, as at 2005, are not up to it. Who knows about the others.

EXAMPLE

<<svg(plot.svg)>>
<<svg(plot.svg,width=800,height=600)>>
<<svg(plot.svg,width=50%)>>

svg(plot.svg)

PROCEDURE

This routine requires attachments enabled. If the attachment is not already present on the wiki then the attachment upload page is shown allowing you to upload the missing attachment.

You must map the mimetype "image/svg+xml" to the .svg and .svgz extensions - either in your web server configuration - Python will automatically add the mimetypes found in the following files:

     "/etc/mime.types",
     "/usr/local/etc/httpd/conf/mime.types",
     "/usr/local/lib/netscape/mime.types",
     "/usr/local/etc/httpd/conf/mime.types",     # Apache 1.2
     "/usr/local/etc/mime.types",                # Apache 1.3

- or by adding the following lines to wikiconfig.py:

  import mimetypes
  mimetypes.add_type("image/svg+xml", ".svg", True)
  mimetypes.add_type("image/svg+xml", ".svgz", True)

- or by some other method that I am not aware of.

This macro must be put in "[yourwiki]/data/plugin/macro/" or for newer versions of MoinMoin in "[yourwiki]/MoinMoin/macro/"

Compatibility

Embedding works fine for FireFox 4 and Safari 5 on Mac OS X. It's likely that it works on other operating systems too, if this both browsers are used.

MODIFICATION HISTORY

@copyright: none
@license: GNU GPL, see COPYING for details.

AndrewArmstrong: 2005-03-04
Initial version by: <andrew_armstrong AT unwired DOT com DOT au>

Discussion

if type[:13] == 'image/svg+xml':
    timestamp = htdocs_access(request) and "?%s" % time.time() or ''
    request.write('<object type="image/svg+xml" data="%s%s" width="100%%" height="100%%">%s</object>' % (
        getAttachUrl(pagename, filename, request, escaped=1), timestamp, wikiutil.escape(filename, 1)))
    return
elif type[:5] == 'image':
    timestamp = htdocs_access(request) and "?%s" % time.time() or ''
    request.write('<img src="%s%s" alt="%s">' % (
        getAttachUrl(pagename, filename, request, escaped=1), timestamp, wikiutil.escape(filename, 1)))
    return
elif type[:4] == 'text':
    .
    .

-- AndrewArmstrong 2005-03-06 13:54:00

See also

MoinMoin: MacroMarket/Svg (last edited 2011-01-27 15:23:18 by MikeBattistella)