1.1 --- a/graphviz.py Mon Sep 19 01:16:32 2011 +0200
1.2 +++ b/graphviz.py Tue Sep 20 00:02:48 2011 +0200
1.3 @@ -104,8 +104,10 @@
1.4
1.5 FILTERS = ['dot', 'neato', 'twopi', 'circo', 'fdp']
1.6 IMAGE_FORMATS = ['png', 'gif']
1.7 - FORMATS = IMAGE_FORMATS + ['ps', 'svg', 'svgz', 'fig', 'mif', \
1.8 - 'hpgl', 'pcl', 'dia', 'imap', 'cmapx']
1.9 + OBJECT_FORMATS = ['svg', 'svgz']
1.10 + OUTPUT_FORMATS = IMAGE_FORMATS + OBJECT_FORMATS
1.11 + FORMATS = OUTPUT_FORMATS + \
1.12 + ['ps', 'fig', 'mif', 'hpgl', 'pcl', 'dia', 'imap', 'cmapx']
1.13 extensions = []
1.14 Dependencies = Dependencies
1.15
1.16 @@ -115,7 +117,12 @@
1.17
1.18 def format(self, formatter):
1.19 """ Send the text. """
1.20 - self.request.flush() # to identify error text
1.21 +
1.22 + request = self.request
1.23 + page = request.page
1.24 + _ = request.getText
1.25 +
1.26 + request.flush() # to identify error text
1.27
1.28 self.filter = Parser.FILTERS[0]
1.29 self.format = 'png'
1.30 @@ -138,8 +145,9 @@
1.31 elif l.lower().startswith('//cmapx='):
1.32 self.cmapx = wikiutil.escape(l.split('=', 1)[1])
1.33
1.34 - if not self.format in Parser.IMAGE_FORMATS:
1.35 - raise NotImplementedError, "only formats %s are currently supported" % Parser.IMAGE_FORMATS
1.36 + if not self.format in Parser.OUTPUT_FORMATS:
1.37 + raise NotImplementedError, "only formats %s are currently supported" % \
1.38 + Parser.OUTPUT_FORMATS
1.39
1.40 if self.cmapx:
1.41 if not self.format in Parser.IMAGE_FORMATS:
1.42 @@ -149,8 +157,8 @@
1.43 img_name = 'graphviz_%s.%s' % (sha.new(self.raw).hexdigest(), self.format)
1.44
1.45 self.pagename = formatter.page.page_name
1.46 - url = AttachFile.getAttachUrl(self.pagename, img_name, self.request)
1.47 - self.attach_dir=AttachFile.getAttachDir(self.request,self.pagename,create=1)
1.48 + url = AttachFile.getAttachUrl(self.pagename, img_name, request)
1.49 + self.attach_dir=AttachFile.getAttachDir(request,self.pagename,create=1)
1.50
1.51 self.delete_old_graphs(formatter)
1.52
1.53 @@ -159,13 +167,14 @@
1.54
1.55 if self.format in Parser.IMAGE_FORMATS:
1.56 if self.cmapx:
1.57 - self.request.write('\n' + self.graphviz(self.raw, format='cmapx') + '\n')
1.58 - self.request.write(formatter.image(src="%s" % url, usemap="#%s" % self.cmapx))
1.59 + request.write('\n' + self.graphviz(self.raw, format='cmapx') + '\n')
1.60 + request.write(formatter.image(src="%s" % url, usemap="#%s" % self.cmapx))
1.61 else:
1.62 - self.request.write(formatter.image(src="%s" % url, alt="graphviz image"))
1.63 + request.write(formatter.image(src="%s" % url, alt="graphviz image"))
1.64 else:
1.65 - # TODO: read the docs and figure out how to do this correctly
1.66 - self.request.write(formatter.attachment_link(True, url=url))
1.67 + request.write(formatter.transclusion(1, data=url))
1.68 + request.write(formatter.text(_("graphviz image")))
1.69 + request.write(formatter.transclusion(0))
1.70
1.71 def delete_old_graphs(self, formatter):
1.72 page_info = formatter.page.lastEditInfo()