diff MpiwgXmlTextServer.py @ 609:7962e6891d99

works with new notes and notesHandwritten.
author casties
date Tue, 15 Jan 2013 18:15:32 +0100
parents 6000c7e24d8a
children 0488cd12355b
line wrap: on
line diff
--- a/MpiwgXmlTextServer.py	Tue Dec 18 19:26:22 2012 +0100
+++ b/MpiwgXmlTextServer.py	Tue Jan 15 18:15:32 2013 +0100
@@ -95,9 +95,12 @@
         logging.debug("getTextInfo mode=%s"%mode)
         
         field = ''
-        if mode in ['pages', 'toc', 'figures', 'handwritten']:
+        if mode in ['pages', 'toc', 'figures', 'notes', 'handwritten']:
             # translate mode to field param
-            field = '&field=%s'%mode
+            if mode == 'handwritten':
+                field = '&field=notesHandwritten'
+            else:
+                field = '&field=%s'%mode
         else:
             mode = None
 
@@ -131,7 +134,9 @@
                 if sys is not None:
                     docinfo['numTextPages'] = getInt(getText(sys.find('countPages'))) 
                     docinfo['numFigureEntries'] = getInt(getText(sys.find('countFigures'))) 
-                    docinfo['numHandwritten'] = getInt(getText(sys.find('countHandwritten'))) 
+                    docinfo['numHandwritten'] = getInt(getText(sys.find('countNotesHandwritten'))) 
+                    docinfo['numNotes'] = getInt(getText(sys.find('countNotes'))) 
+                    docinfo['numPlaces'] = getInt(getText(sys.find('countPlaces'))) 
                     docinfo['numTocEntries'] = getInt(getText(sys.find('countTocEntries'))) 
                     
             else:
@@ -161,7 +166,7 @@
                         docinfo['pageNumbers'] = pages
                                     
                     # toc
-                    elif lt == 'toc' or lt == 'figures' or lt == 'handwritten':
+                    elif lt in ['toc', 'figures', 'notes', 'notesHandwritten']:
                         # contains tags with table of contents/figures
                         # <item n="2.1." lv="2">CAP.I. <ref o="119">132</ref></item>
                         tocs = []
@@ -660,15 +665,18 @@
         last = first + size
         tocs = fulltoc[first:last]
         tp = '<div>'
-        label = {'figures': 'Figure', 'handwritten': 'Handwritten note'}.get(mode, 'Item')
+        label = {'figures': 'Figure', 'notes': 'Note', 'handwritten': 'Handwritten note'}.get(mode, 'Item')
         for toc in tocs:
             pageurl = self.getLink('pn', toc['pn'])
             tp += '<div class="tocline">'
             content = toc['content']
+            lvs = toc['level-string']
             if content:
-                tp += '<div class="toc name">[%s] %s</div>'%(toc['level-string'], toc['content'])
+                tp += '<div class="toc name">[%s] %s</div>'%(lvs, toc['content'])
+            elif lvs:
+                tp += '<div class="toc name">[%s %s]</div>'%(label, lvs)
             else:
-                tp += '<div class="toc name">[%s %s]</div>'%(label, toc['level-string'])
+                tp += '<div class="toc name">[%s]</div>'%(label)
             
             if toc.get('no', None):
                 tp += '<div class="toc page"><a href="%s">Page: %s (%s)</a></div>'%(pageurl, toc['pn'], toc['no'])