diff --git a/froxy-templates/examples/profile.rs b/froxy-templates/examples/profile.rs new file mode 100644 index 0000000..1bf1b7f --- /dev/null +++ b/froxy-templates/examples/profile.rs @@ -0,0 +1,38 @@ +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); + let data = profile::render( + &env, + profile::ProfileData { + user: profile::ProfileUser { + position: Some(SmolStr::new_static("f1r1s1")), + last_active: None, + image: "https://friends.42paris.fr/proxy/resize/512/03c61af252becbca11aac5ff49a2e61c/maiboyer.jpg".into(), + name: SmolStr::new_static("maiboyer"), + pool: None, //Some(SmolStr::new_static("August 2025")), + is_friend: false, + github: Some("https://github.com/Maix0".to_string()), + website: None, //Some("https://maix.me".to_string()), + discord: None,// Some("maix".to_string()), + recit: Some("Yes".to_string()), + }, + }, + ) + .unwrap(); + + println!("{data}"); +} diff --git a/froxy-templates/src/profile.rs b/froxy-templates/src/profile.rs index ef5f924..efa7e5c 100644 --- a/froxy-templates/src/profile.rs +++ b/froxy-templates/src/profile.rs @@ -21,13 +21,11 @@ pub fn render(env: &minijinja::Environment, data: ProfileData) -> Result, - pub last_active: SmolStr, + pub last_active: Option, pub image: String, pub name: SmolStr, pub pool: Option, - pub id: u64, pub is_friend: bool, - pub is_self: bool, pub github: Option, pub website: Option, diff --git a/froxy-templates/src/templates/profile.html b/froxy-templates/src/templates/profile.html index 936fddf..c3d1015 100644 --- a/froxy-templates/src/templates/profile.html +++ b/froxy-templates/src/templates/profile.html @@ -22,32 +22,30 @@

{{ user.name }} - {% if 'None' not in user.pool %}Piscine de {{ user.pool }}{% endif %} + {% if user.pool %}Piscine de {{ user.pool }}{% endif %}

- {{ user.position if user.position else 'Absent' }} {{ user.last_active }} + {{ user.position if user.position else "Absent" }} {{ user.last_active if user.last_active or ""}} {% if user.position %}{% endif %} - {% if !user.is_self %} - - - {% endif %} + +
-
{{ user.recit if user.recit and len(user.recit) > 0 else '' }}
+
{{ user.recit if user.recit and user.recit else '' }}