Ticket #65 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 1 year ago

Trac 0.9b2 compatability

Reported by: Ken McIvor <mcivor@iit.edu> Assigned to: vgough
Priority: normal Component: LatexFormulaMacro
Severity: normal Keywords: patch
Cc: Trac Release: 0.8

Description

Here's a patch which makes your wonderful formula macro work under the latest version of trac:

--- formula.py-0.8      2005-10-07 15:05:20.000000000 -0500
+++ formula.py-0.9      2005-10-21 18:49:42.023380773 -0500
@@ -3,6 +3,9 @@
 by Valient Gough <vgough@pobox.com>

 Changes:
+    2005-10-21  Ken McIvor <mcivor@iit.edu>:
+        * Updated to support trac 0.9b2.
+        * Improved the error messages for missing configuration elements.
     2005-10-03:
        * make image format selectable via 'image_format' configuration option
          (defaults to 'jpg')
@@ -107,32 +110,32 @@

 def render(hdf, env, texData, density, fleqnMode, mathMode):
     # gets paths from configuration
-    tmpdir = env.get_config('latex', 'temp_dir')
-    imagePath = env.get_config('latex', 'image_path')
-    displayPath = env.get_config('latex', 'display_path')
-    fleqnIndent = env.get_config('latex', 'fleqn_indent')
-    latexPath = env.get_config('latex', 'latex_path')
-    dvipsPath = env.get_config('latex', 'dvips_path')
-    convertPath = env.get_config('latex', 'convert_path')
-    texMag = env.get_config('latex', 'text_mag')
-    imageFormat = env.get_config('latex', 'image_format')
-
-    if not tmpdir or not imagePath or not displayPath:
-       return "<b>Error: missing configuration settings in 'latex' macro</b><br>"
-
-    # set defaults
-    if not fleqnIndent:
-        fleqnIndent = '5%'
-    if not latexPath:
-       latexPath = 'latex'
-    if not dvipsPath:
-       dvipsPath = 'dvips'
-    if not convertPath:
-       convertPath = 'convert'
-    if not texMag:
-       texMag = 1000 # I'm told this is latex's default value
-    if not imageFormat:
-       imageFormat = 'jpg'
+    cfg = env.config
+    tmpdir = cfg.get('latex', 'temp_dir')
+    imagePath = cfg.get('latex', 'image_path')
+    displayPath = cfg.get('latex', 'display_path')
+    fleqnIndent = cfg.get('latex', 'fleqn_indent', '5%')
+    latexPath = cfg.get('latex', 'latex_path', 'latex')
+    dvipsPath = cfg.get('latex', 'dvips_path', 'dvips')
+    convertPath = cfg.get('latex', 'convert_path', 'convert')
+    texMag = cfg.get('latex', 'text_mag', 1000)
+    imageFormat = cfg.get('latex', 'image_format', 'jpg')
+
+
+    def make_cfg_error(element):
+        msg = """\
+<div class="system-message">
+ <strong>Error: the <code>formula</code> macro requires the setting <code>%s</code> in the configuration section <code>latex</code></strong>
+</div>
+"""
+        return msg % element
+
+    if not tmpdir:
+        return make_cfg_error('temp_dir')
+    elif not imagePath:
+        return make_cfg_error('image_path')
+    elif not displayPath:
+        return make_cfg_error('display_path')

     path = tmpdir # + hdf.getValue("project.name.encoded", "default")
     # create temporary directory if necessary
@@ -219,6 +222,8 @@

 # arguments start with "#" on the beginning of a line
 def execute(hdf, text, env):
+    cfg = env.config
+
     # TODO: unescape all html escape codes
     text = text.replace("&amp;", "&")

@@ -226,7 +231,7 @@
     density = 100
     mathMode = 1    # default to using display-math mode for LaTeX processing
     displayMode = 0 # default to generating inline formula
-    fleqnMode   = env.get_config('latex', 'fleqn')
+    fleqnMode   = cfg.get('latex', 'fleqn')
     centerImage = 0
     indentImage = 0
     indentClass = ""

Attachments

Change History

10/25/05 10:46:06 changed by cryos@gentoo.org

Applied this patch to my trac installation and I can now use the latex macros in my installation of 0.9 beta2. It seems to work well after applying the patch and realising that the htdocs directory is served up as $projectbaseurl/chrome/site.

04/21/06 00:34:00 changed by vgough

  • status changed from new to closed.
  • resolution set to fixed.

(In [678]) Apply changes from Ken McIvor? fixes #65

03/19/07 13:33:30 changed by gdelfino@mac.com

  • release set to 0.8.
  • status changed from closed to reopened.
  • resolution deleted.

Is this compatible with Trac 0.10?

03/19/07 14:26:09 changed by Ken McIvor <mcivken@iit.edu>

  • status changed from reopened to closed.
  • resolution set to wontfix.

I don't know if it's compatible with version 0.10. You should try and then open a new ticket if you discover problems.


Add/Change #65 (Trac 0.9b2 compatability)




Change Properties
Action