comparison documentViewer.py @ 541:c4cc01b104d7

better metadata display for index page.
author casties
date Mon, 20 Aug 2012 20:13:56 +0200
parents dbf25bd05fc6
children 6cdc31e9ed8e
comparison
equal deleted inserted replaced
540:4b43a57ad9b3 541:c4cc01b104d7
15 import math 15 import math
16 import urlparse 16 import urlparse
17 import re 17 import re
18 import string 18 import string
19 import json 19 import json
20
21 from Products.MetaDataProvider import MetaDataFolder
20 22
21 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml 23 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml
22 24
23 def serializeNode(node, encoding="utf-8"): 25 def serializeNode(node, encoding="utf-8"):
24 """returns a string containing node as XML""" 26 """returns a string containing node as XML"""
551 docinfo = self.getTextInfo(mode=tocMode, docinfo=docinfo) 553 docinfo = self.getTextInfo(mode=tocMode, docinfo=docinfo)
552 554
553 # bib info 555 # bib info
554 bib = self.metadataService.getBibData(dom=metaDom) 556 bib = self.metadataService.getBibData(dom=metaDom)
555 if bib: 557 if bib:
556 docinfo = self.getDocinfoFromBib(docinfo, bib) 558 # save extended version as 'bibx'
559 bibx = self.metadataService.getBibData(dom=metaDom, all=True, recursive=1)
560 if len(bibx) == 1:
561 # unwrap list if possible
562 bibx = bibx[0]
563
564 docinfo['bibx'] = bibx
565 docinfo = self.getDocinfoFromBib(docinfo, bib, bibx)
557 else: 566 else:
558 # no bib - try info.xml 567 # no bib - try info.xml
559 docinfo = self.getDocinfoFromPresentationInfoXml(docinfo) 568 docinfo = self.getDocinfoFromPresentationInfoXml(docinfo)
560 569
561 # auth info 570 # auth info
665 docinfo['pageFlow'] = texttool.get('page-flow', 'ltr') 674 docinfo['pageFlow'] = texttool.get('page-flow', 'ltr')
666 675
667 # odd pages are left 676 # odd pages are left
668 docinfo['oddPage'] = texttool.get('odd-scan-position', 'left') 677 docinfo['oddPage'] = texttool.get('odd-scan-position', 'left')
669 678
670 # number of title page (0: not defined) 679 # number of title page (default 1)
671 docinfo['titlePage'] = texttool.get('title-scan-no', 0) 680 docinfo['titlePage'] = texttool.get('title-scan-no', 1)
672 681
673 # old presentation stuff 682 # old presentation stuff
674 presentation = texttool.get('presentation', None) 683 presentation = texttool.get('presentation', None)
675 if presentation and docPath: 684 if presentation and docPath:
676 if presentation.startswith('http:'): 685 if presentation.startswith('http:'):
678 else: 687 else:
679 docinfo['presentationUrl'] = os.path.join(docPath, presentation) 688 docinfo['presentationUrl'] = os.path.join(docPath, presentation)
680 689
681 return docinfo 690 return docinfo
682 691
683 def getDocinfoFromBib(self, docinfo, bib): 692 def getDocinfoFromBib(self, docinfo, bib, bibx=None):
684 """reads contents of bib element into docinfo""" 693 """reads contents of bib element into docinfo"""
685 logging.debug("getDocinfoFromBib bib=%s"%repr(bib)) 694 logging.debug("getDocinfoFromBib bib=%s"%repr(bib))
686 # put all raw bib fields in dict "bib" 695 # put all raw bib fields in dict "bib"
687 docinfo['bib'] = bib 696 docinfo['bib'] = bib
688 bibtype = bib.get('@type', None) 697 bibtype = bib.get('@type', None)