Attachment 'patch-svg.diff'
Download 1 --- graphviz.py Mon Sep 19 01:16:32 2011 +0200
2 +++ graphviz.py Tue Sep 20 00:02:48 2011 +0200
3 @@ -104,8 +104,10 @@
4
5 FILTERS = ['dot', 'neato', 'twopi', 'circo', 'fdp']
6 IMAGE_FORMATS = ['png', 'gif']
7 - FORMATS = IMAGE_FORMATS + ['ps', 'svg', 'svgz', 'fig', 'mif', \
8 - 'hpgl', 'pcl', 'dia', 'imap', 'cmapx']
9 + OBJECT_FORMATS = ['svg', 'svgz']
10 + OUTPUT_FORMATS = IMAGE_FORMATS + OBJECT_FORMATS
11 + FORMATS = OUTPUT_FORMATS + \
12 + ['ps', 'fig', 'mif', 'hpgl', 'pcl', 'dia', 'imap', 'cmapx']
13 extensions = []
14 Dependencies = Dependencies
15
16 @@ -115,7 +117,12 @@
17
18 def format(self, formatter):
19 """ Send the text. """
20 - self.request.flush() # to identify error text
21 +
22 + request = self.request
23 + page = request.page
24 + _ = request.getText
25 +
26 + request.flush() # to identify error text
27
28 self.filter = Parser.FILTERS[0]
29 self.format = 'png'
30 @@ -138,8 +145,9 @@
31 elif l.lower().startswith('//cmapx='):
32 self.cmapx = wikiutil.escape(l.split('=', 1)[1])
33
34 - if not self.format in Parser.IMAGE_FORMATS:
35 - raise NotImplementedError, "only formats %s are currently supported" % Parser.IMAGE_FORMATS
36 + if not self.format in Parser.OUTPUT_FORMATS:
37 + raise NotImplementedError, "only formats %s are currently supported" % \
38 + Parser.OUTPUT_FORMATS
39
40 if self.cmapx:
41 if not self.format in Parser.IMAGE_FORMATS:
42 @@ -149,8 +157,8 @@
43 img_name = 'graphviz_%s.%s' % (sha.new(self.raw).hexdigest(), self.format)
44
45 self.pagename = formatter.page.page_name
46 - url = AttachFile.getAttachUrl(self.pagename, img_name, self.request)
47 - self.attach_dir=AttachFile.getAttachDir(self.request,self.pagename,create=1)
48 + url = AttachFile.getAttachUrl(self.pagename, img_name, request)
49 + self.attach_dir=AttachFile.getAttachDir(request,self.pagename,create=1)
50
51 self.delete_old_graphs(formatter)
52
53 @@ -159,13 +167,14 @@
54
55 if self.format in Parser.IMAGE_FORMATS:
56 if self.cmapx:
57 - self.request.write('\n' + self.graphviz(self.raw, format='cmapx') + '\n')
58 - self.request.write(formatter.image(src="%s" % url, usemap="#%s" % self.cmapx))
59 + request.write('\n' + self.graphviz(self.raw, format='cmapx') + '\n')
60 + request.write(formatter.image(src="%s" % url, usemap="#%s" % self.cmapx))
61 else:
62 - self.request.write(formatter.image(src="%s" % url, alt="graphviz image"))
63 + request.write(formatter.image(src="%s" % url, alt="graphviz image"))
64 else:
65 - # TODO: read the docs and figure out how to do this correctly
66 - self.request.write(formatter.attachment_link(True, url=url))
67 + request.write(formatter.transclusion(1, data=url))
68 + request.write(formatter.text(_("graphviz image")))
69 + request.write(formatter.transclusion(0))
70
71 def delete_old_graphs(self, formatter):
72 page_info = formatter.page.lastEditInfo()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.