Mercurial > hg > documentViewer
comparison documentViewer.py @ 591:5850689ecfac
ocrsearch layer for images.
author | casties |
---|---|
date | Fri, 16 Nov 2012 13:41:02 +0100 |
parents | ed4485d2748e |
children | eb46138db658 |
comparison
equal
deleted
inserted
replaced
590:ed4485d2748e | 591:5850689ecfac |
---|---|
60 pn = docinfo['imgFileNames'].get(pf, default) | 60 pn = docinfo['imgFileNames'].get(pf, default) |
61 else: | 61 else: |
62 # no extension | 62 # no extension |
63 pn = default | 63 pn = default |
64 | 64 |
65 return pn | |
66 | |
67 return default | |
68 | |
69 def getPfForPn(docinfo, pn, default=None): | |
70 """returns image file name for image number or default""" | |
71 if 'imgFileIndexes' in docinfo: | |
72 pn = docinfo['imgFileIndexes'].get(pn, default) | |
65 return pn | 73 return pn |
66 | 74 |
67 return default | 75 return default |
68 | 76 |
69 | 77 |
102 layer_text_search = PageTemplateFile('zpt/layer_text_search', globals()) | 110 layer_text_search = PageTemplateFile('zpt/layer_text_search', globals()) |
103 layer_text_annotator = PageTemplateFile('zpt/layer_text_annotator', globals()) | 111 layer_text_annotator = PageTemplateFile('zpt/layer_text_annotator', globals()) |
104 layer_text_gis = PageTemplateFile('zpt/layer_text_gis', globals()) | 112 layer_text_gis = PageTemplateFile('zpt/layer_text_gis', globals()) |
105 layer_text_pundit = PageTemplateFile('zpt/layer_text_pundit', globals()) | 113 layer_text_pundit = PageTemplateFile('zpt/layer_text_pundit', globals()) |
106 layer_image_annotator = PageTemplateFile('zpt/layer_image_annotator', globals()) | 114 layer_image_annotator = PageTemplateFile('zpt/layer_image_annotator', globals()) |
115 layer_image_ocrsearch = PageTemplateFile('zpt/layer_image_ocrsearch', globals()) | |
107 layer_index_extended = PageTemplateFile('zpt/layer_index_extended', globals()) | 116 layer_index_extended = PageTemplateFile('zpt/layer_index_extended', globals()) |
108 # toc templates | 117 # toc templates |
109 toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) | 118 toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) |
110 toc_text = PageTemplateFile('zpt/toc_text', globals()) | 119 toc_text = PageTemplateFile('zpt/toc_text', globals()) |
111 toc_figures = PageTemplateFile('zpt/toc_figures', globals()) | 120 toc_figures = PageTemplateFile('zpt/toc_figures', globals()) |
775 docinfo['numPages'] = 0 | 784 docinfo['numPages'] = 0 |
776 return docinfo | 785 return docinfo |
777 | 786 |
778 # save list of image names and numbers | 787 # save list of image names and numbers |
779 imgNames = {} | 788 imgNames = {} |
789 imgIndexes = {} | |
780 for f in dir: | 790 for f in dir: |
781 fn = f.findtext('name') | 791 fn = f.findtext('name') |
782 pn = f.findtext('index') | 792 pn = getInt(f.findtext('index')) |
783 imgNames[fn] = getInt(pn) | 793 imgNames[fn] = pn |
794 imgIndexes[pn] = fn | |
784 | 795 |
785 docinfo['imgFileNames'] = imgNames | 796 docinfo['imgFileNames'] = imgNames |
797 docinfo['imgFileIndexes'] = imgIndexes | |
786 return docinfo | 798 return docinfo |
787 | 799 |
788 | 800 |
789 def getDocinfoFromPresentationInfoXml(self,docinfo): | 801 def getDocinfoFromPresentationInfoXml(self,docinfo): |
790 """gets DC-like bibliographical information from the presentation entry in texttools""" | 802 """gets DC-like bibliographical information from the presentation entry in texttools""" |
846 # replace pf in request params (used for creating new URLs) | 858 # replace pf in request params (used for creating new URLs) |
847 self.REQUEST.form.pop('pf', None) | 859 self.REQUEST.form.pop('pf', None) |
848 self.REQUEST.form['pn'] = pn | 860 self.REQUEST.form['pn'] = pn |
849 else: | 861 else: |
850 pn = getInt(pn, 1) | 862 pn = getInt(pn, 1) |
863 pf = getPfForPn(docinfo, pn) | |
864 pageinfo['pf'] = pf | |
851 | 865 |
852 pageinfo['pn'] = pn | 866 pageinfo['pn'] = pn |
853 rows = int(rows or self.thumbrows) | 867 rows = int(rows or self.thumbrows) |
854 pageinfo['rows'] = rows | 868 pageinfo['rows'] = rows |
855 cols = int(cols or self.thumbcols) | 869 cols = int(cols or self.thumbcols) |
888 if pageNumber is not None: | 902 if pageNumber is not None: |
889 pageinfo['pageNumberOrig'] = pageNumber['no'] | 903 pageinfo['pageNumberOrig'] = pageNumber['no'] |
890 pageinfo['pageNumberOrigNorm'] = pageNumber['non'] | 904 pageinfo['pageNumberOrigNorm'] = pageNumber['non'] |
891 | 905 |
892 # cache search results | 906 # cache search results |
893 pageinfo['resultPageSize'] = getInt(self.REQUEST.get('resultPageSize', 10)) | |
894 query = self.REQUEST.get('query',None) | 907 query = self.REQUEST.get('query',None) |
895 pageinfo['query'] = query | 908 pageinfo['query'] = query |
896 if query: | 909 if query and viewMode == 'text': |
910 pageinfo['resultPageSize'] = getInt(self.REQUEST.get('resultPageSize', 10)) | |
897 queryType = self.REQUEST.get('queryType', 'fulltextMorph') | 911 queryType = self.REQUEST.get('queryType', 'fulltextMorph') |
898 pageinfo['queryType'] = queryType | 912 pageinfo['queryType'] = queryType |
899 pageinfo['resultStart'] = getInt(self.REQUEST.get('resultStart', '1')) | 913 pageinfo['resultStart'] = getInt(self.REQUEST.get('resultStart', '1')) |
900 self.getSearchResults(mode=queryType, query=query, pageinfo=pageinfo, docinfo=docinfo) | 914 self.getSearchResults(mode=queryType, query=query, pageinfo=pageinfo, docinfo=docinfo) |
901 | 915 |
908 | 922 |
909 return pageinfo | 923 return pageinfo |
910 | 924 |
911 | 925 |
912 def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): | 926 def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): |
913 """returns dict with array of page informations for one screenfull of thumbnails""" | 927 """returns dict with array of page information for one screenfull of thumbnails""" |
914 batch = {} | 928 batch = {} |
915 grpsize = rows * cols | 929 grpsize = rows * cols |
916 if maxIdx == 0: | 930 if maxIdx == 0: |
917 maxIdx = start + grpsize | 931 maxIdx = start + grpsize |
918 | 932 |