Mercurial > hg > documentViewer
comparison documentViewer.py @ 496:f83ffab77502 metalify-1
last version from HEAD
new zogilib version
author | casties |
---|---|
date | Fri, 18 Jun 2010 21:41:28 +0200 |
parents | ede0c93de798 |
children |
comparison
equal
deleted
inserted
replaced
495:ede0c93de798 | 496:f83ffab77502 |
---|---|
5 from AccessControl import ClassSecurityInfo | 5 from AccessControl import ClassSecurityInfo |
6 from AccessControl import getSecurityManager | 6 from AccessControl import getSecurityManager |
7 from Globals import package_home | 7 from Globals import package_home |
8 | 8 |
9 from Ft.Xml import EMPTY_NAMESPACE, Parse | 9 from Ft.Xml import EMPTY_NAMESPACE, Parse |
10 from Ft.Xml.Domlette import PrettyPrint, Print | 10 import Ft.Xml.Domlette |
11 import os.path | 11 import os.path |
12 import sys | 12 import sys |
13 import urllib | 13 import urllib |
14 import urllib2 | 14 import urllib2 |
15 import logging | 15 import logging |
41 return rc | 41 return rc |
42 | 42 |
43 def serializeNode(node, encoding='utf-8'): | 43 def serializeNode(node, encoding='utf-8'): |
44 """returns a string containing node as XML""" | 44 """returns a string containing node as XML""" |
45 buf = cStringIO.StringIO() | 45 buf = cStringIO.StringIO() |
46 Print(node, stream=buf, encoding=encoding) | 46 Ft.Xml.Domlette.Print(node, stream=buf, encoding=encoding) |
47 s = buf.getvalue() | 47 s = buf.getvalue() |
48 buf.close() | 48 buf.close() |
49 return s | 49 return s |
50 | 50 |
51 | 51 |
170 | 170 |
171 def getSearch(self, **args): | 171 def getSearch(self, **args): |
172 """get search""" | 172 """get search""" |
173 return self.template.fulltextclient.getSearch(**args) | 173 return self.template.fulltextclient.getSearch(**args) |
174 | 174 |
175 def getNumPages(self, **args): | 175 def getNumPages(self, docinfo): |
176 """get numpages""" | 176 """get numpages""" |
177 return self.template.fulltextclient.getNumPages(**args) | 177 return self.template.fulltextclient.getNumPages(docinfo) |
178 | 178 |
179 def getTranslate(self, **args): | 179 def getTranslate(self, **args): |
180 """get translate""" | 180 """get translate""" |
181 return self.template.fulltextclient.getTranslate(**args) | 181 return self.template.fulltextclient.getTranslate(**args) |
182 | 182 |
264 | 264 |
265 def generateMarks(self,mk): | 265 def generateMarks(self,mk): |
266 ret="" | 266 ret="" |
267 if mk is None: | 267 if mk is None: |
268 return "" | 268 return "" |
269 if type(mk) is not ListType: | 269 if not isinstance(mk, list): |
270 mk=[mk] | 270 mk=[mk] |
271 for m in mk: | 271 for m in mk: |
272 ret+="mk=%s"%m | 272 ret+="mk=%s"%m |
273 return ret | 273 return ret |
274 | 274 |
275 | 275 |
303 if params.get("mode", None) == "filepath": #wenn beim erst Aufruf filepath gesetzt wurde aendere das nun zu imagepath | 303 if params.get("mode", None) == "filepath": #wenn beim erst Aufruf filepath gesetzt wurde aendere das nun zu imagepath |
304 params["mode"] = "imagepath" | 304 params["mode"] = "imagepath" |
305 params["url"] = getParentDir(params["url"]) | 305 params["url"] = getParentDir(params["url"]) |
306 | 306 |
307 # quote values and assemble into query string | 307 # quote values and assemble into query string |
308 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) | 308 #ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
309 ps = urllib.urlencode(params) | |
309 url=self.REQUEST['URL1']+"?"+ps | 310 url=self.REQUEST['URL1']+"?"+ps |
310 return url | 311 return url |
311 | 312 |
312 def getLinkAmp(self,param=None,val=None): | 313 def getLinkAmp(self,param=None,val=None): |
313 """link to documentviewer with parameter param set to val""" | 314 """link to documentviewer with parameter param set to val""" |
585 if textUrls and (len(textUrls) > 0): | 586 if textUrls and (len(textUrls) > 0): |
586 textUrl = getTextFromNode(textUrls[0]) | 587 textUrl = getTextFromNode(textUrls[0]) |
587 docinfo['textURLPath'] = textUrl | 588 docinfo['textURLPath'] = textUrl |
588 if not docinfo['imagePath']: | 589 if not docinfo['imagePath']: |
589 # text-only, no page images | 590 # text-only, no page images |
590 docinfo = self.getNumPages(docinfo) #im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht | 591 docinfo = self.getNumPages(docinfo) |
591 | 592 |
592 presentationUrls = dom.xpath("//texttool/presentation") | 593 presentationUrls = dom.xpath("//texttool/presentation") |
593 docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag | 594 docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag |
594 | 595 |
595 if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen | 596 if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen |