Reintroduce templating
This commit is contained in:
parent
589cfa26f3
commit
5c6afd32a9
27
src/web.rs
27
src/web.rs
|
@ -21,7 +21,7 @@ use std::sync::Arc;
|
|||
use async_sqlx_session::PostgresSessionStore;
|
||||
use chrono::Duration;
|
||||
use sqlx::types::chrono::Utc;
|
||||
use tera::Tera;
|
||||
use tera::{Tera, Context};
|
||||
use tokio::sync::broadcast;
|
||||
use tracing::info;
|
||||
use warp::Filter;
|
||||
|
@ -119,7 +119,30 @@ impl App {
|
|||
s,
|
||||
)
|
||||
}
|
||||
);
|
||||
)
|
||||
// example route, remove later or something
|
||||
.or(warp::path!("hello" / String).map({
|
||||
let tera = self.tera.clone();
|
||||
move |name: String| {
|
||||
let mut ctx = Context::new();
|
||||
ctx.insert("name", &name);
|
||||
warp::reply::html(tera.render("hello.html", &ctx).unwrap())
|
||||
}
|
||||
}))
|
||||
.or(warp::path!("tmtd" / String).map({
|
||||
let tera = self.tera.clone(); {
|
||||
move |_| {
|
||||
let mut ctx = Context::new();
|
||||
ctx.insert("tasks", &vec!["test1", "test2"]);
|
||||
ctx.insert("task_title", "TODO");
|
||||
ctx.insert("description", "TODO");
|
||||
ctx.insert("task_date", "TODO");
|
||||
ctx.insert("status", "TODO");
|
||||
ctx.insert("assignee", "TODO");
|
||||
warp::reply::html(tera.render("task_page.html", &ctx).unwrap())
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
let (_, server) =
|
||||
warp::serve(route).bind_with_graceful_shutdown(self.config.listen_addr, async move {
|
||||
|
|
|
@ -22,7 +22,7 @@ navbar<br>
|
|||
<!-- Some only selecting specific task code here, for smarter people then me -->
|
||||
|
||||
{% for task in tasks %}
|
||||
{% include "templates/task.html" %}
|
||||
{% include "task.html" %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock content %}
|
||||
|
|
Loading…
Reference in a new issue