src/pyams_content_es/component/paragraph.py
changeset 23 35cf2c00874c
parent 20 ea4bfc8f6278
child 26 76977fecfcbf
--- a/src/pyams_content_es/component/paragraph.py	Mon Sep 11 15:11:37 2017 +0200
+++ b/src/pyams_content_es/component/paragraph.py	Tue Sep 12 16:38:57 2017 +0200
@@ -16,10 +16,12 @@
 # import standard library
 
 # import interfaces
+from pyams_content.component.gallery.interfaces import IGalleryParagraph
 from pyams_content.component.illustration.interfaces import IIllustrationParagraph
 from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget
 from pyams_content.component.paragraph.interfaces.header import IHeaderParagraph
 from pyams_content.component.paragraph.interfaces.html import IHTMLParagraph
+from pyams_content.shared.imagemap.interfaces import IImageMapParagraph
 from pyams_content_es.interfaces import IDocumentIndexInfo
 
 # import packages
@@ -67,6 +69,34 @@
     return info
 
 
+@adapter_config(context=IGalleryParagraph, provides=IDocumentIndexInfo)
+def GalleryParagraphIndexInfo(paragraph):
+    """Gallery paragraph index info"""
+    info = {}
+    for lang, title in paragraph.title.items():
+        if title:
+            info.setdefault(lang, title)
+    for image in IGalleryParagraph(paragraph).values():
+        for attr in ('title', 'alt_title', 'description', 'author', 'author_comments', 'sound_title',
+                     'sound_description'):
+            for lang, value in (getattr(image, attr, {}) or {}).items():
+                if value:
+                    new_info = '{old}\n{value}'.format(old=info.get(lang, ''),
+                                                       value=value or '')
+                    info[lang] = new_info
+    return info
+
+
+@adapter_config(context=IImageMapParagraph, provides=IDocumentIndexInfo)
+def ImagemapParagraphIndexInfo(paragraph):
+    """Image map paragraph index info"""
+    info = {}
+    for lang, title in paragraph.title.items():
+        if title:
+            info.setdefault(lang, title)
+    return info
+
+
 @adapter_config(name='body', context=IParagraphContainerTarget, provides=IDocumentIndexInfo)
 def ParagraphContainerTargetIndexInfo(content):
     """Paragraph container index info"""