# HG changeset patch # User casties # Date 1334079704 -7200 # Node ID 3f375a0484029fce5adb4e519669f8e40dcbd210 # Parent 70c3ae5eac7c268825bff6480c02b13f4608e3c6 moved search and dict into separate layers. removed search_template. added tocMode=concordance. fixed bug with paging tocs. diff -r 70c3ae5eac7c -r 3f375a048402 css/docuviewer.css --- a/css/docuviewer.css Thu Apr 05 19:29:50 2012 +0200 +++ b/css/docuviewer.css Tue Apr 10 19:41:44 2012 +0200 @@ -17,12 +17,14 @@ } div.toc-text .toc, -div.toc-figures .toc { +div.toc-figures .toc, +div.toc-concordance .toc { float:left; clear:right; } div.toc-text .toc.float.right, -div.toc-figures .toc.float.right { +div.toc-figures .toc.float.right, +div.toc-concordance .toc.float.right { float:right; } diff -r 70c3ae5eac7c -r 3f375a048402 documentViewer.py --- a/documentViewer.py Thu Apr 05 19:29:50 2012 +0200 +++ b/documentViewer.py Tue Apr 10 19:41:44 2012 +0200 @@ -16,6 +16,7 @@ import urlparse import re import string +import json from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml @@ -123,19 +124,22 @@ viewer_images = PageTemplateFile('zpt/viewer_images', globals()) viewer_index = PageTemplateFile('zpt/viewer_index', globals()) # available layer types - availableLayers = {'text': ['dict','search','gis','annotator'], - 'xml': None, 'images': None, 'index': None} + builtinLayers = {'text': ['dict','search','gis','annotator'], + 'xml': None, 'images': None, 'index': None} + availableLayers = builtinLayers; # layer templates + layer_text_dict = PageTemplateFile('zpt/layer_text_dict', globals()) + layer_text_search = PageTemplateFile('zpt/layer_text_search', globals()) layer_text_annotator = PageTemplateFile('zpt/layer_text_annotator', globals()) layer_text_gis = PageTemplateFile('zpt/layer_text_gis', globals()) # toc templates toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) toc_text = PageTemplateFile('zpt/toc_text', globals()) toc_figures = PageTemplateFile('zpt/toc_figures', globals()) + toc_concordance = PageTemplateFile('zpt/toc_concordance', globals()) toc_none = PageTemplateFile('zpt/toc_none', globals()) # other templates common_template = PageTemplateFile('zpt/common_template', globals()) - search_template = PageTemplateFile('zpt/search_template', globals()) info_xml = PageTemplateFile('zpt/info_xml', globals()) docuviewer_css = ImageFile('css/docuviewer.css',globals()) # make ImageFile better for development @@ -408,6 +412,45 @@ """link to documentviewer with parameter param set to val""" return self.getLink(param=param, val=val, params=params, baseUrl=baseUrl, paramSep='&', duplicates=duplicates) + + def setAvailableLayers(self, newLayerString=None): + """sets availableLayers to newLayerString or tries to autodetect available layers. + assumes layer templates have the form layer_{m}_{l} for layer l in mode m. + newLayerString is parsed as JSON.""" + if newLayerString is not None: + try: + layers = json.loads(newLayerString) + if 'text' in layers and 'images' in layers: + self.availableLayers = layers + return + except: + pass + + logging.error("invalid layers=%s! autodetecting..."%repr(newLayerString)) + + # start with builtin layers + self.availableLayers = self.builtinLayers.copy() + # add layers from templates + for t in self.template: + if t.startswith('layer_'): + try: + (x, m, l) = t.split('_', 3) + if m not in self.availableLayers: + # mode m doesn't exist -> new list + self.availableLayers[m] = [l] + + else: + # m exists -> append + if l not in self.availableLayers[m]: + self.availableLayers[m].append() + + except: + pass + + def getAvailableLayersJson(self): + """returns available layers as JSON string.""" + return json.dumps(self.availableLayers) + def getInfo_xml(self,url,mode): """returns info about the document as XML""" @@ -837,7 +880,7 @@ else: batch['prevStart'] = None - if start + grpsize < maxIdx: + if start + grpsize <= maxIdx: batch['nextStart'] = start + grpsize else: batch['nextStart'] = None @@ -863,12 +906,12 @@ # list of elements in this batch this = [] j = 0 - for i in range(start, min(start+size, end)): + for i in range(start, min(start+size, end+1)): if data: if fullData: - d = data[i] + d = data.get(i, None) else: - d = data[j] + d = data.get(j, None) j += 1 else: @@ -887,13 +930,14 @@ else: batch['nextStart'] = None + logging.debug("getBatch start=%s size=%s end=%s batch=%s"%(start,size,end,repr(batch))) return batch security.declareProtected('View management screens','changeDocumentViewerForm') changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals()) - def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): + def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',availableLayers=None,RESPONSE=None): """init document viewer""" self.title=title self.digilibBaseUrl = digilibBaseUrl @@ -905,6 +949,8 @@ self.metadataService = getattr(self, 'metadata') except Exception, e: logging.error("Unable to find MetaDataFolder 'metadata': "+str(e)) + + self.setAvailableLayers(availableLayers) if RESPONSE is not None: RESPONSE.redirect('manage_main') diff -r 70c3ae5eac7c -r 3f375a048402 zpt/changeDocumentViewer.zpt --- a/zpt/changeDocumentViewer.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/changeDocumentViewer.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -17,6 +17,10 @@

