Support adding opensearch XML search engine with autodiscovery
So as of today when one needs/wants to add a new search engine, they either need to rely on having it in the default search engines list, or do the thing of manually collecting the URL of a search (i.e. search for foobar in search engine Baz) then changing the queried keywords with %s.
I think it could be easier to have an indication somewhere in the headerbar that allows adding the search engine if one is detected. There is a nice standard, OpenSearch, that allows autodiscovery of search engines and to actually get this search URL automatically without needing to manually do the thing described above.
One possibility would be to add a menu entry to the main menu when a search engine is detected, but then, that's barely discoverable. So maybe a clickable icon in the search bar next to the reader mode and bookmark icons would be discoverable enough? That needs design really though from a proper designer (i.e. not me) :)
So on the technical side of things, adding support for OpenSearch XML files would need those things to be done:
- autodiscovery is done by searching for a
link
tag in the page's HTMLhead
tag, with rel="search" and type="application/opensearchdescription.xml". So basically looking for<link rel="search" type="application/opensearchdescription+xml" title="Example search engine" href="https://www.example.org/opensearch.xml">
in<head></head>
. - the XML file contains some useful informations like an icon, a short name, a description, but for basic support only the short name and the search URL would be needed. So to get the corresponding %s-URL that epiphany uses, it would just need to get the
template
attribute for anUrl
tag with an appropriate type for searching (i.e. (X)HTML), and with method="get", and replace{searchTerms}
with%s
. In practice it's slightly more involved, with rules described here and there.
Further down, the opensearch specification allows providing search suggestions that e.g. DuckDuckGo provides. See https://github.com/dewitt/opensearch/blob/master/mediawiki/Specifications/OpenSearch/Extensions/Suggestions/1.1/Draft%201.wiki for details.
Here's an example opensearch XML file from DuckDuckGo to understand the structure of the file:
<?xml version="1.0" encoding="utf-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>DuckDuckGo</ShortName>
<Description>Search DuckDuckGo</Description>
<InputEncoding>UTF-8</InputEncoding>
<LongName>DuckDuckGo Search</LongName>
<Image height="16" width="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB8lBMVE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WHRkYXRlOm1vZGlmeQAyMDE0LTAxLTE5VDIwOjAxOjExLTA1OjAwX0yGIAAAAABJRU5ErkJggg==</Image>
<Url type="text/html" method="get" template="https://duckduckgo.com/?q={searchTerms}&atb=v267-1__"/>
<Url type="application/x-suggestions+json" template="https://duckduckgo.com/ac/?q={searchTerms}&type=list"/>
</OpenSearchDescription>
Here's a non-exhaustive list of search engines that support OpenSearch XML that I could find quickly: DuckDuckGo, Qwant, Ecosia, Searx, wikipedia, crates.io, Github/Gitlab, etc. The last few ones aren't search engines in the sense of e.g. DuckDuckGo/Qwant, but they still provide search capabilities and as such it's nice to have. I myself have only one "real" search engine, but around 10 other engines that I use with a bang shortcut on a daily basis or with the up/down arrows in the search bar autocomplete popover, with engines like Wikipedia, developer.gnome.org or Internet Archive. Some other popular engines don't seems to have an opensearch XML file, like Google and Bing. I assume they dropped it so people have to install an extension in browsers that doesn't support adding %s-urls like Firefox, which means there's third-party code that runs in the browser. It's especially strange since an opensearch XML file is literally no maintenance, just make one, link it in the HTML head tag and you're done for the foreseeable future. I might be wrong on this but it seems quite unlikely it's because of maintenance burden…