Changeset 3136 for trunk


Ignore:
Timestamp:
01/12/11 11:53:49 (9 years ago)
Author:
jukka
Message:

Added chart.apis.google.com as external latex service and adjusted html escaping for latex code.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/FieldsWidgets.py

    r3133 r3136  
    950950        return cleaned_value 
    951951 
     952 
    952953    def textOnly(self, instance, **kwargs): 
    953954        chapters=self.get(instance) 
    954955        if chapters and isinstance(chapters, list): 
    955             return '\n'.join([x['text'] for x in chapters]) 
     956            res=[] 
     957            for ch in chapters: 
     958                if ch: 
     959                    try: 
     960                        res.append(to_unicode(ch['text'])) 
     961                    except UnicodeDecodeError: 
     962                        pass 
     963            return u'\n'.join(res) 
    956964        elif chapters: 
    957965            return str(chapters)         
  • trunk/LatexTool.py

    r3072 r3136  
    2929from AccessControl import ClassSecurityInfo 
    3030from DocumentTemplate.html_quote import html_quote 
     31from urllib import quote_plus 
    3132from string import strip, join, replace 
    32 import os, sys, re, zLOG, string, math, popen2, select 
     33import os, sys, re, zLOG, string, math, popen2, select, htmllib 
    3334from struct import pack, unpack 
    3435from cgi import escape 
     
    7172class AlignError(Exception): pass 
    7273 
     74 
     75def unescape(s): 
     76    p = htmllib.HTMLParser(None) 
     77    p.save_bgn() 
     78    p.feed(s) 
     79    return p.save_end() 
    7380 
    7481def findinpath(exe): 
     
    184191    def getRemoteImageFor(self, latexCode): 
    185192        print 'using remote latex' 
    186         alt= html_quote(latexRemoveDelim.match(latexCode).group(2)) 
    187         if latexCode.startswith('\\('): 
    188             latexCode=latexCode[2:-2] # remove ( ) from '(code)'  
    189         src=''.join((EXTERNAL_LATEX_SERVICE,latexCode)) 
     193        code=unescape(latexCode) 
     194        code=latexRemoveDelim.match(code).group(2) 
     195        alt= html_quote(code) 
     196        src=''.join((EXTERNAL_LATEX_SERVICE,quote_plus(code))) 
    190197        return '<img alt="%s" class="equation" src="%s" border="0" align="middle" />' % (alt, src) 
    191198 
  • trunk/config.py

    r3072 r3136  
    9393# Forkosh service seems to be closed for us now. 
    9494#EXTERNAL_LATEX_SERVICE='http://www.forkosh.dreamhost.com/mimetex.cgi?' 
    95 EXTERNAL_LATEX_SERVICE='' 
     95EXTERNAL_LATEX_SERVICE='http://chart.apis.google.com/chart?cht=tx&chl=' 
    9696 
    9797# To disable local latex, uncomment line below: 
  • trunk/skins/lemill/RSSResults.py

    r3094 r3136  
    1818if 'portfolio' in REQUEST: 
    1919    if 'groups' in path: 
    20         group=context.getBlog()         
    21         if group: 
    22             results=pc.browsingSearch(REQUEST=REQUEST, sort_limit=max, group=group.UID(), author='', RSS=True) 
     20        try: 
     21            group=context.getBlog()         
     22            if group: 
     23                results=pc.browsingSearch(REQUEST=REQUEST, sort_limit=max, group=group.UID(), author='', RSS=True) 
     24        except AttributeError: 
     25             pass 
    2326    elif 'people' in path: 
    24         results=pc.browsingSearch(REQUEST=REQUEST, sort_limit=max, group='', author=context.getMemberId(), RSS=True) 
     27        try: 
     28            results=pc.browsingSearch(REQUEST=REQUEST, sort_limit=max, group='', author=context.getMemberId(), RSS=True) 
     29        except AttributeError: 
     30            pass 
    2531elif 'groups' in path: 
    26     results=context.getRSSResults(max=max) 
     32    try: 
     33        results=context.getRSSResults(max=max) 
     34    except AttributeError: 
     35        pass 
    2736else: 
    2837    results=pc.browsingSearch(REQUEST=REQUEST, sort_limit=max, RSS=True) 
  • trunk/skins/lemill/macros_messages.pt

    r3045 r3136  
    2525    <div class="portalMessage" i18n:domain="lemill"> <form tal:attributes="action string:${here_url}/updateLanguage" id="languageUpdater" method="post"> 
    2626            <span i18n:translate="text_res_language_missing">This resource doesn't have language defined. If you can, please help others to find it by telling us in which language it is.</span><br/><select name="lang" id="lang">  
    27             <option tal:attributes="value la" tal:content="python:context.script_getPrettyLanguage(la)" tal:repeat="la context/getLanguagelist" /></select></form></div> 
     27            <option tal:attributes="value la" tal:content="python:context.script_getPrettyLanguage(la)" tal:repeat="la context/getLanguagelist" /></select><input type="hidden" name="minor_edit" value="1" /></form></div> 
    2828<script type="text/javascript"> 
    2929$('select#lang').change(function() {this.form.submit();}); 
     
    4545        <option tal:attributes="value co" tal:content="co" tal:repeat="co context/getCountrylist" /> 
    4646      </select> 
     47     <input type="hidden" name="minor_edit" value="1" /> 
    4748    </form> 
    4849    <script type="text/javascript"> 
Note: See TracChangeset for help on using the changeset viewer.