diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-29 11:10:21 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-29 11:10:21 +0200 |
commit | f62c7f2a8cc143454779dc99334ca9fc80ddabd5 (patch) | |
tree | f31dbb908715d2deb2860e2097fa13dd41d759d5 /server/src/ui/home.rs | |
parent | 73d2d5eb01fceae9e0b1c58afb648822000c878a (diff) | |
download | jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.bz2 jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.zst |
still just moving code around
Diffstat (limited to 'server/src/ui/home.rs')
-rw-r--r-- | server/src/ui/home.rs | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/server/src/ui/home.rs b/server/src/ui/home.rs index 2a79965..6127e8c 100644 --- a/server/src/ui/home.rs +++ b/server/src/ui/home.rs @@ -3,27 +3,43 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ -use super::{error::MyResult, node::DatabaseNodeUserDataExt}; -use crate::{api::AcceptJson, database::Database, locale::AcceptLanguage, logic::session::Session}; -use anyhow::Context; -use chrono::{Datelike, Utc}; -use jellycommon::{api::ApiHomeResponse, user::WatchedState, NodeID, NodeKind, Rating, Visibility}; -use rocket::{get, serde::json::Json, Either, State}; + +use super::error::MyResult; +use crate::{api::AcceptJson, locale::AcceptLanguage}; +use jellybase::database::Database; +use jellycommon::api::ApiHomeResponse; +use jellyimport::is_importing; +use jellylogic::session::Session; +use jellyui::{ + home::HomePage, + render_page, + scaffold::{RenderInfo, SessionInfo}, +}; +use rocket::{ + figment::value::magic::Either, get, response::content::RawHtml, serde::json::Json, State, +}; #[get("/home")] pub fn r_home( - sess: Session, + session: Session, db: &State<Database>, aj: AcceptJson, lang: AcceptLanguage, -) -> MyResult<Either<DynLayoutPage, Json<ApiHomeResponse>>> { +) -> MyResult<Either<RawHtml<String>, Json<ApiHomeResponse>>> { let AcceptLanguage(lang) = lang; - let resp = jellylogic::home::home(&db, sess)?; + let r = jellylogic::home::home(&db, &session)?; Ok(if *aj { - Either::Right(Json(resp)) + Either::Right(Json(r)) } else { - Either::Left(jellyui::home::home_page(resp)) + Either::Left(RawHtml(render_page( + &HomePage { lang: &lang, r }, + RenderInfo { + importing: is_importing(), + session: Some(SessionInfo { user: session.user }), + }, + lang, + ))) }) } |