--- documentViewer/MpdlXmlTextServer.py 2010/09/24 12:23:12 1.39 +++ documentViewer/MpdlXmlTextServer.py 2010/10/25 10:30:05 1.191 @@ -38,12 +38,10 @@ class MpdlXmlTextServer(SimpleItem): url = self.serverUrl+method return documentViewer.getHttpData(url,data,timeout=self.timeout) - def getSearch(self, pn=1, pageinfo=None, docinfo=None, query=None, queryType=None, lemma=None): + def getSearch(self, pn=1, pageinfo=None, docinfo=None, query=None, queryType=None, lemma=None, characterNormalization=None): """get search list""" docpath = docinfo['textURLPath'] url = docinfo['url'] - logging.debug("documentViewer (gettoc) docpath: %s"%(docpath)) - logging.debug("documentViewer (gettoc) url: %s"%(url)) pagesize = pageinfo['queryPageSize'] pn = pageinfo['searchPN'] sn = pageinfo['sn'] @@ -56,7 +54,7 @@ class MpdlXmlTextServer(SimpleItem): tocPN = pageinfo['tocPN'] selfurl = self.absolute_url() - data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,highlightQuery)) + data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&characterNormalization=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,characterNormalization ,urllib.quote(highlightQuery))) #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) pagexml = data.replace('?document=%s'%str(docpath),'?url=%s'%url) @@ -118,24 +116,94 @@ class MpdlXmlTextServer(SimpleItem): return serializeNode(pagenode) return "no text here" - def getNumPages(self, docinfo): - """get list of pages from fulltext and put in docinfo""" + """def getNumPages(self, docinfo): + ""get list of pages from fulltext and put in docinfo"" if 'numPages' in docinfo: # already there - return docinfo - + return docinfo xquery = '//pb' text = self.getServerData("xquery.xql","document=%s&xquery=%s"%(docinfo['textURLPath'],xquery)) - #text = self.template.fulltextclient.eval("/mpdl/interface/xquery.xql", "document=%s&xquery=%s"%(docinfo['textURLPath'],xquery)) docinfo['numPages'] = text.count("0: + originalPage= getTextFromNode(pagedivs[0]) + #return docinfo['originalPage'] + return originalPage + + def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization=""): """returns single page from fulltext""" docpath = docinfo['textURLPath'] path = docinfo['textURLPath'] url = docinfo['url'] + name = docinfo['name'] viewMode= pageinfo['viewMode'] + highlightQuery = pageinfo['highlightQuery'] tocMode = pageinfo['tocMode'] characterNormalization=pageinfo['characterNormalization'] tocPN = pageinfo['tocPN'] @@ -144,11 +212,12 @@ class MpdlXmlTextServer(SimpleItem): textmode = "textPollux" else: textmode = mode - #logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization)) + #logging.debug("documentViewer highlightQuery: %s"%(highlightQuery)) textParam = "document=%s&mode=%s&pn=%s&characterNormalization=%s"%(docpath,textmode,pn,characterNormalization) if highlightQuery is not None: - textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn) - + #textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn) + textParam = "document=%s&mode=%s&pn=%s&characterNormalization=%s&highlightQuery=%s&sn=%s"%(docpath,textmode,pn,characterNormalization, highlightQuery, sn) + logging.debug("documentViewer highlightQuery: %s"%(highlightQuery)) pagexml = self.getServerData("page-fragment.xql",textParam) #pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False) @@ -184,7 +253,8 @@ class MpdlXmlTextServer(SimpleItem): if hrefNode: href=hrefNode.nodeValue if href.startswith('http://chinagis.mpiwg-berlin.mpg.de'): - hrefNode.nodeValue =href.replace('chinagis_REST','chinagis') + hrefNode.nodeValue =href.replace('chinagis_REST/REST/db/chgis/mpdl','chinagis/REST/db/mpdl/%s'%name) + l.setAttributeNS(None, 'target', '_blank') return serializeNode(pagenode) if mode == "pureXml":