Changeset 551:f558624d3f73 in documentViewer


Ignore:
Timestamp:
Sep 19, 2012, 8:13:52 AM (12 years ago)
Author:
casties
Branch:
default
Message:

add attributes for pundit.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • MpdlXmlTextServer.py

    r544 r551  
    251251            modes.remove('search')
    252252                           
     253        # pundit mode
     254        punditMode = False
     255        if 'pundit' in modes:
     256            punditMode = True
     257            # ignore mode in the following
     258            modes.remove('pundit')
     259                           
    253260        # other modes don't combine
    254261        if 'dict' in modes:
     
    289296            selfurl = self.getLink()
    290297            if pagediv is not None:
     298                if punditMode:
     299                    pagediv = self.addPunditAttributes(pagediv, pageinfo, docinfo)
     300                   
     301                # check all a-tags
    291302                links = pagediv.findall(".//a")
    292303                for l in links:
     
    303314                viewerurl = docinfo['viewerUrl']
    304315                selfurl = self.getLink()
     316                if punditMode:
     317                    pagediv = self.addPunditAttributes(pagediv, pageinfo, docinfo)
     318                   
    305319                # check all a-tags
    306320                links = pagediv.findall(".//a")
     
    362376        return None
    363377   
     378    def addPunditAttributes(self, pagediv, pageinfo, docinfo):
     379        """add about attributes for pundit annotation tool"""
     380        textid = docinfo.get('DRI', "fn=%s"%docinfo.get('documentPath', '???'))
     381        pn = pageinfo.get('pn', '1')
     382        #  TODO: use pn as well?
     383        # check all div-tags
     384        divs = pagediv.findall(".//div")
     385        for d in divs:
     386            id = d.get('id')
     387            if id:
     388                d.set('about', "http://echo.mpiwg-berlin.mpg.de/%s/pn=%s/#%s"%(textid,pn,id))
     389                cls = d.get('class','')
     390                cls += ' pundit-content'
     391                d.set('class', cls.strip())
     392
     393        return pagediv
    364394
    365395    def getSearchResults(self, mode, query=None, pageinfo=None, docinfo=None):
  • version.txt

    r543 r551  
    1 DocumentViewer 2.2.2
     1DocumentViewer 2.2.3
Note: See TracChangeset for help on using the changeset viewer.