changeset 299:1c25a98e3d9d

reverted changeset 269:1e3e876e38fb for Image and partly for text_x_arnica
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 26 Nov 2008 23:07:44 +0100
parents b08869e17e8b
children 7ccb9bd8983a
files data/plugin/macro/Image.py data/plugin/parser/text_x_arnica.py
diffstat 2 files changed, 19 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/Image.py	Sat Nov 08 16:28:11 2008 +0100
+++ b/data/plugin/macro/Image.py	Wed Nov 26 23:07:44 2008 +0100
@@ -48,11 +48,9 @@
                  item_name, # PageName/AttachName for now, later this is just the item name
                  headline=None,
                  caption=None,
-                 raw=None,
         ):
         self.request = request
         self.pagename, self.attachname = item_name.rsplit('/', 1)
-        self.raw = raw
 
         # cached property values:
         self.__filename = None
@@ -63,25 +61,6 @@
         self.__ctime = None
         self.__headline = headline
         self.__caption = caption
-        self.__description = self.attachname
-
-    def _get_description(self):
-        if self.raw is None:
-            self.__description = self.attachname
-            return self.__description
-        else:
-            quotes = self.raw.split('\n')
-            quotes = [quote.strip() for quote in quotes]
-            quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
-            image_alias = self.attachname
-            for line in quotes:
-                if line.startswith('[[') and line.endswith(']]'):
-                    img, alias = line[2:-2].split('|', 1)
-                    if img.strip() == self.attachname:
-                        self.__description = alias.strip()
-                        break
-            return self.__description
-    description = property(_get_description)
 
     def _get_filename(self):
         if self.__filename is None:
@@ -265,16 +244,8 @@
 
         <<Image(PageName/attachname,width=100,alt="sample image")>>
     """
-    arnica_parser = wikiutil.importWikiPlugin(macro.request.cfg, "parser", "text_x_arnica", function="Parser")
     if '/' not in itemname:
         itemname = macro.formatter.page.page_name + '/' + itemname
-    raw = " * [[%s | %s]]\n" % (itemname.split('/')[1], (alt or (itemname.split('/')[1])))
-    img = Image(macro.request, itemname, caption=alt, raw=raw)
-    try:
-        exif_date = time.strftime("%Y-%m-%d %H:%M:%S", macro.request.user.getTime(img.exif["DateTimeOriginal"]))
-    except KeyError:
-        exif_date = '--'
-    # ToDo use alt attribute in arnica for one image instead of Slide Show title
-    ap = arnica_parser(raw, macro.request, image=img)
-    ap.arnica_image[img.attachname] = (img.url(), img.url(size=(width, height)), exif_date, img.description, "0")
-    return ap.render(macro.formatter)
+    img = Image(macro.request, itemname, caption=alt)
+    return macro.formatter.image(src=img.url((width, height)), alt=img.caption)
+
--- a/data/plugin/parser/text_x_arnica.py	Sat Nov 08 16:28:11 2008 +0100
+++ b/data/plugin/parser/text_x_arnica.py	Wed Nov 26 23:07:44 2008 +0100
@@ -286,6 +286,21 @@
         from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
         return wikiutil.renderText(self.request, WikiParser, text)
 
+    def get_image_alias(self):
+        """  gets the quotes from the item list and returns a dictionary of image and alias """
+        # ToDo keep the order of the given quotes
+        quotes = self.raw.split('\n')
+        quotes = [quote.strip() for quote in quotes]
+        quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
+        image_alias = {}
+        counter = 0
+        for line in quotes:
+            if line.startswith('[[') and line.endswith(']]'):
+                img, alias = line[2:-2].split('|', 1)
+                image_alias[img.strip()] = (self.formatter.text(alias.strip()), counter)
+                counter += 1
+        return image_alias
+
     def select_files(self, formatter):
         """ select files """
         # we need to take the page_name from the formatter.page otherwise
@@ -295,14 +310,7 @@
             self.pagename = self.target_page
         path = AttachFile.getAttachDir(self.request, self.pagename, create=1)
         image_dict = {}
-        image_alias = {}
-        counter = 0
-        for attfile in _get_files(self.request, self.pagename):
-            itemname = self.pagename + '/' + attfile
-            img = self.Image(self.request, itemname, raw=self.raw)
-            if img.description != attfile:
-                image_alias[attfile] = (img.description, counter)
-                counter += 1
+        image_alias = self.get_image_alias()
         if self.only_items:
             # get the same order of files and aliastext as on the page written
             files = image_alias.keys()