Mercurial > hg > documentViewer
changeset 412:759ed7577eef
zwei neue Methoden
author | abukhman |
---|---|
date | Mon, 20 Dec 2010 14:52:07 +0100 |
parents | 691f0c341b33 |
children | ea9aaecd73f1 |
files | MpdlXmlTextServer.py documentViewer.py zpt/page_main_double.zpt |
diffstat | 3 files changed, 79 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/MpdlXmlTextServer.py Mon Dec 06 11:41:55 2010 +0100 +++ b/MpdlXmlTextServer.py Mon Dec 20 14:52:07 2010 +0100 @@ -117,29 +117,50 @@ return serializeNode(pagenode) return "no text here" - """def getNumPages(self, docinfo): - ""get list of pages from fulltext and put in docinfo"" - if 'numPages' in docinfo: - # already there - return docinfo - xquery = '//pb' - text = self.getServerData("xquery.xql","document=%s&xquery=%s"%(docinfo['textURLPath'],xquery)) - docinfo['numPages'] = text.count("<pb ") - return docinfo - """ - def getNumTextPages (self, docinfo): + + def getNumTextPages (self, docinfo=None): """get list of pages from fulltext (texts without images) and put in docinfo""" + docpath = docinfo['textURLPath'] + selfurl = self.absolute_url() + #viewMode= pageinfo['viewMode'] if 'numPages' in docinfo: # allredy there return docinfo - xpath ='/count(//pb)' - text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'], xpath)) - dom = Parse(text) - result= dom.xpath("//result/resultPage") - - docinfo['numPages']=int(getTextFromNode(result[0])) - return docinfo + + text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) + dom =Parse(text) + pagedivs = dom.xpath("//div[@class='countPages']") + logging.debug ("pagedivs=%s"%(pagedivs)) + if len(pagedivs)>0: + docinfo['numPages']= int(getTextFromNode(pagedivs[0])) + return docinfo + + def getTocEntries (self, docinfo=None): + """ number of text entries""" + docpath = docinfo['textURLPath'] + selfurl = self.absolute_url() + if (docpath!=None): + text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) + dom =Parse(text) + pagedivs = dom.xpath("//div[@class='countTocEntries']") + logging.debug ("pagedivs=%s"%(pagedivs)) + originalPage = getTextFromNode(pagedivs[0]) + tc = int (originalPage) + return tc + def getFigureEntries (self, docinfo=None): + """ number of figure entries""" + docpath = docinfo['textURLPath'] + selfurl = self.absolute_url() + if (docpath!=None): + text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) + dom = Parse(text) + pagedivs = dom.xpath("//div[@class='countFigureEntries']") + logging.debug ("pagedivs=%s"%(pagedivs)) + originalPage = getTextFromNode(pagedivs[0]) + tc = int (originalPage) + return tc + def getGisPlaces(self, docinfo=None, pageinfo=None): """ Show all Gis Places of whole Page""" xpath='//place' @@ -183,22 +204,7 @@ myList = ",".join(hrefList) logging.debug("getALLGisPlaces :%s"%(myList)) return myList - - - def getPDF (self, docinfo=None, pageinfo=None): - """Show and Save different Pages as PDF in Options""" - selfurl=self.absolute_url() - pn=pageinfo['current'] - - viewMode =pageinfo['viewMode'] - - #text = ("page-fragment.xql","document=%s&mode=%s&pn=%s&export=%s"%(docinfo['textURLPath'], 'text', pn,'pdf')) - #text = self.getServerData("page-fragment.xql", "document=%s&mode=%s&pn=%s&export=%s"(docinfo['textURLPath'],'text', pn,'pdf')) - #logging.debug("text :%s"%(text)) - #dom =Parse(text) - #logging.debug("text :%s"%(text)) - #return text - + def getOrigPages (self, docinfo=None, pageinfo=None): """Show original page """ docpath = docinfo.get('textURLPath',None) @@ -228,14 +234,11 @@ dom =Parse(text) pagedivs = dom.xpath("//div[@class='countPlaces']") logging.debug ("pagedivs=%s"%(pagedivs)) - #originalPage= getTextFromNode(pagedivs[0]) - #return allPlaces if len(pagedivs)>0: originalPage= getTextFromNode(pagedivs[0]) - #return docinfo['originalPage'] return originalPage - def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization="regPlusNorm", highlightQuery=None, sn=None, optionToggle=None): + def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization="reg", highlightQuery=None, sn=None, optionToggle=None): """returns single page from fulltext""" docpath = docinfo['textURLPath'] path = docinfo['textURLPath'] @@ -396,43 +399,34 @@ def getQueryResultHitsText(self, docinfo=None, pageinfo=None): """number of hits in Text of Contents mode""" + selfurl = self.absolute_url() + docpath = docinfo['textURLPath'] + viewMode= pageinfo['viewMode'] + text = self.getServerData("page-fragment.xql","document=%s&mode=%s"%(docinfo['textURLPath'], 'text')) + dom =Parse(text) + pagedivs = dom.xpath("//div[@class='countTocEntries']") + logging.debug ("pagedivs=%s"%(pagedivs)) + if len(pagedivs)>0: + originalPage= (getTextFromNode(pagedivs[0])) + tc = int (originalPage) + tc1 =tc/30+1 + return tc1 - docpath = docinfo['textURLPath'] - pagesize = pageinfo['queryPageSize'] - pn = pageinfo['searchPN'] - query =pageinfo['query'] - queryType =pageinfo['queryType'] - tocSearch = 0 - tocDiv = None - tocMode = pageinfo['tocMode'] - tocPN = pageinfo['tocPN'] - pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'toc')) - pagedom = Parse(pagexml) - logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom)) - numdivs = pagedom.xpath("//div[@class='queryResultHits']") - tocSearch = int(getTextFromNode(numdivs[0])) - tc=int((tocSearch/30)+1) - return tc - def getQueryResultHitsFigures(self, docinfo=None, pageinfo=None): """number of hits in Text of Figures mode""" - docpath = docinfo['textURLPath'] - pagesize = pageinfo['queryPageSize'] - pn = pageinfo['searchPN'] - query =pageinfo['query'] - queryType =pageinfo['queryType'] - tocSearch = 0 - tocDiv = None - tocMode = pageinfo['tocMode'] - tocPN = pageinfo['tocPN'] - pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'figures')) - pagedom = Parse(pagexml) - logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom)) - numdivs = pagedom.xpath("//div[@class='queryResultHits']") - tocSearch = int(getTextFromNode(numdivs[0])) - tc=int((tocSearch/30)+1) - return tc + selfurl = self.absolute_url() + docpath = docinfo['textURLPath'] + viewMode= pageinfo['viewMode'] + text = self.getServerData("page-fragment.xql","document=%s&mode=%s"%(docinfo['textURLPath'], 'text')) + dom =Parse(text) + pagedivs = dom.xpath("//div[@class='countFigureEntries']") + logging.debug ("pagedivs=%s"%(pagedivs)) + if len(pagedivs)>0: + originalPage= (getTextFromNode(pagedivs[0])) + tc = int (originalPage) + tc1 =tc/30+1 + return tc1 def getToc(self, mode="text", docinfo=None):
--- a/documentViewer.py Mon Dec 06 11:41:55 2010 +0100 +++ b/documentViewer.py Mon Dec 20 14:52:07 2010 +0100 @@ -147,6 +147,7 @@ toc_text = PageTemplateFile('zpt/toc_text', globals()) toc_figures = PageTemplateFile('zpt/toc_figures', globals()) page_main_images = PageTemplateFile('zpt/page_main_images', globals()) + page_main_double = PageTemplateFile('zpt/page_main_double', globals()) page_main_text = PageTemplateFile('zpt/page_main_text', globals()) page_main_text_dict = PageTemplateFile('zpt/page_main_text_dict', globals()) page_main_gis =PageTemplateFile ('zpt/page_main_gis', globals()) @@ -212,10 +213,6 @@ """get query""" return self.template.fulltextclient.getQueryResultHitsFigures(**args) - def getPDF(self, **args): - """get query""" - return self.template.fulltextclient.getPDF(**args) - def getSearch(self, **args): """get search""" return self.template.fulltextclient.getSearch(**args) @@ -236,6 +233,14 @@ """get original page number """ return self.template.fulltextclient.getAllPlaces(**args) + def getTocEntries(self, **args): + """get original page number """ + return self.template.fulltextclient.getTocEntries(**args) + + def getFigureEntries(self, **args): + """get original page number """ + return self.template.fulltextclient.getFigureEntries(**args) + def getNumPages(self, docinfo): """get numpages""" return self.template.fulltextclient.getNumPages(docinfo) @@ -348,7 +353,6 @@ """getBrowser the version of browser """ names="" names = browserCheck(self) - #logging.debug("XXXXXXXXXXXXXXXX: %s"%names) return names def findDigilibUrl(self): @@ -834,7 +838,7 @@ pageinfo['numgroups'] += 1 pageinfo['viewMode'] = viewMode pageinfo['tocMode'] = tocMode - pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','regPlusNorm') + pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') pageinfo['optionToggle'] = self.REQUEST.get('optionToggle','') pageinfo['query'] = self.REQUEST.get('query','') pageinfo['queryType'] = self.REQUEST.get('queryType','')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/page_main_double.zpt Mon Dec 20 14:52:07 2010 +0100 @@ -0,0 +1,4 @@ + +<tal:block tal:define="pageinfo python:options.get('pageinfo',None); docinfo python:options.get('docinfo',None) "> + <div tal:content="structure python:here.getTextPage(mode='image',pn=pageinfo['current'],docinfo=docinfo, pageinfo=pageinfo)"></div> +</tal:block> \ No newline at end of file