Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f41e316

Browse files
committedMar 12, 2025
opensearch: autocomplete: Add opensearch compatibility
OpenSearch suggestions extension: https://github.com/dewitt/opensearch/blob/master/mediawiki/Specifications/OpenSearch/Extensions/Suggestions/1.1/Draft%201.wiki
1 parent 68a4e76 commit f41e316

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎elixir/autocomplete.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def on_get(self, req, resp):
3333
ident_prefix = req.get_param('q')
3434
family = req.get_param('f')
3535
project = req.get_param('p')
36+
opensearch_mode = req.get_param('opensearch') == 'true'
3637

3738
ident_prefix = validate_ident(ident_prefix)
3839
if ident_prefix is None:
@@ -82,7 +83,11 @@ def on_get(self, req, resp):
8283

8384
resp.status = falcon.HTTP_200
8485
resp.content_type = falcon.MEDIA_JSON
85-
resp.media = response
86+
87+
if not opensearch_mode:
88+
resp.media = response
89+
else:
90+
resp.media = [ident_prefix, response]
8691

8792
query.close()
8893

‎static/search.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
<InputEncoding>UTF-8</InputEncoding>
66
<Image width="16" height="16" type="image/x-icon">https://elixir.bootlin.com/static/favicon.ico</Image>
77
<Url rel="results" type="text/html" template="https://elixir.bootlin.com/linux/latest/A/ident/{searchTerms}"/>
8+
<Url rel="suggestions" type="application/x-suggestions+json" template="https://elixir.bootlin.com/acp?q={searchTerms}&amp;f=A&amp;p=linux&amp;opensearch=true"/>
89
</OpenSearchDescription>

0 commit comments

Comments
 (0)
Please sign in to comment.