--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content_es/shared/resource.py Thu Dec 27 14:27:48 2018 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2008-2018 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.shared.resource import IResourceInfo, IWfResource
+from pyams_content_es.interfaces import IDocumentIndexInfo
+from pyams_utils.adapter import adapter_config
+from pyams_utils.html import html_to_text
+
+
+@adapter_config(name='resource_info', context=IWfResource, provides=IDocumentIndexInfo)
+def resource_index_info(content):
+ """Resource index info"""
+ resource_info = IResourceInfo(content)
+ field_names = content.field_names
+ result = {
+ 'author': resource_info.author if 'author' in field_names else None,
+ 'editor': resource_info.editor if 'editor' in field_names else None,
+ 'editor_reference': resource_info.editor_reference if 'editor_reference' in field_names else None,
+ 'isbn_number': resource_info.isbn_number if 'isbn_number' in field_names else None
+ }
+ if 'summary' in field_names:
+ for lang, summary in (resource_info.summary or {}).items():
+ result.setdefault('summary', {})[lang] = html_to_text(summary)
+ if 'publisher_words' in field_names:
+ for lang, words in (resource_info.publisher_words or {}).items():
+ result.setdefault('publisher_words', {})[lang] = html_to_text(words)
+ return {
+ 'resource_info': result
+ }