From 5d5ba7f5e442dd088676816f45aeb979adfee993 Mon Sep 17 00:00:00 2001 From: Franciszek Stachura Date: Tue, 11 Mar 2025 13:57:18 +0100 Subject: [PATCH 1/3] opensearch: Add opensearch manifest OpenSearch is a standard that allows browsers to discover search engines. A special XML file with information about the search engine is linked from its webpage in a link tag. OpenSearch is supported by Firefox and (maybe) macOS Safari. It used to be supported by Chromium-based browsers, but that feature was deprecated. https://stackoverflow.com/questions/56400952/does-chrome-allow-auto-discovery-of-opensearch MDN Docs: https://developer.mozilla.org/en-US/docs/Web/XML/Guides/OpenSearch OpenSearch specification: https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md --- docker/000-default.conf | 3 +++ static/search.xml | 8 ++++++++ templates/layout.html | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 static/search.xml diff --git a/docker/000-default.conf b/docker/000-default.conf index a94ae180..7dabe672 100644 --- a/docker/000-default.conf +++ b/docker/000-default.conf @@ -8,6 +8,9 @@ AllowOverride None Require all granted + + ForceType "application/opensearchdescription+xml; charset=utf-8" + ServerName MY_LOCAL_IP diff --git a/static/search.xml b/static/search.xml new file mode 100644 index 00000000..47815df3 --- /dev/null +++ b/static/search.xml @@ -0,0 +1,8 @@ + + + Elixir (Linux) + Elixir Cross Referencer - Linux + UTF-8 + https://elixir.bootlin.com/favicon.ico + + diff --git a/templates/layout.html b/templates/layout.html index 92a16539..0e32391b 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -15,6 +15,8 @@ Elixir Cross Referencer - Explore source code in your browser - Particularly useful for the Linux kernel and other low-level projects in C/C++ (bootloaders, C libraries...) {%- endblock %}"> + + From 289d7bb654c481dea07cef814f583e470ace559e Mon Sep 17 00:00:00 2001 From: Franciszek Stachura Date: Tue, 11 Mar 2025 14:01:47 +0100 Subject: [PATCH 2/3] opensearch: autocomplete: Add opensearch compatibility Add a parameter to autocomplete that enables opensearch-compatible response format. OpenSearch suggestions extension: https://github.com/dewitt/opensearch/blob/master/mediawiki/Specifications/OpenSearch/Extensions/Suggestions/1.1/Draft%201.wiki --- elixir/autocomplete.py | 7 ++++++- static/search.xml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/elixir/autocomplete.py b/elixir/autocomplete.py index 023eb37f..7407aad0 100755 --- a/elixir/autocomplete.py +++ b/elixir/autocomplete.py @@ -33,6 +33,7 @@ def on_get(self, req, resp): ident_prefix = req.get_param('q') family = req.get_param('f') project = req.get_param('p') + opensearch_mode = req.get_param('opensearch') == 'true' ident_prefix = validate_ident(ident_prefix) if ident_prefix is None: @@ -82,7 +83,11 @@ def on_get(self, req, resp): resp.status = falcon.HTTP_200 resp.content_type = falcon.MEDIA_JSON - resp.media = response + + if not opensearch_mode: + resp.media = response + else: + resp.media = [ident_prefix, response] query.close() diff --git a/static/search.xml b/static/search.xml index 47815df3..1597fa05 100644 --- a/static/search.xml +++ b/static/search.xml @@ -5,4 +5,5 @@ UTF-8 https://elixir.bootlin.com/favicon.ico + From 0a5791c7a2640066b1faf319f8dab00e2bd995b5 Mon Sep 17 00:00:00 2001 From: Franciszek Stachura Date: Thu, 24 Apr 2025 22:58:58 +0200 Subject: [PATCH 3/3] opensearch: Add automatic manifest updates https://developer.mozilla.org/en-US/docs/Web/XML/Guides/OpenSearch#supporting_automatic_updates_for_opensearch_description --- static/search.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/static/search.xml b/static/search.xml index 1597fa05..46de91db 100644 --- a/static/search.xml +++ b/static/search.xml @@ -6,4 +6,5 @@ https://elixir.bootlin.com/favicon.ico +