Mercurial > hg > documentViewer
changeset 629:e36bf3226fde
text image viewer eingecheckt
author | dwinter |
---|---|
date | Tue, 26 May 2015 10:58:27 +0200 |
parents | 447251b5af65 |
children | 25295ceb11b1 0c3aab828864 |
files | css/docuviewer.css documentViewer.py zpt/viewer/common_template.zpt zpt/viewer/layer_text_image_dict.zpt zpt/viewer/viewer_text.zpt zpt/viewer/viewer_text_image.zpt |
diffstat | 6 files changed, 382 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/css/docuviewer.css Wed Feb 11 17:18:23 2015 +0100 +++ b/css/docuviewer.css Tue May 26 10:58:27 2015 +0200 @@ -75,6 +75,31 @@ vertical-align: top; } + + +/* +* two colomn stype for image - text +*/ +div.two-column { + display: table; +} + +div.two-column-row { + display: table-row; +} + +div.two-column-left { + display: table-cell; + vertical-align: top; +} + +div.two-column-right { + display: table-cell; + vertical-align: top; +} + + + /* * TOC */
--- a/documentViewer.py Wed Feb 11 17:18:23 2015 +0100 +++ b/documentViewer.py Tue May 26 10:58:27 2015 +0200 @@ -95,12 +95,14 @@ viewer_index = PageTemplateFile('zpt/viewer/viewer_index', globals()) viewer_thumbs = PageTemplateFile('zpt/viewer/viewer_thumbs', globals()) viewer_indexonly = PageTemplateFile('zpt/viewer/viewer_indexonly', globals()) + viewer_text_image = PageTemplateFile('zpt/viewer/viewer_text_image', globals()) # available layer types (annotator not default) builtinLayers = {'text': ['dict','search','gis'], - 'xml': None, 'image': None, 'index': ['extended']} + 'xml': None, 'image': None, 'index': ['extended'],'text_image': ['dict'],} availableLayers = builtinLayers; # layer templates layer_text_dict = PageTemplateFile('zpt/viewer/layer_text_dict', globals()) + layer_text_image_dict = PageTemplateFile('zpt/viewer/layer_text_image_dict', globals()) layer_text_search = PageTemplateFile('zpt/viewer/layer_text_search', globals()) layer_text_annotator = PageTemplateFile('zpt/viewer/layer_text_annotator', globals()) layer_text_gis = PageTemplateFile('zpt/viewer/layer_text_gis', globals()) @@ -976,7 +978,9 @@ pageinfo['pageZero'] = pageZero pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=minPageNo, maxIdx=np) # more page parameters - pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') + #pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') + #becuase it is buggy this currently disabled and set to orig. + pageinfo['characterNormalization'] = 'orig' if docinfo.get('pageNumbers'): # get original page numbers pageNumber = docinfo['pageNumbers'].get(pn, None)
--- a/zpt/viewer/common_template.zpt Wed Feb 11 17:18:23 2015 +0100 +++ b/zpt/viewer/common_template.zpt Tue May 26 10:58:27 2015 +0200 @@ -30,6 +30,8 @@ <ul class="view-switcher" metal:define-slot="view-switcher"> <li tal:condition="docpath" tal:attributes="class python:here.getStyle(viewMode, 'text')"><a tal:omit-tag="python:viewMode=='text'" tal:attributes="href python:here.getLink('viewMode','text')">Text</a></li> + <li tal:condition="docpath" tal:attributes="class python:here.getStyle(viewMode, 'text')"><a + tal:omit-tag="python:viewMode=='text_image'" tal:attributes="href python:here.getLink('viewMode','text_image')">Text Image</a></li> <li tal:condition="python:docinfo.get('imagePath',None)" tal:attributes="class python:here.getStyle(viewMode, 'image')"><a tal:omit-tag="python:viewMode=='image'" tal:attributes="href python:here.getLink('viewMode','image')">Image</a></li> <li tal:condition="docpath" tal:attributes="class python:here.getStyle(viewMode, 'xml')"><a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/viewer/layer_text_image_dict.zpt Tue May 26 10:58:27 2015 +0200 @@ -0,0 +1,45 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<!-- not used here +<metal:block metal:define-macro="html_head"> +</metal:block> +--> +</head> +<body> + <!-- right-side options --> + <div class="col buttons"> + <!-- LAYER DISPLAY OPTION --> + <ul> + <metal:block metal:define-macro="layer_select_li"> + <li> + <input type="checkbox" class="autosubmit" name="viewLayer" value="dict" + tal:attributes="checked python:'dict' in viewLayers" /> Dictionary + </li> + </metal:block> + </ul> + </div> + + <metal:block metal:define-macro="options_box" tal:condition="python:'dict' in viewLayers"> + <!--"BEGIN DICTIONARY OVERVIEW"--> + <!-- <div class="options"> + <h4>Dictionary view</h4> + <form name="f3" action=""> + <div>Open dictionary definition</div> + <ul> + <li> + <input type="radio" name="r3" /> in new Tab + </li> + <li> + <input type="radio" name="r3" /> in new Window + </li> + </ul> + </form> + </div> --> + <!--"END DICTIONARY OVERVIEW"--> + </metal:block> + +</body> + +</html>
--- a/zpt/viewer/viewer_text.zpt Wed Feb 11 17:18:23 2015 +0100 +++ b/zpt/viewer/viewer_text.zpt Tue May 26 10:58:27 2015 +0200 @@ -108,17 +108,17 @@ <div class="options"> <h4>Text normalization</h4> <form tal:attributes="action viewerUrl" class="autosubmit" - tal:define="norm python:pageinfo.get('characterNormalization','regPlusNorm');"> + tal:define="norm python:pageinfo.get('characterNormalization','orig');"> <input type="hidden" tal:define="params python:here.getParams(params={'characterNormalization':None, 'viewLayer':viewLayer})" tal:repeat="param params" tal:attributes="name param; value python:params[param]" /> <ul> <li><input type="radio" class="autosubmit" name="characterNormalization" value="orig" tal:attributes="checked python:norm=='orig'" /> Original</li> - <li><input type="radio" class="autosubmit" name="characterNormalization" value="reg" + <!--<li><input type="radio" class="autosubmit" name="characterNormalization" value="reg" tal:attributes="checked python:norm=='reg'" /> Regularized</li> <li><input type="radio" class="autosubmit" name="characterNormalization" value="regPlusNorm" - tal:attributes="checked python:norm=='regPlusNorm'" /> Normalized</li> + tal:attributes="checked python:norm=='regPlusNorm'" /> Normalized</li>--> </ul> <input type="submit" value="Go!" /> </form>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/viewer/viewer_text_image.zpt Tue May 26 10:58:27 2015 +0200 @@ -0,0 +1,301 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode; + tocMode pageinfo/tocMode; viewLayer pageinfo/viewLayer; viewLayers pageinfo/viewLayers; + availableLayers python:here.getAvailableLayers().get('text', None); + viewerUrl docinfo/viewerUrl; + rootUrl here/getDocumentViewerURL; + numPages docinfo/numPages | nothing; dlBaseUrl docinfo/digilibBaseUrl | nothing;"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title + tal:content="python:docinfo.get('creator',' ') + ' - ' + docinfo.get('title',' ')" /> +<link rel="stylesheet" href="template/docuviewer_css" type="text/css" /> +<!--[if IE]><link rel="stylesheet" href="template/docuviewer_ie_css" type="text/css" /><![endif]--> +<script type="text/javascript" + tal:attributes="src string:$rootUrl/template/jquery_js"></script> +<script type="text/javascript"> + $(document).ready(function() { + // autosubmit forms + $('form.autosubmit').find('.autosubmit').change(function() { + this.form.submit(); + }); + $('form.autosubmit input[type="submit"]').hide(); + }); +// --> +</script> + +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.js"></script> +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.cookie.js"></script> +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.digilib.js"></script> +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.digilib.geometry.js"></script> +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.digilib.arrows.js"></script> +<script type="text/javascript" + tal:attributes="src string:$dlBaseUrl/jquery/jquery.digilib.marks.js"></script> +<link rel="stylesheet" type="text/css" + tal:attributes="href string:$dlBaseUrl/jquery/jquery.digilib.css" /> + + +<script type="text/javascript" + tal:content="python:'''\n + var dlOpts = {\n + 'interactionMode' : 'fullscreen',\n + 'digilibBaseUrl' : '%s',\n + 'fn' : '%s',\n + 'pn' : '%s',\n + 'suppressParamNames' : ['fn'],\n + 'scalerInsets' : {'x':300, 'y':100}\n + };\n'''%(dlBaseUrl,docinfo.get('imagePath',''),pageinfo.get('pn','1'))"></script> + +<!-- layer headers (rendered always) --> +<tal:block tal:repeat="layer availableLayers"> + <tal:block + tal:define="mpath string:here/template/layer_text_${layer}/macros/html_head" + tal:condition="python:exists(mpath)"> + <metal:block metal:use-macro="python:path(mpath)" /> + </tal:block> +</tal:block> + +<script type="text/javascript"> + $(document).ready(function() { + // autosubmit forms + $('form.autosubmit').find('.autosubmit').change(function() { + this.form.submit(); + }); + $('form.autosubmit input[type="submit"]').hide(); + // get digilib div + $digilib = $('div#scaler'); + // configure digilib + $digilib.digilib(dlOpts); + }); +// --> +</script> + + +</head> +<!-- body --> +<body tal:condition="numPages"> + <tal:block + tal:define="docpath docinfo/textURLPath | nothing; + pn pageinfo/pn; + flowLtr python:docinfo.get('pageFlow','ltr')!='rtl'; + textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo);"> + <!-- header --> + <div class="page-head"> + <metal:block + metal:use-macro="here/template/common_template/macros/head" /> + </div> + + <div class="page-body" + tal:condition="python:here.isAccessible(docinfo)"> + <!--table of contents--> + <div class="col toc"> + <metal:block + metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" /> + </div> + + <!-- text page --> + <div class="col main"> + <div class="ruler top"> + <metal:block + metal:use-macro="here/template/common_template/macros/page_ruler" /> + </div> + <div class="two-column"> + <div class="two-column-row"> + <div class="two-column-left"> + <div class="content text"> + <div class="pageHeaderTitle" + tal:condition="exists:pageinfo/pageHeaderTitle" + tal:content="structure pageinfo/pageHeaderTitle" /> + <tal:block tal:condition="textPage" + tal:replace="structure textPage" /> + <div class="emptyPage" tal:condition="not:textPage">[Error: + no text]</div> + </div> + </div> + <div class="two-column-right"> + <div tal:attributes="class string:content image $viewLayer"> + <div id="scaler"> + <img + tal:attributes="src string:${docinfo/imageURL}&pn=${pageinfo/pn}&dw=500&dh=500" /> + </div> + </div> + </div> + </div> + </div> + + + + + </div> + <!-- end of col-main --> + + <!-- layer columns (rendered always) --> + <tal:block tal:repeat="layer availableLayers"> + <tal:block + tal:define="mpath string:here/template/layer_text_${layer}/macros/extra_column" + tal:condition="python:exists(mpath)"> + <metal:block metal:use-macro="python:path(mpath)" /> + </tal:block> + </tal:block> + + <!-- right-side options --> + <div class="col buttons"> + <!--BEGIN TEXT LAYERS --> + <div class="options" tal:condition="availableLayers"> + <h4>Text layer</h4> + <form tal:attributes="action viewerUrl" class="autosubmit"> + <input type="hidden" + tal:define="params python:here.getParams(params={'viewLayer':None})" + tal:repeat="param params" + tal:attributes="name param; value python:params[param]" /> + <ul> + <!-- text layer select buttons (rendered always) --> + <tal:block tal:repeat="layer availableLayers"> + <tal:block + tal:define="mpath string:here/template/layer_text_${layer}/macros/layer_select_li" + tal:condition="python:exists(mpath)"> + <li metal:use-macro="python:path(mpath)" /> + </tal:block> + </tal:block> + </ul> + <input type="submit" value="Go!" /> + </form> + </div> + <!--END TEXT LAYERS--> + + <!--"BEGIN TEXT SIZE"--> + <!-- <div class="options"> + <h4>Text size</h4> + <ul class="fsizer"> + <li><a href="javascript:fontSize(12);" class="fs_sml">S</a></li> + <li><a href="javascript:fontSize(14);" class="fs_med">M</a></li> + <li><a href="javascript:fontSize(16);" class="fs_lrg">L</a></li> + </ul> + </div> --> + <!--"END TEXT SIZE"--> + + <!--"BEGIN TEXT NORMALIZATION"--> + <div class="options"> + <h4>Text normalization</h4> + <form tal:attributes="action viewerUrl" class="autosubmit" + tal:define="norm python:pageinfo.get('characterNormalization','orig');"> + <input type="hidden" + tal:define="params python:here.getParams(params={'characterNormalization':None, 'viewLayer':viewLayer})" + tal:repeat="param params" + tal:attributes="name param; value python:params[param]" /> + <ul> + <li><input type="radio" class="autosubmit" + name="characterNormalization" value="orig" + tal:attributes="checked python:norm=='orig'" /> Original</li> + <!--<li><input type="radio" class="autosubmit" name="characterNormalization" value="reg" + tal:attributes="checked python:norm=='reg'" /> Regularized</li> + <li><input type="radio" class="autosubmit" name="characterNormalization" value="regPlusNorm" + tal:attributes="checked python:norm=='regPlusNorm'" /> Normalized</li>--> + </ul> + <input type="submit" value="Go!" /> + </form> + </div> + <!--"END TEXT NORMALIZATION"--> + + + <!-- digilib options --> + <div class="options digilib"> + <ul> + <li><a href="javascript:$digilib.digilib('zoomBy', 1.4)"> + <img tal:condition="exists:here/template/zoom-in.png" + tal:attributes="src here/template/zoom-in.png/absolute_url" /> + zoom in + </a></li> + <li><a href="javascript:$digilib.digilib('zoomBy', 0.7)"> + <img tal:condition="exists:here/template/zoom-out.png" + tal:attributes="src here/template/zoom-out.png/absolute_url" /> + zoom out + </a></li> + <li><a href="javascript:$digilib.digilib('zoomArea')"> <img + tal:condition="exists:here/template/zoom-area.png" + tal:attributes="src here/template/zoom-area.png/absolute_url" /> + zoom area + </a></li> + <li><a href="javascript:$digilib.digilib('zoomFull')"> <img + tal:condition="exists:here/template/zoom-full.png" + tal:attributes="src here/template/zoom-full.png/absolute_url" /> + full page + </a></li> + <li><a + href="javascript:$digilib.digilib('zoomFull', 'width')"> <img + tal:condition="exists:here/template/pagewidth.png" + tal:attributes="src here/template/pagewidth.png/absolute_url" /> + page width + </a></li> + <li><a href="javascript:$digilib.digilib('setMark')"> <img + tal:condition="exists:here/template/mark.png" + tal:attributes="src here/template/mark.png/absolute_url" /> + set mark + </a></li> + <li><a href="javascript:$digilib.digilib('removeMark')"> + <img tal:condition="exists:here/template/delmark.png" + tal:attributes="src here/template/delmark.png/absolute_url" /> + remove mark + </a></li> + <li><a href="javascript:$digilib.digilib('reference')"> + <img tal:condition="exists:here/template/reference.png" + tal:attributes="src here/template/reference.png/absolute_url" /> + get reference + </a></li> + <li><a + href="javascript:$digilib.digilib('digilibUrl', 'open_new')"> + <img tal:condition="exists:here/template/digilib.png" + tal:attributes="src here/template/digilib.png/absolute_url" /> + digilib + </a></li> + </ul> + </div> + + + + + <!-- layer option boxes (rendered if active) --> + <tal:block tal:repeat="layer availableLayers"> + <tal:block + tal:define="mpath string:here/template/layer_text_${layer}/macros/options_box" + tal:condition="python:exists(mpath)"> + <metal:block metal:use-macro="python:path(mpath)" /> + </tal:block> + </tal:block> + </div> + <!-- /col-right --> + + </div> + <!-- /page-body --> + + <div class="page-body" + tal:condition="python:not here.isAccessible(docinfo)"> + <div class="errortext">Sorry, access to this document is + restricted.</div> + </div> + + <tal:block + tal:condition="exists:here/template/site_template.pt/macros/footer"> + <!-- footer --> + <metal:block + metal:use-macro="here/template/site_template.pt/macros/footer" /> + </tal:block> + </tal:block> +</body> +<body tal:condition="not:numPages"> + <div class="errortext">Sorry, document doesn't exist.</div> + <tal:block + tal:condition="exists:here/template/site_template.pt/macros/footer"> + <!-- footer --> + <metal:block + metal:use-macro="here/template/site_template.pt/macros/footer" /> + </tal:block> +</body> +</html>