Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Commit cf1aa6f

Browse files
authored
Merge pull request #201 from eea/develop
Fix autocomplete widget to work with Plone 5.2
2 parents 9fa35ce + 7754c95 commit cf1aa6f

15 files changed

Lines changed: 350 additions & 166 deletions

File tree

Jenkinsfile

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -137,78 +137,79 @@ pipeline {
137137
}
138138
}
139139

140-
// stage('Functional tests') {
141-
// steps {
142-
// parallel(
143-
// "WWW": {
144-
// node(label: 'docker') {
145-
// script {
146-
// try {
147-
// checkout scm
148-
// sh '''mkdir -p xunit-functional'''
149-
// sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-www eeacms/www-devel /debug.sh bin/instance fg'''
150-
// sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-www):8080/'''
151-
// sh '''casperjs test $FTEST_DIR/eea/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-www):8080 --xunit=xunit-functional/ftestsreport.xml'''
152-
// stash name: "xunit-functional", includes: "xunit-functional/*.xml"
153-
// } catch (err) {
154-
// sh '''docker logs --tail=100 $BUILD_TAG-ft-www'''
155-
// throw err
156-
// } finally {
157-
// sh '''docker stop $BUILD_TAG-ft-www'''
158-
// sh '''docker rm -v $BUILD_TAG-ft-www'''
159-
// }
160-
// archiveArtifacts '*.png'
161-
// junit 'xunit-functional/ftestsreport.xml'
162-
// }
163-
// }
164-
// },
165-
166-
// "KGS": {
167-
// node(label: 'docker') {
168-
// script {
169-
// try {
170-
// checkout scm
171-
// sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-kgs eeacms/kgs-devel /debug.sh bin/instance fg'''
172-
// sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-kgs):8080/'''
173-
// sh '''casperjs test $FTEST_DIR/kgs/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-kgs):8080 --xunit=ftestsreport.xml'''
174-
// } catch (err) {
175-
// sh '''docker logs --tail=100 $BUILD_TAG-ft-kgs'''
176-
// throw err
177-
// } finally {
178-
// sh '''docker stop $BUILD_TAG-ft-kgs'''
179-
// sh '''docker rm -v $BUILD_TAG-ft-kgs'''
180-
// }
181-
// archiveArtifacts '*.png'
182-
// junit 'ftestsreport.xml'
183-
// }
184-
// }
185-
// },
186-
187-
// // "Plone4": {
188-
// // node(label: 'docker') {
189-
// // script {
190-
// // try {
191-
// // checkout scm
192-
// // sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-plone4 eeacms/plone-test:4'''
193-
// // sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-plone4):8080/'''
194-
// // sh '''casperjs test $FTEST_DIR/plone4/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-plone4):8080 --xunit=ftestsreport.xml'''
195-
// // } catch (err) {
196-
// // sh '''docker logs --tail=100 $BUILD_TAG-ft-plone4'''
197-
// // throw err
198-
// // } finally {
199-
// // sh '''docker stop $BUILD_TAG-ft-plone4'''
200-
// // sh '''docker rm -v $BUILD_TAG-ft-plone4'''
201-
// // }
202-
// // }
203-
// // archiveArtifacts '*.png'
204-
// // junit 'ftestsreport.xml'
205-
// // }
206-
207-
// // }
208-
209-
// )
210-
// }
211-
// }
140+
stage('Functional tests') {
141+
steps {
142+
parallel(
143+
"WWW": {
144+
node(label: 'docker-host') {
145+
script {
146+
try {
147+
checkout scm
148+
sh '''hostname'''
149+
sh '''mkdir -p xunit-functional'''
150+
sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-www eeacms/www-devel /debug.sh bin/instance fg'''
151+
sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-www):8080/'''
152+
sh '''casperjs test $FTEST_DIR/eea/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-www):8080 --xunit=xunit-functional/ftestsreport.xml'''
153+
stash name: "xunit-functional", includes: "xunit-functional/*.xml"
154+
} catch (err) {
155+
sh '''docker logs --tail=100 $BUILD_TAG-ft-www'''
156+
throw err
157+
} finally {
158+
sh '''docker stop $BUILD_TAG-ft-www'''
159+
sh '''docker rm -v $BUILD_TAG-ft-www'''
160+
}
161+
archiveArtifacts '*.png'
162+
junit 'xunit-functional/ftestsreport.xml'
163+
}
164+
}
165+
},
166+
167+
"KGS": {
168+
node(label: 'docker') {
169+
script {
170+
try {
171+
checkout scm
172+
sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-kgs eeacms/kgs-devel /debug.sh bin/instance fg'''
173+
sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-kgs):8080/'''
174+
sh '''casperjs test $FTEST_DIR/kgs/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-kgs):8080 --xunit=ftestsreport.xml'''
175+
} catch (err) {
176+
sh '''docker logs --tail=100 $BUILD_TAG-ft-kgs'''
177+
throw err
178+
} finally {
179+
sh '''docker stop $BUILD_TAG-ft-kgs'''
180+
sh '''docker rm -v $BUILD_TAG-ft-kgs'''
181+
}
182+
archiveArtifacts '*.png'
183+
junit 'ftestsreport.xml'
184+
}
185+
}
186+
},
187+
188+
// "Plone4": {
189+
// node(label: 'docker') {
190+
// script {
191+
// try {
192+
// checkout scm
193+
// sh '''docker run -d -e ADDONS=$GIT_NAME -e DEVELOP=src/$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" --name=$BUILD_TAG-ft-plone4 eeacms/plone-test:4'''
194+
// sh '''timeout 600 wget --retry-connrefused --tries=60 --waitretry=10 -q http://$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-plone4):8080/'''
195+
// sh '''casperjs test $FTEST_DIR/plone4/*.js --url=$(docker inspect --format {{.NetworkSettings.IPAddress}} $BUILD_TAG-ft-plone4):8080 --xunit=ftestsreport.xml'''
196+
// } catch (err) {
197+
// sh '''docker logs --tail=100 $BUILD_TAG-ft-plone4'''
198+
// throw err
199+
// } finally {
200+
// sh '''docker stop $BUILD_TAG-ft-plone4'''
201+
// sh '''docker rm -v $BUILD_TAG-ft-plone4'''
202+
// }
203+
// }
204+
// archiveArtifacts '*.png'
205+
// junit 'ftestsreport.xml'
206+
// }
207+
208+
// }
209+
210+
)
211+
}
212+
}
212213

