Skip to content

Commit f01aa85

Browse files
authored
Merge pull request #406 from nikomatsakis/rust-team-blog
create the "Inside Rust" blog
2 parents a0a6fb7 + 012bde1 commit f01aa85

13 files changed

+172
-59
lines changed

Cargo.lock

Lines changed: 22 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ edition = "2018"
66

77
[dependencies]
88
handlebars = "1.1.0"
9+
lazy_static = "1.4.0"
910
serde = "1.0"
1011
serde_derive = "1.0"
1112
serde_yaml = "0.8"
1213
serde_json = "1.0"
1314
comrak = "0.4"
1415
fs_extra = "1.1.0"
16+
regex = "1.3"
1517
sass-rs = "0.2.1"
1618
time = "0.1.41"

posts/2018-01-03-new-years-rust-a-call-for-community-blogposts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "New Year's Rust: A Call for Community Blogposts"
33
author: "The Rust Core Team"
4+
layout: post
45
---
56

67
'Tis the season for people and communities to reflect and set goals- and the Rust team is

posts/2018-10-30-help-test-rust-2018.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "Help test Rust 2018"
33
author: "The Rust Core Team"
4+
layout: post
45
---
56

67
Back in July, we talked about ["Rust 2018"]. In short, we are launching a

posts/2019-10-03-inside-rust-blog.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: post
3+
title: "Announcing the Inside Rust blog"
4+
author: Niko Matsakis
5+
---
6+
7+
Today we're happy to announce that we're starting a second blog, the
8+
[**Inside Rust** blog][irb]. This blog will be used to post regular
9+
updates by the various Rust teams and working groups. If you're
10+
interested in following along with the "nitty gritty" of Rust
11+
development, then you should take a look!
12+
13+
[irb]: /inside-rust/index.html
14+

posts/blog.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
title: Rust Blog
22
index-title: The Rust Programming Language Blog
3+
link-text: the main Rust blog
34
description: Empowering everyone to build reliable and efficient software.
5+
index-html: This is the <b>main Rust blog</b>. The
6+
<a href="https://www.rust-lang.org/governance/teams/core">core team</a>
7+
uses this blog to announce big developments in the world of Rust.
48
maintained-by: the Rust Team
9+
requires-team: false
10+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
layout: post
3+
title: "Announcing the Inside Rust blog!"
4+
author: Niko Matsakis
5+
description: "A new blog where the Rust team can post updates on the latest developments"
6+
team: the core team <https://www.rust-lang.org/governance/teams/core>
7+
---
8+
9+
Welcome to the inaugural post of the **Inside Rust** blog! This is a
10+
new blog where the various Rust teams and working groups can post
11+
updates about new developments. It's a great place to watch if you're
12+
interested in following along with Rust development -- and a
13+
particularly great place to watch if you're interested in contributing
14+
to Rust. Expect to see updates on new projects, calls for help, design
15+
notes, and other similar items. Thanks for reading!
16+

posts/inside-rust/blog.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: Inside Rust Blog
2+
index-title: The "Inside Rust" Blog
3+
link-text: the "Inside Rust" blog
4+
description: Want to follow along with Rust development? Curious how you might get involved? Take a look!
5+
index-html: This is the <b>"Inside Rust"</b> blog. This blog is aimed at those who wish
6+
to follow along with Rust development. The various
7+
<a href="https://www.rust-lang.org/governance">Rust teams and working groups</a>
8+
use this blog to post status updates, calls for help, and other
9+
similar announcements.
10+
maintained-by: the Rust Teams
11+
requires-team: true

src/blogs.rs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,38 @@ static POSTS_EXT: &str = "md";
88

99
#[derive(Deserialize)]
1010
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
11-
struct Manifest {
12-
title: String,
13-
index_title: String,
14-
description: String,
15-
maintained_by: String,
11+
pub(crate) struct Manifest {
12+
/// Title to display in the "top row".
13+
pub(crate) title: String,
14+
15+
/// Title to use in the html header.
16+
pub(crate) index_title: String,
17+
18+
/// Description for metadata
19+
pub(crate) description: String,
20+
21+
/// Who maintains this blog? Appears in the rss feed.
22+
pub(crate) maintained_by: String,
23+
24+
/// Raw html describing the blog to insert into the index page.
25+
pub(crate) index_html: String,
26+
27+
/// If true, posts require a `team` in their metadata.
28+
pub(crate) requires_team: bool,
29+
30+
/// What text to use when linking to this blog in the "see also"
31+
/// section from other blogs.
32+
pub(crate) link_text: String,
1633
}
1734

1835
#[derive(Serialize)]
1936
pub(crate) struct Blog {
2037
title: String,
2138
index_title: String,
39+
link_text: String,
2240
description: String,
2341
maintained_by: String,
42+
index_html: String,
2443
#[serde(serialize_with = "add_postfix_slash")]
2544
prefix: PathBuf,
2645
posts: Vec<Post>,
@@ -36,7 +55,7 @@ impl Blog {
3655
let path = entry?.path();
3756
let ext = path.extension().and_then(|e| e.to_str());
3857
if path.metadata()?.file_type().is_file() && ext == Some(POSTS_EXT) {
39-
posts.push(Post::open(&path)?);
58+
posts.push(Post::open(&path, &manifest)?);
4059
}
4160
}
4261

@@ -54,6 +73,8 @@ impl Blog {
5473
index_title: manifest.index_title,
5574
description: manifest.description,
5675
maintained_by: manifest.maintained_by,
76+
index_html: manifest.index_html,
77+
link_text: manifest.link_text,
5778
prefix,
5879
posts,
5980
})
@@ -63,6 +84,10 @@ impl Blog {
6384
&self.title
6485
}
6586

87+
pub(crate) fn link_text(&self) -> &str {
88+
&self.link_text
89+
}
90+
6691
pub(crate) fn index_title(&self) -> &str {
6792
&self.index_title
6893
}

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,18 @@ impl Generator {
131131
}
132132

133133
fn render_index(&self, blog: &Blog) -> Result<(), Box<dyn Error>> {
134+
let other_blogs: Vec<_> = self.blogs.iter().filter(|b| b.index_title() != blog.index_title())
135+
.map(|other_blog| json!({
136+
"link_text": other_blog.link_text(),
137+
"url": PathBuf::from("/").join(other_blog.prefix()).join("index.html"),
138+
}))
139+
.collect();
140+
134141
let data = json!({
135142
"title": blog.index_title(),
136143
"parent": "layout",
137144
"blog": blog,
145+
"other_blogs": other_blogs,
138146
});
139147
self.render_template(blog.prefix().join("index.html"), "index", data)?;
140148
Ok(())
@@ -159,7 +167,7 @@ impl Generator {
159167
"post": post,
160168
});
161169

162-
self.render_template(path.join(filename), "post", data)?;
170+
self.render_template(path.join(filename), &post.layout, data)?;
163171
Ok(())
164172
}
165173

0 commit comments

Comments
 (0)