changeset 24:9d46f04d556a

arnica_slides: fixed header for cgi deployment
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 23 May 2008 14:31:15 +0200
parents 26d9d5f67365
children 294c4312845a
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Fri May 23 10:30:14 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Fri May 23 14:31:15 2008 +0200
@@ -10,6 +10,10 @@
 """
 Dependencies = []
 import os
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin import  caching, config, wikiutil
 from MoinMoin.Page import Page
 from MoinMoin.action import AttachFile
@@ -168,14 +172,14 @@
     @param image_for_webnail:  identifier for AttchFile or arnica_slides
     """
     if not image_for_webnail:
-        static_url = getAttachUrl(pagename, "")
+        static_url = getAttachUrl(request.getScriptname(), pagename, "")
     else:
         static_url = AttachFile.getAttachUrl(pagename, "", request)
 
     option_webnail = option_list(static_url + target[idx], pagename, target, request, image_for_webnail)
 
     inner_table_style = ' style="border-style:none; margin:10px;"'
-
+        
     this_webnail_list = ''
     for name in target:
         this_webnail_list += static_url + name + ','
@@ -216,7 +220,7 @@
    </tr>
    <tr>
     <td style="border-style:none" colspan="5" align="center" bgcolor="#C0C0C0">
-     <img src="%(server)s/%(this_image)s" name="show">
+     <img src="%(server)s%(this_image)s" name="show">
     </td>
    </tr>
    <tr valign="center">
@@ -247,7 +251,7 @@
 "option_webnails": option_webnail,
 }
     return html
-    
+
 def option_list(this_image, pagename, text, request, image_for_webnail):
     """ generates the pulldown option list
     @param this_image: selected image  on top
@@ -259,7 +263,7 @@
 
     for filename in text:
         if not image_for_webnail:
-            url = getAttachUrl(pagename, filename)
+            url = getAttachUrl(request.getScriptname(), pagename, filename)
         else:
             url = AttachFile.getAttachUrl(pagename, filename, request)
 
@@ -274,10 +278,11 @@
 
     return txt
 
-def getAttachUrl(pagename, filename):
+def getAttachUrl(base_url, pagename, filename):
     """ Get URL that points to cache of `filename` on page `pagename`. """
-    url = "/%(pagename)s?action=arnica_slides&do=view&target=%(filename)s" % {'pagename': pagename,
-                                                                              'filename': filename}
+    url = "%(base_url)s/%(pagename)s?action=arnica_slides&do=view&target=%(filename)s" % {'base_url': base_url,
+                                                                                          'pagename': pagename,
+                                                                                          'filename': filename}
     return wikiutil.escape(url)
 
 class arnica_slides(ActionBase):
@@ -377,23 +382,26 @@
             all_exif_date = all_exif_date.split(',')
             all_exif_date = (all_exif_date[1:])
 
-           # XXX Check that all lists have same length
+            # XXX Check that all lists have same length
             idx = images.index(target)
 
             image_for_webnail = int(request.form.get("image_for_webnail", [0])[0])
 
             if not image_for_webnail:
-                static_url = getAttachUrl(pagename, target)
+                static_url = getAttachUrl(request.getScriptname(), pagename, target)
             else:
                 static_url = AttachFile.getAttachUrl(pagename, target, request)
 
             web['src'] = static_url
             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))
+                                     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)