feat(atward): Serve OpenSearch XML file to support Firefox
Firefox users can not easily add search engines to the browser unless the page serves an OpenSearch description. This CL adds said description according to the documentation: https://developer.mozilla.org/en-US/docs/Web/OpenSearch Change-Id: I358c5940304f4abd9e45dd72a64e46d3ce44b3e3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3105 Tested-by: BuildkiteCI Reviewed-by: cynthia <cynthia@tvl.fyi>
This commit is contained in:
parent
99d11bef5f
commit
cb497a0cca
3 changed files with 20 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
<meta name="description" content="The Virus Lounge">
|
<meta name="description" content="The Virus Lounge">
|
||||||
<link rel="stylesheet" type="text/css" href="https://tvl.fyi/static/tazjin.css" media="all">
|
<link rel="stylesheet" type="text/css" href="https://tvl.fyi/static/tazjin.css" media="all">
|
||||||
<link rel="icon" type="image/webp" href="https://tvl.fyi/static/favicon.webp">
|
<link rel="icon" type="image/webp" href="https://tvl.fyi/static/favicon.webp">
|
||||||
|
<link rel="search" type="application/opensearchdescription+xml" title="TVL Search" href="https://at.tvl.fyi/opensearch.xml">
|
||||||
<title>TVL Search</title>
|
<title>TVL Search</title>
|
||||||
<body class="light">
|
<body class="light">
|
||||||
<header>
|
<header>
|
||||||
|
|
|
@ -113,6 +113,13 @@ fn dispatch(handlers: &[Handler], query: &Query) -> Option<String> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the opensearch.xml file which is required for adding atward
|
||||||
|
/// as a search engine in Firefox.
|
||||||
|
fn opensearch() -> Response {
|
||||||
|
Response::text(include_str!("opensearch.xml"))
|
||||||
|
.with_unique_header("Content-Type", "application/opensearchdescription+xml")
|
||||||
|
}
|
||||||
|
|
||||||
/// Render the atward index page which gives users some information
|
/// Render the atward index page which gives users some information
|
||||||
/// about how to use the service.
|
/// about how to use the service.
|
||||||
fn index() -> Response {
|
fn index() -> Response {
|
||||||
|
@ -133,6 +140,10 @@ fn main() {
|
||||||
|
|
||||||
rouille::start_server(&address, move |request| {
|
rouille::start_server(&address, move |request| {
|
||||||
rouille::log(&request, std::io::stderr(), || {
|
rouille::log(&request, std::io::stderr(), || {
|
||||||
|
if request.url() == "/opensearch.xml" {
|
||||||
|
return opensearch();
|
||||||
|
}
|
||||||
|
|
||||||
let query = match Query::from_request(&request) {
|
let query = match Query::from_request(&request) {
|
||||||
Some(q) => q,
|
Some(q) => q,
|
||||||
None => return index(),
|
None => return index(),
|
||||||
|
|
8
web/atward/src/opensearch.xml
Normal file
8
web/atward/src/opensearch.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<ShortName>TVL</ShortName>
|
||||||
|
<Description>The Virus Lounge Search</Description>
|
||||||
|
<InputEncoding>UTF-8</InputEncoding>
|
||||||
|
<Url type="text/html" template="https://at.tvl.fyi/">
|
||||||
|
<Param name="q" value="{searchTerms}"/>
|
||||||
|
</Url>
|
||||||
|
</OpenSearchDescription>
|
Loading…
Reference in a new issue