From 978cc48a57753cec8246446d49f35871e8000285 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:38:37 +0100 Subject: [PATCH] index is now a md file, fallback to README, fallback to info about how to setup the index page --- Dockerfile | 1 + README.md | 2 +- src/routes/index.rs | 18 ++++++++++-- static/css/index.css | 4 +-- templates/index.html | 66 ++++---------------------------------------- 5 files changed, 26 insertions(+), 65 deletions(-) diff --git a/Dockerfile b/Dockerfile index c42cd5f..9bfdc3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ WORKDIR /app COPY --from=builder /usr/local/cargo/bin/ewp /app/ewp COPY --from=builder /usr/src/ewp/LICENSE /app/LICENSE +COPY --from=builder /usr/src/ewp/README.md /app/README.md COPY --from=builder /usr/src/ewp/static /app/static COPY --from=builder /usr/src/ewp/templates /app/templates diff --git a/README.md b/README.md index afacd3e..ae45e61 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ Easy WebPage generator [![status-badge](https://ci.mylloon.fr/api/badges/Anri/mylloon.fr/status.svg)](https://ci.mylloon.fr/Anri/mylloon.fr) - See [issues](https://git.mylloon.fr/Anri/mylloon.fr/issues) -- See [documentation](./Documentation.md) +- See [documentation](https://git.mylloon.fr/Anri/mylloon.fr/src/branch/main/Documentation.md) diff --git a/src/routes/index.rs b/src/routes/index.rs index b8291d8..5ff067d 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -4,7 +4,10 @@ use ramhorns::Content; use crate::{ config::Config, - misc::utils::{make_kw, Html}, + misc::{ + markdown::{read_file, File, TypeFileMetadata}, + utils::{make_kw, Html}, + }, template::{Infos, NavBar}, }; @@ -17,10 +20,20 @@ async fn page(config: web::Data) -> impl Responder { struct IndexTemplate { navbar: NavBar, fullname: String, + content: Option, } #[once(time = 60)] fn build_page(config: Config) -> String { + let mut content = read_file( + &format!("{}/index.md", config.locations.data_dir), + TypeFileMetadata::Generic, + ); + + if content.is_none() { + content = read_file("README.md", TypeFileMetadata::Generic); + } + config.tmpl.render( "index.html", IndexTemplate { @@ -33,11 +46,12 @@ fn build_page(config: Config) -> String { .fullname .to_owned() .unwrap_or("Fullname".to_owned()), + content, }, Infos { page_title: config.fc.fullname, page_desc: Some("Page principale".into()), - page_kw: make_kw(&["index", "étudiant"]), + page_kw: make_kw(&["index", "étudiant", "accueil"]), }, ) } diff --git a/static/css/index.css b/static/css/index.css index ac60ac0..6c654d4 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -64,8 +64,8 @@ h1 { opacity: 1; } -#friends a { - padding-right: 10px; +#friends a:not(h1 > a) { + padding-right: 5px; } #friends h1 { diff --git a/templates/index.html b/templates/index.html index 0ca4289..3eb1916 100644 --- a/templates/index.html +++ b/templates/index.html @@ -22,66 +22,12 @@

-
-

Qui suis-je ?

-

Je m'appelle Anri, mon pseudo est Mylloon.

-

- J'aime beaucoup l'informatique depuis très petit, ce site est écrit de - A à Z par moi-même (modulo la quantité astronomique de librairie - utilisé) en Rust. J'adore le monde de l'open source, l'immense - majorité de mes projets sont sous licence - AGPLv3. -

-

- En ce moment, je suis en master d'informatique à Paris Cité - (anciennement Paris 7), c'est marrant on fait de l'OCaml 🤓☝️. -

-
- -
-

Personnes incroyables

- 21_12 - - Azazouille - - 102jjwy - - jas -
- - {{/data}} + {{#content}} {{&content}} {{/content}} {{^content}} +

+ Welcome to EWP, create a index.md file inside your + data/ directory to get started. +

+ {{/content}} {{/data}}