# HG changeset patch # User casties # Date 1348042432 -7200 # Node ID f558624d3f730ad0b48286e388106f87b22a33b8 # Parent a35ec08c782d45668c0871dc036b6697042abe79 add attributes for pundit. diff -r a35ec08c782d -r f558624d3f73 MpdlXmlTextServer.py --- a/MpdlXmlTextServer.py Fri Sep 07 18:14:12 2012 +0200 +++ b/MpdlXmlTextServer.py Wed Sep 19 10:13:52 2012 +0200 @@ -250,6 +250,13 @@ # ignore mode in the following modes.remove('search') + # pundit mode + punditMode = False + if 'pundit' in modes: + punditMode = True + # ignore mode in the following + modes.remove('pundit') + # other modes don't combine if 'dict' in modes: # dict is called textPollux in the backend @@ -288,6 +295,10 @@ # get full url assuming documentViewer is parent selfurl = self.getLink() if pagediv is not None: + if punditMode: + pagediv = self.addPunditAttributes(pagediv, pageinfo, docinfo) + + # check all a-tags links = pagediv.findall(".//a") for l in links: href = l.get('href') @@ -302,6 +313,9 @@ if pagediv is not None: viewerurl = docinfo['viewerUrl'] selfurl = self.getLink() + if punditMode: + pagediv = self.addPunditAttributes(pagediv, pageinfo, docinfo) + # check all a-tags links = pagediv.findall(".//a") for l in links: @@ -361,6 +375,22 @@ return None + def addPunditAttributes(self, pagediv, pageinfo, docinfo): + """add about attributes for pundit annotation tool""" + textid = docinfo.get('DRI', "fn=%s"%docinfo.get('documentPath', '???')) + pn = pageinfo.get('pn', '1') + # TODO: use pn as well? + # check all div-tags + divs = pagediv.findall(".//div") + for d in divs: + id = d.get('id') + if id: + d.set('about', "http://echo.mpiwg-berlin.mpg.de/%s/pn=%s/#%s"%(textid,pn,id)) + cls = d.get('class','') + cls += ' pundit-content' + d.set('class', cls.strip()) + + return pagediv def getSearchResults(self, mode, query=None, pageinfo=None, docinfo=None): """loads list of search results and stores XML in docinfo""" diff -r a35ec08c782d -r f558624d3f73 version.txt --- a/version.txt Fri Sep 07 18:14:12 2012 +0200 +++ b/version.txt Wed Sep 19 10:13:52 2012 +0200 @@ -1,1 +1,1 @@ -DocumentViewer 2.2.2 \ No newline at end of file +DocumentViewer 2.2.3 \ No newline at end of file