diff options
Diffstat (limited to 'server/src/routes/ui/home.rs')
-rw-r--r-- | server/src/routes/ui/home.rs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs index ebed647..6c6fdbc 100644 --- a/server/src/routes/ui/home.rs +++ b/server/src/routes/ui/home.rs @@ -3,14 +3,19 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ -use super::{account::session::Session, layout::LayoutPage, node::NodeCard}; +use super::{ + account::session::Session, + layout::LayoutPage, + node::{DatabaseNodeUserDataExt, NodeCard}, +}; use crate::{ database::Database, routes::ui::{error::MyResult, layout::DynLayoutPage}, }; +use anyhow::Context; use chrono::{Datelike, Utc}; use jellybase::CONF; -use jellycommon::{user::WatchedState, Rating}; +use jellycommon::{user::WatchedState, NodeID, Rating}; use rocket::{get, State}; use tokio::fs::read_to_string; @@ -21,14 +26,12 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> { .flat_map(|i| Some(items[cheap_daily_random(i).checked_rem(items.len())?].clone())) .collect::<Vec<_>>(); - // let toplevel = T_NODE - // .get(db, "library")? - // .context("root node missing")? - // .into_iter() - // .map(|n| db.get_node_with_userdata(&n, &sess)) - // .collect::<anyhow::Result<Vec<_>>>()? - // .into_iter() - // .collect::<Vec<_>>(); + let toplevel = db + .get_node_children(NodeID::from_slug("library")) + .context("root node missing")? + .into_iter() + .map(|n| db.get_node_with_userdata(n, &sess)) + .collect::<anyhow::Result<Vec<_>>>()?; items.sort_by_key(|(n, _)| { n.ratings @@ -68,9 +71,9 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> { title: "Home".to_string(), content: markup::new! { h2 { "Explore " @CONF.brand } - // ul.children.hlist {@for (id, node, udata) in &toplevel { - // li { @NodeCard { id, node, udata } } - // }} + ul.children.hlist {@for (node, udata) in &toplevel { + li { @NodeCard { node, udata } } + }} @if !continue_watching.is_empty() { h2 { "Continue Watching" } ul.children.hlist {@for (node, udata) in &continue_watching { |