diff data/plugin/parser/text_x_arnica.py @ 273:f91c1930abaf

text_x_arnica: replaced DataBrowserWidget by CSS. columns=0 means thumbnails flow onto new line is needed.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 16 Sep 2008 11:17:55 +0200
parents 4e0a4ce23497
children e3c509f99aad
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Sun Sep 14 23:12:01 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Tue Sep 16 11:17:55 2008 +0200
@@ -16,14 +16,10 @@
 
 import os, re, time
 from random import randint
-
 from MoinMoin import wikiutil
 from MoinMoin.action import AttachFile
 from MoinMoin.packages import packLine
 from MoinMoin.Page import Page
-from MoinMoin.util.dataset import TupleDataset, Column
-from MoinMoin.util import timefuncs
-from MoinMoin.widget.browser import DataBrowserWidget
 
 parser_name = __name__.split('.')[-1]
 
@@ -40,7 +36,7 @@
                     webnail_width=640):
     """ dummy function to initialize all default parameters for arnica. The parameters are checked for wrong input.
     @param target_page: page to read attachments from. empty pagename is current page.
-    @param columns: number of columns for thumbnails
+    @param columns: number of columns for thumbnails, default is 4. 0 means no linebreak 
     @param file_regex: regex for selecting images
     @param image_for_webnail if set then the image is shown instead of the webnail
     @param show_text: default shows description
@@ -97,10 +93,7 @@
             # ToDo use formatter
             request.write(self.formatter.text(err))
 
-        self.inner_table_style = ' style="border-style:none; margin:10px;"'
-        self.td_style = ' align="center" style="padding:0; margin:2px 2px; border-style:none"'
         self.arnica_image = {} # self.arnica_image[image] = (webnail, thumbnail, exif_date, description, order)
-
         self.Image = wikiutil.importWikiPlugin(self.request.cfg, "macro", "Image", function="Image")
 
     def html_tools_restricted(self, this_target):
@@ -136,7 +129,6 @@
 </form>
 """ % {
             'url': Page(self.request, self.pagename).url(self.request),
-            'style': self.td_style,
             'htdocs': self.request.cfg.url_prefix_static,
             "pagename": wikiutil.quoteWikinameURL(self.pagename),
             "this_target": this_target,
@@ -177,8 +169,6 @@
         "url": Page(self.request, self.pagename).url(self.request),
         "pagename": self.pagename,
         "htdocs": self.request.cfg.url_prefix_static,
-        "tablestyle": self.inner_table_style,
-        "style": self.td_style,
         "description": packLine([self.arnica_image[image][3]] + [self.arnica_image[img][2] for img in selected_images]),
         "exif_date": packLine([self.arnica_image[image][2]] + [self.arnica_image[img][2] for img in selected_images]),
         "target": self.arnica_image[image][0],
@@ -198,7 +188,6 @@
         html = ''
         if self.show_tools:
             html = '<div class="html-show-tools">%(tools)s</div>' % {
-                "style": self.td_style,
                 "tools": self.html_tools(image)}
         return html
 
@@ -255,8 +244,6 @@
 </div>
 """ % {
         "title": title,
-        "tdstyle": self.td_style,
-        "style": self.inner_table_style,
         "url": Page(self.request, self.pagename).url(self.request),
         "pagename": self.pagename,
         "description": packLine([self.arnica_image[image][3]] + [self.arnica_image[img][3] for img in selected_images]),
@@ -396,13 +383,6 @@
             self.request.write(self.formatter.div(0))
             self.request.write(self.formatter.div(0))
 
-        cols = min([self.columns, len(self.arnica_image)])
-        if self.album:
-            cols = 1
-        data = TupleDataset()
-        data.columns = []
-        for dummy in range(cols):
-            data.columns.extend([Column('', label=(''))])
         col_count = 1
         result = []
         image_names = self.arnica_image.keys()
@@ -411,39 +391,25 @@
         if self.album:
             album_image = self.album_image or self.arnica_image.keys()[0] #self.high_resolution_image[0]
             if not album_image in self.arnica_image.keys():
-                text = self.formatter.text(_("""You can't use as album image:
+                html = self.formatter.text(_("""You can't use as album image:
 "%(album_image)s" because it does not exist or it is not listed
 in your item list!""") % {"album_image": album_image, })
             else:
                 #self.create_thumbnail_and_webnail_image(image, self.web_key[i], self.thumb_key[i], self.imgtype[i])
                 #self.webnail_image = self.web_key
-                text = self.html_arrange_thumbnails(album_image, selected_images)
+                html = self.html_arrange_thumbnails(album_image, selected_images)
 
-            result.append(''.join(text))
+            result.append(''.join(html))
         else:
             for image in selected_images:
-                text = self.html_arrange_thumbnails(image, selected_images)
-                if col_count <= cols:
-                    result.append(''.join(text))
-                if col_count == cols:
+                html = self.html_arrange_thumbnails(image, selected_images)
+                result.append(''.join(html))
+                if col_count == self.columns and self.columns != 0:
                     col_count = 0
-                    data.addRow(tuple(result))
-                    # resets the result list after the row is added
-                    result = []
+                    result.append('<br style=clear:both>') 
                 col_count += 1
-            if result:
-                result += [""] * (cols - col_count + 1)
-
-        # adds the last row if it is not filled up
-        if result:
-            data.addRow(tuple(result))
-        browser = DataBrowserWidget(self.request, show_header=False)
-        browser.setData(data)
-        # workaround for 1.7/1.8 remove default definition of form in DataBrowserWidget
-        html = browser.render(method="POST")
-        dummy = '''<form action="%s" method="POST" name="dbw.form"><div><div>''' % Page(self.request, self.pagename).url(self.request)
-        html = html.replace(dummy, '').replace("</div></div></form>", "")
-        return html
+        
+        return ''.join(result) 
 
 
     def format(self, formatter):