564
|
1 from OFS.SimpleItem import SimpleItem
|
|
2 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
|
|
3
|
|
4 import xml.etree.ElementTree as ET
|
|
5
|
|
6 import re
|
|
7 import logging
|
|
8 import urllib
|
|
9 import urlparse
|
|
10 import base64
|
|
11
|
|
12 from SrvTxtUtils import getInt, getText, getHttpData
|
|
13
|
|
14 def serialize(node):
|
|
15 """returns a string containing an XML snippet of node"""
|
|
16 s = ET.tostring(node, 'UTF-8')
|
|
17 # snip off XML declaration
|
|
18 if s.startswith('<?xml'):
|
|
19 i = s.find('?>')
|
|
20 return s[i+3:]
|
|
21
|
|
22 return s
|
|
23
|
|
24
|
|
25 class MpiwgXmlTextServer(SimpleItem):
|
|
26 """TextServer implementation for MPIWG-XML server"""
|
|
27 meta_type="MPIWG-XML TextServer"
|
|
28
|
|
29 manage_options=(
|
|
30 {'label':'Config','action':'manage_changeMpiwgXmlTextServerForm'},
|
|
31 )+SimpleItem.manage_options
|
|
32
|
|
33 manage_changeMpiwgXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpiwgXmlTextServer", globals())
|
|
34
|
|
35 def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpiwg-mpdl-cms-web/", timeout=40, serverName=None, repositoryType='production'):
|
|
36 """constructor"""
|
|
37 self.id=id
|
|
38 self.title=title
|
|
39 self.timeout = timeout
|
|
40 self.repositoryType = repositoryType
|
|
41 if serverName is None:
|
|
42 self.serverUrl = serverUrl
|
|
43 else:
|
|
44 self.serverUrl = "http://%s/mpiwg-mpdl-cms-web/"%serverName
|
|
45
|
|
46 def getHttpData(self, url, data=None):
|
|
47 """returns result from url+data HTTP request"""
|
|
48 return getHttpData(url,data,timeout=self.timeout)
|
|
49
|
|
50 def getServerData(self, method, data=None):
|
|
51 """returns result from text server for method+data"""
|
|
52 url = self.serverUrl+method
|
|
53 return getHttpData(url,data,timeout=self.timeout)
|
|
54
|
|
55
|
|
56 def getRepositoryType(self):
|
|
57 """returns the repository type, e.g. 'production'"""
|
572
|
58 return getattr(self, 'repositoryType', None)
|
564
|
59
|
|
60 def getTextDownloadUrl(self, type='xml', docinfo=None):
|
|
61 """returns a URL to download the current text"""
|
|
62 docpath = docinfo.get('textURLPath', None)
|
|
63 if not docpath:
|
|
64 return None
|
|
65
|
|
66 docpath = docpath.replace('.xml','.'+type)
|
|
67 url = '%sdoc/GetDocument?id=%s'%(self.serverUrl.replace('interface/',''), docpath)
|
|
68 return url
|
|
69
|
|
70
|
|
71 def getPlacesOnPage(self, docinfo=None, pn=None):
|
|
72 """Returns list of GIS places of page pn"""
|
|
73 #FIXME!
|
|
74 docpath = docinfo.get('textURLPath',None)
|
|
75 if not docpath:
|
|
76 return None
|
|
77
|
|
78 places=[]
|
|
79 text=self.getServerData("xpath.xql", "document=%s&xpath=//place&pn=%s"%(docpath,pn))
|
|
80 dom = ET.fromstring(text)
|
|
81 result = dom.findall(".//resultPage/place")
|
|
82 for l in result:
|
|
83 id = l.get("id")
|
|
84 name = l.text
|
|
85 place = {'id': id, 'name': name}
|
|
86 places.append(place)
|
|
87
|
|
88 return places
|
|
89
|
|
90
|
565
|
91 def getTextInfo(self, mode=None, docinfo=None):
|
564
|
92 """reads document info, including page concordance, from text server"""
|
|
93 logging.debug("getTextInfo mode=%s"%mode)
|
565
|
94
|
|
95 field = ''
|
568
|
96 if mode in ['pages', 'toc', 'figures', 'handwritten']:
|
565
|
97 # translate mode to field param
|
|
98 field = '&field=%s'%mode
|
|
99 else:
|
|
100 mode = None
|
|
101
|
564
|
102 # check cached info
|
|
103 if mode:
|
|
104 # cached toc-request?
|
|
105 if 'full_%s'%mode in docinfo:
|
|
106 return docinfo
|
|
107
|
|
108 else:
|
565
|
109 # cached but no toc-request?
|
564
|
110 if 'numTextPages' in docinfo:
|
|
111 return docinfo
|
|
112
|
|
113 docpath = docinfo.get('textURLPath', None)
|
|
114 if docpath is None:
|
|
115 logging.error("getTextInfo: no textURLPath!")
|
|
116 return docinfo
|
|
117
|
|
118 # fetch docinfo
|
565
|
119 pagexml = self.getServerData("query/GetDocInfo","docId=%s%s"%(docpath,field))
|
564
|
120 dom = ET.fromstring(pagexml)
|
565
|
121 # all info in tag <doc>
|
|
122 doc = dom
|
564
|
123 if doc is None:
|
|
124 logging.error("getTextInfo: unable to find document-tag!")
|
|
125 else:
|
565
|
126 if mode is None:
|
|
127 # get general info from system-tag
|
568
|
128 sys = doc.find('system')
|
|
129 if sys is not None:
|
|
130 docinfo['numTextPages'] = getInt(getText(sys.find('countPages')))
|
|
131 docinfo['numFigureEntries'] = getInt(getText(sys.find('countFigures')))
|
|
132 docinfo['numHandwritten'] = getInt(getText(sys.find('countHandwritten')))
|
|
133 docinfo['numTocEntries'] = getInt(getText(sys.find('countTocEntries')))
|
565
|
134
|
|
135 else:
|
|
136 # result is in list-tag
|
|
137 l = doc.find('list')
|
|
138 if l is not None:
|
|
139 lt = l.get('type')
|
|
140 # pageNumbers
|
|
141 if lt == 'pages':
|
|
142 # contains tags with page numbers
|
|
143 # <item n="14" o="2" o-norm="2" file="0014"/>
|
|
144 # n=scan number, o=original page no, on=normalized original page no
|
|
145 # pageNumbers is a dict indexed by scan number
|
|
146 pages = {}
|
|
147 for i in l:
|
|
148 page = {}
|
|
149 pn = getInt(i.get('n'))
|
|
150 page['pn'] = pn
|
568
|
151 no = i.get('o')
|
565
|
152 page['no'] = no
|
568
|
153 non = i.get('o-norm')
|
565
|
154 page['non'] = non
|
|
155
|
|
156 if pn > 0:
|
|
157 pages[pn] = page
|
|
158
|
|
159 docinfo['pageNumbers'] = pages
|
|
160 logging.debug("got pageNumbers=%s"%repr(pages))
|
|
161
|
|
162 # toc
|
568
|
163 elif lt == 'toc' or lt == 'figures' or lt == 'handwritten':
|
565
|
164 # contains tags with table of contents/figures
|
568
|
165 # <item n="2.1." lv="2">CAP.I. <ref o="119">132</ref></item>
|
565
|
166 tocs = []
|
568
|
167 for te in l:
|
|
168 if te.tag == 'item':
|
|
169 toc = {}
|
|
170 toc['level-string'] = te.get('n')
|
|
171 toc['level'] = te.get('lv')
|
|
172 toc['content'] = te.text.strip()
|
|
173 ref = te.find('ref')
|
|
174 toc['pn'] = getInt(ref.text)
|
|
175 toc['no'] = ref.get('o')
|
|
176 toc['non'] = ref.get('o-norm')
|
|
177 tocs.append(toc)
|
564
|
178
|
565
|
179 # save as full_toc/full_figures
|
|
180 docinfo['full_%s'%mode] = tocs
|
564
|
181
|
|
182 return docinfo
|
|
183
|
|
184
|
|
185 def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None):
|
|
186 """returns single page from fulltext"""
|
|
187
|
|
188 logging.debug("getTextPage mode=%s, pn=%s"%(mode,pn))
|
|
189 # check for cached text -- but ideally this shouldn't be called twice
|
|
190 if pageinfo.has_key('textPage'):
|
|
191 logging.debug("getTextPage: using cached text")
|
|
192 return pageinfo['textPage']
|
|
193
|
|
194 docpath = docinfo.get('textURLPath', None)
|
|
195 if not docpath:
|
|
196 return None
|
|
197
|
|
198 # just checking
|
|
199 if pageinfo['current'] != pn:
|
|
200 logging.warning("getTextPage: current!=pn!")
|
|
201
|
|
202 # stuff for constructing full urls
|
|
203 selfurl = docinfo['viewerUrl']
|
|
204 textParams = {'docId': docpath,
|
|
205 'page': pn}
|
565
|
206
|
564
|
207 if 'characterNormalization' in pageinfo:
|
565
|
208 cn = pageinfo['characterNormalization']
|
|
209 # TODO: change values in form
|
|
210 if cn == 'regPlusNorm':
|
|
211 cn = 'norm'
|
|
212
|
|
213 textParams['normalization'] = cn
|
564
|
214
|
|
215 if not mode:
|
|
216 # default is dict
|
|
217 mode = 'text'
|
|
218
|
|
219 modes = mode.split(',')
|
|
220 # check for multiple layers
|
|
221 if len(modes) > 1:
|
|
222 logging.debug("getTextPage: more than one mode=%s"%mode)
|
|
223
|
|
224 # search mode
|
|
225 if 'search' in modes:
|
|
226 # add highlighting
|
|
227 highlightQuery = pageinfo.get('highlightQuery', None)
|
|
228 if highlightQuery:
|
|
229 textParams['highlightQuery'] = highlightQuery
|
|
230 textParams['highlightElem'] = pageinfo.get('highlightElement', '')
|
|
231 textParams['highlightElemPos'] = pageinfo.get('highlightElementPos', '')
|
|
232
|
|
233 # ignore mode in the following
|
|
234 modes.remove('search')
|
|
235
|
|
236 # pundit mode
|
|
237 punditMode = False
|
|
238 if 'pundit' in modes:
|
|
239 punditMode = True
|
|
240 # ignore mode in the following
|
|
241 modes.remove('pundit')
|
|
242
|
|
243 # other modes don't combine
|
|
244 if 'dict' in modes:
|
|
245 textmode = 'dict'
|
|
246 textParams['mode'] = 'tokenized'
|
|
247 textParams['outputFormat'] = 'html'
|
|
248 elif 'xml' in modes:
|
|
249 textmode = 'xml'
|
|
250 textParams['mode'] = 'untokenized'
|
|
251 textParams['outputFormat'] = 'xmlDisplay'
|
|
252 textParams['normalization'] = 'orig'
|
|
253 elif 'gis' in modes:
|
|
254 #FIXME!
|
|
255 textmode = 'gis'
|
|
256 else:
|
|
257 # text is default mode
|
|
258 textmode = 'text'
|
|
259 textParams['mode'] = 'untokenized'
|
|
260 textParams['outputFormat'] = 'html'
|
|
261
|
565
|
262 try:
|
570
|
263 # fetch the page
|
|
264 pagexml = self.getServerData("query/GetPage",urllib.urlencode(textParams))
|
565
|
265 dom = ET.fromstring(pagexml)
|
|
266 except Exception, e:
|
570
|
267 logging.error("Error reading page: %s"%e)
|
565
|
268 return None
|
|
269
|
566
|
270 # plain text or text-with-links mode
|
|
271 if textmode == "text" or textmode == "dict":
|
574
|
272 # the text is in div@class=text
|
|
273 pagediv = dom.find(".//div[@class='text']")
|
|
274 logging.debug("pagediv: %s"%repr(pagediv))
|
564
|
275 if pagediv is not None:
|
567
|
276 #self._processPbTag(pagediv, pageinfo)
|
566
|
277 self._processFigures(pagediv, docinfo)
|
|
278 #self._fixEmptyDivs(pagediv)
|
565
|
279 # get full url assuming documentViewer is parent
|
|
280 selfurl = self.getLink()
|
564
|
281 # check all a-tags
|
|
282 links = pagediv.findall('.//a')
|
|
283 for l in links:
|
|
284 href = l.get('href')
|
|
285 if href:
|
|
286 # is link with href
|
|
287 linkurl = urlparse.urlparse(href)
|
|
288 if linkurl.path.endswith('GetDictionaryEntries'):
|
|
289 #TODO: replace wordInfo page
|
|
290 # is dictionary link - change href (keeping parameters)
|
|
291 #l.set('href', href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/template/viewer_wordinfo'%viewerurl))
|
|
292 # add target to open new page
|
|
293 l.set('target', '_blank')
|
|
294
|
566
|
295 elif href.startswith('#note-'):
|
|
296 # note link FIXME!
|
564
|
297 l.set('href', href.replace('#note-',"%s#note-"%selfurl))
|
566
|
298
|
|
299 if punditMode:
|
|
300 self._addPunditAttributes(pagediv, pageinfo, docinfo)
|
|
301
|
564
|
302 return serialize(pagediv)
|
|
303
|
|
304 # xml mode
|
|
305 elif textmode == "xml":
|
574
|
306 # the text is in body
|
|
307 pagediv = dom.find(".//body")
|
|
308 logging.debug("pagediv: %s"%repr(pagediv))
|
564
|
309 if pagediv is not None:
|
|
310 return serialize(pagediv)
|
|
311
|
|
312 # pureXml mode WTF?
|
|
313 elif textmode == "pureXml":
|
574
|
314 # the text is in body
|
|
315 pagediv = dom.find(".//body")
|
|
316 logging.debug("pagediv: %s"%repr(pagediv))
|
564
|
317 if pagediv is not None:
|
|
318 return serialize(pagediv)
|
|
319
|
566
|
320 # gis mode FIXME!
|
564
|
321 elif textmode == "gis":
|
574
|
322 # the text is in div@class=text
|
|
323 pagediv = dom.find(".//div[@class='text']")
|
|
324 logging.debug("pagediv: %s"%repr(pagediv))
|
564
|
325 if pagediv is not None:
|
|
326 # fix empty div tags
|
565
|
327 self._fixEmptyDivs(pagediv)
|
564
|
328 # check all a-tags
|
|
329 links = pagediv.findall(".//a")
|
|
330 # add our URL as backlink
|
|
331 selfurl = self.getLink()
|
|
332 doc = base64.b64encode(selfurl)
|
|
333 for l in links:
|
|
334 href = l.get('href')
|
|
335 if href:
|
|
336 if href.startswith('http://mappit.mpiwg-berlin.mpg.de'):
|
|
337 l.set('href', re.sub(r'doc=[\w+/=]+', 'doc=%s'%doc, href))
|
|
338 l.set('target', '_blank')
|
|
339
|
|
340 return serialize(pagediv)
|
|
341
|
574
|
342 logging.error("getTextPage: error in text mode %s or text!"%(textmode))
|
564
|
343 return None
|
565
|
344
|
566
|
345 def _processPbTag(self, pagediv, pageinfo):
|
565
|
346 """extracts information from pb-tag and removes it from pagediv"""
|
|
347 pbdiv = pagediv.find(".//span[@class='pb']")
|
|
348 if pbdiv is None:
|
|
349 logging.warning("getTextPage: no pb-span!")
|
|
350 return pagediv
|
|
351
|
|
352 # extract running head
|
|
353 rh = pbdiv.find(".//span[@class='rhead']")
|
|
354 if rh is not None:
|
|
355 pageinfo['pageHeaderTitle'] = getText(rh)
|
|
356
|
|
357 # remove pb-div from parent
|
|
358 ppdiv = pagediv.find(".//span[@class='pb']/..")
|
|
359 ppdiv.remove(pbdiv)
|
|
360 return pagediv
|
564
|
361
|
565
|
362 def _addPunditAttributes(self, pagediv, pageinfo, docinfo):
|
564
|
363 """add about attributes for pundit annotation tool"""
|
|
364 textid = docinfo.get('DRI', "fn=%s"%docinfo.get('documentPath', '???'))
|
|
365 pn = pageinfo.get('pn', '1')
|
|
366 # TODO: use pn as well?
|
|
367 # check all div-tags
|
|
368 divs = pagediv.findall(".//div")
|
|
369 for d in divs:
|
|
370 id = d.get('id')
|
|
371 if id:
|
566
|
372 # TODO: check path (cf RFC2396)
|
564
|
373 d.set('about', "http://echo.mpiwg-berlin.mpg.de/%s/pn=%s/#%s"%(textid,pn,id))
|
|
374 cls = d.get('class','')
|
|
375 cls += ' pundit-content'
|
|
376 d.set('class', cls.strip())
|
|
377
|
|
378 return pagediv
|
|
379
|
566
|
380 def _processFigures(self, pagediv, docinfo):
|
|
381 """processes figure-tags"""
|
|
382 divs = pagediv.findall(".//span[@class='figure']")
|
|
383 scalerUrl = docinfo['digilibScalerUrl']
|
|
384 viewerUrl = docinfo['digilibViewerUrl']
|
|
385 for d in divs:
|
|
386 try:
|
|
387 a = d.find('a')
|
|
388 img = a.find('img')
|
|
389 imgsrc = img.get('src')
|
|
390 imgurl = urlparse.urlparse(imgsrc)
|
|
391 imgq = imgurl.query
|
|
392 imgparams = urlparse.parse_qs(imgq)
|
|
393 fn = imgparams.get('fn', None)
|
|
394 if fn is not None:
|
|
395 # parse_qs puts parameters in lists
|
|
396 fn = fn[0]
|
|
397 # TODO: check valid path
|
|
398 # fix img@src
|
|
399 newsrc = '%s?fn=%s&dw=200&dh=200'%(scalerUrl,fn)
|
|
400 img.set('src', newsrc)
|
|
401 # fix a@href
|
|
402 newlink = '%s?fn=%s'%(viewerUrl,fn)
|
|
403 a.set('href', newlink)
|
|
404 a.set('target', '_blank')
|
|
405
|
|
406 except:
|
|
407 logging.warn("processFigures: strange figure!")
|
|
408
|
|
409
|
565
|
410 def _fixEmptyDivs(self, pagediv):
|
|
411 """fixes empty div-tags by inserting a space"""
|
|
412 divs = pagediv.findall('.//div')
|
|
413 for d in divs:
|
|
414 if len(d) == 0 and not d.text:
|
|
415 # make empty divs non-empty
|
|
416 d.text = ' '
|
|
417
|
|
418 return pagediv
|
|
419
|
|
420
|
564
|
421 def getSearchResults(self, mode, query=None, pageinfo=None, docinfo=None):
|
|
422 """loads list of search results and stores XML in docinfo"""
|
|
423
|
|
424 logging.debug("getSearchResults mode=%s query=%s"%(mode, query))
|
|
425 if mode == "none":
|
|
426 return docinfo
|
|
427
|
568
|
428 #TODO: put mode into query
|
|
429
|
564
|
430 cachedQuery = docinfo.get('cachedQuery', None)
|
|
431 if cachedQuery is not None:
|
|
432 # cached search result
|
|
433 if cachedQuery == '%s_%s'%(mode,query):
|
|
434 # same query
|
|
435 return docinfo
|
|
436
|
|
437 else:
|
|
438 # different query
|
|
439 del docinfo['resultSize']
|
568
|
440 del docinfo['results']
|
564
|
441
|
|
442 # cache query
|
|
443 docinfo['cachedQuery'] = '%s_%s'%(mode,query)
|
|
444
|
|
445 # fetch full results
|
|
446 docpath = docinfo['textURLPath']
|
568
|
447 params = {'docId': docpath,
|
564
|
448 'query': query,
|
568
|
449 'pageSize': 1000,
|
|
450 'page': 1,
|
|
451 'outputFormat': 'html'}
|
|
452 pagexml = self.getServerData("query/QueryDocument",urllib.urlencode(params))
|
|
453 results = []
|
|
454 try:
|
|
455 dom = ET.fromstring(pagexml)
|
|
456 # page content is currently in multiple <td align=left>
|
|
457 alldivs = dom.findall(".//td[@align='left']")
|
|
458 for div in alldivs:
|
|
459 # TODO: can we put etree in the session?
|
|
460 results.append(div)
|
|
461
|
|
462 except Exception, e:
|
|
463 logging.error("GetSearchResults: Error parsing search result: %s"%e)
|
564
|
464
|
568
|
465 # store results in docinfo
|
|
466 docinfo['resultSize'] = len(results)
|
|
467 docinfo['results'] = results
|
564
|
468
|
|
469 return docinfo
|
|
470
|
|
471
|
|
472 def getResultsPage(self, mode="text", query=None, pn=None, start=None, size=None, pageinfo=None, docinfo=None):
|
|
473 """returns single page from the table of contents"""
|
|
474 logging.debug("getResultsPage mode=%s, pn=%s"%(mode,pn))
|
|
475 # get (cached) result
|
|
476 self.getSearchResults(mode=mode, query=query, pageinfo=pageinfo, docinfo=docinfo)
|
|
477
|
568
|
478 resultxml = docinfo.get('results', None)
|
564
|
479 if not resultxml:
|
568
|
480 logging.error("getResultPage: unable to find results")
|
564
|
481 return "Error: no result!"
|
|
482
|
|
483 if size is None:
|
|
484 size = pageinfo.get('resultPageSize', 10)
|
|
485
|
|
486 if start is None:
|
|
487 start = (pn - 1) * size
|
|
488
|
|
489 fullresult = ET.fromstring(resultxml)
|
|
490
|
|
491 if fullresult is not None:
|
|
492 # paginate
|
|
493 first = start-1
|
|
494 len = size
|
|
495 del fullresult[:first]
|
|
496 del fullresult[len:]
|
|
497 tocdivs = fullresult
|
|
498
|
|
499 # check all a-tags
|
|
500 links = tocdivs.findall(".//a")
|
|
501 for l in links:
|
|
502 href = l.get('href')
|
|
503 if href:
|
|
504 # assume all links go to pages
|
|
505 linkUrl = urlparse.urlparse(href)
|
|
506 linkParams = urlparse.parse_qs(linkUrl.query)
|
|
507 # take some parameters
|
|
508 params = {'pn': linkParams['pn'],
|
|
509 'highlightQuery': linkParams.get('highlightQuery',''),
|
|
510 'highlightElement': linkParams.get('highlightElement',''),
|
|
511 'highlightElementPos': linkParams.get('highlightElementPos','')
|
|
512 }
|
|
513 url = self.getLink(params=params)
|
|
514 l.set('href', url)
|
|
515
|
|
516 return serialize(tocdivs)
|
|
517
|
|
518 return "ERROR: no results!"
|
|
519
|
|
520
|
|
521 def getToc(self, mode='text', docinfo=None):
|
|
522 """returns list of table of contents from docinfo"""
|
|
523 logging.debug("getToc mode=%s"%mode)
|
|
524 if mode == 'text':
|
|
525 queryType = 'toc'
|
|
526 else:
|
|
527 queryType = mode
|
|
528
|
|
529 if not 'full_%s'%queryType in docinfo:
|
|
530 # get new toc
|
|
531 docinfo = self.getTextInfo(queryType, docinfo)
|
|
532
|
|
533 return docinfo.get('full_%s'%queryType, [])
|
|
534
|
568
|
535
|
564
|
536 def getTocPage(self, mode='text', pn=None, start=None, size=None, pageinfo=None, docinfo=None):
|
|
537 """returns single page from the table of contents"""
|
|
538 logging.debug("getTocPage mode=%s, pn=%s start=%s size=%s"%(mode,repr(pn),repr(start),repr(size)))
|
|
539 fulltoc = self.getToc(mode=mode, docinfo=docinfo)
|
|
540 if len(fulltoc) < 1:
|
|
541 logging.error("getTocPage: unable to find toc!")
|
|
542 return "Error: no table of contents!"
|
|
543
|
|
544 if size is None:
|
|
545 size = pageinfo.get('tocPageSize', 30)
|
|
546
|
|
547 if start is None:
|
|
548 start = (pn - 1) * size
|
|
549
|
|
550 # paginate
|
|
551 first = (start - 1)
|
|
552 last = first + size
|
|
553 tocs = fulltoc[first:last]
|
|
554 tp = '<div>'
|
|
555 for toc in tocs:
|
|
556 pageurl = self.getLink('pn', toc['pn'])
|
|
557 tp += '<div class="tocline">'
|
568
|
558 content = toc['content']
|
|
559 if content:
|
|
560 tp += '<div class="toc name">[%s] %s</div>'%(toc['level-string'], toc['content'])
|
|
561 else:
|
|
562 tp += '<div class="toc name">[Figure %s]</div>'%(toc['level-string'])
|
|
563
|
|
564 if toc.get('no', None):
|
|
565 tp += '<div class="toc page"><a href="%s">Page: %s (%s)</a></div>'%(pageurl, toc['pn'], toc['no'])
|
|
566 else:
|
|
567 tp += '<div class="toc page"><a href="%s">Page: %s</a></div>'%(pageurl, toc['pn'])
|
|
568
|
564
|
569 tp += '</div>\n'
|
|
570
|
|
571 tp += '</div>\n'
|
|
572
|
|
573 return tp
|
|
574
|
|
575
|
|
576 def manage_changeMpiwgXmlTextServer(self,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,repositoryType=None,RESPONSE=None):
|
|
577 """change settings"""
|
|
578 self.title=title
|
|
579 self.timeout = timeout
|
|
580 self.serverUrl = serverUrl
|
|
581 if repositoryType:
|
|
582 self.repositoryType = repositoryType
|
|
583 if RESPONSE is not None:
|
|
584 RESPONSE.redirect('manage_main')
|
|
585
|
|
586 # management methods
|
|
587 def manage_addMpiwgXmlTextServerForm(self):
|
|
588 """Form for adding"""
|
|
589 pt = PageTemplateFile("zpt/manage_addMpiwgXmlTextServer", globals()).__of__(self)
|
|
590 return pt()
|
|
591
|
|
592 def manage_addMpiwgXmlTextServer(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,RESPONSE=None):
|
|
593 #def manage_addMpiwgXmlTextServer(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de:30030/mpdl/interface/",timeout=40,RESPONSE=None):
|
|
594 """add zogiimage"""
|
|
595 newObj = MpiwgXmlTextServer(id=id,title=title,serverUrl=serverUrl,timeout=timeout)
|
|
596 self.Destination()._setObject(id, newObj)
|
|
597 if RESPONSE is not None:
|
|
598 RESPONSE.redirect('manage_main')
|
|
599
|
|
600 |