41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use smol_str::SmolStr;
|
|
|
|
pub use crate::templates::PROFILE as TEMPLATE;
|
|
|
|
pub fn add_to_context(env: &mut minijinja::Environment) {
|
|
if env.get_template("template.html").is_err() {
|
|
crate::meta_template::add_to_context(env);
|
|
}
|
|
if env.get_template("open_modal.html").is_err() {
|
|
crate::open_modal::add_to_context(env);
|
|
}
|
|
|
|
env.add_template("profile.html", TEMPLATE).unwrap();
|
|
}
|
|
|
|
pub fn render(env: &minijinja::Environment, data: ProfileData) -> Result<String, minijinja::Error> {
|
|
let template = env.get_template("profile.html")?;
|
|
template.render(data)
|
|
}
|
|
|
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
pub struct ProfileUser {
|
|
pub position: Option<SmolStr>,
|
|
pub last_active: Option<SmolStr>,
|
|
pub image: String,
|
|
pub name: SmolStr,
|
|
pub pool: Option<SmolStr>,
|
|
pub is_friend: bool,
|
|
|
|
pub github: Option<String>,
|
|
pub website: Option<String>,
|
|
pub discord: Option<String>,
|
|
|
|
/// profile description
|
|
pub recit: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
pub struct ProfileData {
|
|
pub user: ProfileUser,
|
|
}
|