Skip to content

create the "Inside Rust" blog #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 22 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ edition = "2018"

[dependencies]
handlebars = "1.1.0"
lazy_static = "1.4.0"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.8"
serde_json = "1.0"
comrak = "0.4"
fs_extra = "1.1.0"
regex = "1.3"
sass-rs = "0.2.1"
time = "0.1.41"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "New Year's Rust: A Call for Community Blogposts"
author: "The Rust Core Team"
layout: post
---

'Tis the season for people and communities to reflect and set goals- and the Rust team is
Expand Down
1 change: 1 addition & 0 deletions posts/2018-10-30-help-test-rust-2018.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Help test Rust 2018"
author: "The Rust Core Team"
layout: post
---

Back in July, we talked about ["Rust 2018"]. In short, we are launching a
Expand Down
14 changes: 14 additions & 0 deletions posts/2019-10-03-inside-rust-blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
layout: post
title: "Announcing the Inside Rust blog"
author: Niko Matsakis
---

Today we're happy to announce that we're starting a second blog, the
[**Inside Rust** blog][irb]. This blog will be used to post regular
updates by the various Rust teams and working groups. If you're
interested in following along with the "nitty gritty" of Rust
development, then you should take a look!

[irb]: /inside-rust/index.html

6 changes: 6 additions & 0 deletions posts/blog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
title: Rust Blog
index-title: The Rust Programming Language Blog
link-text: the main Rust blog
description: Empowering everyone to build reliable and efficient software.
index-html: This is the <b>main Rust blog</b>. The
<a href="https://www.rust-lang.org/governance/teams/core">core team</a>
uses this blog to announce big developments in the world of Rust.
maintained-by: the Rust Team
requires-team: false

16 changes: 16 additions & 0 deletions posts/inside-rust/2019-09-25-Welcome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: post
title: "Announcing the Inside Rust blog!"
author: Niko Matsakis
description: "A new blog where the Rust team can post updates on the latest developments"
team: the core team <https://www.rust-lang.org/governance/teams/core>
---

Welcome to the inaugural post of the **Inside Rust** blog! This is a
new blog where the various Rust teams and working groups can post
updates about new developments. It's a great place to watch if you're
interested in following along with Rust development -- and a
particularly great place to watch if you're interested in contributing
to Rust. Expect to see updates on new projects, calls for help, design
notes, and other similar items. Thanks for reading!

11 changes: 11 additions & 0 deletions posts/inside-rust/blog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Inside Rust Blog
index-title: The "Inside Rust" Blog
link-text: the "Inside Rust" blog
description: Want to follow along with Rust development? Curious how you might get involved? Take a look!
index-html: This is the <b>"Inside Rust"</b> blog. This blog is aimed at those who wish
to follow along with Rust development. The various
<a href="https://www.rust-lang.org/governance">Rust teams and working groups</a>
use this blog to post status updates, calls for help, and other
similar announcements.
maintained-by: the Rust Teams
requires-team: true
37 changes: 31 additions & 6 deletions src/blogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,38 @@ static POSTS_EXT: &str = "md";

#[derive(Deserialize)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
struct Manifest {
title: String,
index_title: String,
description: String,
maintained_by: String,
pub(crate) struct Manifest {
/// Title to display in the "top row".
pub(crate) title: String,

/// Title to use in the html header.
pub(crate) index_title: String,

/// Description for metadata
pub(crate) description: String,

/// Who maintains this blog? Appears in the rss feed.
pub(crate) maintained_by: String,

/// Raw html describing the blog to insert into the index page.
pub(crate) index_html: String,

/// If true, posts require a `team` in their metadata.
pub(crate) requires_team: bool,

/// What text to use when linking to this blog in the "see also"
/// section from other blogs.
pub(crate) link_text: String,
}

#[derive(Serialize)]
pub(crate) struct Blog {
title: String,
index_title: String,
link_text: String,
description: String,
maintained_by: String,
index_html: String,
#[serde(serialize_with = "add_postfix_slash")]
prefix: PathBuf,
posts: Vec<Post>,
Expand All @@ -36,7 +55,7 @@ impl Blog {
let path = entry?.path();
let ext = path.extension().and_then(|e| e.to_str());
if path.metadata()?.file_type().is_file() && ext == Some(POSTS_EXT) {
posts.push(Post::open(&path)?);
posts.push(Post::open(&path, &manifest)?);
}
}

Expand All @@ -54,6 +73,8 @@ impl Blog {
index_title: manifest.index_title,
description: manifest.description,
maintained_by: manifest.maintained_by,
index_html: manifest.index_html,
link_text: manifest.link_text,
prefix,
posts,
})
Expand All @@ -63,6 +84,10 @@ impl Blog {
&self.title
}

pub(crate) fn link_text(&self) -> &str {
&self.link_text
}

pub(crate) fn index_title(&self) -> &str {
&self.index_title
}
Expand Down
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ impl Generator {
}

fn render_index(&self, blog: &Blog) -> Result<(), Box<dyn Error>> {
let other_blogs: Vec<_> = self.blogs.iter().filter(|b| b.index_title() != blog.index_title())
.map(|other_blog| json!({
"link_text": other_blog.link_text(),
"url": PathBuf::from("/").join(other_blog.prefix()).join("index.html"),
}))
.collect();

let data = json!({
"title": blog.index_title(),
"parent": "layout",
"blog": blog,
"other_blogs": other_blogs,
});
self.render_template(blog.prefix().join("index.html"), "index", data)?;
Ok(())
Expand All @@ -159,7 +167,7 @@ impl Generator {
"post": post,
});

self.render_template(path.join(filename), "post", data)?;
self.render_template(path.join(filename), &post.layout, data)?;
Ok(())
}

Expand Down
Loading