feat(core): allow the use of custom search suggestion module

defines the search suggestion ResourceLoader module
used by the skin. It deprecates the  config
This commit is contained in:
alistair3149 2022-12-02 17:59:45 -05:00
parent 57d50ea5c5
commit 391266c0a7
No known key found for this signature in database
4 changed files with 12 additions and 16 deletions

View file

@ -110,7 +110,7 @@ Name | Description | Values | Default
### Search suggestions
Name | Description | Values | Default
:--- | :--- | :--- | :---
`$wgCitizenEnableSearch` | Enable or disable rich search suggestions |`true` - enable; `false` - disable | `true`
`$wgCitizenSearchModule` | Which ResourceLoader module to use for search suggestion (e.g. `mediawiki.searchSuggest`). | string | `skins.citizen.search`
`$wgCitizenSearchGateway` | Which gateway to use for fetching search suggestion |`mwActionApi`; `mwRestApi` | `mwActionApi`
`$wgCitizenSearchDescriptionSource` | Source of description text on search suggestions (only takes effect if `$wgCitizenSearchGateway` is `mwActionApi`) | `wikidata` - Use description provided by [WikibaseLib](Extension:WikibaseLib) or [ShortDescription](https://www.mediawiki.org/wiki/Extension:ShortDescription); `textextracts` - Use description provided by [TextExtracts](https://www.mediawiki.org/wiki/Extension:TextExtracts); `pagedescription` - Use description provided by [Description2](https://www.mediawiki.org/wiki/Extension:Description2) or any other extension that sets the `description` page property | `textextracts`
`$wgCitizenMaxSearchResults` | Max number of search suggestions | Integer > 0 | `6`

View file

@ -44,7 +44,7 @@ class ResourceLoaderHooks {
Config $config
) {
return [
'wgCitizenEnableSearch' => $config->get( 'CitizenEnableSearch' ),
'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' ),
];
}

View file

@ -142,8 +142,8 @@ function bindExpandOnSlash( window, checkbox, input ) {
* @return {void}
*/
function initSearch( window ) {
const
searchConfig = require( './config.json' ).wgCitizenEnableSearch,
const
searchModule = require( './config.json' ).wgCitizenSearchModule,
searchBoxes = document.querySelectorAll( '.citizen-search-box' );
if ( !searchBoxes.length ) {
@ -169,14 +169,10 @@ function initSearch( window ) {
} );
}
if ( searchConfig ) {
setLoadingIndicatorListeners( searchBox, true, renderSearchLoadingIndicator );
loadSearchModule( input, 'skins.citizen.search', () => {
setLoadingIndicatorListeners( searchBox, false, renderSearchLoadingIndicator );
} );
} else {
loadSearchModule( input, 'mediawiki.searchSuggest', () => {} );
}
setLoadingIndicatorListeners( searchBox, true, renderSearchLoadingIndicator );
loadSearchModule( input, searchModule, () => {
setLoadingIndicatorListeners( searchBox, false, renderSearchLoadingIndicator );
} );
} );
}

View file

@ -545,10 +545,10 @@
"descriptionmsg": "citizen-config-manifestbackgroundcolor",
"public": true
},
"EnableSearch": {
"value": true,
"description": "Enable or disable rich search suggestions",
"descriptionmsg": "citizen-config-enablesearch",
"SearchModule": {
"value": "skins.citizen.search",
"description": "Which module to use for search suggestion. Avaliable options: [citizen|mw]",
"descriptionmsg": "citizen-config-searchmodule",
"public": true
},
"SearchGateway": {