diff --git a/raws/artworks/2020.md b/raws/artworks/2020.md index 2fce476..0e4b1e6 100644 --- a/raws/artworks/2020.md +++ b/raws/artworks/2020.md @@ -1,6 +1,6 @@ --- title: Blender 2020 -description: 2020 blender artworks +tags: 2020 blender artworks date: 2020-01-01 yearonly: true url: 2020.html diff --git a/raws/artworks/2021.md b/raws/artworks/2021.md index 3e196d2..9b85867 100644 --- a/raws/artworks/2021.md +++ b/raws/artworks/2021.md @@ -1,6 +1,6 @@ --- title: Blender 2021 -description: 2021 blender artworks +tags: 2021 blender artworks date: 2021-01-01 yearonly: true url: 2021.html diff --git a/raws/blog/2020-01-04_blog.md b/raws/blog/2020-01-04_blog.md index f2ea536..408e942 100644 --- a/raws/blog/2020-01-04_blog.md +++ b/raws/blog/2020-01-04_blog.md @@ -1,6 +1,6 @@ --- title: Les sites web perso -description: blog sites perso +tags: blog sites perso date: 2020-01-04 yearonly: false url: les-sites-web-perso.html diff --git a/raws/blog/2020-01-12_docker.md b/raws/blog/2020-01-12_docker.md index 2254b86..809783f 100644 --- a/raws/blog/2020-01-12_docker.md +++ b/raws/blog/2020-01-12_docker.md @@ -1,6 +1,6 @@ --- title: La grande virtualization -description: docker virtualization +tags: docker virtualization date: 2020-01-12 yearonly: false url: la-grande-virtualization.html diff --git a/raws/blog/2020-03-03_migrationGitea.md b/raws/blog/2020-03-03_migrationGitea.md index e1cac78..fe8718e 100644 --- a/raws/blog/2020-03-03_migrationGitea.md +++ b/raws/blog/2020-03-03_migrationGitea.md @@ -1,6 +1,6 @@ --- title: Migration gitea vers docker -description: gitea docker +tags: gitea docker date: 2020-03-03 yearonly: false url: migration-gitea-docker.html diff --git a/raws/blog/2020-03-07_pwa.md b/raws/blog/2020-03-07_pwa.md index b74b29d..8474d36 100644 --- a/raws/blog/2020-03-07_pwa.md +++ b/raws/blog/2020-03-07_pwa.md @@ -1,6 +1,6 @@ ---- +--- title: Faire une PWA avec VueJS -description: docker vuejs buefy +tags: docker vuejs buefy date: 2020-03-07 yearonly: false url: pwavuejs.html diff --git a/raws/blog/2020-04-19_sculpt.md b/raws/blog/2020-04-19_sculpt.md index a059d08..e164228 100644 --- a/raws/blog/2020-04-19_sculpt.md +++ b/raws/blog/2020-04-19_sculpt.md @@ -1,6 +1,6 @@ --- title: Sculpter avec Blender -description: sculpt blender 3D +tags: sculpt blender 3D date: 2020-04-19 yearonly: false url: sculptblender.html diff --git a/raws/blog/2020-04-23_vanillajs.md b/raws/blog/2020-04-23_vanillajs.md index 32cfbe5..63b3bf5 100644 --- a/raws/blog/2020-04-23_vanillajs.md +++ b/raws/blog/2020-04-23_vanillajs.md @@ -1,6 +1,6 @@ --- title: Les frameworks Javascript -description: javascript framework +tags: javascript framework date: 2020-04-23 yearonly: false url: vanillajs.html diff --git a/raws/blog/2020-06-06_sculpt2.md b/raws/blog/2020-06-06_sculpt2.md index 20d9904..8e287ad 100644 --- a/raws/blog/2020-06-06_sculpt2.md +++ b/raws/blog/2020-06-06_sculpt2.md @@ -1,6 +1,6 @@ --- title: Sculpter avec Blender 2 -description: sculpt blender 3D +tags: sculpt blender 3D date: 2020-06-06 yearonly: false url: sculptblender2.html diff --git a/raws/blog/2021-01-15_drone.md b/raws/blog/2021-01-15_drone.md index f09fbea..c5d904a 100644 --- a/raws/blog/2021-01-15_drone.md +++ b/raws/blog/2021-01-15_drone.md @@ -1,6 +1,6 @@ --- title: Setup Gitea / Drone / Docker -description: gitea drone cicd docker +tags: gitea drone cicd docker date: 2021-01-15 yearonly: false url: giteadronedocker.html diff --git a/raws/projets/2018-01-01_initial2D.md b/raws/projets/2018-01-01_initial2D.md index 95705ff..93ac733 100644 --- a/raws/projets/2018-01-01_initial2D.md +++ b/raws/projets/2018-01-01_initial2D.md @@ -1,6 +1,6 @@ --- title: Initial2D -description: A simple GTK race game +tags: A simple GTK race game date: 2018-01-01 yearonly: true url: initial2D.html diff --git a/raws/projets/2019-01-01_oozik.md b/raws/projets/2019-01-01_oozik.md index 925c31d..1f19a35 100644 --- a/raws/projets/2019-01-01_oozik.md +++ b/raws/projets/2019-01-01_oozik.md @@ -1,6 +1,6 @@ --- title: Oozik -description: Lecteur de musique collaboratif +tags: Lecteur de musique collaboratif date: 2019-01-01 yearonly: true url: oozik.html diff --git a/raws/projets/2019-02-01_nexusV6.md b/raws/projets/2019-02-01_nexusV6.md index c59f185..1f3932c 100644 --- a/raws/projets/2019-02-01_nexusV6.md +++ b/raws/projets/2019-02-01_nexusV6.md @@ -1,6 +1,6 @@ --- title: NexusV6 -description: Main website, iteration 6 +tags: Main website, iteration 6 date: 2019-02-01 yearonly: true url: nexusv6.html diff --git a/raws/projets/2020-01-01_etienneRemote.md b/raws/projets/2020-01-01_etienneRemote.md index b914083..da6c7ec 100644 --- a/raws/projets/2020-01-01_etienneRemote.md +++ b/raws/projets/2020-01-01_etienneRemote.md @@ -1,6 +1,6 @@ --- title: Etienne's Remote -description: Une télécommande de soundboard +tags: Une télécommande de soundboard date: 2020-01-01 yearonly: true url: etienneremote.html diff --git a/raws/projets/2020-02-01_cloud32.md b/raws/projets/2020-02-01_cloud32.md index 9edcaff..ecaea41 100644 --- a/raws/projets/2020-02-01_cloud32.md +++ b/raws/projets/2020-02-01_cloud32.md @@ -1,6 +1,6 @@ --- title: Cloud32 -description: Un cloud personnel pas pratique +tags: Un cloud personnel pas pratique date: 2020-02-01 yearonly: true url: cloud32.html diff --git a/raws/projets/2020-03-01_lilStreamy.md b/raws/projets/2020-03-01_lilStreamy.md index 43cb18f..128f23f 100644 --- a/raws/projets/2020-03-01_lilStreamy.md +++ b/raws/projets/2020-03-01_lilStreamy.md @@ -1,6 +1,6 @@ --- title: LilStreamy -description: application web video p2p +tags: application web video p2p date: 2020-03-01 yearonly: true url: lilstreamy.html diff --git a/raws/projets/2020-04-01_mozen.md b/raws/projets/2020-04-01_mozen.md index 387146a..fc6b694 100644 --- a/raws/projets/2020-04-01_mozen.md +++ b/raws/projets/2020-04-01_mozen.md @@ -1,6 +1,6 @@ --- title: Mozen -description: Bibliothèque de machine learning +tags: Bibliothèque de machine learning date: 2020-04-01 yearonly: true url: mozen.html diff --git a/raws/projets/2020-05-01_voozik.md b/raws/projets/2020-05-01_voozik.md index 697c787..c495fe2 100644 --- a/raws/projets/2020-05-01_voozik.md +++ b/raws/projets/2020-05-01_voozik.md @@ -1,6 +1,6 @@ --- title: Voozik -description: Application web musique/video p2p +tags: Application web musique/video p2p date: 2020-05-01 yearonly: true url: voozik.html diff --git a/raws/projets/2020-06-01_tronio.md b/raws/projets/2020-06-01_tronio.md index b261451..f4146e2 100644 --- a/raws/projets/2020-06-01_tronio.md +++ b/raws/projets/2020-06-01_tronio.md @@ -1,6 +1,6 @@ --- title: Tron.io -description: Jeu web +tags: Jeu web date: 2020-06-01 yearonly: true url: tronio.html diff --git a/raws/projets/2021-01-01_nexusV7.md b/raws/projets/2021-01-01_nexusV7.md index 8c41ba9..3ec760a 100644 --- a/raws/projets/2021-01-01_nexusV7.md +++ b/raws/projets/2021-01-01_nexusV7.md @@ -1,6 +1,6 @@ --- title: NexusV7 -description: Static site generator +tags: Static site generator tags: rust, static site generator date: 2021-01-01 yearonly: true diff --git a/src/generator/loader.rs b/src/generator/loader.rs index 0ffa2ba..317cb30 100644 --- a/src/generator/loader.rs +++ b/src/generator/loader.rs @@ -54,6 +54,8 @@ fn load_section(dir_entry: &DirEntry) -> Section { let section_name = dir_entry.file_name().into_string().unwrap(); let section_url = section_name.to_lowercase().trim().replace(" ", "_"); + section_posts.sort_by(|a, b| b.date_compare.partial_cmp(&a.date_compare).unwrap()); + println!("[LOADER] Loaded section {} with {} posts", section_name, section_posts.len()); return Section { @@ -70,4 +72,4 @@ fn load_post(path: &Path) -> Post { }; let marky = Marky::from_file(&file); return Post::from_marky(marky); -} \ No newline at end of file +} diff --git a/src/generator/models/post.rs b/src/generator/models/post.rs index f303e0b..46d8d59 100644 --- a/src/generator/models/post.rs +++ b/src/generator/models/post.rs @@ -8,8 +8,9 @@ use crate::markdown::marky::Marky; pub struct Post { pub title: String, pub date: String, + pub date_compare: i32, + pub date_printable: String, pub url: String, - pub description: String, pub tags: Vec, pub body: String, pub is_year_only: bool, @@ -17,11 +18,30 @@ pub struct Post { impl Post { pub fn from_marky(marky: Marky) -> Post { + let date = marky.metadata.get("date").map_or(String::from("none"), String::from); + let is_year_only = marky.metadata.get("yearonly").map_or(false, |a| a == "true"); + + let (year, month, day) = to_date_number(&date); + + let date_compare = year * 1200 + month * 100 + day; + + let mut date_printable = String::new(); + if is_year_only { + date_printable.push_str(&year.to_string()); + } else { + date_printable.push_str(&day.to_string()); + date_printable.push_str("-"); + date_printable.push_str(&month.to_string()); + date_printable.push_str("-"); + date_printable.push_str(&year.to_string()); + } + Post { title: marky.metadata.get("title").map_or(String::from("none"), String::from), - date: marky.metadata.get("date").map_or(String::from("none"), String::from), + date: date, + date_compare: date_compare, + date_printable: date_printable, url: marky.metadata.get("url").map_or(String::from("none"), String::from), - description: marky.metadata.get("description").map_or(String::from("none"), String::from), tags: tags_string_to_vec(marky.metadata.get("tags").map_or(String::from("none"), String::from)), is_year_only: marky.metadata.get("yearonly").map_or(false, |a| a == "true"), body: to_html(&marky.content), @@ -30,5 +50,20 @@ impl Post { } fn tags_string_to_vec(tags: String) -> Vec { - return tags.split(",").map(String::from).collect(); + return tags.split_whitespace().map(String::from).collect(); +} + +// Convert yyyy-MM-dd to yyyy, MM, dd +fn to_date_number(date: &String) -> (i32, i32, i32) { + let split: Vec<&str> = date.split("-").collect(); + + if split.len() == 0 { + return (0, 0, 0); + } + + let year = split[0].parse::().unwrap(); + let month = split[1].parse::().unwrap(); + let day = split[2].parse::().unwrap(); + + return (year, month, day); } \ No newline at end of file diff --git a/templates/article.hbs b/templates/article.hbs index 5bd8657..a5ed259 100644 --- a/templates/article.hbs +++ b/templates/article.hbs @@ -1,7 +1,12 @@

{{post.title}}

-
{{post.date}}
+
+ {{#each post.tags}} + {{this}} + {{/each}} +
+
{{post.date_printable}}

{{{post.body}}}
diff --git a/templates/submenu.hbs b/templates/submenu.hbs index b3dc490..ced3d14 100644 --- a/templates/submenu.hbs +++ b/templates/submenu.hbs @@ -7,7 +7,7 @@ {{#each section.posts}} {{this.title}} - + {{/each}}