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/external_compat.rs | 6 +++++- server/src/routes/ui/home.rs | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'server/src') diff --git a/server/src/routes/external_compat.rs b/server/src/routes/external_compat.rs index 7babfa5..eda3537 100644 --- a/server/src/routes/external_compat.rs +++ b/server/src/routes/external_compat.rs @@ -5,6 +5,7 @@ */ use super::ui::{account::session::Session, error::MyResult}; use crate::routes::ui::node::rocket_uri_macro_r_library_node; +use crate::routes::ui::player::{rocket_uri_macro_r_player, PlayerConfig}; use anyhow::anyhow; use jellybase::database::Database; use rocket::{get, response::Redirect, State}; @@ -18,7 +19,10 @@ pub fn r_ext_youtube_watch(_session: Session, db: &State, v: &str) -> Err(anyhow!("element not found"))? }; let node = db.get_node(id)?.ok_or(anyhow!("node missing"))?; - Ok(Redirect::to(rocket::uri!(r_library_node(&node.slug)))) + Ok(Redirect::to(rocket::uri!(r_player( + &node.slug, + PlayerConfig::default() + )))) } #[get("/channel/")] 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