From 8a23681a128c9f943e4481a454d2ebbf7cf899ce Mon Sep 17 00:00:00 2001 From: MCorange99 Date: Fri, 29 Mar 2024 23:35:38 +0200 Subject: [PATCH] NOT WORKING --- src/web/routes/mod.rs | 23 +++++++++++++++-- src/web/templates.rs | 17 +++++++++--- templates/index.html | 60 ++++++++++--------------------------------- 3 files changed, 48 insertions(+), 52 deletions(-) diff --git a/src/web/routes/mod.rs b/src/web/routes/mod.rs index 3292679..ff69700 100644 --- a/src/web/routes/mod.rs +++ b/src/web/routes/mod.rs @@ -6,12 +6,31 @@ use askama::Template; use crate::{database::Database, web::templates::IndexTemplate}; +use super::templates::IndexTemplatePost; + // NOTE: Not usefull to have database here but just so u know how pub async fn index(_: Data>) -> Result { let html = IndexTemplate { - placeholder: "hewwo world" + posts: vec![ + IndexTemplatePost { + image: String::from("/static/assets/uwu.jpg"), + title: String::from("Cutie"), + description: String::from("Yes you are ;3"), + url: String::from("https://djc.github.io/askama/template_expansion.html") + } + ], + title: String::from("Very cool mcoranges website :3"), }.render().expect("Failed to render index.html"); Ok(Html(html)) -} \ No newline at end of file +} +/* +
+ post img + +

Title text

+

Description text

+
+
+*/ \ No newline at end of file diff --git a/src/web/templates.rs b/src/web/templates.rs index c1764cd..2daf485 100644 --- a/src/web/templates.rs +++ b/src/web/templates.rs @@ -1,7 +1,16 @@ use askama::Template; -#[derive(Debug, Clone, Copy, Template)] +#[derive(Debug, Clone, Template)] #[template(path = "index.html")] -pub struct IndexTemplate<'a> { - pub placeholder: &'a str, -} \ No newline at end of file +pub struct IndexTemplate{ + pub title: String, + pub posts: Vec +} + +#[derive(Debug, Clone)] +pub struct IndexTemplatePost { + pub image: String, + pub title: String, + pub description: String, + pub url: String +} diff --git a/templates/index.html b/templates/index.html index 8595aeb..628bdc8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,78 +1,46 @@ - - - placeholder + {{title}} - - - -
-
- -

Placeholder

- +

{{title}}

- - -
- -
- Home Home Home Home -
-
- - -

{{placeholder}}

- -
- post img - -

Title text

-

Description text

-
-
- -
- post img - -

Title text

-

Description text

-
-
- + {% for post in posts %} +
+ post img + +

{{post.title}}

+

{{post.description}}

+
+
+ {% endfor %}
-
-
-
- +

login

secrets beyond human comprehension lie beneath this unassuming login screen

- -
+
@@ -82,7 +50,7 @@
- +