aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/home.rs
blob: c544336ed62a3decee12c77c8cda0aaabb03be21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use super::{account::session::Session, layout::LayoutPage};
use crate::{
    database::Database,
    routes::ui::{error::MyResult, layout::DynLayoutPage},
};
use jellybase::CONF;
use rocket::{get, State};
use tokio::fs::read_to_string;

#[get("/")]
pub fn r_home(_sess: Session, _db: &State<Database>) -> DynLayoutPage {
    LayoutPage {
        title: "Home".to_string(),
        content: markup::new! {
            p { "Welcome to " @CONF.brand  }
            p.error { "TODO: continue watching" }
            p.error { "TODO: recently added" }
            p.error { "TODO: best rating" }
            p.error { "TODO: random" }
        },
        ..Default::default()
    }
}

#[get("/", rank = 2)]
pub async fn r_home_unpriv() -> MyResult<DynLayoutPage<'static>> {
    let front = read_to_string(CONF.asset_path.join("front.htm")).await?;
    Ok(LayoutPage {
        title: "Home".to_string(),
        content: markup::new! {
            @markup::raw(&front)
        },
        ..Default::default()
    })
}