Changeset 91
- Timestamp:
- 08/02/05 04:44:06 (3 years ago)
- Files:
-
- latexformulamacro/stable/formula.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
latexformulamacro/stable/formula.py
r90 r91 4 4 5 5 Changes: 6 2005-08-02: 7 * remove hard-coded paths, read from configuration. Fixes #26 6 8 2005-07-27: 7 9 * figured out how to get rid of the annoying internal error after latex … … 13 15 enclosure of commands in display-math mode ("$$ ... $$") 14 16 2005-07-26: first release 17 18 Installation: 19 1. Copy into wiki-macros directory. 20 2. Edit conf/trac.ini and add a [latex] group with three values: 21 [latex] 22 # temp_dir points to directory where temporary files are created 23 temp_dir = /var/tmp/trac 24 # image_path is directory where final images are written 25 image_path = /var/www/html/formula 26 # display_path is URL where formula images can be accessed 27 display_path = http://foo.net/formula 15 28 16 29 Usage: … … 53 66 """ 54 67 55 # TODO: Paths to change for your system: 56 # directory where temporary files are created 57 tmpdir = "/var/www/html/trac/tex/" 58 # directory where images are written 59 imagePath = "/var/www/html/formula/" 60 # URL base for accessing images 61 displayPath = "http://arg0.net/formula/" 62 63 # if the version string changes, then images will be regenerated 64 version = "0.1" 68 # if the output version string changes, then images will be regenerated 69 outputVersion = "0.1" 65 70 66 71 … … 72 77 73 78 def render(hdf, env, texData, density, mathMode): 74 path = tmpdir # + hdf.getValue("project.name.encoded", "default") + "/" 79 # gets paths from configuration 80 tmpdir = env.get_config('latex', 'temp_dir'); 81 imagePath = env.get_config('latex', 'image_path'); 82 displayPath = env.get_config('latex', 'display_path'); 83 84 if not tmpdir or not imagePath or not displayPath: 85 return "<b>Error: missing configuration settings in 'latex' macro</b><br>"; 86 87 path = tmpdir # + hdf.getValue("project.name.encoded", "default") 75 88 # create temporary directory if necessary 76 89 try: 77 if os.path.exists(path) is False:90 if not os.path.exists(path): 78 91 mkdir(path) 79 92 except: … … 84 97 hash = sha.new(texData); 85 98 hash.update( "%d" % density ) 86 hash.update( version )99 hash.update( outputVersion ) 87 100 name = hash.hexdigest() 88 jpgFile = imagePath + name + ".jpg"101 jpgFile = "%s/%s.jpg" % (imagePath, name) 89 102 90 103 log = "<br>"; 91 if os.path.exists(jpgFile) is False:104 if not os.path.exists(jpgFile): 92 105 # latex writes out lots of stuff to the current directory, so we have 93 106 # to run it from there. … … 105 118 106 119 # use dvips to convert to eps 107 dviFile = path + name + ".dvi"108 epsFile = path + name + ".eps"120 dviFile = "%s/%s.dvi" % (path, name) 121 epsFile = "%s/%s.eps" % (path, name) 109 122 cmd = "dvips -q -D 600 -E -n 1 -p 1 -o %s %s" % (epsFile, dviFile) 110 123 log += execprog( cmd ) … … 114 127 log += execprog( cmd ) 115 128 116 html = "<img src='%s %s.jpg' border='0' style='vertical-align: middle;' alt='formula' />" % (displayPath, name)129 html = "<img src='%s/%s.jpg' border='0' style='vertical-align: middle;' alt='formula' />" % (displayPath, name) 117 130 return html 118 131 #return log;
