Mercurial > hg > documentViewer
diff documentViewer.py @ 83:ec12a2440daa
My last update Bukhman Andrey
author | abukhman |
---|---|
date | Mon, 08 Mar 2010 16:02:33 +0100 |
parents | 260078dfd1c4 |
children | a6e4f9b6729a |
line wrap: on
line diff
--- a/documentViewer.py Fri Feb 12 15:33:02 2010 +0100 +++ b/documentViewer.py Mon Mar 08 16:02:33 2010 +0100 @@ -1,4 +1,3 @@ - from OFS.Folder import Folder from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate @@ -11,8 +10,9 @@ from Ft.Xml.Domlette import PrettyPrint, Print from Ft.Xml import EMPTY_NAMESPACE, Parse + import Ft.Xml.XPath - +import xmlrpclib import os.path import sys import cgi @@ -233,6 +233,11 @@ else: return style + def getTextLanguage(self,url,docinfo): + docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) + lang = urlencode({'':docinfo['lang']}) + return lang + def isAccessible(self, docinfo): """returns if access to the resource is granted""" @@ -424,7 +429,13 @@ docinfo['lang']='' return docinfo - + + + def getNumPages(self, xquery, docinfo=None): #New Method 24.02.2010 + text=self.viewerTemplates.query.eval("/mpdl/interface/xquery.xql","document="+ docinfo['textURLPath'] +"&xquery="+str(xquery)) + docinfo['numPages'] = text.count("<pb ") + return docinfo + def getDocinfoFromTextTool(self,url,dom=None,docinfo=None): """parse texttool tag in index meta""" @@ -467,15 +478,15 @@ imageDirs=dom.xpath("//texttool/image") if imageDirs and (len(imageDirs)>0): imageDir=getTextFromNode(imageDirs[0]) + else: # we balk with no image tag / not necessary anymore because textmode is now standard #raise IOError("No text-tool info in %s"%(url)) imageDir="" - docinfo['numPages']=1 # im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht - + #xquery="//pb" docinfo['imagePath'] = "" # keine Bilder docinfo['imageURL'] = "" - + if imageDir and archivePath: #print "image: ", imageDir, " archivepath: ", archivePath imageDir=os.path.join(archivePath,imageDir) @@ -504,9 +515,8 @@ textUrls=dom.xpath("//texttool/text-url-path") if textUrls and (len(textUrls)>0): textUrl=getTextFromNode(textUrls[0]) - - docinfo['textURLPath'] = textUrl - + docinfo['textURLPath'] = textUrl + presentationUrls=dom.xpath("//texttool/presentation") docinfo = self.getBibinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get info von bib tag @@ -518,10 +528,11 @@ presentationUrl=url.replace('index.meta',presentationPath) else: presentationUrl=url + "/" + presentationPath - + docinfo=self.getNumPages('//pb', docinfo) #im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht docinfo = self.getBibinfoFromTextToolPresentation(presentationUrl,docinfo=docinfo,dom=dom) docinfo = self.getAuthinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get access info + return docinfo @@ -608,6 +619,7 @@ pageinfo['start'] = start pageinfo['end'] = start + grpsize if docinfo is not None: + np = int(docinfo['numPages']) pageinfo['end'] = min(pageinfo['end'], np) pageinfo['numgroups'] = int(np / grpsize)