index should almost be done
This commit is contained in:
parent
8e82ec9523
commit
bbc7cda33f
3 changed files with 269 additions and 63 deletions
86
froxy-templates/examples/index.rs
Normal file
86
froxy-templates/examples/index.rs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use froxy_templates::index::{self, ClusterData, IndexData, LocationData, MapPos, PcIssue};
|
||||
use smol_str::SmolStr;
|
||||
|
||||
fn main() {
|
||||
let mut env = minijinja::Environment::new();
|
||||
index::add_to_context(&mut env);
|
||||
|
||||
let data = index::render(
|
||||
&env,
|
||||
IndexData {
|
||||
clusters: HashMap::from([(
|
||||
SmolStr::new_static("F1"),
|
||||
ClusterData {
|
||||
users: 80,
|
||||
max_pc: 100,
|
||||
dead_pc: 1,
|
||||
silent: false,
|
||||
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(),
|
||||
me: false,
|
||||
friend: false,
|
||||
close_friend: false,
|
||||
pooled: false,
|
||||
})]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
current_cluster: SmolStr::new_static("F1"),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
println!("{data}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue