From c787171d6b9bffc5b32f20fc7a669ed5494f4f86 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 25 Jan 2024 18:23:07 +0100 Subject: [PATCH] portfolio genericity --- src/routes/portfolio.rs | 15 ++++++++++++--- templates/portfolio/index.html | 8 ++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/routes/portfolio.rs b/src/routes/portfolio.rs index 9b3f1ee..b528002 100644 --- a/src/routes/portfolio.rs +++ b/src/routes/portfolio.rs @@ -20,6 +20,7 @@ async fn page(config: web::Data) -> impl Responder { #[derive(Content, Debug)] struct PortfolioTemplate<'a> { navbar: NavBar, + about: Option, location_apps: Option<&'a str>, apps: Option>, archived_apps: Option>, @@ -30,22 +31,29 @@ struct PortfolioTemplate<'a> { #[once(time = 60)] fn build_page(config: Config) -> String { let projects_dir = format!("{}/projects", config.locations.data_dir); + let apps_dir = format!("{}/apps", projects_dir); let ext = ".md"; + // Get about + let about = read_file( + &format!("{}/about.md", projects_dir), + TypeFileMetadata::Generic, + ); + // Get apps - let apps = glob(&format!("{projects_dir}/*{ext}")) + let apps = glob(&format!("{apps_dir}/*{ext}")) .unwrap() .map(|e| read_file(&e.unwrap().to_string_lossy(), TypeFileMetadata::Portfolio).unwrap()) .collect::>(); let appdata = if apps.is_empty() { - (None, Some(projects_dir.as_str())) + (None, Some(apps_dir.as_str())) } else { (Some(apps), None) }; // Get archived apps - let archived_apps = glob(&format!("{projects_dir}/archive/*{ext}")) + let archived_apps = glob(&format!("{apps_dir}/archive/*{ext}")) .unwrap() .map(|e| read_file(&e.unwrap().to_string_lossy(), TypeFileMetadata::Portfolio).unwrap()) .collect::>(); @@ -63,6 +71,7 @@ fn build_page(config: Config) -> String { portfolio: true, ..NavBar::default() }, + about, apps: appdata.0, location_apps: appdata.1, archived_apps: archived_appdata.0, diff --git a/templates/portfolio/index.html b/templates/portfolio/index.html index d3aa640..b2ce21e 100644 --- a/templates/portfolio/index.html +++ b/templates/portfolio/index.html @@ -10,14 +10,10 @@
{{#data}}

Portfolio

-

- Je programme depuis 2018 et j'ai appris une multitude de langages - depuis. Étant passionné de logiciels libres depuis que je m'y intéresse, - je publie tout sur des forges publiques. -

+ {{#about}} {{&content}} {{/about}} - {{#location_apps}} + {{#location_apps}}

{{location_apps}} {{err_msg}}

{{/location_apps}} {{^location_apps}}