NOT WORKING

This commit is contained in:
Gvidas Juknevičius 2024-03-29 23:35:38 +02:00
parent b7cf19f229
commit 8a23681a12
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
3 changed files with 48 additions and 52 deletions

View File

@ -6,12 +6,31 @@ use askama::Template;
use crate::{database::Database, web::templates::IndexTemplate}; use crate::{database::Database, web::templates::IndexTemplate};
use super::templates::IndexTemplatePost;
// NOTE: Not usefull to have database here but just so u know how // NOTE: Not usefull to have database here but just so u know how
pub async fn index(_: Data<Mutex<Database>>) -> Result<impl Responder> { pub async fn index(_: Data<Mutex<Database>>) -> Result<impl Responder> {
let html = IndexTemplate { 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"); }.render().expect("Failed to render index.html");
Ok(Html(html)) Ok(Html(html))
} }
/*
<div class="post">
<img src="/static/assets/uwu.jpg" alt="post img">
<span>
<h2>Title text</h3>
<p>Description text</p>
</span>
</div>
*/

View File

@ -1,7 +1,16 @@
use askama::Template; use askama::Template;
#[derive(Debug, Clone, Copy, Template)] #[derive(Debug, Clone, Template)]
#[template(path = "index.html")] #[template(path = "index.html")]
pub struct IndexTemplate<'a> { pub struct IndexTemplate{
pub placeholder: &'a str, pub title: String,
pub posts: Vec<IndexTemplatePost>
}
#[derive(Debug, Clone)]
pub struct IndexTemplatePost {
pub image: String,
pub title: String,
pub description: String,
pub url: String
} }

View File

@ -1,78 +1,46 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>{{title}}</title>
<title>placeholder</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/css/global.css"> <link rel="stylesheet" href="/static/css/global.css">
<link rel="stylesheet" href="/static/css/index.css"> <link rel="stylesheet" href="/static/css/index.css">
</head> </head>
<body> <body>
<input type="checkbox" id="toggle"> <input type="checkbox" id="toggle">
<div id="content"> <div id="content">
<div class="box titlebar"> <div class="box titlebar">
<h1>{{title}}</h1>
<h1>Placeholder</h1>
</div> </div>
<div id="main-pane"> <div id="main-pane">
<div class="box" id="sidenav"> <div class="box" id="sidenav">
<a href="#">Home</a> <a href="#">Home</a>
<a href="#">Home</a> <a href="#">Home</a>
<a href="#">Home</a> <a href="#">Home</a>
<a href="#">Home</a> <a href="#">Home</a>
<label id="login-btn" for="toggle">Login</label> <label id="login-btn" for="toggle">Login</label>
</div> </div>
<div class="box" id="content-pane"> <div class="box" id="content-pane">
{% for post in posts %}
<p>{{placeholder}}</p>
<div class="post"> <div class="post">
<img class="post-img" src="/static/assets/uwu.jpg" alt="post img"> <a href="{{post.url}}"><img src="{{post.image}}" alt="post img"></a>
<span> <span>
<h2 class="post-title">Title text</h3> <a href="{{post.url}}"><h2>{{post.title}}</h3></a>
<p class="post-desc">Description text</p> <p>{{post.description}}</p>
</span> </span>
</div> </div>
{% endfor %}
<div class="post">
<img class="post-img" src="/static/assets/uwu.jpg" alt="post img">
<span>
<h2 class="post-title">Title text</h3>
<p class="post-desc">Description text</p>
</span>
</div> </div>
</div> </div>
</div>
</div> </div>
<div id="login-modal-container"> <div id="login-modal-container">
<div id="login-modal"> <div id="login-modal">
<h1>login <labeL for="toggle">(x)</labeL></h1> <h1>login <labeL for="toggle">(x)</labeL></h1>
<p>secrets beyond human comprehension lie beneath this unassuming login screen</p> <p>secrets beyond human comprehension lie beneath this unassuming login screen</p>
<div class="container"> <div class="container">
<div class="form-group"> <div class="form-group">
<label for="uname"><b>Email:</b></label> <label for="uname"><b>Email:</b></label>
<input type="text" name="uname" required> <input type="text" name="uname" required>