rer.solrpush 1.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. rer/solrpush/__init__.py +7 -0
  2. rer/solrpush/adapters/__init__.py +1 -0
  3. rer/solrpush/adapters/configure.zcml +13 -0
  4. rer/solrpush/adapters/file.py +52 -0
  5. rer/solrpush/adapters/rss_feed.py +28 -0
  6. rer/solrpush/behaviors/__init__.py +0 -0
  7. rer/solrpush/behaviors/configure.zcml +16 -0
  8. rer/solrpush/behaviors/solr_fields.py +41 -0
  9. rer/solrpush/browser/__init__.py +0 -0
  10. rer/solrpush/browser/configure.zcml +111 -0
  11. rer/solrpush/browser/controlpanel.py +96 -0
  12. rer/solrpush/browser/elevate_settings.py +35 -0
  13. rer/solrpush/browser/maintenance.py +476 -0
  14. rer/solrpush/browser/query_debug.py +12 -0
  15. rer/solrpush/browser/querybuilder.py +168 -0
  16. rer/solrpush/browser/scales.py +80 -0
  17. rer/solrpush/browser/static/.gitkeep +0 -0
  18. rer/solrpush/browser/static/dist/dev/main.js +58240 -0
  19. rer/solrpush/browser/static/dist/dev/main.js.map +180 -0
  20. rer/solrpush/browser/static/dist/prod/main.js +9604 -0
  21. rer/solrpush/browser/static/dist/prod/main.js.map +1 -0
  22. rer/solrpush/browser/static/javascripts/FacetsContainer/index.js +46 -0
  23. rer/solrpush/browser/static/javascripts/ProgressBar/index.js +40 -0
  24. rer/solrpush/browser/static/javascripts/ProgressBarContainer/index.js +66 -0
  25. rer/solrpush/browser/static/javascripts/index.js +14 -0
  26. rer/solrpush/browser/static/package.json +13 -0
  27. rer/solrpush/browser/static/styles.css +22 -0
  28. rer/solrpush/browser/static/styles.css.map +1 -0
  29. rer/solrpush/browser/static/styles.scss +27 -0
  30. rer/solrpush/browser/static/yarn.lock +1408 -0
  31. rer/solrpush/browser/templates/controlpanel_layout.pt +49 -0
  32. rer/solrpush/browser/templates/query_debug.pt +17 -0
  33. rer/solrpush/browser/templates/reindex_solr.pt +35 -0
  34. rer/solrpush/configure.zcml +81 -0
  35. rer/solrpush/indexer.py +120 -0
  36. rer/solrpush/interfaces/__init__.py +8 -0
  37. rer/solrpush/interfaces/adapter.py +13 -0
  38. rer/solrpush/interfaces/elevate.py +98 -0
  39. rer/solrpush/interfaces/layer.py +6 -0
  40. rer/solrpush/interfaces/queueprocessor.py +6 -0
  41. rer/solrpush/interfaces/settings.py +194 -0
  42. rer/solrpush/locales/README.rst +37 -0
  43. rer/solrpush/locales/__init__.py +0 -0
  44. rer/solrpush/locales/en/LC_MESSAGES/rer.solrpush.mo +0 -0
  45. rer/solrpush/locales/en/LC_MESSAGES/rer.solrpush.po +399 -0
  46. rer/solrpush/locales/it/LC_MESSAGES/rer.solrpush.mo +0 -0
  47. rer/solrpush/locales/it/LC_MESSAGES/rer.solrpush.po +399 -0
  48. rer/solrpush/locales/rer.solrpush.pot +402 -0
  49. rer/solrpush/locales/update.py +71 -0
  50. rer/solrpush/locales/update.sh +12 -0
  51. rer/solrpush/parser.py +211 -0
  52. rer/solrpush/permissions.zcml +18 -0
  53. rer/solrpush/profiles/default/actions.xml +21 -0
  54. rer/solrpush/profiles/default/browserlayer.xml +7 -0
  55. rer/solrpush/profiles/default/catalog.xml +4 -0
  56. rer/solrpush/profiles/default/controlpanel.xml +31 -0
  57. rer/solrpush/profiles/default/metadata.xml +8 -0
  58. rer/solrpush/profiles/default/registry/bundle.xml +25 -0
  59. rer/solrpush/profiles/default/registry/criteria.xml +55 -0
  60. rer/solrpush/profiles/default/registry/settings.xml +6 -0
  61. rer/solrpush/profiles/default/rolemap.xml +13 -0
  62. rer/solrpush/profiles/default/types/Document.xml +12 -0
  63. rer/solrpush/profiles/to_1100/componentregistry.xml +9 -0
  64. rer/solrpush/profiles/to_1100/metadata.xml +5 -0
  65. rer/solrpush/profiles/to_1300/controlpanel.xml +13 -0
  66. rer/solrpush/profiles/to_1300/registry.xml +5 -0
  67. rer/solrpush/profiles/uninstall/browserlayer.xml +7 -0
  68. rer/solrpush/profiles/uninstall/controlpanel.xml +21 -0
  69. rer/solrpush/profiles/uninstall/registry.xml +17 -0
  70. rer/solrpush/restapi/__init__.py +0 -0
  71. rer/solrpush/restapi/configure.zcml +8 -0
  72. rer/solrpush/restapi/services/__init__.py +0 -0
  73. rer/solrpush/restapi/services/configure.zcml +8 -0
  74. rer/solrpush/restapi/services/elevate_schema/__init__.py +0 -0
  75. rer/solrpush/restapi/services/elevate_schema/configure.zcml +14 -0
  76. rer/solrpush/restapi/services/elevate_schema/get.py +12 -0
  77. rer/solrpush/restapi/services/solr_search/__init__.py +0 -0
  78. rer/solrpush/restapi/services/solr_search/batch.py +129 -0
  79. rer/solrpush/restapi/services/solr_search/configure.zcml +14 -0
  80. rer/solrpush/restapi/services/solr_search/get.py +25 -0
  81. rer/solrpush/restapi/services/solr_search/solr_search_handler.py +86 -0
  82. rer/solrpush/setuphandlers.py +20 -0
  83. rer/solrpush/testing.py +161 -0
  84. rer/solrpush/tests/__init__.py +0 -0
  85. rer/solrpush/tests/docs/example.docx +0 -0
  86. rer/solrpush/tests/docs/example.ods +0 -0
  87. rer/solrpush/tests/docs/example.pdf +0 -0
  88. rer/solrpush/tests/docs/plone_logo.png +0 -0
  89. rer/solrpush/tests/test_behaviors.py +61 -0
  90. rer/solrpush/tests/test_elevate.py +124 -0
  91. rer/solrpush/tests/test_events.py +181 -0
  92. rer/solrpush/tests/test_image_tags.py +85 -0
  93. rer/solrpush/tests/test_maintenance.py +165 -0
  94. rer/solrpush/tests/test_querybuilder.py +272 -0
  95. rer/solrpush/tests/test_restapi_search.py +127 -0
  96. rer/solrpush/tests/test_search.py +177 -0
  97. rer/solrpush/tests/test_setup.py +67 -0
  98. rer/solrpush/tests/test_solr_interface.py +359 -0
  99. rer/solrpush/tests/test_tika.py +85 -0
  100. rer/solrpush/tests/test_vocabularies.py +113 -0
  101. rer/solrpush/upgrades.py +76 -0
  102. rer/solrpush/upgrades.zcml +86 -0
  103. rer/solrpush/utils/__init__.py +6 -0
  104. rer/solrpush/utils/solr_common.py +122 -0
  105. rer/solrpush/utils/solr_indexer.py +295 -0
  106. rer/solrpush/utils/solr_search.py +352 -0
  107. rer/solrpush/vocabularies.py +50 -0
  108. rer.solrpush-1.3.4-py3.10-nspkg.pth +1 -0
  109. rer.solrpush-1.3.4.dist-info/LICENSE.GPL +339 -0
  110. rer.solrpush-1.3.4.dist-info/LICENSE.rst +15 -0
  111. rer.solrpush-1.3.4.dist-info/METADATA +507 -0
  112. rer.solrpush-1.3.4.dist-info/RECORD +116 -0
  113. rer.solrpush-1.3.4.dist-info/WHEEL +5 -0
  114. rer.solrpush-1.3.4.dist-info/entry_points.txt +5 -0
  115. rer.solrpush-1.3.4.dist-info/namespace_packages.txt +1 -0
  116. rer.solrpush-1.3.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,49 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
