Aujourd’hui, nous allons voir comment créer un plugin OpenSearch.
Today, we will see how to create a simple OpenSearch plugin.
OpenSearch plugin ?
Un plugin OpenSearch est ce qui est utilisé par votre navigateur pour effectuer une recherche, sans a avoir à se rendre sur la page du site sur lequel on veut effectuer la recherche. Cela consiste en un simple fichier XML
An OpenSearch plugin is what your browser uses to search something on a site without having to open it. It consists on a simple XML file.
Code & comments
<searchplugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
//What appears in the field when empty
//Ce qui apparaît quand le champ est vide
<os:shortname>Pixiv</os:shortname>
//Tooltip (view image below)
//Infobulle (voir l'image ci-dessous)
<os:description>Pixiv Search</os:description>
//Encoding -DUH-
<os:inputencoding>UTF-8</os:inputencoding>
//Image used (here URI encoded)
//Image utilisée (ici encodé en URI)
<os:image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACIElEQVQ4jZWTz0tUURTHT9CuopAW0aJlmxaFmxbRJmjRoj+gCAJbRDHT/HgvKAWDoIUQGEVBIUHEvHnvDjyVJFPTKCOmFIeYyhnKrKlxXvN0HB01jOjT4uI0kwm2OIvLvd8P58M9RySijovheGIq/qsMxxfDOSliOqVVlxEbCcWRc3EkbCOGswZEzYo+JJCogwRiiKHY3dbL4TvPOHr3OfuvD7Kp2UUCln5zPlEPEVMhQYutzS6hrhRPJ3weZQp0JD9y+8UE/VmPrF+hbSjDlouu7qgWIkGLE7Ekk6VFigvLHLw5pFsOWrqjkM2hW0+YXlwmNVVmx6VurbgCuDfyiTfeHP7CMsOT0zr0t+vZGI3XHgPQM15gQ7gGMLP0g52XH5DKlxn9OltPr1YCCVh0v50CYG/7gFYxFXIslkTCNplihZE1AQoJxLjwMA1AkxrRiqZCJGQjhmLcXz/gVGJU/4qpEDHUOgEWvRkPgH21CiuAjF/hZa5UnYVqMOogZ+5zpGMYADed/xOuBaS9OXLlJQ7cGGRzs6uDEYeGlk6CnWP8/AVDH4o0tHQiEWc14HWhzNT8d+JjOfqzHn0Zj8H330gX5kjlywTcMTaaCa1YN0g1CsnPM0ggRkNrF3uu9tHYPsCuKz1aKWjVq1UBUVWRqMO74jyvvpSQcFxPYsTWrhH730G9TBWRcLxpe2u3nysvkfUrbGtx196++vCMRO3TvwGcp3kFcNIIyQAAAABJRU5ErkJggg==</os:image>
//URL to reach when an empty field is submitted
//URL à atteindre quand un champ vide est envoyé
<searchform>http://pixiv.net</searchform>
//URL to which send the request, and which method (POST/GET) to use
//URL à laquelle envoyer la requête, et quelle méthode (POST/GET) utiliser
<os:url type="text/html" method="GET" template="http://www.pixiv.net/member_illust.php">
//Elements of the request
//Eléments de la requête
<os:param name="mode" value="medium">
<os:param name="illust_id" value="{searchTerms}">
</os:param></os:param></os:url>
</searchplugin>
How to distribute ?
Simply add the following line in the header section of your page(s).
<link rel="search" type="application/opensearchdescription+xml" title="searchTitle" href="pluginURL">