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
   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     some modification by wkpark@kldp.org
  14     - No unique key needed
  15     - image map support
  16 
  17 """
  18 
  19 import string, sys,sha,os
  20 from MoinMoin import config
  21 
  22 def process(request, formatter, lines):
  23     webdoturl = "http://www.research.att.com/~north/cgi-bin/webdot1.7.11/webdot.cgi/"
  24     local_url = "http://localhost/cache"
  25     local_dir = "/var/www/html/cache"
  26 
  27     del lines[0]
  28     buff = string.join(lines, '\n')
  29     buff = unicode(buff, config.charset).encode('UTF-8')
  30     dotfilename = sha.new(buff).hexdigest()
  31 
  32     # open the file
  33     outpath = "%s/WebDot/attachments/%s.dot" % (local_dir,dotfilename)
  34     outurl = "%s/WebDot/attachments/" % (local_url)
  35     if not os.path.isdir(local_dir + "/WebDot/attachments"):
  36         os.makedirs(local_dir + "/WebDot/attachments", 0777 | config.umask)
  37     if not os.path.exists(outpath):
  38         dotfile = file(outpath,'w')
  39 
  40         # write the file
  41         dotfile.write(buff)
  42         dotfile.close()
  43 
  44     dotimg = "%s%s%s.dot.dot" % (webdoturl, outurl, dotfilename)
  45 
  46     sys.stdout.write('<a href=%(dotimg)s.map><img border=1 src="%(dotimg)s.png" ismap></a>' % locals())

MoinMoin: moindotProcessor2 (last edited 2007-10-29 19:15:17 by localhost)