version 1.163, 2011/01/06 15:44:18
|
version 1.170, 2011/03/01 14:53:15
|
Line 43 def getTextFromNode(nodename):
|
Line 43 def getTextFromNode(nodename):
|
rc = rc + node.data |
rc = rc + node.data |
return rc |
return rc |
|
|
def serializeNode(node, encoding='utf-8'): |
def serializeNode(node, encoding="utf-8"): |
"""returns a string containing node as XML""" |
"""returns a string containing node as XML""" |
buf = cStringIO.StringIO() |
stream = cStringIO.StringIO() |
Ft.Xml.Domlette.Print(node, stream=buf, encoding=encoding) |
logging.debug("BUF: %s"%(stream)) |
s = buf.getvalue() |
Ft.Xml.Domlette.PrettyPrint(node, stream=stream, encoding=encoding) |
buf.close() |
s = stream.getvalue() |
|
logging.debug("BUF: %s"%(s)) |
|
stream.close() |
return s |
return s |
|
|
def browserCheck(self): |
def browserCheck(self): |
Line 58 def browserCheck(self):
|
Line 60 def browserCheck(self):
|
bt['ua'] = ua |
bt['ua'] = ua |
bt['isIE'] = False |
bt['isIE'] = False |
bt['isN4'] = False |
bt['isN4'] = False |
|
bt['versFirefox']="" |
|
bt['versIE']="" |
|
bt['versSafariChrome']="" |
|
bt['versOpera']="" |
|
|
if string.find(ua, 'MSIE') > -1: |
if string.find(ua, 'MSIE') > -1: |
bt['isIE'] = True |
bt['isIE'] = True |
else: |
else: |
bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) |
bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) |
|
# Safari oder Chrome identification |
|
try: |
|
nav = ua[string.find(ua, '('):] |
|
nav1=ua[string.find(ua,')'):] |
|
nav2=nav1[string.find(nav1,'('):] |
|
nav3=nav2[string.find(nav2,')'):] |
|
ie = string.split(nav, "; ")[1] |
|
ie1 =string.split(nav1, " ")[2] |
|
ie2 =string.split(nav3, " ")[1] |
|
ie3 =string.split(nav3, " ")[2] |
|
if string.find(ie3, "Safari") >-1: |
|
bt['versSafariChrome']=string.split(ie2, "/")[1] |
|
except: pass |
|
# IE identification |
try: |
try: |
nav = ua[string.find(ua, '('):] |
nav = ua[string.find(ua, '('):] |
ie = string.split(nav, "; ")[1] |
ie = string.split(nav, "; ")[1] |
if string.find(ie, "MSIE") > -1: |
if string.find(ie, "MSIE") > -1: |
bt['versIE'] = string.split(ie, " ")[1] |
bt['versIE'] = string.split(ie, " ")[1] |
except: pass |
except: pass |
|
# Firefox identification |
|
try: |
|
nav = ua[string.find(ua, '('):] |
|
nav1=ua[string.find(ua,')'):] |
|
if string.find(ie1, "Firefox") >-1: |
|
nav5= string.split(ie1, "/")[1] |
|
logging.debug("FIREFOX: %s"%(nav5)) |
|
bt['versFirefox']=nav5[0:3] |
|
except:pass |
|
#Opera identification |
|
try: |
|
if string.find(ua,"Opera") >-1: |
|
nav = ua[string.find(ua, '('):] |
|
nav1=nav[string.find(nav,')'):] |
|
bt['versOpera']=string.split(nav1,"/")[2] |
|
except:pass |
|
|
bt['isMac'] = string.find(ua, 'Macintosh') > -1 |
bt['isMac'] = string.find(ua, 'Macintosh') > -1 |
bt['isWin'] = string.find(ua, 'Windows') > -1 |
bt['isWin'] = string.find(ua, 'Windows') > -1 |
Line 127 def getHttpData(url, data=None, num_trie
|
Line 163 def getHttpData(url, data=None, num_trie
|
raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg)) |
raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg)) |
#return None |
#return None |
|
|
|
|
|
|
## |
## |
## documentViewer class |
## documentViewer class |
## |
## |
Line 302 class documentViewer(Folder):
|
Line 336 class documentViewer(Folder):
|
if (docinfo.get('textURLPath',None)): |
if (docinfo.get('textURLPath',None)): |
page = self.getTextPage(docinfo=docinfo, pageinfo=pageinfo) |
page = self.getTextPage(docinfo=docinfo, pageinfo=pageinfo) |
pageinfo['textPage'] = page |
pageinfo['textPage'] = page |
pt = getattr(self.template, 'viewer_main') |
tt = getattr(self, 'template') |
|
pt = getattr(tt, 'viewer_main') |
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk)) |
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk)) |
|
|
def generateMarks(self,mk): |
def generateMarks(self,mk): |
Line 319 class documentViewer(Folder):
|
Line 354 class documentViewer(Folder):
|
def getBrowser(self): |
def getBrowser(self): |
"""getBrowser the version of browser """ |
"""getBrowser the version of browser """ |
bt = browserCheck(self) |
bt = browserCheck(self) |
|
logging.debug("BROWSER VERSION: %s"%(bt)) |
return bt |
return bt |
|
|
def findDigilibUrl(self): |
def findDigilibUrl(self): |
Line 593 class documentViewer(Folder):
|
Line 629 class documentViewer(Folder):
|
docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) |
docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) |
except: |
except: |
docinfo['lang']='' |
docinfo['lang']='' |
|
try: |
|
docinfo['city']=getTextFromNode(dom.xpath("//bib/city")[0]) |
|
except: |
|
docinfo['city']='' |
|
try: |
|
docinfo['number_of_pages']=getTextFromNode(dom.xpath("//bib/number_of_pages")[0]) |
|
except: |
|
docinfo['number_of_pages']='' |
|
try: |
|
docinfo['series_volume']=getTextFromNode(dom.xpath("//bib/series_volume")[0]) |
|
except: |
|
docinfo['series_volume']='' |
|
try: |
|
docinfo['number_of_volumes']=getTextFromNode(dom.xpath("//bib/number_of_volumes")[0]) |
|
except: |
|
docinfo['number_of_volumes']='' |
|
try: |
|
docinfo['translator']=getTextFromNode(dom.xpath("//bib/translator")[0]) |
|
except: |
|
docinfo['translator']='' |
|
try: |
|
docinfo['edition']=getTextFromNode(dom.xpath("//bib/edition")[0]) |
|
except: |
|
docinfo['edition']='' |
|
try: |
|
docinfo['series_author']=getTextFromNode(dom.xpath("//bib/series_author")[0]) |
|
except: |
|
docinfo['series_author']='' |
|
try: |
|
docinfo['publisher']=getTextFromNode(dom.xpath("//bib/publisher")[0]) |
|
except: |
|
docinfo['publisher']='' |
|
try: |
|
docinfo['series_title']=getTextFromNode(dom.xpath("//bib/series_title")[0]) |
|
except: |
|
docinfo['series_title']='' |
|
try: |
|
docinfo['isbn_issn']=getTextFromNode(dom.xpath("//bib/isbn_issn")[0]) |
|
except: |
|
docinfo['isbn_issn']='' |
return docinfo |
return docinfo |
|
|
|
|
Line 691 class documentViewer(Folder):
|
Line 766 class documentViewer(Folder):
|
if textUrls and (len(textUrls) > 0): |
if textUrls and (len(textUrls) > 0): |
textUrl = getTextFromNode(textUrls[0]) |
textUrl = getTextFromNode(textUrls[0]) |
docinfo['textURLPath'] = textUrl |
docinfo['textURLPath'] = textUrl |
|
textUrlkurz = string.split(textUrl, ".")[0] |
|
docinfo['textURLPathkurz'] = textUrlkurz |
#if not docinfo['imagePath']: |
#if not docinfo['imagePath']: |
# text-only, no page images |
# text-only, no page images |
#docinfo = self.getNumTextPages(docinfo) |
#docinfo = self.getNumTextPages(docinfo) |
Line 822 class documentViewer(Folder):
|
Line 899 class documentViewer(Folder):
|
pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') |
pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') |
pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') |
pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') |
|
|
toc = int (pageinfo['tocPN']) |
toc = int (pageinfo['tocPN']) |
pageinfo['textPages'] =int (toc) |
pageinfo['textPages'] =int (toc) |
|
|
|
|
|
|
if 'tocSize_%s'%tocMode in docinfo: |
if 'tocSize_%s'%tocMode in docinfo: |
tocSize = int(docinfo['tocSize_%s'%tocMode]) |
tocSize = int(docinfo['tocSize_%s'%tocMode]) |
tocPageSize = int(pageinfo['tocPageSize']) |
tocPageSize = int(pageinfo['tocPageSize']) |