Changeset 503:030251fe9dbc in documentViewer


Ignore:
Timestamp:
Feb 16, 2012, 1:30:01 PM (12 years ago)
Author:
casties
Branch:
elementtree
Message:

more cleanup.
made viewType into viewLayer and viewType=xml into viewMode=xml.

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r501 r503  
    116116    # templates and forms
    117117    viewer_text = PageTemplateFile('zpt/viewer_text', globals())
     118    viewer_xml = PageTemplateFile('zpt/viewer_xml', globals())
    118119    viewer_images = PageTemplateFile('zpt/viewer_images', globals())
    119120    viewer_index = PageTemplateFile('zpt/viewer_index', globals())
     
    259260 
    260261    security.declareProtected('View','index_html')
    261     def index_html(self,url,mode="texttool",viewMode="auto",viewType=None,tocMode="thumbs",start=1,pn=1):
     262    def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode="thumbs",start=1,pn=1):
    262263        """
    263264        view page
    264265        @param url: url which contains display information
    265266        @param mode: defines how to access the document behind url
    266         @param viewMode: 'images': display images, 'text': display text, default is 'auto'
    267         @param viewType: sub-type of viewMode, e.g. 'dict' for viewMode='text'
     267        @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto'
     268        @param viewLayer: sub-type of viewMode, e.g. 'dict' for viewMode='text'
    268269        @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none)
    269270        """
    270271       
    271         logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewType=%s start=%s pn=%s"%(mode,url,viewMode,viewType,start,pn))
     272        logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewLayer=%s start=%s pn=%s"%(mode,url,viewMode,viewLayer,start,pn))
    272273       
    273274        if not hasattr(self, 'template'):
     
    289290            if docinfo.get('textURL', None) or docinfo.get('textURLPath', None):
    290291                viewMode = "text"
    291                 viewType = "dict"
     292                viewLayer = "dict"
    292293            else:
    293294                viewMode = "images"
     
    296297            # legacy fix
    297298            viewMode = "text"
    298             viewType = "dict"
    299            
    300         # stringify viewType
    301         if isinstance(viewType, list):
    302             logging.debug("index_html: viewType is list:%s"%viewType)
    303             viewType = ','.join([t for t in viewType if t])
     299            viewLayer = "dict"
     300           
     301        # stringify viewLayer
     302        if isinstance(viewLayer, list):
     303            logging.debug("index_html: viewLayer is list:%s"%viewLayer)
     304            viewLayer = ','.join([t for t in viewLayer if t])
    304305                       
    305         pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewType=viewType, tocMode=tocMode)
     306        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
    306307                   
    307308        # get template /template/viewer_$viewMode
     
    704705   
    705706
    706     def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewType=None, tocMode=None):
     707    def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None):
    707708        """returns pageinfo with the given parameters"""
    708         logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewType=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewType,tocMode))
     709        logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode))
    709710        pageinfo = {}
    710711        pageinfo['viewMode'] = viewMode
    711         pageinfo['viewType'] = viewType
     712        pageinfo['viewLayer'] = viewLayer
    712713        pageinfo['tocMode'] = tocMode
    713714
     
    731732            if docinfo.get('textURLPath', None):
    732733                # cache text page as well
    733                 pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=current, docinfo=docinfo, pageinfo=pageinfo)
     734                pageinfo['textPage'] = self.getTextPage(mode=viewLayer, pn=current, docinfo=docinfo, pageinfo=pageinfo)
    734735                np = int(docinfo.get('numPages', 0))
    735736               
  • zpt/viewer_images.zpt

    r501 r503  
    33<html xmlns="http://www.w3.org/1999/xhtml"
    44  tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode;
    5               tocMode pageinfo/tocMode; viewType pageinfo/viewType; viewerUrl docinfo/viewerUrl;
     5              tocMode pageinfo/tocMode; viewerUrl docinfo/viewerUrl;
    66              numPages docinfo/numPages | nothing; dlBaseUrl docinfo/digilibBaseUrl | nothing;">
    77<head>
  • zpt/viewer_text.zpt

    r502 r503  
    33<html xmlns="http://www.w3.org/1999/xhtml"
    44  tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode;
    5               tocMode pageinfo/tocMode; viewType pageinfo/viewType; viewerUrl docinfo/viewerUrl;
     5              tocMode pageinfo/tocMode; viewLayer pageinfo/viewLayer; viewerUrl docinfo/viewerUrl;
    66              rootUrl here/getDocumentViewerURL;
    77              numPages docinfo/numPages | nothing;">
     
    2929                               pn pageinfo/pn;
    3030                               flowLtr python:pageinfo.get('pageFlow','ltr')!='rtl';
    31                                textPage python:here.getTextPage(mode=viewType, pn=pn, docinfo=docinfo, pageinfo=pageinfo) or '[no text here]';">
     31                               textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo) or '[no text here]';">
    3232    <!-- header -->
    3333    <div class="page-head">
     
    6767          <form tal:attributes="action viewerUrl" class="autosubmit">
    6868            <input type="hidden"
    69               tal:define="params python:here.getParams(params={'viewType':None})"
     69              tal:define="params python:here.getParams(params={'viewLayer':None,'viewMode':None})"
    7070              tal:repeat="param params"
    71               tal:attributes="name param; value python:params[param]" /> <input
    72               class="autosubmit" type="radio" name="viewType" value=""
    73               tal:attributes="checked python:viewType!='xml'" /> Text<br /> <span
    74               class="optionsText" tal:condition="python:viewType!='xml'">
    75               &nbsp;&nbsp;<input type="checkbox" class="autosubmit" name="viewType"
    76               value="dict" tal:attributes="checked python:viewType=='dict'" /> Dictionary<br />
    77             </span> <span class="optionsText"
    78               tal:condition="python:viewType!='xml' and docinfo.get('numPlaces',0)">
    79               &nbsp;&nbsp;<input type="checkbox" class="autosubmit" name="viewType"
    80               value="gis" tal:attributes="checked python:viewType=='gis'" /> Places<br />
    81             </span> <input type="radio" class="autosubmit" name="viewType"
    82               tal:attributes="value string:xml; checked python:viewType=='xml'" /> XML<br />
     71              tal:attributes="name param; value python:params[param]" />
     72            <input class="autosubmit" type="radio" name="viewMode" value="text"
     73              tal:attributes="checked python:viewMode=='text'" /> Text<br />
     74            <span class="optionsText">
     75              &nbsp;&nbsp;<input type="checkbox" class="autosubmit" name="viewLayer"
     76              value="dict" tal:attributes="checked python:viewLayer=='dict'" /> Dictionary<br />
     77            </span>
     78            <span class="optionsText" tal:condition="python:docinfo.get('numPlaces',0)">
     79              &nbsp;&nbsp;<input type="checkbox" class="autosubmit" name="viewLayer"
     80              value="gis" tal:attributes="checked python:viewLayer=='gis'" /> Places<br />
     81            </span>
     82            <input type="radio" class="autosubmit" name="viewMode" value="xml"
     83              tal:attributes="checked python:viewMode=='xml'" /> XML<br />
    8384            <input type="submit" value="Go!" />
    8485          </form>
     
    9899
    99100        <!--"BEGIN DICTIONARY OVERVIEW"-->
    100         <div class="options" tal:condition="python:viewType=='dict'">
     101        <div class="options" tal:condition="python:viewLayer=='dict'">
    101102          <h4>Dictionary view</h4>
    102103          <form name="f3" action="">
     
    107108
    108109        <!--"BEGIN TEXT NORMALIZATION"-->
    109         <div class="options" tal:condition="python:viewType!='xml'">
     110        <div class="options" tal:condition="python:viewLayer!='xml'">
    110111          <h4>Text normalization</h4>
    111112          <form tal:attributes="action viewerUrl" class="autosubmit"
     
    127128
    128129        <!--"BEGIN PLACES"-->
    129         <div class="options" tal:condition="python:viewType=='gis'">
     130        <div class="options" tal:condition="python:viewLayer=='gis'">
    130131          <tal:block
    131132            tal:define="gisPlaces python:here.getGisPlaces(docinfo=docinfo, pageinfo=pageinfo); gisAllPlaces python:here.getAllGisPlaces(docinfo=docinfo, pageinfo=pageinfo);">
Note: See TracChangeset for help on using the changeset viewer.