changeset 543:8893fdfafd75

arnica: set slideshow ui elements independent of portrait or landscape images. (thanks to Johannes Berg)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 16 Jul 2010 15:50:26 +0200
parents 5557cb62baab
children 02470d83aab9
files data/plugin/action/arnica_slides.py data/plugin/parser/text_x_arnica.py
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Wed Jul 14 00:06:47 2010 +0200
+++ b/data/plugin/action/arnica_slides.py	Fri Jul 16 15:50:26 2010 +0200
@@ -213,7 +213,7 @@
     }
     return html
 
-def html_slideform(request, pagename, alias, exif_date, images, original_images, idx):
+def html_slideform(request, pagename, alias, exif_date, images, original_images, idx, webnail_width):
     """ html code for the slideform
     @param request: request object
     @param pagename: pagename where the attachments are located
@@ -222,6 +222,7 @@
     @param images: list of webnail image IDs (either cache keys or attachment names)
     @param original_images: list of original image attachment names (thumbnails and webnails are derived from it)
     @param idx: index position of the image
+    @param webnail_width: width of webnail
     """
     image_url = images[idx]
     this_webnail_list = images
@@ -268,7 +269,7 @@
     html = """
 <div class="arnica-slides">
 %(navigation)s
-<div class="image">
+<div class="image" style="width:%(webnail_size)dpx;height:%(webnail_size)dpx">
 <img src="%(server)s%(this_image)s" name="show" alt="%(alt_text)s">
 </div>
 <div class="image-description">
@@ -285,6 +286,7 @@
         "this_image": wikiutil.escape(image_url),
         "pagename": pagename,
         "navigation": navigation,
+        "webnail_size": webnail_width,
     }
     return html
 
@@ -353,17 +355,24 @@
             original_images = request.form.get('original_images', [''])[0]
             all_description = request.form.get('alias', [''])[0]
             all_exif_date = request.form.get('exif_date', [''])[0]
+            webnail_width = int(request.form.get('webnail_width', [''])[0])
         else:
             target = request.values.get('target', '')
             images = request.values.get('images', '')
             original_images = request.values.get('original_images', '')
             all_description = request.values.get('alias', '')
             all_exif_date = request.values.get('exif_date', '')
-
+            webnail_width = int(request.values.get('webnail_width', ''))
 
-        if not (target and images and all_description and all_exif_date):
+        if not (target and images and all_description and all_exif_date and webnail_width):
             return _("Missing required parameters!"), "error"
 
+        try:
+            webnail_width = int(webnail_width)
+        except ValueError:
+            # not translated ... can only happen with bogus user agents
+            return "bogus parameter"
+
         images = unpackLine(images)
         images = images[1:]
 
@@ -397,7 +406,8 @@
                                  html_head=html_js(request, idx))
 
         request.write(request.formatter.startContent("content"))
-        html = html_slideform(request, pagename, all_description, all_exif_date, images, original_images, idx)
+        html = html_slideform(request, pagename, all_description, all_exif_date,
+                              images, original_images, idx, webnail_width)
         request.write(request.formatter.rawHTML(html))
         request.write(request.formatter.endContent())
         footer = request.theme.send_footer(pagename)
--- a/data/plugin/parser/text_x_arnica.py	Wed Jul 14 00:06:47 2010 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Fri Jul 16 15:50:26 2010 +0200
@@ -240,6 +240,7 @@
              <input type="hidden" name="images" value="%(images)s">
              <input type="hidden" name="original_images" value="%(original_images)s">
              <input type="hidden" name="exif_date" value="%(exif_date)s">
+             <input type="hidden" name="webnail_width" value="%(webnail_width)d">
              <input type="image" value="submit" title="%(submit_title)s" src="%(thumbnail)s">
         </div>
       </div>
@@ -266,6 +267,7 @@
         "alias_html": self.html_show_alias(image),
         "submit_title": {True: "images", False: "slide show"}[self.album_link_page],
         "action": {True: "show", False: "arnica_slides"}[self.album_link_page],
+        "webnail_width": self.webnail_width,
         }
         return html