From 9d6411fd92e73c204425f8dd37dc3cf567f604e4 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 30 Jan 2025 18:34:09 +0100 Subject: avoid transitive crate deps by re-export --- server/src/routes/ui/home.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'server/src/routes/ui/home.rs') 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 */ -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) -> MyResult { .flat_map(|i| Some(items[cheap_daily_random(i).checked_rem(items.len())?].clone())) .collect::>(); - // let toplevel = T_NODE - // .get(db, "library")? - // .context("root node missing")? - // .into_iter() - // .map(|n| db.get_node_with_userdata(&n, &sess)) - // .collect::>>()? - // .into_iter() - // .collect::>(); + 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::>>()?; items.sort_by_key(|(n, _)| { n.ratings @@ -68,9 +71,9 @@ pub fn r_home(sess: Session, db: &State) -> MyResult { 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 { -- cgit v1.2.3-70-g09d2