summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-09-04 17:04:36 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-09-04 17:04:36 +0200
commit9ab63b13d74b272d5a557e61f486ff980917d41d (patch)
treece31aa5b33e8b6def474886785da2fbcdb7df35f
parent26ae8d459562c67f0eefdb035c6d24ac718c0b7d (diff)
Add some style elements
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/frontend.rs33
-rw-r--r--src/main.rs1
2 files changed, 29 insertions, 5 deletions
diff --git a/src/frontend.rs b/src/frontend.rs
index 964367e..e5a9285 100644
--- a/src/frontend.rs
+++ b/src/frontend.rs
@@ -6,9 +6,16 @@ use actix_web::HttpRequest;
use actix_web::HttpResponse;
use actix_web::Error;
+// TODO: This is not how you do it
+#[get("/style.css")]
+pub async fn css() -> &'static str {
+ std::include_str!("../static/bulma.css")
+}
+
#[get("/")]
pub async fn index() -> Result<maud::Markup> {
Ok(maud::html! {
+ link rel="stylesheet" href="style.css";
html {
body {
h1 { "Waterlevels" }
@@ -37,6 +44,7 @@ pub struct LandscapeSize {
pub async fn make_landscape(form: web::Form<LandscapeSize>) -> Result<maud::Markup> {
if form.elements > 100 {
return Ok(maud::html! {
+ link rel="stylesheet" href="style.css";
html {
body {
p { "For runtime reasons, this application only supports landscapes up to 100 elements" }
@@ -46,6 +54,7 @@ pub async fn make_landscape(form: web::Form<LandscapeSize>) -> Result<maud::Mark
}
Ok(maud::html! {
+ link rel="stylesheet" href="style.css";
html {
body {
h1 { "Hello World!" }
@@ -95,6 +104,7 @@ pub async fn calculate(req: HttpRequest) -> Result<maud::Markup> {
// This is just "good enough" for now.
if ls.hours > 1000 {
return Ok(maud::html! {
+ link rel="stylesheet" href="style.css";
html {
body {
h1 { "Landscape error" }
@@ -107,20 +117,33 @@ pub async fn calculate(req: HttpRequest) -> Result<maud::Markup> {
let calculated_landscape = crate::backend::landscape::Landscape::new(ls.levels.clone()).rain(ls.hours);
Ok(maud::html! {
+ link rel="stylesheet" href="style.css";
html {
body {
- h1 { "Landscape!" }
+ h1 { "Landscape" }
p { "Filling in " (ls.hours) " hours" }
- @for value in &ls.levels {
- p { (value) }
+ table class="table" {
+ tbody {
+ tr {
+ @for value in &ls.levels {
+ td { (value) }
+ }
+ }
+ }
}
h2 { "Filled" }
- @for val in calculated_landscape.into_inner() {
- p { (val.0) " + " (val.1) }
+ table class="table" {
+ tbody {
+ tr {
+ @for val in calculated_landscape.into_inner() {
+ td { (val.0) " + " (val.1) }
+ }
+ }
+ }
}
}
}
diff --git a/src/main.rs b/src/main.rs
index cf87858..8a99b08 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,7 @@ async fn main() -> anyhow::Result<()> {
App::new()
.wrap(Logger::default())
.wrap(Logger::new("%a %{User-Agent}i"))
+ .service(crate::frontend::css)
.service(crate::frontend::index)
.service(crate::frontend::make_landscape)
.service(crate::frontend::calculate)