How to implement chromium openSearch? - html

I'm trying to implement the Tab To Search on my website URL by using opensearch. I followed the steps in openSearch Documentation but still didn't work for me. please help me in figuring out what I'm missing.
My XML file:
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>localhost</ShortName>
<Description>Search localhost</Description>
<Url type="text/html" method="get" template="localhost:8080/?query={searchTerms}"/>
</OpenSearchDescription>
And my Head tag in the index.html file is:
<!doctype html>
<html>
<head>
<link rel="search"
type="application/opensearchdescription+xml"
title="Google IFL"
href="tabToSearch.xml">
</head>
Result: Whenever i press the Tab button it jumps to the next url enter image description here

The structure is correct, the issue is that you forgot to add an http protocol in template.
Without the protocol, it won't be added to chrome.
- <Url type="text/html" method="get" template="localhost:8080/?query={searchTerms}"/>
+ <Url type="text/html" method="get" template="http://localhost:8080/?query={searchTerms}"/>
Once you do this, you will be able to see it in Chrome custom search engine settings.
However, it will work when you try to search localhost but not localhost:8080. It will still use the good port in search. This is because the search keyword will not have the port.

Related

Does Chrome allow auto discovery of OpenSearch?

Our company has an internal website that I am trying to add Chrome Omnibox support for via OpenSearch. The site is built with ASP.NET MVC 5.
I have added the following line to the <head> tag of my layout page:
<link rel="search" type="application/opensearchdescription+xml" title="ABC" href="/abcopensearch.xml" />
Here is my xml document which lives at the root level and is named abcopensearch.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns:moz="http://www.mozilla.org/2006/browser/search/" xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>ABC</ShortName>
<Description>Find all your assets</Description>
<Url type="text/html" method="get" template="https://www.abcstaff.com/Abc?q={searchTerms}"/>
<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>
What am I missing? Did Chrome remove the ability to automatically add search engines? I've restarted Chrome several times.

How to show OpenSearch suggestions in Safari?

We have a intranet website to search customer details. This website is attempting to implement OpenSearch with the suggestions extension as documented at http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.1#Declaring_a_JSON-formatted_search_suggestion_URL.
In /index.html:
<link rel="search" type="application/opensearchdescription+xml" title="XXX" href="/opensearch.xml" />
In /opensearch.xml:
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>XXX</ShortName>
<Description>XXX</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">
https://XXX/favicon.ico
</Image>
<Url rel="results" type="text/html" method="get" template="https://XXX/search.php?q={searchTerms}"/>
<Url rel="suggestions" type="application/x-suggestions+json" method="get" template="https://XXX/opensearch-suggestions.php?q={searchTerms}"/>
</OpenSearchDescription>
Then opensearch-suggestions.php returns a static response:
["a#b.c",["a#b.c"],["XXX"],["XXX.php?email=a#b.c"]]
We can successfully get Safari to send the search to the desired page. However, while typing the suggestions are from DuckDuckGo and not our search engine.
Test case:
Use macOS + Safari
Command-N (new window, focuses URL bar)
Type our intranet URL (the URL bar shows "Top Hit: (THE URL)")
Press TAB (the URL bar changes to "Search (THE URL)")
Type a search term like aaa
Expected result:
XXX is the autocomplete suggestion (see opensearch-suggestions.php above)
Actual result:
The URL bar shows "DuckDuckGo Suggestions" and some suggestions from DDG.
Have we implemented this incorrectly? Is there an incompatibility that will prevent us from implementing this standard?
The reason why this didn't work was because Safari does not send cookies in the OpenSearch suggestions request.
This behavior is not defined in the OpenSearch specification and I don't see any documentation in Safari either.

How does Google Chrome automatically add search URI's to its ‘Other search engines’? [duplicate]

