diff --git a/includes/Hooks.php b/includes/Hooks.php index ccbecf76..5bc237e9 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -35,6 +35,7 @@ class Hooks { Config $config ) { return [ + 'wgVectorSearchHost' => $config->get( 'VectorSearchHost' ), 'wgVectorUseCoreSearch' => $config->get( 'VectorUseCoreSearch' ), ]; } diff --git a/resources/mediawiki.d.ts b/resources/mediawiki.d.ts index ff255833..6d5ad08d 100644 --- a/resources/mediawiki.d.ts +++ b/resources/mediawiki.d.ts @@ -36,7 +36,8 @@ interface MediaWiki { }; Api: MwApiConstructor; config: { - get( configKey: string|null ): string; + get( configKey: string|null, fallback?: any|null ): string; + set( configKey: string|null, value: any|null ): void; }, loader: { /** diff --git a/resources/skins.vector.js/searchLoader.js b/resources/skins.vector.js/searchLoader.js index 372a286f..eb52e491 100644 --- a/resources/skins.vector.js/searchLoader.js +++ b/resources/skins.vector.js/searchLoader.js @@ -132,6 +132,11 @@ function initSearchLoader( document ) { var searchForm = document.getElementById( SEARCH_FORM_ID ), searchInput = document.getElementById( SEARCH_INPUT_ID ); + // Allow developers to defined $wgVectorSearchHost in LocalSettings to target different APIs + if ( config.wgVectorSearchHost ) { + mw.config.set( 'wgVectorSearchHost', config.wgVectorSearchHost ); + } + if ( !searchForm || !searchInput ) { return; } diff --git a/resources/skins.vector.search/App.vue b/resources/skins.vector.search/App.vue index 2913e14d..e87716a3 100644 --- a/resources/skins.vector.search/App.vue +++ b/resources/skins.vector.search/App.vue @@ -52,7 +52,7 @@ module.exports = { }, domain: function () { // It might be helpful to allow this to be configurable in future. - return location.host; + return mw.config.get( 'wgVectorSearchHost', location.host ); } }, props: { diff --git a/skin.json b/skin.json index 7564c131..9b55fa90 100644 --- a/skin.json +++ b/skin.json @@ -173,6 +173,10 @@ } }, "config": { + "VectorSearchHost": { + "value": "", + "description": "Override default search API. Can be used with $wgDisableTextSearch and $wgSearchForwardUrl to mimic user experience on production." + }, "VectorUseIconWatch": { "value": true },