From 99d11bef5fd32aa5dfb3b091fea3e6b15fc6ac26 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 11 May 2021 16:46:01 +0200 Subject: [PATCH] feat(atward): Add an index page with setup instructions Adds an index page that is rendered when there is no query parameter in the URL. This means that going to at.tvl.fyi / atward.tvl.fyi yields an actually useful page. Change-Id: I018973a3c3e8b7b7167876fa99f34a008a17a4f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3104 Tested-by: BuildkiteCI Reviewed-by: flokli --- web/atward/src/index.html | 75 +++++++++++++++++++++++++++++++++++++++ web/atward/src/main.rs | 10 +++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 web/atward/src/index.html diff --git a/web/atward/src/index.html b/web/atward/src/index.html new file mode 100644 index 000000000..c9a7c494e --- /dev/null +++ b/web/atward/src/index.html @@ -0,0 +1,75 @@ + + + + + + +TVL Search + +
+

atward

+
+
+ +

+ atward is TVL's search + service. It can be configured as a browser search engine for easy + access to TVL bugs, code reviews, code paths and more. +

+ +

Setting up atward

+

+ To configure atward, add a search engine to your browser with the + following search string: +

  https://at.tvl.fyi/?q=%s
+ Consider setting a shortcut, for example t or tvl. + You can now quickly access TVL resources by typing something + like t b/42 in your URL bar to get to the bug with ID + 42. +

+ +

Supported queries

+

+ The following query types are supported in atward: +

+

+ +

Configuration

+

+ Some behaviour of atward can be configured by adding query + parameters to the search string: +

+

+

+ In Firefox, configuring query parameters is difficult as + users can not edit search engines directly. There are browser + extensions and other workarounds for this issue, but we do not + recommend any particular one. +

+ +

Source code

+

+ atward's source code lives + at //web/atward. +

+ +
+ + diff --git a/web/atward/src/main.rs b/web/atward/src/main.rs index 49e23dde7..44ab4d29c 100644 --- a/web/atward/src/main.rs +++ b/web/atward/src/main.rs @@ -113,6 +113,14 @@ fn dispatch(handlers: &[Handler], query: &Query) -> Option { None } +/// Render the atward index page which gives users some information +/// about how to use the service. +fn index() -> Response { + Response::html(include_str!("index.html")) +} + +/// Render the fallback page which informs users that their query is +/// unsupported. fn fallback() -> Response { Response::text("error for emphasis that i am angery and the query whimchst i angery atward") .with_status_code(404) @@ -127,7 +135,7 @@ fn main() { rouille::log(&request, std::io::stderr(), || { let query = match Query::from_request(&request) { Some(q) => q, - None => return fallback(), + None => return index(), }; match dispatch(&queries, &query) {