index is now a md file, fallback to README, fallback to info about how to setup the index page
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2024-01-24 12:38:37 +01:00
parent fbde0a07c6
commit 978cc48a57
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
5 changed files with 26 additions and 65 deletions

View file

@ -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

View file

@ -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)

View file

@ -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<Config>) -> impl Responder {
struct IndexTemplate {
navbar: NavBar,
fullname: String,
content: Option<File>,
}
#[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"]),
},
)
}

View file

@ -64,8 +64,8 @@ h1 {
opacity: 1;
}
#friends a {
padding-right: 10px;
#friends a:not(h1 > a) {
padding-right: 5px;
}
#friends h1 {

View file

@ -22,66 +22,12 @@
</div>
<p id="subname"></p>
<article>
<h1>Qui suis-je ?</h1>
<p>Je m'appelle <b>Anri</b>, mon pseudo est <b>Mylloon</b>.</p>
{{#content}} {{&content}} {{/content}} {{^content}}
<p>
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
<a
href="https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License"
target="_blank"
rel="noreferrer"
>AGPLv3</a
>.
<b>Welcome to EWP</b>, create a <code>index.md</code> file inside your
<code>data/</code> directory to get started.
</p>
<p>
En ce moment, je suis en master d'informatique à Paris Cité
(anciennement Paris 7), c'est marrant on fait de l'OCaml 🤓☝️.
</p>
</article>
<article id="friends">
<h1>Personnes incroyables</h1>
<a
href="https://github.com/2-1-1-2"
title="GitHub de 21_12"
target="_blank"
rel="noreferrer"
><img src="/badges/friends/21_12.webp" alt="21_12" loading="lazy"
/></a>
<a
href="https://twitter.com/azazouille_"
title="Twitter de Azazouille"
target="_blank"
rel="noreferrer"
><img
src="/badges/friends/azazouille.webp"
alt="Azazouille"
loading="lazy"
/></a>
<a
href="https://102jjwy.carrd.co/"
title="Carrd de 102jjwy"
target="_blank"
rel="noreferrer"
><img src="/badges/friends/102jjwy.webp" alt="102jjwy" loading="lazy"
/></a>
<a
href="https://twitter.com/archivesmilfs"
title="Compte twitter favori de jas"
target="_blank"
rel="noreferrer"
><img src="/badges/friends/jas.webp" alt="jas" loading="lazy"
/></a>
</article>
{{/data}}
{{/content}} {{/data}}
</main>
<script src="/js/index.js"></script>
</body>