1 """
   2     MoinDot - WebDot/MoinMoin collaboration macro
   3 
   4     Copyright (c) 2002 by Deepfile, Inc. <pj@deepfile.com>
   5     Released into the public domain
   6 
   7     Usage:  {{{#!moindot someuniquekey  
   8                 ... 
   9             }}}
  10     Omitting someuniquekey is permitted, but WILL cause problems if you put two graphs on one page,
  11     and MAY cause problems if you have two graphs on the site even if on different pages
  12 
  13 """
  14 
  15 import string, sys
  16 
  17 def process(request, formatter, lines):
  18     webdoturl = "http://webdot.graph.viz/cgi-bin/webdot/"
  19     localdir = "/var/www/html/webdot/"
  20     localurl = "http://localhost/webdot/"
  21 
  22     # parse bangpath for arguments
  23     args=string.split(lines[0])
  24     if len(args) > 1:
  25         dotfilename = "moindot-%s.dot" % args[1]
  26     else:    
  27         dotfilename = "moindot.dot"
  28 
  29     # open the file
  30     dotfile = file(localdir+dotfilename,'w')
  31 
  32     # write the file
  33     # remove bangpath
  34     del lines[0]
  35     # dotfile.writelines(lines) doesn't work - we need \n's
  36     for line in lines:
  37         dotfile.write(line)
  38         dotfile.write("\n")
  39     dotfile.close()
  40 
  41     dotjpgurl = "%s%s%s.dot.jpg" % (webdoturl, localurl, dotfilename)
  42 
  43     sys.stdout.write("<IMG SRC=\""+dotjpgurl+"\">")

MoinMoin: moindotProcessor (last edited 2007-10-29 19:21:15 by localhost)