mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-27 17:10:19 +00:00
Development: Allow us to test search with different API hosts
By default the API uses location.host as the host, however during development it is useful to test against production wikis For example to test against English Wikipedia: $wgVectorSearchHost = 'en.wikipedia.org'; Note: Links when clicked will not take the user to the target page, and instead will take the user to the search results page with a link to create the page. The following config can be used to workaround that page: $wgDisableTextSearch = true; $wgSearchForwardUrl = "/w/index.php?title=$1"; Change-Id: I5fbac7f54844d7a9d6976007bc0d0ff9938b9f2b
This commit is contained in:
parent
e0c47dc462
commit
dce24c9784
|
@ -35,6 +35,7 @@ class Hooks {
|
|||
Config $config
|
||||
) {
|
||||
return [
|
||||
'wgVectorSearchHost' => $config->get( 'VectorSearchHost' ),
|
||||
'wgVectorUseCoreSearch' => $config->get( 'VectorUseCoreSearch' ),
|
||||
];
|
||||
}
|
||||
|
|
3
resources/mediawiki.d.ts
vendored
3
resources/mediawiki.d.ts
vendored
|
@ -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: {
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue