changeset 70:beea6a9e50c2

arnica_slides: slide_show refactored to a method
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 06 Jun 2008 20:26:16 +0200
parents 6e6ba41483f6
children 42ec0fd97f59
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 51 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Fri Jun 06 13:06:29 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Fri Jun 06 20:26:16 2008 +0200
@@ -376,6 +376,56 @@
         """ Do the action and either return error msg or None, if there was no error. """
         return None
 
+    def slide_show(self, pagename):
+        """ does show the slide show """
+        _ = self.request.getText
+        request = self.request
+        if not request.user.may.read(pagename):
+            msg = _("You are not allowed to view this page.")
+            request.theme.add_msg(msg, "error")
+            Page(request, pagename).send_page()
+
+        target = request.form.get('target', [''])[0]
+        images = request.form.get('images', [''])[0]
+
+        images = unpackLine(images)
+        images = (images[1:])
+
+        all_description = request.form.get('alias', [''])[0]
+        all_description = unpackLine(all_description)
+        #this_description = all_description[0]
+        all_description = (all_description[1:])
+
+        all_exif_date = request.form.get('exif_date', [''])[0]
+        all_exif_date = unpackLine(all_exif_date)
+        all_exif_date = (all_exif_date[1:])
+
+        # XXX Check that all lists have same length
+        idx = images.index(target)
+
+        image_for_webnail = (request.form.get("image_for_webnail", [0])[0])  is 'True'
+        web = {}
+        if not image_for_webnail:
+            web['src'] = getAttachUrl(request.getScriptname(), pagename, target)
+        else:
+            web['src']  = AttachFile.getAttachUrl(pagename, target, request)
+
+        web['title'] = target
+
+        mimetype = "text/html"
+        request.emit_http_headers(["Content-Type: %s; charset=%s" % (mimetype, config.charset)])
+
+        request.theme.send_title(pagename,
+                                 pagename=pagename,
+                                 body_onload="arnica_preload();",
+                                 html_head=html_js(request, idx))
+
+        request.write(request.formatter.startContent("content"))
+        html = 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))
+
     def render(self):
         """ does execute the commands of the form data """
         _ = self.request.getText
@@ -392,45 +442,7 @@
 
         # View Slides
         if command == 'VS':
-            web = {}
-            images = request.form.get('images', [''])[0]
-            images = unpackLine(images)
-            images = (images[1:])
-
-            all_description = request.form.get('alias', [''])[0]
-            all_description = unpackLine(all_description)
-            #this_description = all_description[0]
-            all_description = (all_description[1:])
-
-            all_exif_date = request.form.get('exif_date', [''])[0]
-            all_exif_date = unpackLine(all_exif_date)
-            all_exif_date = (all_exif_date[1:])
-
-            # XXX Check that all lists have same length
-            idx = images.index(target)
-
-            image_for_webnail = (request.form.get("image_for_webnail", [0])[0])  is 'True'
-            if not image_for_webnail:
-                web['src'] = getAttachUrl(request.getScriptname(), pagename, target)
-            else:
-                web['src']  = AttachFile.getAttachUrl(pagename, target, request)
-
-            web['title'] = target
-
-            mimetype = "text/html"
-            request.emit_http_headers(["Content-Type: %s; charset=%s" % (mimetype, config.charset)])
-
-            request.theme.send_title(pagename,
-                                     pagename=pagename,
-                                     body_onload="arnica_preload();",
-                                     html_head=html_js(request, idx))
-
-            request.write(request.formatter.startContent("content"))
-            html = 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))
-
+            self.slide_show(pagename)
         # view sends a cached attachment (thumbnail or webnail) to the browser
         elif command == 'view':
             send_cache_file(request, pagename, arena_dir, target)