From 27d25a1818a829bac27eed0d8e2351b3eb301cba Mon Sep 17 00:00:00 2001 From: famfo Date: Sat, 16 Apr 2022 13:00:02 +0200 Subject: [PATCH] Move web pages --- src/web.rs | 17 ++++------------- templates/form.css | 1 - templates/hello.html | 5 ----- templates/navbar.html | 10 ++++++++++ templates/{ => task}/create_task.html | 8 +------- templates/{ => task}/task.html | 0 templates/{ => task}/task_page.html | 10 ++-------- 7 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 templates/form.css delete mode 100644 templates/hello.html create mode 100644 templates/navbar.html rename templates/{ => task}/create_task.html (86%) rename templates/{ => task}/task.html (100%) rename templates/{ => task}/task_page.html (76%) diff --git a/src/web.rs b/src/web.rs index 07d382c..d041c38 100644 --- a/src/web.rs +++ b/src/web.rs @@ -110,7 +110,7 @@ impl App { config, db, session_store, - tera: Arc::new(Tera::new("templates/*.html")?), + tera: Arc::new(Tera::new("templates/**/*.html")?), }) } @@ -126,16 +126,7 @@ impl App { ) } ) - // 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").map({ + .or(warp::path("task").map({ let tera = self.tera.clone(); move || { let mut ctx = Context::new(); @@ -151,7 +142,7 @@ impl App { tasks.push(task_ctx); } ctx.insert("tasks", &tasks); - warp::reply::html(tera.render("task_page.html", &ctx).unwrap()) + warp::reply::html(tera.render("task/task_page.html", &ctx).unwrap()) } })) .or(warp::path("task") @@ -160,7 +151,7 @@ impl App { let tera = self.tera.clone(); move || { let ctx = Context::new(); - warp::reply::html(tera.render("create_task.html", &ctx).unwrap()) + warp::reply::html(tera.render("task/create_task.html", &ctx).unwrap()) } })) .or(warp::post() diff --git a/templates/form.css b/templates/form.css deleted file mode 100644 index 8b13789..0000000 --- a/templates/form.css +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/hello.html b/templates/hello.html deleted file mode 100644 index 4618656..0000000 --- a/templates/hello.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -Hello, {{name}} -{% endblock content %} \ No newline at end of file diff --git a/templates/navbar.html b/templates/navbar.html new file mode 100644 index 0000000..b85085e --- /dev/null +++ b/templates/navbar.html @@ -0,0 +1,10 @@ +logo or something
+navbar
+ +home | +tasks | +users | +admin panel + +
+ diff --git a/templates/create_task.html b/templates/task/create_task.html similarity index 86% rename from templates/create_task.html rename to templates/task/create_task.html index ae62135..6594c3e 100644 --- a/templates/create_task.html +++ b/templates/task/create_task.html @@ -2,14 +2,8 @@ {% block content %} -logo or something
-navbar
+{% include "navbar.html" %} -tasks | -users | -(admin panel) - -


diff --git a/templates/task.html b/templates/task/task.html similarity index 100% rename from templates/task.html rename to templates/task/task.html diff --git a/templates/task_page.html b/templates/task/task_page.html similarity index 76% rename from templates/task_page.html rename to templates/task/task_page.html index 849c619..cb115e7 100644 --- a/templates/task_page.html +++ b/templates/task/task_page.html @@ -2,14 +2,8 @@ {% block content %} -logo or something
-navbar
+{% include "navbar.html" %} -tasks | -users | -(admin panel) - -
Create issue

@@ -25,7 +19,7 @@ navbar