version 1.37, 2008/11/04 22:03:56
|
version 1.42, 2010/03/08 15:02:33
|
Line 1
|
Line 1
|
|
|
|
|
from OFS.Folder import Folder |
from OFS.Folder import Folder |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
Line 11 from Ft.Xml.Domlette import Nonvalidatin
|
Line 10 from Ft.Xml.Domlette import Nonvalidatin
|
from Ft.Xml.Domlette import PrettyPrint, Print |
from Ft.Xml.Domlette import PrettyPrint, Print |
from Ft.Xml import EMPTY_NAMESPACE, Parse |
from Ft.Xml import EMPTY_NAMESPACE, Parse |
|
|
import Ft.Xml.XPath |
|
|
|
|
import Ft.Xml.XPath |
|
import xmlrpclib |
import os.path |
import os.path |
import sys |
import sys |
import cgi |
import cgi |
Line 189 class documentViewer(Folder):
|
Line 189 class documentViewer(Folder):
|
del params[param] |
del params[param] |
else: |
else: |
params[param] = str(val) |
params[param] = str(val) |
|
if params["mode"] == "filepath": #wenn beim erst Aufruf filepath gesetzt wurde aendere das nun zu imagepath |
|
params["mode"] = "imagepath" |
|
params["url"] = getParentDir(params["url"]) |
|
|
# quote values and assemble into query string |
# quote values and assemble into query string |
ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
Line 210 class documentViewer(Folder):
|
Line 213 class documentViewer(Folder):
|
ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
url=self.REQUEST['URL1']+"?"+ps |
url=self.REQUEST['URL1']+"?"+ps |
return url |
return url |
|
|
def getInfo_xml(self,url,mode): |
def getInfo_xml(self,url,mode): |
"""returns info about the document as XML""" |
"""returns info about the document as XML""" |
|
|
Line 229 class documentViewer(Folder):
|
Line 233 class documentViewer(Folder):
|
else: |
else: |
return style |
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): |
def isAccessible(self, docinfo): |
"""returns if access to the resource is granted""" |
"""returns if access to the resource is granted""" |
Line 257 class documentViewer(Folder):
|
Line 266 class documentViewer(Folder):
|
docinfo = {} |
docinfo = {} |
|
|
for x in range(cut): |
for x in range(cut): |
|
|
path=getParentDir(path) |
path=getParentDir(path) |
|
|
infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
|
|
logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) |
logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) |
Line 354 class documentViewer(Folder):
|
Line 365 class documentViewer(Folder):
|
docinfo = {} |
docinfo = {} |
|
|
if dom is None: |
if dom is None: |
for x in range(cut+1): |
for x in range(cut): |
path=getParentDir(path) |
path=getParentDir(path) |
dom = self.getIndexMeta(path) |
dom = self.getIndexMeta(path) |
|
|
Line 376 class documentViewer(Folder):
|
Line 387 class documentViewer(Folder):
|
docinfo = {} |
docinfo = {} |
|
|
if dom is None: |
if dom is None: |
for x in range(cut+1): |
for x in range(cut): |
path=getParentDir(path) |
path=getParentDir(path) |
dom = self.getIndexMeta(path) |
dom = self.getIndexMeta(path) |
|
|
|
logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) |
# put in all raw bib fields as dict "bib" |
# put in all raw bib fields as dict "bib" |
bib = dom.xpath("//bib/*") |
bib = dom.xpath("//bib/*") |
if bib and len(bib)>0: |
if bib and len(bib)>0: |
Line 419 class documentViewer(Folder):
|
Line 431 class documentViewer(Folder):
|
return docinfo |
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): |
def getDocinfoFromTextTool(self,url,dom=None,docinfo=None): |
"""parse texttool tag in index meta""" |
"""parse texttool tag in index meta""" |
logger("documentViewer (getdocinfofromtexttool)", logging.INFO,"url: %s"%(url)) |
logger("documentViewer (getdocinfofromtexttool)", logging.INFO,"url: %s"%(url)) |
Line 460 class documentViewer(Folder):
|
Line 478 class documentViewer(Folder):
|
imageDirs=dom.xpath("//texttool/image") |
imageDirs=dom.xpath("//texttool/image") |
if imageDirs and (len(imageDirs)>0): |
if imageDirs and (len(imageDirs)>0): |
imageDir=getTextFromNode(imageDirs[0]) |
imageDir=getTextFromNode(imageDirs[0]) |
|
|
else: |
else: |
# we balk with no image tag / not necessary anymore because textmode is now standard |
# we balk with no image tag / not necessary anymore because textmode is now standard |
#raise IOError("No text-tool info in %s"%(url)) |
#raise IOError("No text-tool info in %s"%(url)) |
imageDir="" |
imageDir="" |
docinfo['numPages']=1 # im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht |
#xquery="//pb" |
|
|
docinfo['imagePath'] = "" # keine Bilder |
docinfo['imagePath'] = "" # keine Bilder |
docinfo['imageURL'] = "" |
docinfo['imageURL'] = "" |
|
|
Line 475 class documentViewer(Folder):
|
Line 493 class documentViewer(Folder):
|
imageDir=imageDir.replace("/mpiwg/online",'') |
imageDir=imageDir.replace("/mpiwg/online",'') |
docinfo=self.getDirinfoFromDigilib(imageDir,docinfo=docinfo) |
docinfo=self.getDirinfoFromDigilib(imageDir,docinfo=docinfo) |
docinfo['imagePath'] = imageDir |
docinfo['imagePath'] = imageDir |
|
|
docinfo['imageURL'] = self.digilibBaseUrl+"/servlet/Scaler?fn="+imageDir |
docinfo['imageURL'] = self.digilibBaseUrl+"/servlet/Scaler?fn="+imageDir |
|
|
viewerUrls=dom.xpath("//texttool/digiliburlprefix") |
viewerUrls=dom.xpath("//texttool/digiliburlprefix") |
Line 493 class documentViewer(Folder):
|
Line 512 class documentViewer(Folder):
|
|
|
docinfo['textURL'] = textUrl |
docinfo['textURL'] = textUrl |
|
|
|
textUrls=dom.xpath("//texttool/text-url-path") |
|
if textUrls and (len(textUrls)>0): |
|
textUrl=getTextFromNode(textUrls[0]) |
|
docinfo['textURLPath'] = textUrl |
|
|
presentationUrls=dom.xpath("//texttool/presentation") |
presentationUrls=dom.xpath("//texttool/presentation") |
docinfo = self.getBibinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get info von bib tag |
docinfo = self.getBibinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get info von bib tag |
|
|
if presentationUrls and (len(presentationUrls)>0): # ueberschreibe diese durch presentation informationen |
if presentationUrls and (len(presentationUrls)>0): # ueberschreibe diese durch presentation informationen |
# presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten |
# presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten |
# durch den relativen Pfad auf die presentation infos |
# durch den relativen Pfad auf die presentation infos |
presentationUrl=url.replace('index.meta',getTextFromNode(presentationUrls[0])) |
presentationPath = getTextFromNode(presentationUrls[0]) |
|
if url.endswith("index.meta"): |
|
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.getBibinfoFromTextToolPresentation(presentationUrl,docinfo=docinfo,dom=dom) |
|
|
docinfo = self.getAuthinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get access info |
docinfo = self.getAuthinfoFromIndexMeta(url,docinfo=docinfo,dom=dom) # get access info |
|
|
return docinfo |
return docinfo |
|
|
|
|
Line 532 class documentViewer(Folder):
|
Line 562 class documentViewer(Folder):
|
path=path.replace("/mpiwg/online","") |
path=path.replace("/mpiwg/online","") |
docinfo['imagePath'] = path |
docinfo['imagePath'] = path |
docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) |
docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) |
|
|
|
pathorig=path |
|
for x in range(cut): |
|
path=getParentDir(path) |
|
logging.error("PATH:"+path) |
imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
docinfo['imageURL'] = imageUrl |
docinfo['imageURL'] = imageUrl |
|
|
docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
#path ist the path to the images it assumes that the index.meta file is one level higher. |
docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
|
docinfo = self.getAuthinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
return docinfo |
return docinfo |
|
|
|
|
Line 583 class documentViewer(Folder):
|
Line 619 class documentViewer(Folder):
|
pageinfo['start'] = start |
pageinfo['start'] = start |
pageinfo['end'] = start + grpsize |
pageinfo['end'] = start + grpsize |
if docinfo is not None: |
if docinfo is not None: |
|
|
np = int(docinfo['numPages']) |
np = int(docinfo['numPages']) |
pageinfo['end'] = min(pageinfo['end'], np) |
pageinfo['end'] = min(pageinfo['end'], np) |
pageinfo['numgroups'] = int(np / grpsize) |
pageinfo['numgroups'] = int(np / grpsize) |
if np % grpsize > 0: |
if np % grpsize > 0: |
pageinfo['numgroups'] += 1 |
pageinfo['numgroups'] += 1 |
logging.debug("getPageInfo: %s"%repr(pageinfo)) |
|
return pageinfo |
return pageinfo |
|
|
def text(self,mode,url,pn): |
def text(self,mode,url,pn): |