Style rework #35

Merged
Anri merged 70 commits from rework into main 2023-10-15 20:58:23 +02:00
4 changed files with 53 additions and 7 deletions
Showing only changes of commit dfe1d9f263 - Show all commits

View file

@ -1,7 +1,12 @@
use actix_web::{get, web, HttpRequest, HttpResponse, Responder};
use cached::proc_macro::once;
use ramhorns::Content;
use crate::{config::Config, misc::utils::get_url, template::Infos};
use crate::{
config::Config,
misc::utils::get_url,
template::{Infos, NavBar},
};
#[get("/")]
pub async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
@ -11,11 +16,21 @@ pub async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder
))
}
#[derive(Content, Debug)]
struct IndexTemplate {
navbar: NavBar,
}
#[once(time = 60)]
pub fn build_page(config: Config, url: String) -> String {
config.tmpl.render(
"index.html",
(),
IndexTemplate {
navbar: NavBar {
index: true,
..NavBar::default()
},
},
Infos {
page_title: config.fc.fullname,
page_desc: Some("Page principale".into()),

View file

@ -22,6 +22,16 @@ pub struct Infos {
pub url: String,
}
#[derive(Content, Debug, Default)]
pub struct NavBar {
pub index: bool,
pub blog: bool,
pub portfolio: bool,
pub networks: bool,
pub contrib: bool,
pub cours: bool,
}
/// Final structure given to template
#[derive(Content, Debug)]
struct Data<T> {

View file

@ -10,3 +10,7 @@
.navbar li:last-child p::after {
content: "";
}
.bold {
font-weight: bold;
}

View file

@ -1,19 +1,36 @@
{{#data}}{{#navbar}}
<nav class="navbar">
<ul>
<li>
<p><a href="/blog">Blog</a></p>
<p class="{{#index}}bold{{/index}}">
<a href="/" title="Page principale">Index</a>
</p>
</li>
<li>
<p><a href="/portfolio">Portfolio</a></p>
<p class="{{#blog}}bold{{/blog}}">
<a href="/blog" title="Page de blog">Blog</a>
</p>
</li>
<li>
<p><a href="/networks">Réseaux</a></p>
<p class="{{#portfolio}}bold{{/portfolio}}">
<a href="/portfolio" title="Page du portfolio">Portfolio</a>
</p>
</li>
<li>
<p><a href="/contrib">Contributions</a></p>
<p class="{{#networks}}bold{{/networks}}">
<a href="/networks" title="Page des réseaux">Réseaux</a>
</p>
</li>
<li>
<p><a href="https://liv.mylloon.fr">Cours</a></p>
<p class="{{#contrib}}bold{{/contrib}}">
<a href="/contrib" title="Page des contributions">Contributions</a>
</p>
</li>
<li>
<p class="{{#cours}}bold{{/cours}}">
<a href="https://liv.mylloon.fr" title="Page des cours">Cours</a>
</p>
</li>
</ul>
</nav>
{{/navbar}}{{/data}}