From d8ffb7cf75b5e69c33079d6e5ad9fc5ba94c8716 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Mon, 16 Sep 2024 13:49:44 +0200 Subject: [PATCH] fix --- Dockerfile | 17 +++++++++++++++++ docker-compose.yml | 10 ++++++++++ src/config.rs | 5 +++-- src/main.rs | 5 +++-- src/site.rs | 4 ++-- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d159435 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:buster as builder + +COPY . /app +WORKDIR /app + +RUN cargo build --release + +FROM debian:buster + +RUN apt update && apt upgrade -y + +COPY ./src/extract_metadata.py /extract_metadata.py +COPY --from=builder /app/target/release/umbrella /umbrella + +WORKDIR / + +CMD ["/umbrella"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c890eec --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' +services: + umbrella: + build: . + ports: + - "8000:8000" + volumes: + - ./config.yml:/config.yml + environment: + ROCKET_ADDRESS: 0.0.0.0 diff --git a/src/config.rs b/src/config.rs index 906d2a2..6e78ab6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -44,7 +44,6 @@ impl Config { impl Project { pub fn build(&self, card_id: &str) -> maud::PreEscaped { let subcard_id = format!("{card_id}_sub"); - // todo : info maud::html!( div class="card" id=(card_id) { @@ -62,7 +61,9 @@ impl Project { @if let Some(contact) = &self.contact { (contact.build()) } - button class="expand-button" onclick=(format!("toggleSubcards('{subcard_id}')")) { "Expand" }; + @if self.sub.as_ref().map(|x| !x.is_empty()).unwrap_or(false) { + button class="expand-button" onclick=(format!("toggleSubcards('{subcard_id}')")) { "Expand" }; + } div class="subcards" id=(subcard_id) { @if let Some(sub) = &self.sub { @for (id, prj) in sub { diff --git a/src/main.rs b/src/main.rs index edb0f34..1faac3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ use config::Config; +use rocket::response::content::RawHtml; use rocket::{get, launch, routes, State}; mod config; mod site; #[get("/")] -pub fn main_page(c: &State) -> String { - site::gen_site(c) +pub fn main_page(c: &State) -> RawHtml { + RawHtml(site::gen_site(c)) } #[launch] diff --git a/src/site.rs b/src/site.rs index d32cf6e..343fecc 100644 --- a/src/site.rs +++ b/src/site.rs @@ -9,10 +9,10 @@ pub fn gen_site(c: &Config) -> String { meta name="viewport" content="width=device-width, initial-scale=1.0"; title { "Umbrella ☂️"}; link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css"; - style { (include_str!("style.css")) }; + style { (maud::PreEscaped(include_str!("style.css"))) }; }; body { - script { (include_str!("script.js")) }; + script { (maud::PreEscaped(include_str!("script.js"))) }; main class="container" { h1 { "Umbrella ☂️" };