--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content_es/component/link.py Fri Jan 04 12:21:56 2019 +0100
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2008-2019 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from pyams_content.component.association import IAssociationItem
+from pyams_content.component.association.interfaces import IAssociationContainer
+from pyams_content.component.links import IBaseLink
+from pyams_content.component.paragraph import IParagraphContainer, IParagraphContainerTarget
+from pyams_content_es.interfaces import IDocumentIndexInfo
+from pyams_utils.adapter import adapter_config
+
+
+@adapter_config(name='link', context=IParagraphContainerTarget, provides=IDocumentIndexInfo)
+def paragraph_container_target_link_index_info(context):
+ """Internal and external links index info"""
+ links = []
+ for paragraph in IParagraphContainer(context).values():
+ associations = IAssociationContainer(paragraph, {})
+ for link in associations.values():
+ if not IAssociationItem(link).visible:
+ continue
+ if not IBaseLink.providedBy(link):
+ continue
+ links.append({
+ 'title': link.title,
+ 'description': link.description
+ })
+ return {'link': links}