Skip to content

Commit ecc9c61

Browse files
Merge pull request #1 from rust-lang/partials
feat(layout)
2 parents 80c877f + 153dd51 commit ecc9c61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+504
-143
lines changed

Cargo.lock

Lines changed: 55 additions & 0 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,6 +6,8 @@ authors = ["Ashley Williams <[email protected]>"]
66
[dependencies]
77
rocket = "0.3.6"
88
rocket_codegen = "0.3.6"
9+
serde = "1.0"
10+
serde_derive = "1.0"
911

1012
[dependencies.rocket_contrib]
1113
version = "*"

src/main.rs

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,67 @@
11
#![feature(plugin)]
22
#![plugin(rocket_codegen)]
33

4-
extern crate rocket_contrib;
54
extern crate rocket;
65

6+
extern crate rocket_contrib;
7+
#[macro_use] extern crate serde_derive;
8+
9+
use std::io;
10+
use std::path::{Path, PathBuf};
11+
712
use rocket_contrib::Template;
13+
use rocket::response::NamedFile;
14+
15+
#[derive(Serialize)]
16+
struct Context {
17+
page: String,
18+
title: String,
19+
parent: String,
20+
}
821

922
#[get("/")]
1023
fn index() -> Template {
11-
let context = {};
12-
Template::render("index", &context)
24+
let page = "index".to_string();
25+
let title = format!("Rust - {}", page).to_string();
26+
let context = Context {
27+
page: "index".to_string(),
28+
title: title,
29+
parent: "layout".to_string(),
30+
};
31+
Template::render(page, &context)
32+
}
33+
34+
#[get("/static/<file..>", rank = 1)]
35+
fn files(file: PathBuf) -> Option<NamedFile> {
36+
NamedFile::open(Path::new("static/").join(file)).ok()
1337
}
1438

1539
#[get("/<category>")]
1640
fn category(category: String) -> Template {
17-
let context = {};
18-
let path = format!("{}/index", category.as_str());
19-
Template::render(path, &context)
41+
let page = format!("{}/index", category.as_str()).to_string();
42+
let title = format!("Rust - {}", page).to_string();
43+
let context = Context {
44+
page: category,
45+
title: title,
46+
parent: "layout".to_string(),
47+
};
48+
Template::render(page, &context)
2049
}
2150

22-
#[get("/<category>/<subject>")]
51+
#[get("/<category>/<subject>", rank = 2)]
2352
fn subject(category: String, subject: String) -> Template {
24-
let context = {};
25-
let path = format!("{}/{}", category.as_str(), subject.as_str());
26-
Template::render(path, &context)
53+
let page = format!("{}/{}", category.as_str(), subject.as_str()).to_string();
54+
let title = format!("Rust - {}", page).to_string();
55+
let context = Context {
56+
page: subject,
57+
title: title,
58+
parent: "layout".to_string(),
59+
};
60+
Template::render(page, &context)
2761
}
2862

2963
fn main() {
3064
rocket::ignite()
3165
.attach(Template::fairing())
32-
.mount("/", routes![index, category, subject]).launch();
66+
.mount("/", routes![index, category, subject, files]).launch();
3367
}

static/favicon.ico

1.12 KB
Binary file not shown.

static/skeleton.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
body {
2+
font-family: sans-serif;
3+
}
4+
5+
section, header, footer, nav {
6+
border: 1px dashed black;
7+
padding: 10px;
8+
margin: 10px auto;
9+
width: 80%;
10+
}
11+
12+
header, footer {
13+
background: black;
14+
color: white;
15+
}
16+
17+
nav {
18+
background: grey;
19+
color: white;
20+
}
21+
22+
header .subtitle {
23+
font-style: italic;
24+
}
25+
26+
div {
27+
border: 1px dotted grey;
28+
padding: 5px;
29+
margin: 5px;
30+
}

