Constructor
new WikidataAutocompleteAdapter()
See AbstractAutocompleteAdapter for parameter documentation, not shown here due to jsdoc bug.
Extends
- AbstractAutocompleteAdapter
Members
acDelay :Number
We override the default; Wikidata can take more of a beating than some other sites. :)
Type:
- Number
acPrimaryTextKey :String
We override the default, because we may display different text (stored in this field) than what we pass along to the application (stored in the label field). The display text may include a parenthetical component that highlights a match against an alias, rather than the primary label.
Type:
- String
displayResults :Number
Type:
- Number
- Source:
- See:
excludedItemClasses :Array.<String>
Items with these classes are typically not going to be the target of reviews.
Type:
- Array.<String>
fetchResults :Number
Because we exclude certain item classes (e.g., disambiguation pages), we fetch a larger number of results than we may need, since we may eliminate some of them. The ratio configured here has proven to strike a good balance where few queries result in zero "good" results.
Type:
- Number
nativeToWikidata :Object
How do lib.reviews language code translate to Wikidata language codes? lib.reviews language code are used as keys, Wikidata codes as values.
Since Wikidata supports a superset of languages and most language code are identical, we only enumerate exceptions.
Type:
- Object
queryServiceTimeout :Number
Timeout for query service validation requests in milliseconds
Type:
- Number
Methods
_extractRowHandler(item, queryString) → {Object}
Transform a result from the Wikidata item into a row that can be rendered by the autocomplete widget.
This:
- WikidataAutocompleteAdapter#ac
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Object | a query result returned by the SPARQL query service (member of |
queryString |
String | the original (unescaped) query string is used for highlighting the match in a composite title that includes both the label and the alias against which the query matched |
Returns:
plain object that only contains the data we can use inside the
application, plus a derived title property for rendering this row in
the autocomplete widget.
- Type
- Object
_renderNavHandler(spec)
Render next/previous navigation within the autocomplete widget.
This:
- WikidataAutocompleteAdapter#ac
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
spec |
Object | Navigation settings Properties
|
_requestHandler(query, offsetopt)
Send an autocomplete request to the Wikidata query service and render the result using the autocomplete widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
query |
String | the query string |
|
offset |
Number |
<optional> |
the offset from which to continue a previous query. |
lookup(url) → {Promise}
Look up a single item in Wikidata given its URL. Uses the MediaWiki API.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
String | the URL to look up |
Returns:
resolves to a LookupResult if successful, rejects with error if not.
- Type
- Promise