213214
stage('Report to SonarQube') {
214215
// Exclude Pull-Requests
@@ -225,14 +226,14 @@ pipeline {
225226
unstash "xunit-reports"
226227
}
227228
unstash "coverage.xml"
228-
// dir('xunit-functional') {
229-
// unstash "xunit-functional"
230-
// }
229+
dir('xunit-functional') {
230+
unstash "xunit-functional"
231+
}
231232
def scannerHome = tool 'SonarQubeScanner';
232233
def nodeJS = tool 'NodeJS11';
233234
withSonarQubeEnv('Sonarqube') {
234235
sh '''sed -i "s|/plone/instance/src/$GIT_NAME|$(pwd)|g" coverage.xml'''
235-
// sh '''find xunit-functional -type f -exec mv {} xunit-reports/ ";"'''
236+
sh '''find xunit-functional -type f -exec mv {} xunit-reports/ ";"'''
236237
sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.python.xunit.skipDetails=true -Dsonar.python.xunit.reportPath=xunit-reports/*.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=./eea -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
237238
sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
238239
}

README.rst

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ Getting started
107107

108108
Faceted settings
109109
================
110-
(*New in version 4.1*)
111110

112111
**Faceted settings** is a menu that appears once you enable Faceted navigation
113112
within your context next to the **Actions** menu and it allows you to perform
114113
the following actions:
115114

115+
Configure
116+
---------
117+
Configure Faceted Navigation TTW.
118+
116119
Enable/disable left portlets
117120
----------------------------
118121
This allows you to gain more space for faceted navigation pages by disabling
@@ -134,16 +137,82 @@ Hide facets criteria if there is only one page of results.
134137
Default: **disabled** (*starting with version 5.2*)
135138

136139
Autocomplete widget
137-
-------------------
140+
===================
141+
142+
Setup
143+
-----
144+
145+
You can enhance and boost search by replacing **ZCatalog** with **Apache Solr**, see `collective.solr`_. Thus:
146+
147+
* Add **collective.solr** to your eggs section in your buildout and re-run buildout::
148+
149+
[buildout]
150+
eggs +=
151+
collective.solr
152+
153+
* With **Plone 5** you'll need to use a more recent version::
154+
155+
[versions]
156+
collective.solr = >= 8.0.0b1
157+
158+
* Start solr::
159+
160+
$ docker run -p 8983:8983 eeacms/solr
161+
162+
* Install **collective.solr** within **Site Setup > Add-ons**
163+
164+
* **Setup and reindex** Solr within **Site Setup > Solr settings**
165+
166+
* Add or replace **Text** widgets with **Text field with suggestions** within your faceted enabled items.
167+
168+
i18n
169+
----
170+
138171
To include a specific select2 locale, French for instance, you can add a resource `++resource++select2/select2_locale_fr.js` in portal_javascripts (Plone 4). It needs to be after the select2.min.js resource. (You need eea.jquery 8.7 minimum)
139172

173+
Suggestions
174+
-----------
175+
140176
You can add a new autocomplete source by registering a IAutocompleteSuggest browser view, you can see an example in
141-
`eea/facetednavigation/tests/autocomplete.py` and `eea/facetednavigation/tests/autocomplete.zcml`
177+
`eea/facetednavigation/tests/autocomplete.py <https://github.com/eea/eea.facetednavigation/blob/master/eea/facetednavigation/tests/autocomplete.py>`_ and
178+
`eea/facetednavigation/tests/autocomplete.zcml <https://github.com/eea/eea.facetednavigation/blob/master/eea/facetednavigation/tests/autocomplete.zcml>`_
179+
180+
You also need to configure Solr to include **/suggest** requestHandler. Within your **solrconfig.xml** add::
181+
182+
<!-- eea.facetednavigation autocomplete -->
183+
<searchComponent name="suggest" class="solr.SpellCheckComponent">
184+
<lst name="spellchecker">
185+
<str name="name">suggest</str>
186+
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
187+
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
188+
<str name="field">Title</str>
189+
<float name="threshold">0.005</float>
190+
<str name="buildOnCommit">true</str>
191+
</lst>
192+
</searchComponent>
193+
194+
<requestHandler name="/suggest" class="org.apache.solr.handler.component.SearchHandler">
195+
<lst name="defaults">
196+
<str name="spellcheck">true</str>
197+
<str name="spellcheck.dictionary">suggest</str>
198+
<str name="spellcheck.count">10</str>
199+
<str name="spellcheck.onlyMorePopular">true</str>
200+
<str name="wt">xml</str>
201+
</lst>
202+
<arr name="components">
203+
<str>suggest</str>
204+
</arr>
205+
</requestHandler>
206+
142207

143208
Extra
144209
=====
145210
You can extend faceted navigation functionality by installing the following add-ons:
146211

212+
* Enhanced text search with autocompletion support
213+
214+
- `collective.solr`_
215+
147216
* Customized vocabularies
148217

149218
- `collective.taxonomy <https://github.com/collective/collective.taxonomy>`_
@@ -267,3 +336,4 @@ EEA_ - European Environment Agency (EU)
267336

268337
.. _EEA: https://www.eea.europa.eu/
269338
.. _`EEA Web Systems Training`: http://www.youtube.com/user/eeacms/videos?view=1
339+
.. _`collective.solr`: https://github.com/collective/collective.solr

docs/HISTORY.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
Changelog
22
=========
33

4+
14.0 - (2020-08-14)
5+
---------------------------
6+
* Upgrade step: Within "Plone > Site Setup > Add-ons" click on
7+
upgrade button available for eea.facetednavigation. If you still get a
8+
JS error with autocomplete facet after this upgrade,
9+
go to Site Setup > Resource Registries and enable, then disable
10+
Development Mode for Faceted Bundles.
11+
[avoinea refs #196]
12+
* Feature: Add possibility to hide Search button with solr autocomplete facet
13+
[avoinea]
14+
* Bug fix: Fix autocomplete solr facet CSS with Plone 5
15+
[avoinea]
16+
* Bug fix: Fix select2 JS error when using autocomplete solr facet
17+
[avoinea refs #196]
18+
19+
420
13.8 - (2020-06-04)
521
---------------------------
622
* Bug fix: make sure orphans used in FacetedQueryHandler.query is an integer

eea/facetednavigation/profiles/common/metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<metadata>
3-
<version>12.0</version>
3+
<version>14.0</version>
44
<dependencies>
55
<dependency>profile-collective.js.jqueryui:default</dependency>
66
<dependency>profile-eea.jquery:03-ajaxfileupload</dependency>

eea/facetednavigation/profiles/plone4/metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<metadata>
3-
<version>12.0</version>
3+
<version>14.0</version>
44
<dependencies>
55
<dependency>profile-eea.jquery:01-jquery</dependency>
66
<dependency>profile-eea.jquery:05-cookie</dependency>

eea/facetednavigation/profiles/plone5/metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<metadata>
3-
<version>12.0</version>
3+
<version>14.0</version>
44
<dependencies>
55
<dependency>profile-eea.facetednavigation:universal</dependency>
66
</dependencies>

eea/facetednavigation/profiles/plone5/registry.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@
398398
<element>jstree</element>
399399
<element>select2uislider</element>
400400
<element>tagcloud</element>
401+
<element>select2</element>
401402
</value>
402403
<value key="depends">jqueryui</value>
403404
<value key="csscompilation">++plone++static/faceted-navigation-jquery.min.css</value>

eea/facetednavigation/upgrades/configure.zcml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
55
i18n_domain="eea">
66

7+
<genericsetup:upgradeSteps
8+
source="12.0"
9+
destination="14.0"
10+
profile="eea.facetednavigation:default">
11+
12+
<genericsetup:upgradeDepends
13+
title="Import registry to fix jsregistry to include also select2 jQuery plugin"
14+
import_steps="plone.app.registry"
15+
/>
16+
17+
</genericsetup:upgradeSteps>
18+
719
<genericsetup:upgradeSteps
820
source="10.6"
921
destination="12.0"

eea/facetednavigation/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13.8
1+
14.0

eea/facetednavigation/widgets/autocomplete/interfaces.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class IAutocompleteSchema(ISchema):
3838
required=False
3939
)
4040

41+
hidebutton = schema.Bool(
42+
title=_(u"Hide search button"),
43+
description=_("Do not display the search button"),
44+
required=False
45+
)
46+
4147

4248
class DefaultSchemata(DS):
4349
""" Schemata default
@@ -48,7 +54,8 @@ class DefaultSchemata(DS):
4854
u'index',
4955
u'autocomplete_view',
5056
u'onlyallelements',
51-
u'multivalued'
57+
u'multivalued',
58+
u'hidebutton',
5259
)
5360

5461

0 commit comments

Comments
 (0)