comparison data/plugin/parser/text_x_arnica.py @ 157:0116eb3e1099

text_x_arnica: replaced baseurl/pagename by Page.url
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 12 Jul 2008 14:42:22 +0200
parents a6ff4cf3dbc2
children cc31ed821e35
comparison
equal deleted inserted replaced
156:a6ff4cf3dbc2 157:0116eb3e1099
197 197
198 files = AttachFile._get_files(request, pagename) 198 files = AttachFile._get_files(request, pagename)
199 files = [fn for fn in files if wikiutil.isPicture(fn) and not fn.startswith('tmp.')] 199 files = [fn for fn in files if wikiutil.isPicture(fn) and not fn.startswith('tmp.')]
200 return files 200 return files
201 201
202 def getCacheUrl(base_url, pagename, filename): 202 def getCacheUrl(url, filename):
203 """ Get URL that points to cache of `filename` on page `pagename`. """ 203 """ Get URL that points to cache of `filename` on page `pagename`. """
204 url = "%(base_url)s/%(pagename)s?action=arnica_slides&do=view&target=%(filename)s" % {'base_url': base_url, 204 url_action = "%(url)s?action=arnica_slides&do=view&target=%(filename)s" % {'url': url,
205 'pagename': pagename, 205 'filename': filename}
206 'filename': filename} 206 return wikiutil.escape(url_action)
207 return wikiutil.escape(url)
208 207
209 class Parser: 208 class Parser:
210 """ arnica parser """ 209 """ arnica parser """
211 extensions = '*.jpg' 210 extensions = '*.jpg'
212 def __init__(self, raw, request, **kw): 211 def __init__(self, raw, request, **kw):
249 """ 248 """
250 if not self.request.user.may.delete(self.pagename): 249 if not self.request.user.may.delete(self.pagename):
251 return '' 250 return ''
252 251
253 return ''' 252 return '''
254 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 253 <form action="%(url)s" method="POST" enctype="multipart/form-data">
255 <div class="rotate-to-left"> 254 <div class="rotate-to-left">
256 <input type="hidden" name="action" value="arnica_slides"> 255 <input type="hidden" name="action" value="arnica_slides">
257 <input type="hidden" name="do" value="rotate_left"> 256 <input type="hidden" name="do" value="rotate_left">
258 <input type="hidden" name="target" value="%(this_target)s"> 257 <input type="hidden" name="target" value="%(this_target)s">
259 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_left.png" title="rotate to left"> 258 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_left.png" title="rotate to left">
260 </div> 259 </div>
261 </form> 260 </form>
262 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 261 <form action="%(url)s" method="POST" enctype="multipart/form-data">
263 <div class="rotate-to-right"> 262 <div class="rotate-to-right">
264 <input type="hidden" name="action" value="arnica_slides"> 263 <input type="hidden" name="action" value="arnica_slides">
265 <input type="hidden" name="do" value="rotate_right"> 264 <input type="hidden" name="do" value="rotate_right">
266 <input type="hidden" name="target" value="%(this_target)s"> 265 <input type="hidden" name="target" value="%(this_target)s">
267 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_right.png" title="rotate to right"> 266 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_right.png" title="rotate to right">
268 </div> 267 </div>
269 </form> 268 </form>
270 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 269 <form action="%(url)s" method="POST" enctype="multipart/form-data">
271 <div class="delete-image"> 270 <div class="delete-image">
272 <input type="hidden" name="action" value="arnica_slides"> 271 <input type="hidden" name="action" value="arnica_slides">
273 <input type="hidden" name="do" value="delete"> 272 <input type="hidden" name="do" value="delete">
274 <input type="hidden" name="target" value="%(this_target)s"> 273 <input type="hidden" name="target" value="%(this_target)s">
275 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_remove_image.png" title="move to bak"> 274 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_remove_image.png" title="move to bak">
276 </div> 275 </div>
277 </form>''' % { 276 </form>''' % {
278 'baseurl': self.request.getScriptname(), 277 'url': Page(self.request, self.pagename).url(self.request),
279 'style': self.td_style, 278 'style': self.td_style,
280 'htdocs': self.request.cfg.url_prefix_static, 279 'htdocs': self.request.cfg.url_prefix_static,
281 "pagename": wikiutil.quoteWikinameURL(self.pagename), 280 "pagename": wikiutil.quoteWikinameURL(self.pagename),
282 "this_target": this_target} 281 "this_target": this_target}
283 282
285 """ html code of thumbnails view with contol 284 """ html code of thumbnails view with contol
286 @param idx: index postion of corresponding data 285 @param idx: index postion of corresponding data
287 """ 286 """
288 this_image = self.full[idx] 287 this_image = self.full[idx]
289 text = ''' 288 text = '''
290 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 289 <form action="%(url)s" method="POST" enctype="multipart/form-data">
291 <div class="get-image"> 290 <div class="get-image">
292 <input type="hidden" name="action" value="AttachFile"> 291 <input type="hidden" name="action" value="AttachFile">
293 <input type="hidden" name="do" value="get"> 292 <input type="hidden" name="do" value="get">
294 <input type="hidden" name="target" value="%(this_target)s"> 293 <input type="hidden" name="target" value="%(this_target)s">
295 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_full_image.png" title="load image"> 294 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_full_image.png" title="load image">
296 </div> 295 </div>
297 </form> 296 </form>
298 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 297 <form action="%(url)s" method="POST" enctype="multipart/form-data">
299 <div class="slide-show"> 298 <div class="slide-show">
300 <input type="hidden" name="action" value="arnica_slides"> 299 <input type="hidden" name="action" value="arnica_slides">
301 <input type="hidden" name="do" value="slide_show"> 300 <input type="hidden" name="do" value="slide_show">
302 <input type="hidden" name="alias" value="%(description)s"> 301 <input type="hidden" name="alias" value="%(description)s">
303 <input type="hidden" name="target" value="%(target)s"> 302 <input type="hidden" name="target" value="%(target)s">
306 <input type="hidden" name="exif_date" value="%(exif_date)s"> 305 <input type="hidden" name="exif_date" value="%(exif_date)s">
307 <input type="hidden" name="image_for_webnail" value="%(image_for_webnail)s"> 306 <input type="hidden" name="image_for_webnail" value="%(image_for_webnail)s">
308 <input type="image" value="submit" title="slide show" src="%(htdocs)s/arnica/img/arnica_load_slide_show.png"> 307 <input type="image" value="submit" title="slide show" src="%(htdocs)s/arnica/img/arnica_load_slide_show.png">
309 </div> 308 </div>
310 </form> %(html_tools_restricted)s''' % { 309 </form> %(html_tools_restricted)s''' % {
311 "baseurl": self.request.getScriptname(), 310 "url": Page(self.request, self.pagename).url(self.request),
312 "pagename": wikiutil.quoteWikinameURL(self.pagename), 311 "pagename": wikiutil.quoteWikinameURL(self.pagename),
313 "htdocs": self.request.cfg.url_prefix_static, 312 "htdocs": self.request.cfg.url_prefix_static,
314 "tablestyle": self.inner_table_style, 313 "tablestyle": self.inner_table_style,
315 "style": self.td_style, 314 "style": self.td_style,
316 "thumbnail_width": self.thumbnail_width, 315 "thumbnail_width": self.thumbnail_width,
356 if self.album: 355 if self.album:
357 title = '<div class="title">%(n)d images (%(album_title)s)</div>' % {"n": len(self.full), 356 title = '<div class="title">%(n)d images (%(album_title)s)</div>' % {"n": len(self.full),
358 "album_title": self.album_title or self.pagename} 357 "album_title": self.album_title or self.pagename}
359 text = ''' 358 text = '''
360 <div class="arrange-thumbnails"> 359 <div class="arrange-thumbnails">
361 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data"> 360 <form action="%(url)s" method="POST" enctype="multipart/form-data">
362 <div class="image"> %(title)s 361 <div class="image"> %(title)s
363 <input type="hidden" name="action" value="arnica_slides"> 362 <input type="hidden" name="action" value="arnica_slides">
364 <input type="hidden" name="do" value="slide_show"> 363 <input type="hidden" name="do" value="slide_show">
365 <input type="hidden" name="alias" value="%(description)s"> 364 <input type="hidden" name="alias" value="%(description)s">
366 <input type="hidden" name="target" value="%(target)s"> 365 <input type="hidden" name="target" value="%(target)s">
376 %(html_tools)s 375 %(html_tools)s
377 </div>'''% { 376 </div>'''% {
378 "title": title, 377 "title": title,
379 "tdstyle": self.td_style, 378 "tdstyle": self.td_style,
380 "style": self.inner_table_style, 379 "style": self.inner_table_style,
381 "baseurl": self.request.getScriptname(), 380 "url": Page(self.request, self.pagename).url(self.request),
382 "pagename": wikiutil.quoteWikinameURL(self.pagename), 381 "pagename": wikiutil.quoteWikinameURL(self.pagename),
383 "description": packLine([self.description[idx]] + self.description), 382 "description": packLine([self.description[idx]] + self.description),
384 "exif_date": packLine([self.exif_date[idx]] + self.exif_date), 383 "exif_date": packLine([self.exif_date[idx]] + self.exif_date),
385 "image_for_webnail": self.image_for_webnail, 384 "image_for_webnail": self.image_for_webnail,
386 "target": self.webimg[idx], 385 "target": self.webimg[idx],
387 "images": packLine([self.webimg[idx]] + self.webimg), 386 "images": packLine([self.webimg[idx]] + self.webimg),
388 "thumbnail": getCacheUrl(self.request.getScriptname(), wikiutil.quoteWikinameURL(self.pagename), self.thumb[idx]), 387 "thumbnail": getCacheUrl(Page(self.request, self.pagename).url(self.request), self.thumb[idx]),
389 "thumbnail_width": self.thumbnail_width, 388 "thumbnail_width": self.thumbnail_width,
390 "html_tools": self.html_show_tools(idx), 389 "html_tools": self.html_show_tools(idx),
391 "date_html": self.html_show_date(idx), 390 "date_html": self.html_show_date(idx),
392 "alias_html": self.html_show_alias(idx) 391 "alias_html": self.html_show_alias(idx)
393 } 392 }