diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-27 14:40:15 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-27 14:40:15 +0100 |
| commit | c05bfcc2775f0e11db6e856bfcf06d0419c35d54 (patch) | |
| tree | ffd0e9fcf6b476a6198287085a514cfa7940c200 /server/src/ui/home.rs | |
| parent | 4ba86694e393c61107e27c4127efc0455b329524 (diff) | |
| download | jellything-c05bfcc2775f0e11db6e856bfcf06d0419c35d54.tar jellything-c05bfcc2775f0e11db6e856bfcf06d0419c35d54.tar.bz2 jellything-c05bfcc2775f0e11db6e856bfcf06d0419c35d54.tar.zst | |
ui changed before object slices
Diffstat (limited to 'server/src/ui/home.rs')
| -rw-r--r-- | server/src/ui/home.rs | 97 |
1 files changed, 35 insertions, 62 deletions
diff --git a/server/src/ui/home.rs b/server/src/ui/home.rs index 1a7da36..6cb6a77 100644 --- a/server/src/ui/home.rs +++ b/server/src/ui/home.rs @@ -4,77 +4,50 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use std::str::FromStr; - use super::error::MyResult; -use crate::{request_info::RequestInfo, ui_responder::UiResponse}; +use crate::request_info::RequestInfo; use anyhow::{Context, Result}; -use jellycommon::{ - jellyobject::{Object, ObjectBuffer, ObjectBufferBuilder}, - *, -}; +use jellycommon::jellyobject::{Object, ObjectBuffer}; use jellydb::Query; -use jellyui::tr; -use rocket::get; +use jellyui::components::home::HomeRow; +use rocket::{get, response::content::RawHtml}; +use std::str::FromStr; #[get("/home")] -pub fn r_home(ri: RequestInfo<'_>) -> MyResult<UiResponse> { +pub fn r_home(ri: RequestInfo<'_>) -> MyResult<RawHtml<String>> { ri.require_user()?; - let mut page = ObjectBufferBuilder::default(); - - page.push(VIEW_TITLE, &&*tr(ri.lang, "home")); - - page.push( - VIEW_NODE_LIST, - home_row( - &ri, - "home.bin.latest_video", - "FILTER (visi = visi AND kind = vide) SORT DESCENDING BY FIRST rldt", - )? - .as_object(), - ); - page.push( - VIEW_NODE_LIST, - home_row( - &ri, - "home.bin.latest_music", - "FILTER (visi = visi AND kind = musi) SORT DESCENDING BY FIRST rldt", - )? - .as_object(), - ); - page.push( - VIEW_NODE_LIST, - home_row_highlight( - &ri, - "home.bin.daily_random", - "FILTER (visi = visi AND kind = movi) SORT RANDOM", - )? - .as_object(), - ); - page.push( - VIEW_NODE_LIST, - home_row( - &ri, - "home.bin.max_rating", - "SORT DESCENDING BY FIRST rtng.imdb", - )? - .as_object(), - ); - page.push( - VIEW_NODE_LIST, - home_row_highlight( - &ri, - "home.bin.daily_random", - "FILTER (visi = visi AND kind = show) SORT RANDOM", - )? - .as_object(), - ); + let mut rows = Vec::new(); + rows.push(home_row( + &ri, + "home.bin.latest_video", + "FILTER (visi = visi AND kind = vide) SORT DESCENDING BY FIRST rldt", + )?); + rows.push(home_row( + &ri, + "home.bin.latest_music", + "FILTER (visi = visi AND kind = musi) SORT DESCENDING BY FIRST rldt", + )?); + rows.push(home_row_highlight( + &ri, + "home.bin.daily_random", + "FILTER (visi = visi AND kind = movi) SORT RANDOM", + )?); + rows.push(home_row( + &ri, + "home.bin.max_rating", + "SORT DESCENDING BY FIRST rtng.imdb", + )?); + rows.push(home_row_highlight( + &ri, + "home.bin.daily_random", + "FILTER (visi = visi AND kind = show) SORT RANDOM", + )?); - Ok(ri.respond_ui(page)) + Ok(ri.respond_ui(rows)) } -fn home_row(ri: &RequestInfo<'_>, title: &str, query: &str) -> Result<ObjectBuffer> { +fn home_row(ri: &RequestInfo<'_>, title: &str, query: &str) -> Result<HomeRow> { let q = Query::from_str(query).context("parse query")?; let mut res = ObjectBuffer::empty(); ri.state.database.transaction(&mut |txn| { @@ -96,7 +69,7 @@ fn home_row(ri: &RequestInfo<'_>, title: &str, query: &str) -> Result<ObjectBuff Ok(res) } -fn home_row_highlight(ri: &RequestInfo<'_>, title: &str, query: &str) -> Result<ObjectBuffer> { +fn home_row_highlight(ri: &RequestInfo<'_>, title: &str, query: &str) -> Result<HomeRow> { let q = Query::from_str(query).context("parse query")?; let mut res = ObjectBuffer::empty(); ri.state.database.transaction(&mut |txn| { |