Changeset 585:83eeed69793f in documentViewer


Ignore:
Timestamp:
Nov 13, 2012, 4:33:34 PM (11 years ago)
Author:
casties
Branch:
default
Message:

new annotator layer for images.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • SrvTxtUtils.py

    r553 r585  
    1212
    1313
    14 srvTxtUtilsVersion = "1.5.1"
     14srvTxtUtilsVersion = "1.6"
    1515
    1616def getInt(number, default=0):
     
    133133    return ImageFile.index_html(self, REQUEST, RESPONSE)
    134134
     135
     136def getBrowserType(self):
     137    """check the browsers request to find out the browser type"""
     138    bt = {}
     139    ua = self.REQUEST.get_header("HTTP_USER_AGENT")
     140    bt['ua'] = ua
     141    bt['isIE'] = False
     142    bt['isN4'] = False
     143    if string.find(ua, 'MSIE') > -1:
     144        bt['isIE'] = True
     145    else:
     146        bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1)
     147       
     148    try:
     149        nav = ua[string.find(ua, '('):]
     150        ie = string.split(nav, "; ")[1]
     151        if string.find(ie, "MSIE") > -1:
     152            bt['versIE'] = string.split(ie, " ")[1]
     153    except: pass
     154   
     155    bt['isMac'] = string.find(ua, 'Macintosh') > -1
     156    bt['isWin'] = string.find(ua, 'Windows') > -1
     157    bt['isIEWin'] = bt['isIE'] and bt['isWin']
     158    bt['isIEMac'] = bt['isIE'] and bt['isMac']
     159    bt['staticHTML'] = False
     160
     161    return bt
     162
     163
  • documentViewer.py

    r584 r585  
    4141    return node
    4242
    43 def browserCheck(self):
    44     """check the browsers request to find out the browser type"""
    45     bt = {}
    46     ua = self.REQUEST.get_header("HTTP_USER_AGENT")
    47     bt['ua'] = ua
    48     bt['isIE'] = False
    49     bt['isN4'] = False
    50     bt['versFirefox']=""
    51     bt['versIE']=""
    52     bt['versSafariChrome']=""
    53     bt['versOpera']=""
    54    
    55     if string.find(ua, 'MSIE') > -1:
    56         bt['isIE'] = True
    57     else:
    58         bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1)
    59     # Safari oder Chrome identification   
    60     try:
    61         nav = ua[string.find(ua, '('):]
    62         nav1=ua[string.find(ua,')'):]
    63         nav2=nav1[string.find(nav1,'('):]
    64         nav3=nav2[string.find(nav2,')'):]
    65         ie = string.split(nav, "; ")[1]
    66         ie1 =string.split(nav1, " ")[2]
    67         ie2 =string.split(nav3, " ")[1]
    68         ie3 =string.split(nav3, " ")[2]
    69         if string.find(ie3, "Safari") >-1:
    70             bt['versSafariChrome']=string.split(ie2, "/")[1]
    71     except: pass
    72     # IE identification
    73     try:
    74         nav = ua[string.find(ua, '('):]
    75         ie = string.split(nav, "; ")[1]
    76         if string.find(ie, "MSIE") > -1:
    77             bt['versIE'] = string.split(ie, " ")[1]
    78     except:pass
    79     # Firefox identification
    80     try:
    81         nav = ua[string.find(ua, '('):]
    82         nav1=ua[string.find(ua,')'):]
    83         if string.find(ie1, "Firefox") >-1:
    84             nav5= string.split(ie1, "/")[1]
    85             logging.debug("FIREFOX: %s"%(nav5))
    86             bt['versFirefox']=nav5[0:3]                   
    87     except:pass
    88     #Opera identification
    89     try:
    90         if string.find(ua,"Opera") >-1:
    91             nav = ua[string.find(ua, '('):]
    92             nav1=nav[string.find(nav,')'):]
    93             bt['versOpera']=string.split(nav1,"/")[2]
    94     except:pass
    95    
    96     bt['isMac'] = string.find(ua, 'Macintosh') > -1
    97     bt['isWin'] = string.find(ua, 'Windows') > -1
    98     bt['isIEWin'] = bt['isIE'] and bt['isWin']
    99     bt['isIEMac'] = bt['isIE'] and bt['isMac']
    100     bt['staticHTML'] = False
    101 
    102     return bt
    103 
    10443def getParentPath(path, cnt=1):
    10544    """returns pathname shortened by cnt"""
     
    10847    # split by /, shorten, and reassemble
    10948    return '/'.join(path.split('/')[0:-cnt])
     49
    11050
    11151##
     
    14585    layer_text_gis = PageTemplateFile('zpt/layer_text_gis', globals())
    14686    layer_text_pundit = PageTemplateFile('zpt/layer_text_pundit', globals())
     87    layer_images_annotator = PageTemplateFile('zpt/layer_images_annotator', globals())
    14788    layer_index_extended = PageTemplateFile('zpt/layer_index_extended', globals())
    14889    # toc templates
     
    161102    docuviewer_ie_css = ImageFile('css/docuviewer_ie.css',globals())
    162103    # make docuviewer_ie_css refreshable for development
    163     docuviewer_ie_css.index_html = refreshingImageFileIndexHtml
     104    #docuviewer_ie_css.index_html = refreshingImageFileIndexHtml
    164105    jquery_js = ImageFile('js/jquery.js',globals())
    165106   
     
    347288        return self.availableLayers
    348289   
    349     def getBrowser(self):
    350         """getBrowser the version of browser """
    351         bt = browserCheck(self)
    352         logging.debug("BROWSER VERSION: %s"%(bt))
    353         return bt
    354        
    355290    def findDigilibUrl(self):
    356291        """try to get the digilib URL from zogilib"""
  • zpt/viewer_images.zpt

    r543 r585  
    33<html xmlns="http://www.w3.org/1999/xhtml"
    44  tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode;
     5              viewLayer pageinfo/viewLayer; viewLayers pageinfo/viewLayers;
     6              availableLayers python:here.getAvailableLayers().get('images', None);
    57              tocMode pageinfo/tocMode; viewerUrl docinfo/viewerUrl;
    68              numPages docinfo/numPages | nothing; dlBaseUrl docinfo/digilibBaseUrl | nothing;">
     
    2729            'scalerInsets' : {'x':300, 'y':100}\n
    2830        };\n'''%(dlBaseUrl,docinfo.get('imagePath',''),pageinfo.get('pn','1'))"></script>
     31
     32<!--  layer headers (rendered always) -->
     33<tal:block tal:repeat="layer availableLayers">
     34  <tal:block tal:define="mpath string:here/template/layer_images_${layer}/macros/html_head" tal:condition="python:exists(mpath)">
     35    <metal:block metal:use-macro="python:path(mpath)" />
     36  </tal:block>
     37</tal:block>
    2938
    3039<script type="text/javascript">
     
    5766        <metal:block metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" />
    5867      </div>
    59       <!-- col-main: text page -->
     68      <!-- col-main: document page -->
    6069      <div class="col main">
    6170        <div class="ruler top">
     
    7079      </div>
    7180      <!-- /col-main -->
     81     
    7282      <div class="col buttons">
     83        <!-- layer switcher -->
     84        <div class="options" tal:condition="availableLayers">
     85          <h4>Image layer</h4>
     86          <form tal:attributes="action viewerUrl" class="autosubmit">
     87            <input type="hidden" tal:define="params python:here.getParams(params={'viewLayer':None})"
     88              tal:repeat="param params" tal:attributes="name param; value python:params[param]" />
     89            <ul>
     90              <!-- layer select buttons (rendered always) -->
     91              <tal:block tal:repeat="layer availableLayers">
     92                <tal:block tal:define="mpath string:here/template/layer_images_${layer}/macros/layer_select_li"
     93                  tal:condition="python:exists(mpath)">
     94                  <li metal:use-macro="python:path(mpath)" />
     95                </tal:block>
     96              </tal:block>
     97            </ul>
     98            <input type="submit" value="Go!" />
     99          </form>
     100        </div>
     101
     102        <!-- digilib options -->
    73103        <div class="options digilib">
    74104          <ul>
     
    105135          </ul>
    106136        </div>
     137
     138        <!--  layer option boxes (rendered if active) -->
     139        <tal:block tal:repeat="layer availableLayers">
     140          <tal:block tal:define="mpath string:here/template/layer_images_${layer}/macros/options_box"
     141            tal:condition="python:exists(mpath)">
     142            <metal:block metal:use-macro="python:path(mpath)" />
     143          </tal:block>
     144        </tal:block>
    107145      </div>
    108     </div>
    109     <!-- page-body -->
     146    </div><!-- /page-body -->
     147   
    110148    <div class="page-body" tal:condition="python:not here.isAccessible(docinfo)">
    111149      <div class="errortext">Sorry, access to this document is restricted.</div>
  • zpt/viewer_text.zpt

    r571 r585  
    7474      <!-- right-side options -->
    7575      <div class="col buttons">
    76         <!--"BEGIN TEXT DISPLAY" -->
     76        <!--BEGIN TEXT LAYERS -->
    7777        <div class="options" tal:condition="availableLayers">
    7878          <h4>Text layer</h4>
     
    9292          </form>
    9393        </div>
    94         <!--"END TEXT DISPLAY"-->
     94        <!--END TEXT LAYERS-->
    9595
    9696        <!--"BEGIN TEXT SIZE"-->
Note: See TracChangeset for help on using the changeset viewer.