Changeset 514:c55e376be01b in documentViewer


Ignore:
Timestamp:
Feb 28, 2012, 6:46:37 PM (12 years ago)
Author:
casties
Branch:
default
Message:

search works even with unicode...

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • SrvTxtUtils.py

    r490 r514  
    1212
    1313
    14 srvTxtUtilsVersion = "1.3"
     14srvTxtUtilsVersion = "1.4"
    1515
    1616def getInt(number, default=0):
     
    2727    except:
    2828        return default
     29
     30def unicodify(s):
     31    """decode str (utf-8 or latin-1 representation) into unicode object"""
     32    if not s:
     33        return u""
     34    if isinstance(s, str):
     35        try:
     36            return s.decode('utf-8')
     37        except:
     38            return s.decode('latin-1')
     39    else:
     40        return s
     41
     42def utf8ify(s):
     43    """encode unicode object or string into byte string in utf-8 representation.
     44       assumes string objects to be utf-8"""
     45    if not s:
     46        return ""
     47    if isinstance(s, str):
     48        return s
     49    else:
     50        return s.encode('utf-8')
    2951
    3052def getText(node, recursive=0):
  • documentViewer.py

    r513 r514  
    1818import string
    1919
    20 from SrvTxtUtils import getInt, getText, getHttpData, refreshingImageFileIndexHtml
     20from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml
    2121   
    2222def serializeNode(node, encoding="utf-8"):
     
    382382        urlParams = self.getParams(param=param, val=val, params=params, duplicates=duplicates)
    383383        # quote values and assemble into query string (not escaping '/')
    384         ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(unicode(v),'/')) for (k, v) in urlParams.items()])
     384        ps = paramSep.join(["%s=%s"%(k, urllib.quote_plus(utf8ify(v), '/')) for (k, v) in urlParams.items()])
    385385        if baseUrl is None:
    386386            baseUrl = self.getDocumentViewerURL()
     
    397397        """returns info about the document as XML"""
    398398        if not self.digilibBaseUrl:
    399             self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"
     399            self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
    400400       
    401401        docinfo = self.getDocinfo(mode=mode,url=url)
  • version.txt

    r498 r514  
    1 DocumentViewer 2.0a
     1DocumentViewer 2.0b
  • zpt/viewer_images.zpt

    r512 r514  
    66              numPages docinfo/numPages | nothing; dlBaseUrl docinfo/digilibBaseUrl | nothing;">
    77<head>
    8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     8  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    99  <title
    1010    tal:content="python:docinfo.get('creator',' ') + ' - ' + docinfo.get('title',' ')" />
  • zpt/viewer_text.zpt

    r512 r514  
    88              numPages docinfo/numPages | nothing;">
    99<head>
    10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     10  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    1111  <title
    1212    tal:content="python:docinfo.get('creator',' ') + ' - ' + docinfo.get('title',' ')" />
Note: See TracChangeset for help on using the changeset viewer.