Changeset 543:6cdc31e9ed8e in documentViewer for documentViewer.py


Ignore:
Timestamp:
Aug 22, 2012, 2:25:38 PM (12 years ago)
Author:
casties
Branch:
default
Message:

fixed problem with dict-mode in default view.
added configurable footer and logo in site_template.pt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r541 r543  
    261261    def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode="thumbs",start=1,pn=1):
    262262        """
    263         view page
     263        show page
    264264        @param url: url which contains display information
    265265        @param mode: defines how to access the document behind url
    266266        @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto'
    267         @param viewLayer: sub-type of viewMode, e.g. 'dict' for viewMode='text'
     267        @param viewLayer: sub-type of viewMode, e.g. layer 'dict' for viewMode='text'
    268268        @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none)
    269269        """
     
    279279            self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
    280280           
     281        # docinfo: information about document (cached)
    281282        docinfo = self.getDocinfo(mode=mode,url=url,tocMode=tocMode)
     283       
     284        # userinfo: user settings (cached)
     285        userinfo = self.getUserinfo()
    282286       
    283287        # auto viewMode: text if there is a text else images
     
    286290                # docinfo.get('textURL', None) not implemented yet
    287291                viewMode = "text"
    288                 if viewLayer is None:
     292                if viewLayer is None and 'viewLayer' not in userinfo:
     293                    # use layer dict as default
    289294                    viewLayer = "dict"
    290295            else:
     
    296301            viewLayer = "dict"
    297302           
    298         pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
     303        # safe viewLayer in userinfo
     304        userinfo['viewLayer'] = viewLayer
     305       
     306        # pageinfo: information about page (not cached)
     307        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
    299308                   
    300309        # get template /template/viewer_$viewMode
     
    495504
    496505
     506    def getUserinfo(self):
     507        """returns userinfo object"""
     508        logging.debug("getUserinfo")
     509        userinfo = {}
     510        # look for cached userinfo in session
     511        if self.REQUEST.SESSION.has_key('userinfo'):
     512            userinfo = self.REQUEST.SESSION['userinfo']
     513            # check if its still current?
     514        else:
     515            # store in session
     516            self.REQUEST.SESSION['userinfo'] = userinfo
     517           
     518        return userinfo
     519
    497520    def getDocinfo(self, mode, url, tocMode=None):
    498521        """returns docinfo depending on mode"""
     
    772795   
    773796
    774     def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None):
     797    def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, userinfo=None, viewMode=None, viewLayer=None, tocMode=None):
    775798        """returns pageinfo with the given parameters"""
    776799        logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode))
Note: See TracChangeset for help on using the changeset viewer.