aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-03-11 05:00:47 +0100
committermetamuffin <metamuffin@disroot.org>2026-03-11 05:00:47 +0100
commitf13f8b4cda8c64b4676ae564206a597ae8a1444e (patch)
tree502042de20d299c581c87eaf8f652258a98b7f13 /ui
parent89d9e1703b06ad6f84933e1399e70a9d055dfbe8 (diff)
downloadjellything-f13f8b4cda8c64b4676ae564206a597ae8a1444e.tar
jellything-f13f8b4cda8c64b4676ae564206a597ae8a1444e.tar.bz2
jellything-f13f8b4cda8c64b4676ae564206a597ae8a1444e.tar.zst
restore old search ui
Diffstat (limited to 'ui')
-rw-r--r--ui/src/components/mod.rs1
-rw-r--r--ui/src/components/search.rs31
-rw-r--r--ui/src/old/search.rs38
3 files changed, 32 insertions, 38 deletions
diff --git a/ui/src/components/mod.rs b/ui/src/components/mod.rs
index 3dd43a4..0161e7b 100644
--- a/ui/src/components/mod.rs
+++ b/ui/src/components/mod.rs
@@ -15,3 +15,4 @@ pub mod node_page;
pub mod props;
pub mod stats;
pub mod user;
+pub mod search;
diff --git a/ui/src/components/search.rs b/ui/src/components/search.rs
new file mode 100644
index 0000000..3d320cf
--- /dev/null
+++ b/ui/src/components/search.rs
@@ -0,0 +1,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) 2026 metamuffin <metamuffin.org>
+*/
+
+use crate::{RenderInfo, components::node_card::NodeCard, page};
+use jellycommon::{Nku, routes::u_items_cont};
+use jellyui_locale::tr;
+
+page!(Search<'_>, |x| tr(x.ri.lang, "search"));
+
+markup::define! {
+ Search<'a>(ri: &'a RenderInfo<'a>, query: &'a str, items: &'a [Nku<'a>], cont: Option<String>) {
+ .search {
+ h1 { @tr(ri.lang, "search") }
+ form[action="", method="GET"] {
+ input[type="text", name="q", placeholder=tr(ri.lang, "search.placeholder"), value=&query];
+ input[type="submit", value="Search"];
+ }
+ }
+ @if !items.is_empty() {
+ ul.nl.grid { @for nku in *items {
+ li { @NodeCard { ri, nku } }
+ }}
+ @if let Some(cont) = cont {
+ a.next_page[href=u_items_cont(cont)] { button { "Show more" } }
+ }
+ }
+ }
+}
diff --git a/ui/src/old/search.rs b/ui/src/old/search.rs
deleted file mode 100644
index 0eb34b9..0000000
--- a/ui/src/old/search.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- 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) 2026 metamuffin <metamuffin.org>
-*/
-
-use crate::{Page, locale::tr, node_card::NodeCard, scaffold::RenderInfo};
-use markup::DynRender;
-
-impl Page for SearchPage<'_> {
- fn title(&self) -> String {
- tr(self.ri.lang, "search.title").to_string()
- }
- fn class(&self) -> Option<&'static str> {
- Some("search")
- }
- fn to_render(&self) -> DynRender<'_> {
- markup::new!(@self)
- }
-}
-
-markup::define! {
- SearchPage<'a>(ri: &'a RenderInfo<'a>, r: Option<ApiSearchResponse>, query: &'a Option<String>) {
- h1 { @tr(ri.lang, "search.title") }
- form[action="", method="GET"] {
- input[type="text", name="query", placeholder=tr(ri.lang, "search.placeholder"), value=&query];
- input[type="submit", value="Search"];
- }
- @if let Some(r) = &r {
- h2 { @tr(ri.lang, "search.results.title") }
- p.stats { @tr(ri.lang, "search.results.stats").replace("{count}", &r.count.to_string()).replace("{dur}", &format!("{:?}", r.duration)) }
- ul.children {@for nodeu in r.results.iter() {
- li { @NodeCard { ri, nodeu } }
- }}
- // TODO pagination
- }
- }
-}