When I enter some of URLs in Google Chrome omnibox, I see message in it "Press TAB to search in $URL". For example, there are some russian sites habrahabr.ru or yandex.ru. When you press TAB you'll be able to search in that site, not in your search engine.
How to make my site to be able for it? Maybe, I need to write some special code in my site pages?
Chrome usually handles this through user preferences. (via chrome://settings/searchEngines)
However, if you'd like to implement this specifically for your users, you need to add a OSD (Open Search Description) to your site.
Making usage of Google Chrome's OmniBox [TAB] Feature for/on personal website?
You then add this XML file to the root of your site, and link to it in your <head> tag:
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />
Now, visitors to your page will automatically have your site's search information placed into Chrome's internal settings at chrome://settings/searchEngines.
OpenSearchDescription XML Format Example
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Your website name (shorter = better)</ShortName>
<Description>
Description about your website search here
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">your site favicon</Image>
<Url type="text/html" method="get" template="http://www.yoursite.com/search/?query={searchTerms}"/>
</OpenSearchDescription>
The important part is the <url> item. {searchTerms} will be replaced with what the user searches for in the omnibar.
Here's a link to OpenSearch for more information.
Implementing omnibox support with search suggestions
The answer given by #element119 works perfect but here is a slightly tweaked code to support search suggestions as well as Mozilla Support.
Follow the steps below to implement omni box support for your site.
Save the following code as search.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<script/>
<ShortName>Site Name</ShortName>
<Description>Site Description (eg: Search sitename)</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">Favicon url</Image>
<Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&q={searchTerms}" />
<Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
<SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
Upload search.xml to the root of your site.
Add the following meta tag to your site's <head> tag
<link rel="search" href="http://www.yoursite.com/search.xml" type="application/opensearchdescription+xml" title="You site name"/>
Make sure to replace the domain urls with your domain.

How to mark a search box for chrome to detect and install in its "Other search engines"?

When I start typing in chrome the names of the following sites:
Amazon
Newegg
Imdb
Quora
many others...
I can hit "tab" and chrome lets me search with that site's specific search engine. What kind of HTML` do I add to a <form> to help chrome automatically detect a search box in a site I made? Can I control the keyword chosen?
I found this chrome doc talking about the feature from the user POV but not from the webmaster's. They call it "Search a specific site (tab to search)". Btw, google maps used to have this feature but recently it's died for some reason.
I finally found an explanation about chromium at http://www.chromium.org/tab-to-search
Basically you need to link to an OpenSearch description document.
<head>
<link type="application/opensearchdescription+xml" rel="search" href="url_of_osdd_file"/>
</head>
And this is the osdd file:
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Search My Site</ShortName>
<Description>Search My Site</Description>
<Url type="text/html" method="get" template="http://my_site/{searchTerms}"/>
</OpenSearchDescription>

How to add google chrome omnibox-search support for your site?

When I enter some of URLs in Google Chrome omnibox, I see message in it "Press TAB to search in $URL". For example, there are some russian sites habrahabr.ru or yandex.ru. When you press TAB you'll be able to search in that site, not in your search engine.
How to make my site to be able for it? Maybe, I need to write some special code in my site pages?
Chrome usually handles this through user preferences. (via chrome://settings/searchEngines)
However, if you'd like to implement this specifically for your users, you need to add a OSD (Open Search Description) to your site.
Making usage of Google Chrome's OmniBox [TAB] Feature for/on personal website?
You then add this XML file to the root of your site, and link to it in your <head> tag:
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />
Now, visitors to your page will automatically have your site's search information placed into Chrome's internal settings at chrome://settings/searchEngines.
OpenSearchDescription XML Format Example
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Your website name (shorter = better)</ShortName>
<Description>
Description about your website search here
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">your site favicon</Image>
<Url type="text/html" method="get" template="http://www.yoursite.com/search/?query={searchTerms}"/>
</OpenSearchDescription>
The important part is the <url> item. {searchTerms} will be replaced with what the user searches for in the omnibar.
Here's a link to OpenSearch for more information.
Implementing omnibox support with search suggestions
The answer given by #element119 works perfect but here is a slightly tweaked code to support search suggestions as well as Mozilla Support.
Follow the steps below to implement omni box support for your site.
Save the following code as search.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<script/>
<ShortName>Site Name</ShortName>
<Description>Site Description (eg: Search sitename)</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">Favicon url</Image>
<Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&q={searchTerms}" />
<Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
<SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
Upload search.xml to the root of your site.
Add the following meta tag to your site's <head> tag
<link rel="search" href="http://www.yoursite.com/search.xml" type="application/opensearchdescription+xml" title="You site name"/>
Make sure to replace the domain urls with your domain.