Contents
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 |
|
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%)>>
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
- ..but "image/svg+xml" is most likely not already defined in any of them.
- 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
Here you find the mozilla firefox with SVG native support and on this table you get more information about svg plugins generally. What's I am interested be on is ( I can check this myself next week ) what happens if a svg file is shown by ImageLink and konqueror with the ksvg plugin. I don't know what internetexplorer shows as error so please give me a note on my homepage describing this. If the problem is that's svg do not belong to the type of files which could be shown on pages directly better we should think on changing this rule in isPicture(url): of wikiutil.py -- ReimarBauer 2005-03-05 09:00:01 Sorry I don't know about konqueror or ksvg. When using ImageLink to display svg it just displays a box with a red 'X' in it - the same as it does when you code ImageLink(not_an_image.txt). The html <img> tag cannot be used for svg even though the mimetype starts with 'image', so changing isPicture is no help (I already tried it). The only way I know is to use the <object> tag (or the deprecated <embed> tag). I think that changing send_viewfile in AttachFile.py to support svg attachments may be handy...that way the attachment 'view' function would work for svg attachments (as is done for images now). Code something like the following could be added:
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