Mercurial > hg > documentViewer
comparison documentViewer.py @ 448:35e7ea6f2368
*** empty log message ***
author | abukhman |
---|---|
date | Fri, 29 Jul 2011 12:33:17 +0200 |
parents | 93b9a5dddb8b |
children | 6c11f3ec8698 |
comparison
equal
deleted
inserted
replaced
447:2169217252a0 | 448:35e7ea6f2368 |
---|---|
593 return docinfo | 593 return docinfo |
594 | 594 |
595 | 595 |
596 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): | 596 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
597 """gets bibliographical info from the index.meta file at path or given by dom""" | 597 """gets bibliographical info from the index.meta file at path or given by dom""" |
598 logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) | 598 #logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) |
599 | 599 |
600 if docinfo is None: | 600 if docinfo is None: |
601 docinfo = {} | 601 docinfo = {} |
602 | 602 |
603 if dom is None: | 603 if dom is None: |
605 path=getParentDir(path) | 605 path=getParentDir(path) |
606 dom = self.getDomFromIndexMeta(path) | 606 dom = self.getDomFromIndexMeta(path) |
607 | 607 |
608 docinfo['indexMetaPath']=self.getIndexMetaPath(path); | 608 docinfo['indexMetaPath']=self.getIndexMetaPath(path); |
609 | 609 |
610 logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) | 610 #logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) |
611 # put in all raw bib fields as dict "bib" | 611 # put in all raw bib fields as dict "bib" |
612 bib = dom.xpath("//bib/*") | 612 bib = dom.xpath("//bib/*") |
613 if bib and len(bib)>0: | 613 if bib and len(bib)>0: |
614 bibinfo = {} | 614 bibinfo = {} |
615 for e in bib: | 615 for e in bib: |
625 bibtype="generic" | 625 bibtype="generic" |
626 | 626 |
627 bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) | 627 bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) |
628 docinfo['bib_type'] = bibtype | 628 docinfo['bib_type'] = bibtype |
629 bibmap=metaData.generateMappingForType(bibtype) | 629 bibmap=metaData.generateMappingForType(bibtype) |
630 logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap)) | 630 #logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap)) |
631 logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype)) | 631 #logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype)) |
632 # if there is no mapping bibmap is empty (mapping sometimes has empty fields) | 632 # if there is no mapping bibmap is empty (mapping sometimes has empty fields) |
633 if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: | 633 if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: |
634 try: | 634 try: |
635 docinfo['author']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['author'][0])[0]) | 635 docinfo['author']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['author'][0])[0]) |
636 except: pass | 636 except: pass |
638 docinfo['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0]) | 638 docinfo['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0]) |
639 except: pass | 639 except: pass |
640 try: | 640 try: |
641 docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) | 641 docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) |
642 except: pass | 642 except: pass |
643 logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) | 643 #logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) |
644 try: | 644 try: |
645 docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) | 645 docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) |
646 except: | 646 except: |
647 docinfo['lang']='' | 647 docinfo['lang']='' |
648 try: | 648 try: |
683 docinfo['series_title']='' | 683 docinfo['series_title']='' |
684 try: | 684 try: |
685 docinfo['isbn_issn']=getTextFromNode(dom.xpath("//bib/isbn_issn")[0]) | 685 docinfo['isbn_issn']=getTextFromNode(dom.xpath("//bib/isbn_issn")[0]) |
686 except: | 686 except: |
687 docinfo['isbn_issn']='' | 687 docinfo['isbn_issn']='' |
688 #logging.debug("I NEED BIBTEX %s"%docinfo) | |
688 return docinfo | 689 return docinfo |
689 | 690 |
690 | 691 |
691 def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): | 692 def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
692 """gets name info from the index.meta file at path or given by dom""" | 693 """gets name info from the index.meta file at path or given by dom""" |
693 if docinfo is None: | 694 if docinfo is None: |
694 docinfo = {} | 695 docinfo = {} |
695 | 696 |
789 #docinfo = self.getNumTextPages(docinfo) | 790 #docinfo = self.getNumTextPages(docinfo) |
790 | 791 |
791 | 792 |
792 presentationUrls = dom.xpath("//texttool/presentation") | 793 presentationUrls = dom.xpath("//texttool/presentation") |
793 docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag | 794 docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag |
795 #docinfo = self.getDownloadfromDocinfoToBibtex(url, docinfo=docinfo, dom=dom) | |
794 docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) | 796 docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) |
795 | 797 |
796 | 798 |
797 if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen | 799 if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen |
798 # presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten | 800 # presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten |
844 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path | 846 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
845 docinfo['imageURL'] = imageUrl | 847 docinfo['imageURL'] = imageUrl |
846 | 848 |
847 #path ist the path to the images it assumes that the index.meta file is one level higher. | 849 #path ist the path to the images it assumes that the index.meta file is one level higher. |
848 docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) | 850 docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
851 #docinfo = self.getDownloadfromDocinfoToBibtex(pathorig,docinfo=docinfo,cut=cut+1) | |
849 docinfo = self.getAuthinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) | 852 docinfo = self.getAuthinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
850 return docinfo | 853 return docinfo |
851 | 854 |
852 | 855 |
853 def getDocinfo(self, mode, url): | 856 def getDocinfo(self, mode, url): |
910 pageinfo['query'] = self.REQUEST.get('query','') | 913 pageinfo['query'] = self.REQUEST.get('query','') |
911 pageinfo['queryType'] = self.REQUEST.get('queryType','') | 914 pageinfo['queryType'] = self.REQUEST.get('queryType','') |
912 pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') | 915 pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') |
913 pageinfo['textPN'] = self.REQUEST.get('textPN','1') | 916 pageinfo['textPN'] = self.REQUEST.get('textPN','1') |
914 pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') | 917 pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') |
918 | |
919 pageinfo ['highlightElementPos'] = self.REQUEST.get('highlightElementPos','') | |
920 pageinfo ['highlightElement'] = self.REQUEST.get('highlightElement','') | |
921 | |
922 | |
915 pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') | 923 pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
916 pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') | 924 pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') |
917 pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') | 925 pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') |
918 toc = int (pageinfo['tocPN']) | 926 toc = int (pageinfo['tocPN']) |
919 pageinfo['textPages'] =int (toc) | 927 pageinfo['textPages'] =int (toc) |
926 tocPages=tocSize/tocPageSize+1 | 934 tocPages=tocSize/tocPageSize+1 |
927 else: | 935 else: |
928 tocPages=tocSize/tocPageSize | 936 tocPages=tocSize/tocPageSize |
929 pageinfo['tocPN'] = min (tocPages,toc) | 937 pageinfo['tocPN'] = min (tocPages,toc) |
930 pageinfo['searchPN'] =self.REQUEST.get('searchPN','1') | 938 pageinfo['searchPN'] =self.REQUEST.get('searchPN','1') |
931 pageinfo['sn'] =self.REQUEST.get('sn','') | 939 #pageinfo['sn'] =self.REQUEST.get('sn','') |
940 pageinfo['s'] =self.REQUEST.get('s','') | |
932 return pageinfo | 941 return pageinfo |
933 | 942 |
934 def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): | 943 def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): |
935 """init document viewer""" | 944 """init document viewer""" |
936 self.title=title | 945 self.title=title |