Changeset 50:6c0f20cecc60 in documentViewer
- Timestamp:
- Jan 11, 2007, 12:03:17 PM (17 years ago)
- Branch:
- default
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r49 r50 18 18 import cgi 19 19 import urllib 20 import logging 20 21 import zLOG 21 22 import urlparse … … 60 61 class documentViewer(Folder): 61 62 """document viewer""" 62 textViewerUrl="http://127.0.0.1:8080/HFQP/testXSLT/getPage?"63 #textViewerUrl="http://127.0.0.1:8080/HFQP/testXSLT/getPage?" 63 64 64 65 meta_type="Document viewer" … … 228 229 if dom is None: 229 230 raise IOError("Unable to read index meta from %s"%(url)) 231 232 return dom 233 234 def getPresentationInfoXML(self, url): 235 """returns dom of info.xml document at url""" 236 num_retries = 3 237 dom = None 238 metaUrl = None 239 if url.startswith("http://"): 240 # real URL 241 metaUrl = url 242 else: 243 # online path 244 server=self.digilibBaseUrl+"/servlet/Texter?fn=" 245 metaUrl=server+url.replace("/mpiwg/online","") 246 247 248 for cnt in range(num_retries): 249 try: 250 # patch dirk encoding fehler treten dann nicht mehr auf 251 # dom = NonvalidatingReader.parseUri(metaUrl) 252 txt=urllib.urlopen(metaUrl).read() 253 dom = Parse(txt) 254 break 255 except: 256 zLOG.LOG("ERROR documentViewer (getPresentationInfoXML)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) 257 258 if dom is None: 259 raise IOError("Unable to read infoXMLfrom %s"%(url)) 230 260 231 261 return dom … … 346 376 docinfo['textURL'] = textUrl 347 377 348 docinfo = self.getBibinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) 378 379 presentationUrls=dom.xpath("//texttool/presentation") 380 if presentationUrls and (len(presentationUrls)>0): 381 # presentation url ergiebt sich ersetzen von index.meta in der url der fr die Metadaten 382 # durch den relativen Pfad auf die presentation infos 383 presentationUrl=url.replace('index.meta',getTextFromNode(presentationUrls[0])) 384 385 docinfo = self.getBibinfoFromTextToolPresentation(presentationUrl,docinfo=docinfo,dom=dom) 386 else: 387 docinfo = self.getBibinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) 349 388 docinfo = self.getAuthinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) 350 389 return docinfo 351 390 352 391 392 def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None): 393 """gets the bibliographical information from the preseantion entry in texttools 394 """ 395 dom=self.getPresentationInfoXML(url) 396 docinfo['author']=getTextFromNode(dom.xpath("//author")[0]) 397 docinfo['title']=getTextFromNode(dom.xpath("//title")[0]) 398 docinfo['year']=getTextFromNode(dom.xpath("//date")[0]) 399 return docinfo 400 353 401 def getDocinfoFromImagePath(self,path,docinfo=None): 354 402 """path ist the path to the images it assumes that the index.meta file is one level higher.""" … … 371 419 zLOG.LOG("documentViewer (getdocinfo)", zLOG.INFO,"mode: %s, url: %s"%(mode,url)) 372 420 # look for cached docinfo in session 373 if self.REQUEST.SESSION.has_key('docinfo'): 421 # XXXX Sesion abgeschaltet 422 if self.REQUEST.SESSION.has_key('docinfo_XX'): 374 423 docinfo = self.REQUEST.SESSION['docinfo'] 375 424 # check if its still current … … 472 521 """try to get the digilib URL from zogilib""" 473 522 url = self.imageViewerUrl[:-1] + "/getScalerUrl" 474 print urlparse.urlparse(url)[0] 475 print urlparse.urljoin(self.absolute_url(),url) 523 #print urlparse.urlparse(url)[0] 524 #print urlparse.urljoin(self.absolute_url(),url) 525 logging.info("finddigiliburl: %s"%urlparse.urlparse(url)[0]) 526 logging.info("finddigiliburl: %s"%urlparse.urljoin(self.absolute_url(),url)) 527 476 528 try: 477 529 if urlparse.urlparse(url)[0]=='': #relative path -
zpt/changeDocumentViewer.zpt
r48 r50 17 17 <p class="form-label">Text viewer URL</p> 18 18 <p class="form-element"><input size="80" tal:attributes="value here/textViewerUrl" name="textViewerUrl"></p> 19 <p class="form-text">Should be a n ECHO_xslt instance, full URL up to the '?' (e.g. 'http://echo.mpiwg-berlin.mpg.de/viewText/getPage?')</p>19 <p class="form-text">Should be a displayXML instance, full URL up to the '?' (e.g. 'http://echo.mpiwg-berlin.mpg.de/viewText?')</p> 20 20 21 21 <p class="form-optional">Thumbnail rows</p> -
zpt/image_main.zpt
r46 r50 1 1 <tal:block tal:define="docinfo options/docinfo; pageinfo options/pageinfo; mode python:options.get('viewMode','images')"> 2 2 <iframe tal:condition="python:mode=='images'" height="100%" width="100%" tal:attributes="src string:${here/imageViewerUrl}fn=${docinfo/imagePath}&pn=${pageinfo/current}"/> 3 <iframe tal:condition="python:mode=='text'" height="100%" width="100%" tal:attributes="src string:${here/textViewerUrl}fn=${docinfo/textURL}& _pn=${pageinfo/current}"/>3 <iframe tal:condition="python:mode=='text'" height="100%" width="100%" tal:attributes="src string:${here/textViewerUrl}fn=${docinfo/textURL}&pn=${pageinfo/current}"/> 4 4 </tal:block>
Note: See TracChangeset
for help on using the changeset viewer.