Mercurial > hg > documentViewer
comparison documentViewer.py @ 20:9884703dae70
new modi
author | dwinter |
---|---|
date | Fri, 23 Dec 2005 15:01:29 +0100 |
parents | 96f74b2bab24 |
children | b139f9937e97 |
comparison
equal
deleted
inserted
replaced
19:b337f4cd3b9d | 20:9884703dae70 |
---|---|
192 imageUrl=genericDigilib+"/servlet/Scaler?fn=%s"%imagepath[0] | 192 imageUrl=genericDigilib+"/servlet/Scaler?fn=%s"%imagepath[0] |
193 | 193 |
194 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self) | 194 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self) |
195 return pt(imageUrl=imageUrl,pt=imagepath[1],start=start) | 195 return pt(imageUrl=imageUrl,pt=imagepath[1],start=start) |
196 | 196 |
197 def imagePathThumb(self,path,start=0): | |
198 """path ist the path to the images it is assumes that the index.meta file is one level higher.""" | |
199 | |
200 path=path.replace("/mpiwg/online","") | |
201 pt=getParamFromDigilib(path,'pt') | |
202 imageUrl=genericDigilib+"/servlet/Scaler?fn=%s"%path | |
203 | |
204 pageT=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self) | |
205 return pageT(imageUrl=imageUrl,pt=pt,start=start) | |
206 | |
207 def headerFromIndexMeta(self,path): | |
208 """gibt header from index meta out""" | |
209 | |
210 metaData=self.metadata.main.meta.bib | |
211 server="http://foxridge.mpiwg-berlin.mpg.de" | |
212 path="/".join(path.split("/")[0:-1]) | |
213 metaUrl=server+path+"/index.meta" | |
214 | |
215 dom = NonvalidatingReader.parseUri(metaUrl) | |
216 type=dom.xpath("//bib/@type") | |
217 if type and (len(type)>0): | |
218 type=type[0].value | |
219 else: | |
220 type="generic" | |
221 type=type.replace("-"," ")# wrong typesiin index meta "-" instead of " " | |
222 hash=metaData.generateMappingForType(type) | |
223 | |
224 author=getTextFromNode(dom.xpath("//bib/%s"%hash['author'][0])[0]) | |
225 title=getTextFromNode(dom.xpath("//bib/%s"%hash['title'][0])[0]) | |
226 year=getTextFromNode(dom.xpath("//bib/%s"%hash['year'][0])[0]) | |
227 | |
228 return author,title,year | |
229 | |
197 def text(self,mode,url,pn): | 230 def text(self,mode,url,pn): |
198 """give text""" | 231 """give text""" |
199 if mode=="texttool": #index.meta with texttool information | 232 if mode=="texttool": #index.meta with texttool information |
200 (viewerUrl,imagepath,textpath)=parseUrlTextTool(url) | 233 (viewerUrl,imagepath,textpath)=parseUrlTextTool(url) |
201 | 234 |
232 list.append(next) | 265 list.append(next) |
233 next=next.nextSibling | 266 next=next.nextSibling |
234 list.append(endNode.parentNode) | 267 list.append(endNode.parentNode) |
235 | 268 |
236 if p==e:# beide im selben paragraphen | 269 if p==e:# beide im selben paragraphen |
237 | 270 pass |
238 else: | 271 # else: |
239 next=p | 272 # next=p |
240 while next!=e: | 273 # while next!=e: |
241 print next,e | 274 # print next,e |
242 list.append(next) | 275 # list.append(next) |
243 next=next.nextSibling | 276 # next=next.nextSibling |
244 | 277 # |
245 for x in list: | 278 # for x in list: |
246 PrettyPrint(x) | 279 # PrettyPrint(x) |
247 | 280 # |
248 return list | 281 # return list |
249 | 282 # |
250 def image(self,mode,url,pn): | 283 def image(self,mode,url,pn): |
251 """give image out""" | 284 """give image out""" |
252 if mode=="texttool": #index.meta with texttool information | 285 if mode=="texttool": #index.meta with texttool information |
253 (viewerUrl,imagepath,textpath)=parseUrlTextTool(url) | 286 (viewerUrl,imagepath,textpath)=parseUrlTextTool(url) |
287 if not viewerUrl: | |
288 viewerUrl=self.imageViewerUrl | |
254 url=viewerUrl+"pn=%s&fn=%s"%(pn,imagepath[0]) | 289 url=viewerUrl+"pn=%s&fn=%s"%(pn,imagepath[0]) |
255 ret="""<iframe height="100%%" width="100%%" src="%s"/>"""%url | 290 ret="""<iframe height="100%%" width="100%%" src="%s"/>"""%url |
256 return url | 291 return url |
292 elif mode=="imagepath": | |
293 url=url.replace("/mpiwg/online","") | |
294 url=self.imageViewerUrl+"pn=%s&fn=%s"%(pn,url) | |
295 ret="""<iframe height="100%%" width="100%%" src="%s"/>"""%url | |
296 return url | |
297 | |
257 | 298 |
258 def thumbs(self,mode,url,start): | 299 def thumbs(self,mode,url,start): |
259 """give thumbs out""" | 300 """give thumbs out""" |
260 if mode=="texttool": #index.meta with texttool information | 301 if mode=="texttool": #index.meta with texttool information |
261 return self.textToolThumb(url,int(start)) | 302 return self.textToolThumb(url,int(start)) |
303 elif mode=="imagepath": | |
304 return self.imagePathThumb(url,int(start)) | |
262 | 305 |
263 security.declareProtected('View','index_html') | 306 security.declareProtected('View','index_html') |
264 | 307 |
265 | 308 |
266 def index_html(self,mode,url,start=0,pn=0): | 309 def index_html(self,mode,url,start=0,pn=1): |
267 ''' | 310 ''' |
268 view it | 311 view it |
269 @param mode: defines which type of document is behind url | 312 @param mode: defines which type of document is behind url |
270 @param url: url which contains display information | 313 @param url: url which contains display information |
271 ''' | 314 ''' |