Skip to content

Commit cbab620

Browse files
authored
Merge pull request #2202
Add archived teams to the website
2 parents 7d45f7b + 9d6a63c commit cbab620

File tree

10 files changed

+154
-27
lines changed

10 files changed

+154
-27
lines changed

locales/en-US/governance.ftl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ governance-rfc-blurb = Each major decision in Rust starts as a Request for Comme
1111
governance-teams-header = Teams
1212
governance-wgs-header = Working Groups
1313
14+
governance-archived-teams-header = Archived teams
15+
governance-archived-teams-description = Some past teams are no longer active. We call these "archived teams".
16+
governance-archived-teams-link = Show archived teams
17+
governance-archived-teams-title = Archived teams
18+
governance-archived-alumni-thanks = We want to thank all past members for their invaluable contributions!
19+
governance-archived-teams-intro = This page contains archived teams that are no longer active.
20+
1421
## governance/index-team.hbs
1522
governance-members = Members & Contacts
1623

src/i18n.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ impl TeamHelperParam {
129129

130130
fn english<'a>(&'a self, team: &'a serde_json::Value) -> &'a str {
131131
match self {
132-
TeamHelperParam::Name => team["website_data"]["name"].as_str().unwrap(),
133-
TeamHelperParam::Description => team["website_data"]["description"].as_str().unwrap(),
132+
TeamHelperParam::Name => team["website_data"]["name"]
133+
.as_str()
134+
.unwrap_or(team["name"].as_str().unwrap()),
135+
TeamHelperParam::Description => team["website_data"]["description"]
136+
.as_str()
137+
.unwrap_or_default(),
134138
TeamHelperParam::Role(role_id) => {
135139
for role in team["roles"].as_array().unwrap() {
136140
if role["id"] == *role_id {

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod redirect;
1717
mod render;
1818
mod rust_version;
1919
mod teams;
20+
mod utils;
2021

2122
const ZULIP_DOMAIN: &str = "https://rust-lang.zulipchat.com";
2223

src/render.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ pub fn render_governance(render_ctx: &RenderCtx) -> anyhow::Result<()> {
207207
)?;
208208
}
209209

210+
let archived_teams_data = render_ctx.teams.archived_teams();
211+
for_all_langs("governance/archived-teams.html", |dst_path, lang| {
212+
render_ctx
213+
.page(
214+
"governance/archived-teams",
215+
"governance-archived-teams-title",
216+
&archived_teams_data,
217+
lang,
218+
)
219+
.render(dst_path)
220+
})?;
221+
210222
Ok(())
211223
}
212224

src/rust_version.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::utils::fetch;
2+
13
static MANIFEST_URL: &str = "https://static.rust-lang.org/dist/channel-rust-stable.toml";
24

35
#[derive(Debug, Clone)]
@@ -6,16 +8,10 @@ pub struct RustVersion(pub String);
68
/// Fetch the latest stable version of Rust.
79
pub fn fetch_rust_version() -> anyhow::Result<RustVersion> {
810
println!("Downloading Rust version");
9-
let mut response = ureq::get(MANIFEST_URL).call()?;
10-
if !response.status().is_success() {
11-
return Err(anyhow::anyhow!(
12-
"Failed to download Rust version (HTTP status {}): {}",
13-
response.status(),
14-
response.body_mut().read_to_string()?
15-
));
16-
}
1711

18-
let manifest: toml::Value = toml::from_str(&response.body_mut().read_to_string()?)?;
12+
let response = fetch(MANIFEST_URL)?;
13+
14+
let manifest: toml::Value = toml::from_str(&response)?;
1915
let rust_version = manifest["pkg"]["rust"]["version"].as_str().unwrap();
2016
let version: String = rust_version.split(' ').next().unwrap().to_owned();
2117
Ok(RustVersion(version))

src/teams.rs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::utils::fetch;
12
use handlebars::{
23
Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderErrorReason,
34
};
@@ -48,17 +49,23 @@ pub fn encode_zulip_stream(
4849
}
4950

5051
#[derive(Debug, Clone)]
51-
pub struct RustTeams(pub Vec<Team>);
52+
pub struct RustTeams {
53+
pub teams: Vec<Team>,
54+
pub archived_teams: Vec<Team>,
55+
}
5256

5357
impl RustTeams {
5458
#[cfg(test)]
5559
fn dummy(teams: Vec<Team>) -> Self {
56-
RustTeams(teams)
60+
RustTeams {
61+
teams,
62+
archived_teams: vec![],
63+
}
5764
}
5865

5966
pub fn index_data(&self) -> IndexData {
6067
let mut teams = self
61-
.0
68+
.teams
6269
.clone()
6370
.into_iter()
6471
.filter(|team| team.website_data.is_some())
@@ -84,7 +91,7 @@ impl RustTeams {
8491
}
8592

8693
pub fn page_data(&self, section: &str, team_page_name: &str) -> anyhow::Result<PageData> {
87-
let teams = self.0.clone();
94+
let teams = self.teams.clone();
8895

8996
// Find the main team first
9097
let main_team = teams
@@ -187,6 +194,16 @@ impl RustTeams {
187194
other_teams,
188195
})
189196
}
197+
198+
pub fn archived_teams(&self) -> ArchivedTeams {
199+
let mut teams: Vec<Team> = self.archived_teams.clone();
200+
teams.sort_by_key(|t| {
201+
let weight = t.website_data.as_ref().map(|d| d.weight).unwrap_or(0);
202+
(Reverse(weight), t.name.clone())
203+
});
204+
205+
ArchivedTeams { teams }
206+
}
190207
}
191208

192209
#[derive(Serialize)]
@@ -214,21 +231,32 @@ pub struct PageData {
214231
other_teams: Vec<Team>,
215232
}
216233

234+
#[derive(Serialize)]
235+
pub struct ArchivedTeams {
236+
teams: Vec<Team>,
237+
}
238+
217239
pub fn load_rust_teams() -> anyhow::Result<RustTeams> {
218240
println!("Downloading Team API data");
219241

220-
let mut response = ureq::get(format!("{BASE_URL}/teams.json")).call()?;
221-
if !response.status().is_success() {
222-
return Err(anyhow::anyhow!(
223-
"Failed to download team API (HTTP status {}): {}",
224-
response.status(),
225-
response.body_mut().read_to_string()?
226-
));
227-
}
228-
229-
let resp: Teams = response.body_mut().read_json()?;
230-
231-
Ok(RustTeams(resp.teams.into_values().collect()))
242+
// Parallelize the download to make website build faster
243+
let (teams, archived_teams) = std::thread::scope(|scope| {
244+
let teams = scope.spawn(|| -> anyhow::Result<Teams> {
245+
let response = fetch(&format!("{BASE_URL}/teams.json"))?;
246+
Ok(serde_json::from_str(&response)?)
247+
});
248+
let archived_teams = scope.spawn(|| -> anyhow::Result<Teams> {
249+
let response = fetch(&format!("{BASE_URL}/archived-teams.json"))?;
250+
Ok(serde_json::from_str(&response)?)
251+
});
252+
(teams.join().unwrap(), archived_teams.join().unwrap())
253+
});
254+
let (teams, archived_teams) = (teams?, archived_teams?);
255+
256+
Ok(RustTeams {
257+
teams: teams.teams.into_values().collect(),
258+
archived_teams: archived_teams.teams.into_values().collect(),
259+
})
232260
}
233261

234262
pub(crate) fn kind_to_str(kind: TeamKind) -> &'static str {

src/utils.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Send a GET request to the given `url` and return the result as a string
2+
pub fn fetch(url: &str) -> anyhow::Result<String> {
3+
let mut response = ureq::get(url).call()?;
4+
if !response.status().is_success() {
5+
return Err(anyhow::anyhow!(
6+
"Failed to download data from `{url}` (HTTP status {}): {}",
7+
response.status(),
8+
response.body_mut().read_to_string()?
9+
));
10+
}
11+
12+
Ok(response.body_mut().read_to_string()?)
13+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<a id="team-{{team.name}}"></a>
2+
<div class="w-100 mw-none mw-8-m mw9-l ph3 center f3">
3+
<header class="pb0 pt5">
4+
<a class="linkable-subheading" href="#team-{{team.name}}">
5+
<h2>{{team-text team name}}</h2>
6+
</a>
7+
<div class="highlight"></div>
8+
</header>
9+
<div>
10+
<div class="mv4 flex flex-column flex-row-l justify-between">
11+
<p class="ma0 f2">{{team-text team description}}</p>
12+
</div>
13+
</div>
14+
{{#if team.alumni}}
15+
<div class="flex flex-column flex-row-l flex-wrap-l justify-start">
16+
{{#each team.alumni as |member|}}
17+
<div class="w-100 w-33-l mb3 flex flex-row items-center">
18+
<a class="mr4 w3 h3 flex-shrink-0" href="https://github.com/{{member.github}}">
19+
<img class="w-100 h-100 bg-white br2"
20+
src="https://avatars.githubusercontent.com/{{member.github}}"
21+
alt="{{member.name}}">
22+
</a>
23+
<div>
24+
{{member.name}}
25+
<div class="f4">
26+
GitHub: <a href="https://github.com/{{member.github}}">{{member.github}}</a>
27+
</div>
28+
{{#if member.roles}}
29+
<div class="f4">{{team-text ../team role (lookup member.roles 0)}}</div>
30+
{{/if}}
31+
</div>
32+
</div>
33+
{{/each}}
34+
</div>
35+
{{/if}}
36+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{#*inline "page"}}
2+
<section class="green" style="padding-bottom: 10px;">
3+
<div class="w-100 mw-none mw-8-m mw9-l center f2">
4+
<p>{{fluent "governance-archived-teams-intro"}} {{fluent "governance-archived-alumni-thanks"}}</p>
5+
</div>
6+
</section>
7+
8+
{{#each data.teams as |team|}}
9+
<section class="green" style="padding-bottom: 15px;">
10+
{{> governance/archived-team team=team}}
11+
</section>
12+
{{/each}}
13+
14+
{{/inline}}
15+
{{~> (lookup this "parent")~}}

templates/governance/index.html.hbs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,20 @@
3737
</div>
3838
</section>
3939

40+
<section id="archived-teams" class="green">
41+
<div class="w-100 mw-none ph3 mw-8-m mw9-l center f3">
42+
<header>
43+
<h2>{{fluent "governance-archived-teams-header"}}</h2>
44+
<div class="highlight"></div>
45+
</header>
46+
<div class="mb2">{{fluent "governance-archived-teams-description"}}</div>
47+
48+
<a href="{{baseurl}}/governance/archived-teams.html" class="center w-100 mw6 button button-secondary">
49+
{{fluent "governance-archived-teams-link"}}
50+
</a>
51+
</div>
52+
</div>
53+
</section>
54+
4055
{{/inline}}
4156
{{~> (lookup this "parent")~}}

0 commit comments

Comments
 (0)