Access groups (separated by ',') that are considered local, i.e. when a ressource restricts access to one of these groups, local access to the ressource is granted.

+

Available Layers

+

+

List of available layers per view mode. JSON, one key per mode, null, or a list of layers per key. + Leave empty for autoconfiguration.

Digilib base URL

Leave empty for autoconfiguration.

diff -r 70c3ae5eac7c -r 3f375a048402 zpt/common_template.zpt --- a/zpt/common_template.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/common_template.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -66,5 +66,31 @@ + + + + + diff -r 70c3ae5eac7c -r 3f375a048402 zpt/layer_text_annotator.zpt --- a/zpt/layer_text_annotator.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/layer_text_annotator.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -2,7 +2,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + @@ -87,7 +87,7 @@ - +

Annotations

diff -r 70c3ae5eac7c -r 3f375a048402 zpt/layer_text_dict.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/layer_text_dict.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -0,0 +1,44 @@ + + + + + + + +
+ +
    + +
  • + Dictionary +
  • +
    +
+
+ + + +
+

Dictionary view

+
+
    +
  • + Tab +
  • +
  • + Window +
  • +
+
+
+ +
+ + + + diff -r 70c3ae5eac7c -r 3f375a048402 zpt/layer_text_gis.zpt --- a/zpt/layer_text_gis.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/layer_text_gis.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -21,9 +21,9 @@
- + -
+
+ + + + + + + +
+ +
    + +
  • + Search hits +
  • +
    +
+
+ + + +
+ +
+

Search results

+
+
+ +
+
+
+
+
+ + + + +
+

Search

+
+ + + + + + + + Clear +
    +
  • + Exact +
  • +
  • + All forms +
  • +
  • + Fulltext index +
  • +
  • + Morphological + index +
  • +
+
+
+ +
+ + + + diff -r 70c3ae5eac7c -r 3f375a048402 zpt/search_template.zpt --- a/zpt/search_template.zpt Thu Apr 05 19:29:50 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - - - - - - - -
-
- -
-
-
- - - - diff -r 70c3ae5eac7c -r 3f375a048402 zpt/toc_concordance.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/toc_concordance.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -0,0 +1,47 @@ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + +
ScanOriginal
+ ScanNo + + [] + +
+
+
+ + + diff -r 70c3ae5eac7c -r 3f375a048402 zpt/toc_figures.zpt --- a/zpt/toc_figures.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/toc_figures.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -9,29 +9,13 @@
- +
- + diff -r 70c3ae5eac7c -r 3f375a048402 zpt/toc_none.zpt --- a/zpt/toc_none.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/toc_none.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -7,20 +7,7 @@
- +
diff -r 70c3ae5eac7c -r 3f375a048402 zpt/toc_text.zpt --- a/zpt/toc_text.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/toc_text.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -9,23 +9,7 @@
- +
diff -r 70c3ae5eac7c -r 3f375a048402 zpt/toc_thumbs.zpt --- a/zpt/toc_thumbs.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/toc_thumbs.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -14,20 +14,7 @@ pageNumbers docinfo/pageNumbers | nothing; left python:test(flowLtr,pageBatch['prevStart'],pageBatch['nextStart']); right python:test(flowLtr,pageBatch['nextStart'],pageBatch['prevStart']);"> - +
diff -r 70c3ae5eac7c -r 3f375a048402 zpt/viewer_text.zpt --- a/zpt/viewer_text.zpt Thu Apr 05 19:29:50 2012 +0200 +++ b/zpt/viewer_text.zpt Tue Apr 10 19:41:44 2012 +0200 @@ -23,8 +23,8 @@ }); // --> - - + + @@ -37,8 +37,6 @@ tal:define="docpath docinfo/textURLPath; pn pageinfo/pn; flowLtr python:docinfo.get('pageFlow','ltr')!='rtl'; - query python:request.get('query', None); - queryType python:request.get('queryType','fulltextMorph'); textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo) or '[no text here]';">
@@ -70,14 +68,13 @@
- -
- -
-

Search results

-
-
-
+ + + + + +
@@ -94,19 +91,7 @@ Text
    - -
  • - - Dictionary -
  • -
  • - Search - hits -
  • - + - -
    -

    Search

    -
    - - - - - - - - Clear -
      -
    • - Exact -
    • -
    • - All forms -
    • -
    • - Fulltext index -
    • -
    • - - Morphological index -
    • -
    -
    -
    - -

    Text size

    @@ -184,22 +128,6 @@
    - -
    -

    Dictionary view

    -
    -
      -
    • - Tab -
    • -
    • - Window -
    • -
    -
    -
    - -

    Text normalization

    @@ -229,8 +157,8 @@
    - - + +