aboutsummaryrefslogtreecommitdiff
path: root/ui/src/search.rs
blob: 092ad57b7aa6c7ece63e5ecae9ef247a4b7f4491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2025 metamuffin <metamuffin.org>
*/

markup::define! {
    SearchPage {
        h1 { @trs(&lang, "search.title") }
        form[action="", method="GET"] {
            input[type="text", name="query", placeholder=&*tr(lang, "search.placeholder"), value=&query];
            input[type="submit", value="Search"];
        }
        @if let Some((count, results, search_dur)) = &results {
            h2 { @trs(&lang, "search.results.title") }
            p.stats { @tr(lang, "search.results.stats").replace("{count}", &count.to_string()).replace("{dur}", &format!("{search_dur:?}")) }
            ul.children {@for (node, udata) in results.iter() {
                li { @NodeCard { node, udata, lang: &lang } }
            }}
            // TODO pagination
        }
    }
}

pub fn search_page() {
    LayoutPage {
        title: tr(lang, "search.title").to_string(),
        class: Some("search"),
        content: SearchPage,
    }
}