add calculator to nojs (nojs seems to always 504 when I use it, see if I can fix that)

This commit is contained in:
Book-reader 2025-09-07 12:25:01 +12:00
parent f955d63937
commit a8c86790fc
2 changed files with 12 additions and 0 deletions

View file

@ -301,6 +301,11 @@ pub async fn search_nojs(
if let Some(redirect) = bang_redirect { if let Some(redirect) = bang_redirect {
return Redirect::to(&redirect).into_response(); 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 { } else {
complications.disabled = true; complications.disabled = true;
query = query.replace("-complications", ""); query = query.replace("-complications", "");

View file

@ -75,6 +75,13 @@
</div> </div>
{% when None %} {% when None %}
{% endmatch %} {% endmatch %}
{% match complications.math %}
{% when Some with (math) %}
<div class="calculator-complication">
<h1>{{ math.equation }} = {{ math.result }}</h1>
</div>
{% when None %}
{% endmatch %}
</div> </div>
<ol class="search-result-list"> <ol class="search-result-list">
{% for result in search_results %} {% for result in search_results %}