changeset 20:bfe4d9738d5e

arnica_slides: bug fix for image_for_webnail=0
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 23 May 2008 05:36:34 +0200
parents 2e91ea8506a0
children 744416ee6590
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Thu May 22 18:39:14 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Fri May 23 05:36:34 2008 +0200
@@ -57,7 +57,7 @@
         url = url.replace('//', '/')
         return attachment_path, url
 
-    def option_list(self, this_image, pagename, text, request):
+    def option_list(self, this_image, pagename, text, request, image_for_webnail):
         """ generates the pulldown option list
         @param this_image: selected image  on top
         @param pagename: pagename of attachments
@@ -67,7 +67,13 @@
         txt = ''
 
         for filename in text:
-            name = AttachFile.getAttachUrl(pagename, filename, request)
+            if not image_for_webnail:
+                name = "/%(pagename)s?action=arnica_slides&do=view&target=%(filename)s" % {'pagename': pagename,
+                                                                                           'filename': filename}  
+                name = wikiutil.escape(name)
+            else:
+                name = AttachFile.getAttachUrl(pagename, filename, request)
+
             if name == this_image:
                 txt += '<option selected value="%(name)s">%(alias)s' % {
                     "name": this_image,
@@ -211,7 +217,7 @@
 
         return html
 
-    def html_slideform(self, request, pagename, alias, exif_date, target, idx):
+    def html_slideform(self, request, pagename, alias, exif_date, target, idx, image_for_webnail):
         """ html code for the slideform
         @param request: request object
         @param pagename: pagename where the attachments are located
@@ -220,14 +226,22 @@
         @param exif_date:  date information 
         @param target: all images 
         @param idx:  index position of the image
+        @param image_for_webnail:  identifier for AttchFile or arnica_slides
         """
 
         attachment_path = AttachFile.getAttachDir(request, pagename)
         static_path, static_url = self.get_path_url(request, pagename, attachment_path )
 
-        option_webnail = self.option_list(static_url + target[idx], pagename, target, request)
-        static_path, static_url = self.get_path_url(request, pagename, attachment_path)
+        if not image_for_webnail:
+            static_url = "/%(pagename)s?action=arnica_slides&do=view&target=" % {'pagename': pagename}  
+            static_url = wikiutil.escape(static_url)
 
+        option_webnail = self.option_list(static_url + target[idx], pagename, target, request, image_for_webnail)
+
+        #static_path, static_url = self.get_path_url(request, pagename, attachment_path)
+        #if not image_for_webnail:
+        #    static_url = "/%(pagename)s?action=arnica_slides&do=view&target=" % {'pagename': pagename}
+            
         inner_table_style = ' style="border-style:none; margin:10px;"'
 
         this_webnail_list = ''
@@ -360,7 +374,8 @@
         attachment_path = AttachFile.getAttachDir(request, self.pagename)
         command = request.form.get('do', ['none'])[0]
         target = request.form.get('target', [None])[0]
-
+        
+        
         if command == 'VS':
             web = {}
             images = request.form.get('target', [''])[0]
@@ -383,6 +398,11 @@
 
             static_path, static_url = self.get_path_url(request, pagename, attachment_path)
 
+            image_for_webnail = int(request.form.get("image_for_webnail", [0])[0])
+            if not image_for_webnail:
+               static_url = "/%(pagename)s?action=arnica_slides&do=view&target=" % {'pagename': pagename}
+               static_url = wikiutil.escape(static_url)
+               
             web['src'] = static_url+target #AttachFile.getAttachUrl(pagename, target, request)
             web['title'] = target
 
@@ -392,7 +412,7 @@
                                  html_head=self.html_js(request, idx))
 
             request.write(request.formatter.startContent("content"))
-            html = self.html_slideform(request, pagename, all_description, all_exif_date, images, idx)
+            html = self.html_slideform(request, pagename, all_description, all_exif_date, images, idx, image_for_webnail)
             request.write(html)
             request.write(request.formatter.endContent())
             request.write(request.theme.send_footer(pagename))