2
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
3
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
4
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5
+ lang="en"
6
+ metal:use-macro="context/prefs_main_template/macros/master"
7
+ i18n:domain="plone">
8
+
9
+ <body>
10
+ <div metal:fill-slot="prefs_configlet_main">
11
+
12
+ <a id="setup-link" class="link-parent"
13
+ tal:attributes="href view/control_panel_url"
14
+ i18n:translate="">
15
+ Site Setup
16
+ </a>
17
+
18
+ <h1 class="documentFirstHeading" tal:content="view/label">View Title</h1>
19
+
20
+ <div metal:use-macro="context/global_statusmessage/macros/portal_message">
21
+ Portal status message
22
+ </div>
23
+
24
+ <div id="content-core">
25
+ <div id="layout-contents">
26
+ <div class="management-buttons">
27
+ <a class="link-parent"
28
+ href="${context/portal_url}/reindex-solr"
29
+ title="Find all objects in Plone and reindex them on SOLR"
30
+ i18n:translate="solr_reindex_label"
31
+ i18n:attributes="title">Reindex</a>
32
+ <a class="link-parent"
33
+ href="${context/portal_url}/reset-solr"
34
+ title="Drop all items in SOLR index."
35
+ i18n:translate="solr_reset_label"
36
+ i18n:attributes="title">Reset</a>
37
+ <a class="link-parent"
38
+ href="${context/portal_url}/sync-solr"
39
+ title="Remove no longer existing contents from SOLR and index missing objects."
40
+ i18n:translate="solr_sync_label"
41
+ i18n:attributes="title">Sync</a>
42
+ </div>
43
+ <span tal:replace="structure view/contents" />
44
+ </div>
45
+ </div>
46
+
47
+ </div>
48
+ </body>
49
+ </html>
@@ -0,0 +1,17 @@
1
+ <div class="query-debug"
2
+ tal:define="query view/query"
3
+ tal:condition="query">
4
+ <div class="portalMessage warning">
5
+ <strong>SOLR query url</strong>
6
+ <a href="${query/url}">${query/url}</a>
7
+ </div>
8
+ <div class="portalMessage warning"
9
+ tal:define="params python:query.get('params', {})">
10
+ <strong>Params details</strong>
11
+ <ul>
12
+ <li tal:repeat="k params">
13
+ <strong>${k}:</strong> <span tal:content="python:params[k]" />
14
+ </li>
15
+ </ul>
16
+ </div>
17
+ </div>
@@ -0,0 +1,35 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
2
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
3
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
4
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5
+ metal:use-macro="context/main_template/macros/master"
6
+ i18n:domain="rer.solrpush">
7
+ <body>
8
+ <metal:title fill-slot="content-title">
9
+ <a class="link-parent"
10
+ href="${context/portal_url}/solrpush-settings"
11
+ title="Go back"
12
+ i18n:translate="go_to_controlpanel"
13
+ i18n:attributes="title">Return to configuration</a>
14
+ <h1 class="documentFirstHeading" tal:content="view/label">View Title</h1>
15
+ </metal:title>
16
+ <metal:description fill-slot="content-description">
17
+ <p class="discreet" tal:content="view/description">
18
+ description
19
+ </p>
20
+ </metal:description>
21
+ <metal:core fill-slot="content-core" tal:define="is_active view/is_active">
22
+ <div class="portalMessage warning" role="status">
23
+ <strong>You might run into problems</strong>
24
+ Please check your settings, be sure what you're doing is right.
25
+ </div>
26
+ <p tal:condition="not:is_active" i18n:translate="reindex_solr_not_active">SOLR push is not active. Unable to sync with solr.</p>
27
+ <tal:active condition="is_active">
28
+ <div id="solr-maintenance"
29
+ data-authenticator="${view/token}"
30
+ data-action="${view/action}" />
31
+ <script src="${view/get_resource_js}"></script>
32
+ </tal:active>
33
+ </metal:core>
34
+ </body>
35
+ </html>
@@ -0,0 +1,81 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
4
+ xmlns:i18n="http://namespaces.zope.org/i18n"
5
+ xmlns:plone="http://namespaces.plone.org/plone"
6
+ i18n_domain="rer.solrpush">
7
+
8
+ <i18n:registerTranslations directory="locales" />
9
+ <include file="permissions.zcml" />
10
+
11
+ <include package=".adapters" />
12
+ <include package=".behaviors" />
13
+ <include package=".browser" />
14
+ <include package=".restapi" />
15
+
16
+
17
+ <include file="upgrades.zcml" />
18
+
19
+ <genericsetup:registerProfile
20
+ name="default"
21
+ title="RER: Solr push"
22
+ directory="profiles/default"
23
+ description="Installs the rer.solrpush add-on."
24
+ provides="Products.GenericSetup.interfaces.EXTENSION"
25
+ post_handler=".setuphandlers.post_install"
26
+ />
27
+
28
+ <genericsetup:registerProfile
29
+ name="uninstall"
30
+ title="RER: Solr push (uninstall)"
31
+ directory="profiles/uninstall"
32
+ description="Uninstalls the rer.solrpush add-on."
33
+ provides="Products.GenericSetup.interfaces.EXTENSION"
34
+ post_handler=".setuphandlers.uninstall"
35
+ />
36
+
37
+ <genericsetup:registerProfile
38
+ name="to_1100"
39
+ title="RER: Solr push remove persistent utility"
40
+ directory="profiles/to_1100"
41
+ description=""
42
+ provides="Products.GenericSetup.interfaces.EXTENSION"
43
+ />
44
+
45
+ <genericsetup:registerProfile
46
+ name="to_1300"
47
+ title="RER: Solr push remove unused control panel"
48
+ directory="profiles/to_1300"
49
+ description=""
50
+ provides="Products.GenericSetup.interfaces.EXTENSION"
51
+ />
52
+
53
+ <utility
54
+ factory=".setuphandlers.HiddenProfiles"
55
+ name="rer.solrpush-hiddenprofiles"
56
+ />
57
+
58
+
59
+ <!-- vocabularies -->
60
+ <utility
61
+ name="rer.solrpush.vocabularies.AvailableSites"
62
+ component=".vocabularies.AvailableSitesVocabulary"
63
+ />
64
+ <utility
65
+ name="rer.solrpush.vocabularies.AvailableSubjects"
66
+ component=".vocabularies.AvailableSubjectsVocabulary"
67
+ />
68
+ <utility
69
+ name="rer.solrpush.vocabularies.AvailablePortalTypes"
70
+ component=".vocabularies.AvailablePortalTypesVocabulary"
71
+ />
72
+
73
+ <!-- indexers -->
74
+ <utility
75
+ factory=".indexer.SolrIndexProcessor"
76
+ name="solrpush.utility"
77
+ />
78
+ <adapter name="path_depth" factory=".indexer.path_depth" />
79
+ <adapter name="path_parents" factory=".indexer.path_parents" />
80
+
81
+ </configure>
@@ -0,0 +1,120 @@
1
+ # -*- coding: utf-8 -*-
2
+ # from operator import itemgetter
3
+ from plone import api
4
+ from plone.dexterity.interfaces import IDexterityContent
5
+ from plone.indexer import indexer
6
+ from Products.CMFCore.indexing import INDEX
7
+ from Products.CMFCore.indexing import REINDEX
8
+ from Products.CMFCore.indexing import UNINDEX
9
+ from pysolr import SolrError
10
+ from rer.solrpush import _
11
+ from rer.solrpush.interfaces import IRerSolrpushLayer
12
+ from rer.solrpush.interfaces import ISolrIndexQueueProcessor
13
+ from rer.solrpush.interfaces.settings import IRerSolrpushSettings
14
+ from rer.solrpush.utils import push_to_solr
15
+ from rer.solrpush.utils import remove_from_solr
16
+ from rer.solrpush.utils.solr_indexer import can_index
17
+ from rer.solrpush.utils.solr_indexer import create_index_dict
18
+ from six.moves import range
19
+ from zope.globalrequest import getRequest
20
+ from zope.interface import implementer
21
+
22
+ import logging
23
+
24
+
25
+ logger = logging.getLogger(__name__)
26
+
27
+
28
+ @implementer(ISolrIndexQueueProcessor)
29
+ class SolrIndexProcessor(object):
30
+ queue = []
31
+
32
+ @property
33
+ def active(self):
34
+ return IRerSolrpushLayer.providedBy(
35
+ getRequest()
36
+ ) and api.portal.get_registry_record(
37
+ "active", interface=IRerSolrpushSettings, default=False
38
+ )
39
+
40
+ @property
41
+ def enabled_types(self):
42
+ return api.portal.get_registry_record(
43
+ "enabled_types", interface=IRerSolrpushSettings, default=[]
44
+ )
45
+
46
+ @property
47
+ def index_fields(self):
48
+ return api.portal.get_registry_record(
49
+ "index_fields", interface=IRerSolrpushSettings, default=None
50
+ )
51
+
52
+ def index(self, obj, attributes=None):
53
+ if (
54
+ self.active
55
+ and getattr(obj, "showinsearch", True) # noqa
56
+ and can_index(obj) # noqa
57
+ ):
58
+ uid = obj.UID()
59
+ data = create_index_dict(obj)
60
+ self.queue = [item for item in self.queue if item[0] != uid] + [
61
+ (uid, INDEX, data, attributes)
62
+ ]
63
+ return True
64
+ return False
65
+
66
+ def reindex(self, obj, attributes=None, update_metadata=None):
67
+ if self.active:
68
+ if not self.index(obj, attributes):
69
+ self.unindex(obj)
70
+
71
+ def unindex(self, obj):
72
+ if self.active:
73
+ uid = obj.UID()
74
+ self.queue = [item for item in self.queue if item[0] != uid] + [
75
+ (uid, UNINDEX, None, None)
76
+ ]
77
+
78
+ def begin(self):
79
+ pass
80
+
81
+ def commit(self, wait=None):
82
+ if self.active and self.queue:
83
+ # TODO: è possibile con sol anche mandare un set di comandi (add+delete) in un
84
+ # unica volta, anzichè uno alla volta, valutare le due opzioni
85
+ # Sort so unindex operations come first
86
+ # for iop, obj in sorted(res.values(), key=itemgetter(0)):
87
+ for uid, iop, data, args in self.queue:
88
+ try:
89
+ if iop in (INDEX, REINDEX):
90
+ push_to_solr(data)
91
+ elif iop == UNINDEX:
92
+ remove_from_solr(uid)
93
+ except SolrError:
94
+ logger.exception("error indexing %s %s", iop, uid)
95
+ message = _(
96
+ "content_indexed_error",
97
+ default=u"There was a problem indexing or unindexing "
98
+ u"this content. Please take note of this address and "
99
+ u"contact site administrator.",
100
+ )
101
+ api.portal.show_message(
102
+ message=message, request=getRequest(), type="warning"
103
+ )
104
+ self.queue = []
105
+
106
+ def abort(self):
107
+ self.queue = []
108
+
109
+
110
+ @indexer(IDexterityContent)
111
+ def path_depth(obj, **kwargs):
112
+ """return depth of physical path"""
113
+ return len(obj.getPhysicalPath())
114
+
115
+
116
+ @indexer(IDexterityContent)
117
+ def path_parents(obj, **kwargs):
118
+ """return all parent paths leading up to the object"""
119
+ elements = obj.getPhysicalPath()
120
+ return ["/".join(elements[: n + 1]) for n in range(1, len(elements))]
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ from rer.solrpush.interfaces.layer import IRerSolrpushLayer
3
+ from rer.solrpush.interfaces.queueprocessor import ISolrIndexQueueProcessor
4
+ from rer.solrpush.interfaces.elevate import IElevateSettings
5
+
6
+ IElevateSettings
7
+ IRerSolrpushLayer
8
+ ISolrIndexQueueProcessor
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+ from zope.interface import Interface
3
+
4
+
5
+ class IExtractFileFromTika(Interface):
6
+ def extract_from_tika(self, file_name, file_obj):
7
+ """Call solr Tika to extract text from given file
8
+ @return: extracted plain text
9
+ """
10
+
11
+
12
+ class ISolrBrain(Interface):
13
+ """ """
@@ -0,0 +1,98 @@
1
+ # -*- coding: utf-8 -*-
2
+ from plone.app.vocabularies.catalog import CatalogSource as CatalogSourceBase
3
+ from plone.app.z3cform.widget import RelatedItemsFieldWidget
4
+ from plone.autoform import directives as form
5
+ from plone.supermodel import model
6
+ from rer.solrpush import _
7
+ from z3c.relationfield.schema import RelationChoice
8
+ from z3c.relationfield.schema import RelationList
9
+ from zope import schema
10
+ from zope.i18n import translate
11
+ from zope.interface import Invalid
12
+ from zope.interface import invariant
13
+ from zope.globalrequest import getRequest
14
+
15
+ import json
16
+
17
+
18
+ class CatalogSource(CatalogSourceBase):
19
+ """
20
+ Without this hack, validation doesn't pass
21
+ """
22
+
23
+ def __contains__(self, value):
24
+ return True # Always contains to allow lazy handling of removed objs
25
+
26
+
27
+ class IElevateRowSchema(model.Schema):
28
+ text = schema.List(
29
+ title=_("elevate_row_schema_text_label", default=u"Text"),
30
+ description=_(
31
+ "elevate_row_schema_text_help",
32
+ default=u"The word that should match in the search.",
33
+ ),
34
+ required=True,
35
+ value_type=schema.TextLine(),
36
+ )
37
+ uid = RelationList(
38
+ title=_("elevate_row_schema_uid_label", u"Elements"),
39
+ description=_(
40
+ "elevate_row_schema_uid_help",
41
+ u"Select a list of elements to elevate for that search word.",
42
+ ),
43
+ value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
44
+ required=True,
45
+ )
46
+ form.widget(
47
+ "uid",
48
+ RelatedItemsFieldWidget,
49
+ vocabulary="plone.app.vocabularies.Catalog",
50
+ )
51
+
52
+
53
+ class IElevateSettings(model.Schema):
54
+ """ """
55
+
56
+ elevate_schema = schema.SourceText(
57
+ title=_(u"elevate_schema_label", default=u"Elevate configuration"),
58
+ description=_(
59
+ u"elevate_schema_help",
60
+ default=u"Insert a list of values for elevate.",
61
+ ),
62
+ required=False,
63
+ )
64
+
65
+ @invariant
66
+ def elevate_invariant(data):
67
+ schema = json.loads(data.elevate_schema)
68
+ request = getRequest()
69
+ words_mapping = [x["text"] for x in schema]
70
+ for i, schema_item in enumerate(schema):
71
+ elevate_text = schema_item.get("text", [])
72
+ if not elevate_text:
73
+ raise Invalid(
74
+ translate(
75
+ _(
76
+ "text_required_label",
77
+ default="Text field must be filled for Group ${id}.",
78
+ mapping=dict(id=i + 1),
79
+ ),
80
+ context=request,
81
+ )
82
+ )
83
+ for text in elevate_text:
84
+ for words_i, words in enumerate(words_mapping):
85
+ if i == words_i:
86
+ # it's the current config
87
+ continue
88
+ if text in words:
89
+ raise Invalid(
90
+ translate(
91
+ _(
92
+ "text_duplicated_label",
93
+ default='"${text}" is used in several groups.',
94
+ mapping=dict(id=i, text=text),
95
+ ),
96
+ context=request,
97
+ )
98
+ )
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ from zope.publisher.interfaces.browser import IDefaultBrowserLayer
3
+
4
+
5
+ class IRerSolrpushLayer(IDefaultBrowserLayer):
6
+ """Marker interface that defines a browser layer."""
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ from Products.CMFCore.interfaces import IIndexQueueProcessor
3
+
4
+
5
+ class ISolrIndexQueueProcessor(IIndexQueueProcessor):
6
+ """ """
@@ -0,0 +1,194 @@
1
+ # -*- coding: utf-8 -*-
2
+ from plone.app.vocabularies.catalog import CatalogSource as CatalogSourceBase
3
+ from plone.app.z3cform.widget import RelatedItemsFieldWidget
4
+ from plone.autoform import directives as form
5
+ from plone.supermodel import model
6
+ from rer.solrpush import _
7
+ from zope import schema
8
+
9
+
10
+ class CatalogSource(CatalogSourceBase):
11
+ """
12
+ Collection tile specific catalog source to allow targeted widget.
13
+ Without this hack, validation doesn't pass
14
+ """
15
+
16
+ def __contains__(self, value):
17
+ return True # Always contains to allow lazy handling of removed objs
18
+
19
+
20
+ class IElevateRowSchema(model.Schema):
21
+ text = schema.TextLine(
22
+ title=_("elevate_row_schema_text_label", default=u"Text"),
23
+ description=_(
24
+ "elevate_row_schema_text_help",
25
+ default=u"The word that should match in the search.",
26
+ ),
27
+ required=True,
28
+ )
29
+ uid = schema.List(
30
+ title=_("elevate_row_schema_uid_label", u"Elements"),
31
+ description=_(
32
+ "elevate_row_schema_uid_help",
33
+ u"Select a list of elements to elevate for that search word.",
34
+ ),
35
+ value_type=schema.Choice(source=CatalogSource()),
36
+ required=True,
37
+ )
38
+ form.widget("uid", RelatedItemsFieldWidget)
39
+
40
+
41
+ class IRerSolrpushConf(model.Schema):
42
+ """"""
43
+
44
+ active = schema.Bool(
45
+ title=_(u"Active"),
46
+ description=_(u"Enable SOLR indexing on this site."),
47
+ required=False,
48
+ default=False,
49
+ )
50
+ search_enabled = schema.Bool(
51
+ title=_(u"Search enabled"),
52
+ description=_(
53
+ u"Site search will use SOLR as engine instead portal_catalog."
54
+ ),
55
+ required=False,
56
+ default=True,
57
+ )
58
+ force_commit = schema.Bool(
59
+ title=_(u"Force commit"),
60
+ description=_(
61
+ u"Force commits on CRUD operations. If enabled, each indexing "
62
+ u"operation to SOLR will be immediately committed and persisted. "
63
+ u"This means that updates are immediately available on SOLR queries." # noqa
64
+ u"If you are using SolrCloud with ZooKeeper, immediate commits "
65
+ u"will slow down response performances when indexing, so it's "
66
+ u"better to turn it off. In this case updates will be available "
67
+ u"when SOLR periodically commit changes."
68
+ ),
69
+ required=False,
70
+ default=True,
71
+ )
72
+
73
+ solr_url = schema.TextLine(
74
+ title=_(u"SOLR url"),
75
+ description=_(u"The SOLR core to connect to."),
76
+ required=True,
77
+ )
78
+
79
+ frontend_url = schema.TextLine(
80
+ title=_(u"Frontend url"),
81
+ description=_(u"If the website has different URL for frontend users."),
82
+ required=False,
83
+ )
84
+
85
+ enabled_types = schema.List(
86
+ title=_(u"enabled_types_label", default=u"Enabled portal types"),
87
+ description=_(
88
+ u"enabled_types_help",
89
+ default=u"Select a list of portal types to index in solr. "
90
+ u"Empty list means that all portal types will be indexed.",
91
+ ),
92
+ required=False,
93
+ default=[],
94
+ missing_value=[],
95
+ value_type=schema.Choice(
96
+ vocabulary="plone.app.vocabularies.PortalTypes"
97
+ ),
98
+ )
99
+
100
+ index_fields = schema.SourceText(
101
+ title=_(
102
+ "index_fields_label",
103
+ default=u"List of fields loaded from SOLR that we use for "
104
+ u"indexing.",
105
+ ),
106
+ description=_(
107
+ u"index_fields_help",
108
+ default=u"We store this list for performance"
109
+ u" reasons. If the configuration changes, you need to click on"
110
+ u" Reload button",
111
+ ),
112
+ required=False,
113
+ )
114
+ # NASCOSTO DAL PANNELLO DI CONTROLLO (vedi: browser/controlpanel.py)
115
+ ready = schema.Bool(
116
+ title=_(u"Ready"),
117
+ description=_(u"SOLR push is ready to be used."),
118
+ required=False,
119
+ default=False,
120
+ )
121
+
122
+
123
+ class IRerSolrpushSearchConf(model.Schema):
124
+ query_debug = schema.Bool(
125
+ title=_(u"Query debug"),
126
+ description=_(
127
+ u"If enabled, when a search to SOLR is performed (for "
128
+ u"example in Collection), the query will be showed in the page for "
129
+ u"debug. Only visible to Managers."
130
+ ),
131
+ required=False,
132
+ default=False,
133
+ )
134
+ remote_elevate_schema = schema.TextLine(
135
+ title=_(u"remote_elevate_label", default=u"Remote elevate"),
136
+ description=_(
137
+ u"remote_elevate_help",
138
+ default=u'If this field is set and no "site_name" is '
139
+ u"passed in query, elevate schema is taken from an external "
140
+ u"source. This is useful if you index several sites and handle "
141
+ u"elevate configuration in one single site. This should be an url "
142
+ u'that points to "@elevate-schema" view.'
143
+ u"For example: http://my-site/@elevate-schema.",
144
+ ),
145
+ default=u"",
146
+ required=False,
147
+ )
148
+ qf = schema.TextLine(
149
+ title=_("qf_label", default=u"qf (query fields)"),
150
+ description=_(
151
+ "qf_help",
152
+ default=u"Set a list of fields, each of which is assigned a boost "
153
+ u"factor to increase or decrease that particular field’s "
154
+ u"importance in the query. "
155
+ u"For example: fieldOne^1000.0 fieldTwo fieldThree^10.0",
156
+ ),
157
+ required=False,
158
+ default=u"",
159
+ )
160
+ bq = schema.TextLine(
161
+ title=_("bq_label", default=u"bq (boost query)"),
162
+ description=_(
163
+ "bq_help",
164
+ default=u"Set a list query clauses that will be added to the main "
165
+ u"query to influence the score. For example if we want to boost "
166
+ u'results that have a specific "searchwords" term: '
167
+ u"searchwords:something^1000",
168
+ ),
169
+ required=False,
170
+ default=u"",
171
+ )
172
+
173
+ bf = schema.TextLine(
174
+ title=_("bf_label", default=u"bf (boost functions)"),
175
+ description=_(
176
+ "bf_help",
177
+ default=u"Set a list of functions (with optional boosts) that "
178
+ u"will be used to construct FunctionQueries which will be added "
179
+ u"to the main query as optional clauses that will influence the "
180
+ u"score. Any function supported natively by Solr can be used, "
181
+ u"along with a boost value. "
182
+ u"For example if we want to give less relevance to "
183
+ u"items deeper in the tree we can set something like this: "
184
+ u"recip(path_depth,10,100,1)",
185
+ ),
186
+ required=False,
187
+ default=u"",
188
+ )
189
+
190
+
191
+ class IRerSolrpushSettings(IRerSolrpushConf, IRerSolrpushSearchConf):
192
+ """
193
+ Marker interface for settings
194
+ """
@@ -0,0 +1,37 @@
1
+ Adding and updating locales
2
+ ---------------------------
3
+
4
+ For every language you want to translate into you need a
5
+ locales/[language]/LC_MESSAGES/collective.task.po
6
+ (e.g. locales/de/LC_MESSAGES/collective.task.po)
7
+
8
+ For German
9
+
10
+ .. code-block:: console
11
+
12
+ $ mkdir de
13
+
14
+ For updating locales
15
+
16
+ .. code-block:: console
17
+
18
+ $ ./bin/update_locale
19
+
20
+ Note
21
+ ----
22
+
23
+ The script uses gettext package for internationalization.
24
+
25
+ Install it before running the script.
26
+
27
+ On macOS
28
+ --------
29
+
30
+ .. code-block:: console
31
+
32
+ $ brew install gettext
33
+
34
+ On Windows
35
+ ----------
36
+
37
+ see https://mlocati.github.io/articles/gettext-iconv-windows.html
File without changes