home: almost finished bibou oracle
This commit is contained in:
parent
01dfdae15e
commit
ddf2fe4913
7 changed files with 101 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ pub struct AppState {
|
|||
pub mp_tracks: Vec<Track>,
|
||||
pub p_tracks: Vec<Track>,
|
||||
pub website_news: Vec<WebsiteArticle>,
|
||||
pub bibou_quotes: Vec<String>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
|
|
@ -31,6 +32,11 @@ impl AppState {
|
|||
|
||||
news
|
||||
},
|
||||
bibou_quotes: serde_json::from_str(
|
||||
&std::fs::read_to_string("content/bibou-quotes.json")
|
||||
.expect("bibou-quotes.json non trouvé"),
|
||||
)
|
||||
.expect("JSON invalide"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ use crate::domain::{AppState, WebsiteArticle};
|
|||
struct HomeTemplate<'a> {
|
||||
tracks: &'a Vec<crate::domain::Track>,
|
||||
news: &'a Vec<WebsiteArticle>,
|
||||
bibou_quotes: &'a Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "partials/home.html")]
|
||||
struct HomePartialTemplate<'a> {
|
||||
news: &'a Vec<WebsiteArticle>,
|
||||
bibou_quotes: &'a Vec<String>,
|
||||
}
|
||||
|
||||
pub async fn home(headers: HeaderMap, state: State<Arc<AppState>>) -> impl IntoResponse {
|
||||
|
|
@ -26,6 +28,7 @@ pub async fn home(headers: HeaderMap, state: State<Arc<AppState>>) -> impl IntoR
|
|||
Html(
|
||||
HomePartialTemplate {
|
||||
news: &state.website_news,
|
||||
bibou_quotes: &state.bibou_quotes,
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
|
|
@ -35,6 +38,7 @@ pub async fn home(headers: HeaderMap, state: State<Arc<AppState>>) -> impl IntoR
|
|||
HomeTemplate {
|
||||
tracks: &state.mp_tracks,
|
||||
news: &state.website_news,
|
||||
bibou_quotes: &state.bibou_quotes,
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue