dce24c9784
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
97 lines
2.4 KiB
Vue
97 lines
2.4 KiB
Vue
<template>
|
|
<div id="p-search">
|
|
<wvui-typeahead-search
|
|
id="searchform"
|
|
ref="searchForm"
|
|
:domain="domain"
|
|
:footer-search-text="$i18n('searchsuggest-containing').escaped()"
|
|
:suggestions-label="$i18n('searchresults').escaped()"
|
|
:accesskey="searchAccessKey"
|
|
:title="searchTitle"
|
|
:placeholder="searchPlaceholder"
|
|
:aria-label="searchPlaceholder"
|
|
:initial-input-value="searchQuery"
|
|
:button-label="$i18n( 'search' ).escaped()"
|
|
:form-action="action"
|
|
:search-language="language"
|
|
:show-thumbnail="showThumbnail"
|
|
:show-description="showDescription"
|
|
>
|
|
<input type="hidden"
|
|
name="title"
|
|
value="Special:Search"
|
|
>
|
|
</wvui-typeahead-search>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
var wvui = require( 'wvui' );
|
|
|
|
module.exports = {
|
|
name: 'App',
|
|
components: wvui,
|
|
mounted: function () {
|
|
// access the element associated with the wvui-typeahead-search component
|
|
// eslint-disable-next-line no-jquery/variable-pattern
|
|
var wvuiSearchForm = this.$refs.searchForm.$el;
|
|
|
|
if ( this.autofocusInput ) {
|
|
// TODO: The wvui-typeahead-search component accepts an id prop but does not
|
|
// display that value as an HTML attribute on the form element.
|
|
wvuiSearchForm.querySelector( 'form' ).setAttribute( 'id', 'searchform' );
|
|
|
|
// TODO: The wvui-typeahead-search component does not accept an autofocus parameter
|
|
// or directive. This can be removed when its does.
|
|
wvuiSearchForm.querySelector( 'input' ).focus();
|
|
}
|
|
},
|
|
computed: {
|
|
language: function () {
|
|
return mw.config.get( 'wgUserLanguage' );
|
|
},
|
|
domain: function () {
|
|
// It might be helpful to allow this to be configurable in future.
|
|
return mw.config.get( 'wgVectorSearchHost', location.host );
|
|
}
|
|
},
|
|
props: {
|
|
autofocusInput: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
action: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
/** The keyboard shortcut to focus search. */
|
|
searchAccessKey: {
|
|
type: String
|
|
},
|
|
/** The access key informational tip for search. */
|
|
searchTitle: {
|
|
type: String
|
|
},
|
|
/** The ghost text shown when no search query is entered. */
|
|
searchPlaceholder: {
|
|
type: String
|
|
},
|
|
/**
|
|
* The search query string taken from the server-side rendered input immediately before
|
|
* client render.
|
|
*/
|
|
searchQuery: {
|
|
type: String
|
|
},
|
|
showThumbnail: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
showDescription: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
}
|
|
};
|
|
</script>
|