Gadgets can change the search API

```
mw.config.set('wgVectorSearchClient', {

   fetchByTitle: function( query, domain, limit ) {
      var xhr = fetch('http://' + domain + '/w/rest.php/v1/search/title?q=banana')
      .then(function (resp) {
          return resp.json();
      }).then(function (json) {
         return {
             results: json.pages
         }
      });
      return {
         fetch: xhr,
         abort: function() {}
      }
   }
})
```

This should be the absolute minimum to allow API clients to configure
the search. This should be considered an interim solution to buy us time to work out a more
elegant way to do this e.g. do this in the API itself…

Bug: T262566
Change-Id: Iac6f2551bed911980064dcb023193f800df0934f
This commit is contained in:
jdlrobson 2020-12-22 12:08:47 -08:00 committed by VolkerE
parent 48edb06b66
commit 289f1d48f5
1 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@
<wvui-typeahead-search
id="searchform"
ref="searchForm"
:client="getClient"
:domain="domain"
:footer-search-text="$i18n('searchsuggest-containing').escaped()"
:suggestions-label="$i18n('searchresults').escaped()"
@ -56,6 +57,14 @@ module.exports = {
}
},
computed: {
/**
* Allow wikis eg. Hebrew Wikipedia to replace the default search API client
*
* @return {void|Object}
*/
getClient: function () {
return mw.config.get( 'wgVectorSearchClient', undefined );
},
language: function () {
return mw.config.get( 'wgUserLanguage' );
},