From a8c86790fcc696fc4addc83df54339d31eb32431 Mon Sep 17 00:00:00 2001 From: Book-reader Date: Sun, 7 Sep 2025 12:25:01 +1200 Subject: [PATCH] add calculator to nojs (nojs seems to always 504 when I use it, see if I can fix that) --- asklyphe-frontend/src/routes/search.rs | 5 +++++ asklyphe-frontend/templates/search.html | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/asklyphe-frontend/src/routes/search.rs b/asklyphe-frontend/src/routes/search.rs index 4e66275..96d8768 100644 --- a/asklyphe-frontend/src/routes/search.rs +++ b/asklyphe-frontend/src/routes/search.rs @@ -301,6 +301,11 @@ pub async fn search_nojs( if let Some(redirect) = bang_redirect { return Redirect::to(&redirect).into_response(); } + + let mut calc_query = query.clone().to_lowercase(); + calc_query = calc_query.replace("calculate", "").replace("what is", ""); + let math = math::calculate(&calc_query); + complications.math = math; } else { complications.disabled = true; query = query.replace("-complications", ""); diff --git a/asklyphe-frontend/templates/search.html b/asklyphe-frontend/templates/search.html index 12b4a44..ccae647 100644 --- a/asklyphe-frontend/templates/search.html +++ b/asklyphe-frontend/templates/search.html @@ -75,6 +75,13 @@ {% when None %} {% endmatch %} + {% match complications.math %} + {% when Some with (math) %} +
+

{{ math.equation }} = {{ math.result }}

+
+ {% when None %} + {% endmatch %}
    {% for result in search_results %}