Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add opensearch manifest for elixir.bootlin.com #401

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/000-default.conf
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@
<Directory /usr/local/elixir/static/>
AllowOverride None
Require all granted
<Files search.xml>
ForceType "application/opensearchdescription+xml; charset=utf-8"
</Files>
</Directory>
<VirtualHost *:80>
ServerName MY_LOCAL_IP
7 changes: 6 additions & 1 deletion elixir/autocomplete.py
Original file line number Diff line number Diff line change
@@ -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()

9 changes: 9 additions & 0 deletions static/search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Elixir (Linux)</ShortName>
<Description>Elixir Cross Referencer - Linux</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">https://elixir.bootlin.com/static/favicon.ico</Image>
<Url rel="results" type="text/html" template="https://elixir.bootlin.com/linux/latest/A/ident/{searchTerms}"/>
<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"/>
</OpenSearchDescription>
2 changes: 2 additions & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
@@ -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 %}">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
<link rel="search" type="application/opensearchdescription+xml" title="Elixir" href="/static/search.xml" />

<link rel="stylesheet" href="/static/style.css?v=15">

<link rel="preload" href="/static/img/2penguins.svg" as="image" />