From 9d4224aef37901d0adf998cffea5dae69a0eca67 Mon Sep 17 00:00:00 2001 From: Maieul BOYER Date: Sun, 8 Feb 2026 14:39:04 +0100 Subject: [PATCH] chore(templates:example): added some better examples --- froxy-templates/examples/index.rs | 117 +++++++++++++++++++++++++++- froxy-templates/examples/profile.rs | 11 --- 2 files changed, 116 insertions(+), 12 deletions(-) diff --git a/froxy-templates/examples/index.rs b/froxy-templates/examples/index.rs index ab9bdd5..bbdafe4 100644 --- a/froxy-templates/examples/index.rs +++ b/froxy-templates/examples/index.rs @@ -66,7 +66,122 @@ fn main() { .to_vec(), }, }, - )]), + ), +( + SmolStr::new_static("F3"), + ClusterData { + users: 80, + max_pc: 400, + dead_pc: 1, + silent: false, + piscine: false, + issues: [ + (SmolStr::new_static("F1r1s1"), PcIssue::Dead), + (SmolStr::new_static("F1r2s1"), PcIssue::Attention), + ] + .into_iter() + .collect(), + map: index::Map { + rows: [ + index::MapRow { + range: SmolStr::new_static("R1"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Wall, + MapPos::Door, + MapPos::Empty, + ] + .to_vec(), + }, + index::MapRow { + range: SmolStr::new_static("R2"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Pc(SmolStr::new_static("F1r1s1")), + MapPos::Pc(SmolStr::new_static("F1r2s1")), + MapPos::Pc(SmolStr::new_static("F1r3s1")), + MapPos::Pc(SmolStr::new_static("F1r4s1")), + MapPos::Pc(SmolStr::new_static("F1r5s1")), + MapPos::Empty, + ] + .to_vec(), + }, + index::MapRow { + range: SmolStr::new_static("R3"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Wall, + MapPos::Door, + MapPos::Empty, + ] + .to_vec(), + }, + ] + .to_vec(), + }, + }, + ), +( + SmolStr::new_static("F2"), + ClusterData { + users: 180, + max_pc: 200, + dead_pc: 1, + silent: true, + piscine: true, + issues: [ + (SmolStr::new_static("F1r1s1"), PcIssue::Dead), + (SmolStr::new_static("F1r2s1"), PcIssue::Attention), + ] + .into_iter() + .collect(), + map: index::Map { + rows: [ + index::MapRow { + range: SmolStr::new_static("R1"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Wall, + MapPos::Door, + MapPos::Empty, + ] + .to_vec(), + }, + index::MapRow { + range: SmolStr::new_static("R2"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Pc(SmolStr::new_static("F1r1s1")), + MapPos::Pc(SmolStr::new_static("F1r2s1")), + MapPos::Pc(SmolStr::new_static("F1r3s1")), + MapPos::Pc(SmolStr::new_static("F1r4s1")), + MapPos::Pc(SmolStr::new_static("F1r5s1")), + MapPos::Empty, + ] + .to_vec(), + }, + index::MapRow { + range: SmolStr::new_static("R3"), + col: [ + MapPos::Empty, + MapPos::Flex, + MapPos::Wall, + MapPos::Door, + MapPos::Empty, + ] + .to_vec(), + }, + ] + .to_vec(), + }, + }, + ) + ]), locations: [(SmolStr::new_static("F1r5s1"), LocationData { login: "maiboyer".into(), image: "https://friends.42paris.fr/proxy/resize/512/03c61af252becbca11aac5ff49a2e61c/maiboyer.jpg".into(), diff --git a/froxy-templates/examples/profile.rs b/froxy-templates/examples/profile.rs index 1bf1b7f..b7fd1e6 100644 --- a/froxy-templates/examples/profile.rs +++ b/froxy-templates/examples/profile.rs @@ -1,17 +1,6 @@ use froxy_templates::profile::{self}; use smol_str::SmolStr; -/* -{ - friends: std::array::from_fn::<_, 10, _>(|i| Friend { - name: "maiboyer".into(), - image: "https://friends.42paris.fr/proxy/resize/512/03c61af252becbca11aac5ff49a2e61c/maiboyer.jpg".into(), - position: (i < 5).then_some("f1r1s1".into()), - last_active: (i > 6).then_some("Last thuesday".into()), - }).to_vec(), - } -*/ - fn main() { let mut env = minijinja::Environment::new(); profile::add_to_context(&mut env);