changeset 42:7bf792c8364b

text_x_arnica: table is done by DataBrowserWidget
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 03 Jun 2008 00:12:49 +0200
parents edc8b8c5ccdd
children 623ddf996af2
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 32 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Mon Jun 02 19:02:58 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Tue Jun 03 00:12:49 2008 +0200
@@ -97,6 +97,8 @@
 from MoinMoin.packages import packLine
 from MoinMoin.Page import Page
 from MoinMoin.filter import EXIF
+from MoinMoin.util.dataset import TupleDataset, Column
+from MoinMoin.widget.browser import DataBrowserWidget
 
 try:
     import Image
@@ -299,10 +301,7 @@
     def mode2_html(self, idx):
         """ html code of mode 2 """
         text = '''
-        <tr valign="center">
         <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
-            <td align="center" valign="center" width="%(thumbnail_width)s"
-            %(tdstyle)s>
                 <input type="hidden" name="action" value="arnica_slides">
                 <input type="hidden" name="do" value="VS">
                 <input type="hidden" name="alias" value='%(description)s'>
@@ -311,10 +310,8 @@
                 <input type="hidden" name="images" value='%(images)s'>
                 <input type="hidden" name="image_for_webnail" value='%(image_for_webnail)s'>
                 <input type="image" value="submit" src="?action=arnica_slides&do=view&target=%(thumbnail)s">
-            </td>
         </form>
             %(alias_html)s
-    </tr>
     <tr>%(tools_html)s%(date_html)s</tr>''' % {
      "tdstyle": self.td_style,
      "baseurl": self.request.getScriptname(),
@@ -372,7 +369,7 @@
         """ html code of mode 1 (default)"""
         text = '''
     <table width="%(thumbnail_width)s" align="center" valign="center"%(style)s>
-    <TR align="center" valign="center">
+    <tr align="center" valign="center">
         <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
             <td align="center" valign="middle" width="%(thumbnail_width)s"
             %(tdstyle)s>
@@ -386,7 +383,7 @@
                 <input type="image" value="submit" type="button" src="?action=arnica_slides&do=view&target=%(thumbnail)s" >
             </td>
         </form>
-    </TR>
+    </tr>
       %(alias_html)s
       %(date_html)s
       %(tools_html)s
@@ -622,25 +619,27 @@
                                    'alias': 'alias'
                                     })
 
-        i = 0
-        z = 1
-        cols = int(self.columns)
+        COLUMNS = int(self.columns)
+        if self.album == '1':
+            COLUMNS = 1
 
-        n = len(self.full)
-        if  self.album == '0':
-            self.request.write("<table%s>" % self.outer_table_style)
-            if self.mode == '1' or cols > 1:
-                self.request.write('<tr valign="top">')
-                self.request.write('<td%s>' % self.td_style)
+        data = TupleDataset()
+        data.columns = []
+
+        for dummy in range(COLUMNS):
+            data.columns.extend([Column('', label=(''))])
+
+        # initialize colums of output table
+
+        col_count = 1
 
         if self.album == '1':
             front_image = self.front_image or self.full[0]
             i = self.full.index(front_image)
 
+        result = []
         for image in self.full:
-            # if we leave that line here the user sees progress in creating webnails and thumbnails
-            # on a slow machine. Otherwise he does see until it is finished nothing and may
-            # believe it is broken.
+            i = self.full.index(image)
             self.create_thumbnail_and_webnail(image, self.web[i], self.thumb[i], self.imgtype[i])
 
             if self.image_for_webnail == '1':
@@ -650,42 +649,26 @@
 
             if self.mode == '1':
                 text = self.mode1_html(i)
-                self.request.write(''.join(text))
 
             if self.mode == '2':
                 text = self.mode2_html(i)
-                if cols > 1:
-                    self.request.write('<table valign="bottom">')
-                self.request.write(''.join(text))
-                if cols > 1:
-                    self.request.write('</table>')
 
-            if self.mode == '1' or cols > 1:
-                if self.album == '0':
-                    if  z < cols:
-                        self.request.write('</td>')
-                        if z < n and  i < n - 1:
-                            self.request.write('<td%s>' % self.td_style)
-                        if i == n - 1:
-                            self.request.write('</tr>')
-                    else:
-                        self.request.write('</td>')
-                        self.request.write('</tr>')
-                        if i < n - 1:
-                            self.request.write('<tr valign="top">')
-                            self.request.write('<td%s>' % self.td_style)
-            i += 1
-            z += 1
-            if z > cols:
-                z = 1
+            if col_count <= COLUMNS:
+                result.append(''.join(text))
 
             if self.album == '1':
-                self.request.write("%(n)s images (%(album_name)s)" % {"n": str(n), "album_name": self.album_name})
                 break
 
-        if self.album == '0':
-            if i < n:
-                self.request.write('</td>')
-                self.request.write('</tr>')
-            self.request.write('</table>')
+            if col_count == COLUMNS:
+                col_count = 0
+                data.addRow(tuple(result))
+                result = []
 
+            col_count += 1
+
+        if result:
+            data.addRow(tuple(result))
+
+        browser = DataBrowserWidget(self.request, show_header=False)
+        browser.setData(data)
+        self.request.write(browser.format())