From ef99d3ebc92767e0af6f0c039de457db32abc8cb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 8 Jan 2024 11:33:42 -0800 Subject: [PATCH] Render custom roles --- Cargo.lock | 5 ++--- locales/en-US/teams.ftl | 2 ++ src/main.rs | 6 ++++++ src/teams.rs | 13 +++++++++++-- templates/governance/group-team.html.hbs | 4 ++++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a8439c3..ccc395ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,7 +708,6 @@ checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -1496,9 +1495,9 @@ dependencies = [ [[package]] name = "rust_team_data" version = "1.0.0" -source = "git+https://github.com/rust-lang/team#811f92f4395068e1b826b208fd7f2ba677abd452" +source = "git+https://github.com/rust-lang/team#3e3704e7655c881533306ef09f077786e47eeda4" dependencies = [ - "indexmap 1.9.1", + "indexmap 2.1.0", "serde", ] diff --git a/locales/en-US/teams.ftl b/locales/en-US/teams.ftl index ca662320..59a24ed9 100644 --- a/locales/en-US/teams.ftl +++ b/locales/en-US/teams.ftl @@ -289,3 +289,5 @@ governance-team-wg-triage-description = Triaging repositories under the rust-lan governance-team-wg-wasm-name = WebAssembly (WASM) working group governance-team-wg-wasm-description = Improving on the end-to-end experience of embedding Rust code in JS libraries and apps via WebAssembly + +governance-role-spec-editor = Editor diff --git a/src/main.rs b/src/main.rs index 24decf08..fd4638fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,7 @@ use sass_rs::{compile_file, Options}; use category::Category; use caching::CachedNamedFile; +use handlebars::handlebars_helper; use handlebars_fluent::{loader::Loader, FluentHelper}; use i18n::{create_loader, LocaleInfo, SupportedLocale, TeamHelper, EXPLICIT_LOCALE_INFO}; @@ -491,6 +492,11 @@ async fn rocket() -> _ { engine .handlebars .register_helper("encode-zulip-stream", Box::new(encode_zulip_stream)); + + handlebars_helper!(concat: |x: String, y: String| x + &y); + engine + .handlebars + .register_helper("concat", Box::new(concat)); }); let rust_version = RustVersion::fetch().await.unwrap_or_default(); diff --git a/src/teams.rs b/src/teams.rs index fd38626b..37492967 100644 --- a/src/teams.rs +++ b/src/teams.rs @@ -298,17 +298,26 @@ mod tests { kind: TeamKind::Team, subteam_of: None, members: vec![ + TeamMember { + name: "Jupiter Doe".into(), + github: "jupiterd".into(), + github_id: 123, + is_lead: false, + roles: vec!["convener".to_owned()], + }, TeamMember { name: "John Doe".into(), github: "johnd".into(), + github_id: 456, is_lead: false, - github_id: 1234, + roles: Vec::new(), }, TeamMember { name: "Jane Doe".into(), github: "janed".into(), + github_id: 789, is_lead: true, - github_id: 1234, + roles: Vec::new(), }, ], alumni: Vec::new(), diff --git a/templates/governance/group-team.html.hbs b/templates/governance/group-team.html.hbs index 670037b2..257ebed3 100644 --- a/templates/governance/group-team.html.hbs +++ b/templates/governance/group-team.html.hbs @@ -60,6 +60,10 @@ {{#if member.is_lead}}
{{fluent "governance-user-team-leader"}}
+ {{else}} + {{#if member.roles}} +
{{fluent (concat "governance-role-" (lookup member.roles 0))}}
+ {{/if}} {{/if}}