diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/atward/src/index.html | 1 | ||||
-rw-r--r-- | web/atward/src/main.rs | 11 | ||||
-rw-r--r-- | web/atward/src/opensearch.xml | 8 |
3 files changed, 20 insertions, 0 deletions
diff --git a/web/atward/src/index.html b/web/atward/src/index.html index c9a7c494e97b..286bc6e546ad 100644 --- a/web/atward/src/index.html +++ b/web/atward/src/index.html @@ -4,6 +4,7 @@ <meta name="description" content="The Virus Lounge"> <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="search" type="application/opensearchdescription+xml" title="TVL Search" href="https://at.tvl.fyi/opensearch.xml"> <title>TVL Search</title> <body class="light"> <header> diff --git a/web/atward/src/main.rs b/web/atward/src/main.rs index 44ab4d29c24b..04beb02cd5d6 100644 --- a/web/atward/src/main.rs +++ b/web/atward/src/main.rs @@ -113,6 +113,13 @@ fn dispatch(handlers: &[Handler], query: &Query) -> Option<String> { 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 /// about how to use the service. fn index() -> Response { @@ -133,6 +140,10 @@ fn main() { rouille::start_server(&address, move |request| { rouille::log(&request, std::io::stderr(), || { + if request.url() == "/opensearch.xml" { + return opensearch(); + } + let query = match Query::from_request(&request) { Some(q) => q, None => return index(), diff --git a/web/atward/src/opensearch.xml b/web/atward/src/opensearch.xml new file mode 100644 index 000000000000..6033987f5b4b --- /dev/null +++ b/web/atward/src/opensearch.xml @@ -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> |