From b6d11b64a9afa8e16df39f575ce1f8fd173449e0 Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Fri, 27 Mar 2020 15:27:19 +0100 Subject: [PATCH] add visualizer --- backend/src/routes.rs | 14 +++++- backend/src/util.rs | 2 +- backend/static/frontend | 1 + backend/static/static | 1 + backend/static/style/base.css | 14 +++++- backend/static/style/visualizer.css | 1 + backend/templates/base.html.tera | 4 +- backend/templates/mapbuilder.html.tera | 2 +- backend/templates/visualizer.html.tera | 69 ++++++++++++++++++++++++++ 9 files changed, 102 insertions(+), 6 deletions(-) create mode 120000 backend/static/frontend create mode 120000 backend/static/static create mode 120000 backend/static/style/visualizer.css create mode 100644 backend/templates/visualizer.html.tera diff --git a/backend/src/routes.rs b/backend/src/routes.rs index 8b36e76..066420e 100644 --- a/backend/src/routes.rs +++ b/backend/src/routes.rs @@ -64,6 +64,18 @@ async fn builder_get() -> Result { Ok(Template::render("mapbuilder", &context)) } +#[get("/frontend/index.html")] +async fn visualizer_get() -> Result { + let context = Context::new("Visualizer", None); + Ok(Template::render("visualizer", &context)) +} + +#[get("/visualizer")] +async fn visualizer_get_bis() -> Result { + let context = Context::new("Visualizer", None); + Ok(Template::render("visualizer", &context)) +} + #[get("/maps/")] async fn map_get(file: String) -> Result { let mut content = String::new(); @@ -74,5 +86,5 @@ async fn map_get(file: String) -> Result { } pub fn fuel(routes: &mut Vec) { - routes.extend(routes![files, index, map_post, map_get, maps_get, builder_get]); + routes.extend(routes![files, index, map_post, map_get, maps_get, builder_get, visualizer_get, visualizer_get_bis]); } diff --git a/backend/src/util.rs b/backend/src/util.rs index e034da3..ce961ce 100644 --- a/backend/src/util.rs +++ b/backend/src/util.rs @@ -1,7 +1,7 @@ use async_std::prelude::*; use async_std::fs; -static NAV: [(&'static str, &'static str); 3] = [("/", "Home"), ("/lobby", "Lobby"), ("/mapbuilder", "Map Builder")]; +static NAV: [(&'static str, &'static str); 4] = [("/", "Home"), ("/lobby", "Lobby"), ("/mapbuilder", "Map Builder"), ("/frontend/index.html", "Visualizer")]; #[derive(Serialize)] pub struct Map { diff --git a/backend/static/frontend b/backend/static/frontend new file mode 120000 index 0000000..ef93659 --- /dev/null +++ b/backend/static/frontend @@ -0,0 +1 @@ +../../frontend/www/frontend \ No newline at end of file diff --git a/backend/static/static b/backend/static/static new file mode 120000 index 0000000..89ec7c4 --- /dev/null +++ b/backend/static/static @@ -0,0 +1 @@ +../../frontend/www/static/ \ No newline at end of file diff --git a/backend/static/style/base.css b/backend/static/style/base.css index a5df373..b257e35 100644 --- a/backend/static/style/base.css +++ b/backend/static/style/base.css @@ -43,4 +43,16 @@ body { display: flex; flex-direction: column; align-items: stretch; -} \ No newline at end of file +} + +.content { + height: 100%; + width: 100%; + display: flex; + justify-content: center; + background: black; + color: #ff7f00; + line-height: 1.5rem; + overflow: hidden; + align-items: center; +} diff --git a/backend/static/style/visualizer.css b/backend/static/style/visualizer.css new file mode 120000 index 0000000..f875154 --- /dev/null +++ b/backend/static/style/visualizer.css @@ -0,0 +1 @@ +../../../frontend/www/static/res/style.css \ No newline at end of file diff --git a/backend/templates/base.html.tera b/backend/templates/base.html.tera index 9ad9ea5..cd0659a 100644 --- a/backend/templates/base.html.tera +++ b/backend/templates/base.html.tera @@ -3,8 +3,8 @@ Planetwars - - + +