You see… step 4 sucks. I would like to use the fancy “new” chrome search… where I type “yo” to get “youtube.com”, press Tab to switch to the youtube search and can immediately search.
Chrome will just activate tab-to-search for sites visited without a path. So doc.rust-lang.org/std won’t work. And since every crate has it’s own search index, it doesn’t make sense to add the search to doc.rust-lang.org directly. Would it be possible to create a new sub domain like std.rust-lang.org? I guess that would be nice to have for some other reasons too.
The opensearch specification seems just to allow absolute URLs (including the server!). Rustdoc is just creates static html files… That would be a problem. Chrome has no problem with relative path’s though… Haven’t tested for Firefox.
The actual search is performed locally via JS. So it still takes a few hundred ms on my machine to load and render the page and finally preparing and executing the search with JS. Again: A consequence of static html files and I understand that generating static html is not bad. Nevertheless: Maybe there is a better way to do that… we could add an option to rustdoc to specify a non local search provider… Something like that. Would be great for the official documentation at least. The search-index.js for the official documentation is 1MB already…
I know that you all have probably more important things to do right now, but still: Any ideas/comments?
You can right click the search field and “Add a keyword for this search” (Firefox) or “Add as search engine” (Chrome). I’ve set the keyword to rs, so I can type e.g. rs iterator, <enter> to quickly get to the search results page.
Even though the search happens client side, the URLs are of the form http://doc.rust-lang.org/std/?search=foo as if the server handled the search. The returned HTML is the same, and you’ll see the main page briefly appear before the JS parses the query string and runs the search.
I didn’t knew the “keyword” feature of Chrome, thanks for that. But I think most users don’t know about it and don’t want to manually set the search engine.
Sure, there is a query URL for that. I still don’t like the “brief” moment before the search results appear. But as already said: Not really possible with static HTML.
Since this is real low priority, I will just look if I can add a small “button” that will trigger a JS function trying to add the search provider to the browser. I think this should be possible somehow.