version 1.55, 2010/05/20 09:28:36
|
version 1.67, 2010/06/08 16:57:36
|
Line 222 class documentViewer(Folder):
|
Line 222 class documentViewer(Folder):
|
url = self.template.zogilib.getDLBaseUrl() |
url = self.template.zogilib.getDLBaseUrl() |
return url |
return url |
|
|
|
def getDocumentViewerURL(self): |
|
"""returns the URL of this instance""" |
|
return self.absolute_url() |
|
|
def getStyle(self, idx, selected, style=""): |
def getStyle(self, idx, selected, style=""): |
"""returns a string with the given style and append 'sel' if path == selected.""" |
"""returns a string with the given style and append 'sel' if path == selected.""" |
#logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) |
#logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) |
Line 665 class documentViewer(Folder):
|
Line 669 class documentViewer(Folder):
|
pageinfo['query'] = self.REQUEST.get('query',' ') |
pageinfo['query'] = self.REQUEST.get('query',' ') |
pageinfo['queryType'] = self.REQUEST.get('queryType',' ') |
pageinfo['queryType'] = self.REQUEST.get('queryType',' ') |
pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') |
pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') |
|
|
pageinfo['textPN'] = self.REQUEST.get('textPN','1') |
pageinfo['textPN'] = self.REQUEST.get('textPN','1') |
pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') |
pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') |
pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
Line 686 class documentViewer(Folder):
|
Line 689 class documentViewer(Folder):
|
pageinfo['tocPN'] = min (tocPages,toc) |
pageinfo['tocPN'] = min (tocPages,toc) |
|
|
pageinfo['searchPN'] =self.REQUEST.get('searchPN','1') |
pageinfo['searchPN'] =self.REQUEST.get('searchPN','1') |
pageinfo['sn'] =self.REQUEST.get('sn','1') |
pageinfo['sn'] =self.REQUEST.get('sn','') |
|
|
return pageinfo |
return pageinfo |
|
|
Line 706 class documentViewer(Folder):
|
Line 709 class documentViewer(Folder):
|
tocMode = pageinfo['tocMode'] |
tocMode = pageinfo['tocMode'] |
tocPN = pageinfo['tocPN'] |
tocPN = pageinfo['tocPN'] |
selfurl = self.absolute_url() |
selfurl = self.absolute_url() |
logging.debug("documentViewer (gettoc) /mpdl/interface/doc-query.xql?document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode)) |
page=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&highlightQuery=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode,highlightQuery) ,outputUnicode=False) |
page=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode) ,outputUnicode=False) |
|
pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url) |
pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url) |
pagedom = Parse(pagexml) |
pagedom = Parse(pagexml) |
if (queryType=="fulltext")or(queryType=="xpath")or(queryType=="xquery")or(queryType=="fulltextMorphLemma"): |
if (queryType=="fulltext")or(queryType=="xpath")or(queryType=="xquery")or(queryType=="fulltextMorphLemma"): |
Line 721 class documentViewer(Folder):
|
Line 723 class documentViewer(Folder):
|
href = hrefNode.nodeValue |
href = hrefNode.nodeValue |
if href.startswith('page-fragment.xql'): |
if href.startswith('page-fragment.xql'): |
selfurl = self.absolute_url() |
selfurl = self.absolute_url() |
#l.setAttributeNS(None, "span class = 'hit highlight'", "background-color: #77DD77;") |
|
pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN)) |
pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN)) |
hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl) |
hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl) |
l.setAttributeNS(None, "onClick", "id='highlighting'") |
|
logging.debug("documentViewer (gettoc) highlightQuery: %s"%(highlightQuery)) |
|
l.setAttributeNS(None, "highlightQuery", "id='highlighting'") |
|
return serializeNode(pagenode) |
return serializeNode(pagenode) |
|
|
if (queryType=="fulltextMorph"): |
if (queryType=="fulltextMorph"): |
pagedivs = pagedom.xpath("//div[@class='queryResult']") |
pagedivs = pagedom.xpath("//div[@class='queryResult']") |
|
|
if len(pagedivs)>0: |
if len(pagedivs)>0: |
pagenode=pagedivs[0] |
pagenode=pagedivs[0] |
links=pagenode.xpath("//a") |
links=pagenode.xpath("//a") |
Line 744 class documentViewer(Folder):
|
Line 741 class documentViewer(Folder):
|
pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN)) |
pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN)) |
hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl) |
hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl) |
if href.startswith('../lt/lemma.xql'): |
if href.startswith('../lt/lemma.xql'): |
selfurl = self.absolute_url() |
|
hrefNode.nodeValue = href.replace('lt/lemma.xql','%s/template/head_main_lemma'%selfurl) |
hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl) |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
|
pagedivs = pagedom.xpath("//div[@class='queryResultMorphExpansion']") |
return serializeNode(pagenode) |
return serializeNode(pagenode) |
|
|
if (queryType=="ftIndex")or(queryType=="ftIndexMorph"): |
if (queryType=="ftIndex")or(queryType=="ftIndexMorph"): |
Line 763 class documentViewer(Folder):
|
Line 761 class documentViewer(Folder):
|
hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn)) |
hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn)) |
|
|
if href.startswith('../lt/lex.xql'): |
if href.startswith('../lt/lex.xql'): |
# selfurl = self.absolute_url() |
|
hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl) |
hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl) |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
if href.startswith('../lt/lemma.xql'): |
if href.startswith('../lt/lemma.xql'): |
#selfurl = self.absolute_url() |
|
hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl) |
hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl) |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;") |
Line 785 class documentViewer(Folder):
|
Line 781 class documentViewer(Folder):
|
docinfo['numPages'] = text.count("<pb ") |
docinfo['numPages'] = text.count("<pb ") |
return docinfo |
return docinfo |
|
|
def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None,): |
def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None, tocMode=None, tocPN=None): |
"""returns single page from fulltext""" |
"""returns single page from fulltext""" |
docpath = docinfo['textURLPath'] |
docpath = docinfo['textURLPath'] |
|
path = docinfo['textURLPath'] |
|
url = docinfo['url'] |
|
viewMode= pageinfo['viewMode'] |
|
tocMode = pageinfo['tocMode'] |
|
tocPN = pageinfo['tocPN'] |
|
selfurl = self.absolute_url() |
|
|
|
#pn = pageinfo['searchPN'] |
|
|
if mode == "text_dict": |
if mode == "text_dict": |
textmode = "textPollux" |
textmode = "textPollux" |
else: |
else: |
textmode = mode |
textmode = mode |
|
|
#selfurl = self.absolute_url() |
textParam = "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn) |
#viewMode= pageinfo['viewMode'] |
if highlightQuery is not None: |
#tocMode = pageinfo['tocMode'] |
textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn) |
#tocPN = pageinfo['tocPN'] |
|
|
|
pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn), outputUnicode=False) |
pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False) |
# post-processing downloaded xml |
|
pagedom = Parse(pagexml) |
pagedom = Parse(pagexml) |
# plain text mode |
# plain text mode |
if mode == "text": |
if mode == "text": |
Line 807 class documentViewer(Folder):
|
Line 810 class documentViewer(Folder):
|
pagedivs = pagedom.xpath("/div") |
pagedivs = pagedom.xpath("/div") |
#queryResultPage |
#queryResultPage |
if len(pagedivs) > 0: |
if len(pagedivs) > 0: |
|
|
pagenode = pagedivs[0] |
pagenode = pagedivs[0] |
links = pagenode.xpath("//a") |
links = pagenode.xpath("//a") |
for l in links: |
for l in links: |
hrefNode = l.getAttributeNodeNS(None, u"href") |
hrefNode = l.getAttributeNodeNS(None, u"href") |
|
|
if hrefNode: |
if hrefNode: |
href= hrefNode.nodeValue |
href= hrefNode.nodeValue |
if href.startswith('#note-0006-01'): |
if href.startswith('#note-'): |
selfurl = self.absolute_url() |
hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn)) |
hrefNode.nodeValue = href.replace("href='#note-'",'xaxa/%s/'%selfurl) |
|
return serializeNode(pagenode) |
return serializeNode(pagenode) |
if mode == "xml": |
if mode == "xml": |
# first div contains text |
# first div contains text |
Line 824 class documentViewer(Folder):
|
Line 827 class documentViewer(Folder):
|
if len(pagedivs) > 0: |
if len(pagedivs) > 0: |
pagenode = pagedivs[0] |
pagenode = pagedivs[0] |
return serializeNode(pagenode) |
return serializeNode(pagenode) |
|
if mode == "pureXml": |
|
# first div contains text |
|
pagedivs = pagedom.xpath("/div") |
|
if len(pagedivs) > 0: |
|
pagenode = pagedivs[0] |
|
return serializeNode(pagenode) |
# text-with-links mode |
# text-with-links mode |
if mode == "text_dict": |
if mode == "text_dict": |
# first div contains text |
# first div contains text |
Line 853 class documentViewer(Folder):
|
Line 862 class documentViewer(Folder):
|
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'target', '_blank') |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=700, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=700, scrollbars=1'); return false;") |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') |
|
|
|
if href.startswith('#note-'): |
|
hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn)) |
|
|
|
|
return serializeNode(pagenode) |
return serializeNode(pagenode) |
|
|
return "no text here" |
return "no text here" |
Line 890 class documentViewer(Folder):
|
Line 904 class documentViewer(Folder):
|
def getToc(self, mode="text", docinfo=None): |
def getToc(self, mode="text", docinfo=None): |
"""loads table of contents and stores in docinfo""" |
"""loads table of contents and stores in docinfo""" |
logging.debug("documentViewer (gettoc) mode: %s"%(mode)) |
logging.debug("documentViewer (gettoc) mode: %s"%(mode)) |
|
if mode == "none": |
|
return docinfo |
|
|
if 'tocSize_%s'%mode in docinfo: |
if 'tocSize_%s'%mode in docinfo: |
# cached toc |
# cached toc |
return docinfo |
return docinfo |
|
|
docpath = docinfo['textURLPath'] |
docpath = docinfo['textURLPath'] |
# we need to set a result set size |
# we need to set a result set size |
pagesize = 1000 |
pagesize = 1000 |
Line 952 class documentViewer(Folder):
|
Line 970 class documentViewer(Folder):
|
#else: |
#else: |
# return "No TOC!" |
# return "No TOC!" |
|
|
|
|
def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): |
def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): |
"""init document viewer""" |
"""init document viewer""" |
self.title=title |
self.title=title |