templates/community/content.hbs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
<a href="/community">⬅️ back to Community</a>
1+
{{#* inline "page"}}
22

3-
<h1>Content</h1>
3+
<section>
4+
<h1>Content</h1>
5+
</section>
6+
7+
{{/inline}}
8+
{{~> (parent)~}}

templates/community/events.hbs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
<a href="/community">⬅️ back to Community</a>
1+
{{#* inline "page"}}
22

3-
<h1>Events</h1>
3+
<section>
4+
<h1>Events</h1>
5+
</section>
6+
7+
{{/inline}}
8+
{{~> (parent)~}}

templates/community/index.hbs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
<a href="/">⬅️ back to Home</a>
1+
{{#*inline "page"}}
22

3-
<h1>Community</h1>
3+
<header>
4+
<h1>Community</h1>
5+
</header>
46

57
<section id="events">
68
<h2>Events</h2>
79
<p>teaser copy</p>
810
<h3><a href="/community/events">Learn More</a></h3>
9-
<section>
10-
11-
<hr/>
11+
</section>
1212

1313
<section id="content">
1414
<h2>Content</h2>
1515
<p>teaser copy</p>
1616
<h3><a href="/community/content">Learn More</a></h3>
1717
</section>
1818

19-
<hr/>
20-
2119
<section id="rustbridge">
2220
<h2>Rust Bridge</h2>
2321
<p>teaser copy</p>
2422
<h3><a href="/learn/rustbridge">Learn More</a></h3>
25-
<section>
23+
</section>
24+
25+
{{/inline}}
26+
{{~> (parent)~}}

templates/contribute/index.hbs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<a href="/">⬅️ back to Home</a>
1+
{{#*inline "page"}}
22

3-
<h1>Contribute</h1>
3+
<header>
4+
<h1>Contribute</h1>
5+
</header>
46

5-
<p>Copy about getting involved</p>
6-
<p>Learn more about Rust's <a href="/governance">governance</a>
7-
<p>Learn more about Rust's <a href="/policies/code-of-conduct">Code of Conduct</a>
8-
9-
<hr/>
7+
<section>
8+
<p>Copy about getting involved</p>
9+
<p>Learn more about Rust's <a href="/governance">governance</a>
10+
<p>Learn more about Rust's <a href="/policies/code-of-conduct">Code of Conduct</a>
11+
</section>
1012

1113
<section id="talk">
1214
<h2>Where to Talk</h2>
@@ -18,11 +20,12 @@
1820
<a href="#">Gitter</a>
1921
</section>
2022

21-
<hr/>
22-
2323
<section id="code">
2424
<h2>Where to Code</h2>
2525
<p>copy</p>
2626
<a href="/contribute/nursery">Rust Nursey</a>
2727
<a href="#">Rust Github</a>
2828
</section>
29+
30+
{{/inline}}
31+
{{~> (parent)~}}

templates/contribute/nursery.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{#*inline "page"}}
2+
3+
<section>
4+
<h1>Nursery</h1>
5+
</section>
6+
7+
{{/inline}}
8+
{{~> (parent)~}}

templates/contribute/where-to-code.hbs

Whitespace-only changes.

templates/contribute/where-to-talk.hbs

Whitespace-only changes.

templates/footer.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<footer>
2+
<a href="#">footer links and stuff</a>
3+
<a href="/policies/code-of-conduct">Code of Conduct</a>
4+
<a href="/policies/code-of-conduct">Security</a>
5+
</footer>

templates/governance/index.hbs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
<a href="/">⬅️ back to Home</a>
1+
{{#*inline "page"}}
22

3-
<h1>Governance</h1>
3+
<header>
4+
<h1>Governance</h1>
5+
</header>
46

57
<section id="governance">
68
<h2>Governance</h2>
79
<p>copy about how rust is governed</p>
810
</section>
911

10-
</hr>
11-
1212
<section id="teams">
1313
<h2>Teams</h2>
1414
<p>teaser copy</p>
1515
<div id="core-team">
1616
<h3>Core Team</h3>
1717
</div>
1818
<div id="teams">
19-
<h3>All the other teams</h3>
20-
<p>link to each team's page</p>
19+
<h3><a href="/governance/teams">Teams</a></h3>
2120
</div>
22-
<section>
23-
24-
</hr>
21+
</section>
2522

2623
<section id="roadmap">
2724
<h2>Roadmap</h2>
2825
<p>Some text about the roadmap and a link to the RFC.</p>
29-
<h3>Learn more about Rust's<a href="what/language-values">Values</a></h3>
26+
<h3>Learn more about Rust's <a href="what/language-values">Values</a></h3>
3027
</section>
3128

32-
</hr>
33-
3429
<section id="code-of-conduct">
3530
<h2>Code of Conduct</h2>
3631
<p>Maybe talk about leadership values here</p>
3732
<h3><a href="/policies/code-of-conduct">Code of Conduct</a></h3>
3833
</section>
34+
35+
{{/inline}}
36+
{{~> (parent)~}}

templates/governance/roadmap.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{#*inline "page"}}
2+
3+
<section>
4+
<h1>Roadmap</h1>
5+
</section>
6+
7+
{{/inline}}
8+
{{~> (parent)~}}

0 commit comments

Comments
 (0)