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
linktag in the page's HTML
headtag, 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
- 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
templateattribute for an
Urltag with an appropriate type for searching (i.e. (X)HTML), and with method="get", and replace
%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:
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…