TableOfContents

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.

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 [http://www.adobe.com/support/downloads/product.jsp?product=46&platform=Windows 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/"

MODIFICATION HISTORY

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

AndrewArmstrong: 2005-03-04 BR 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 DateTime(2005-03-06T13:54:00Z+10)