Skip to content

feat(layout) #1

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 1 commit into from
Feb 9, 2018
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
55 changes: 55 additions & 0 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,6 +6,8 @@ authors = ["Ashley Williams <[email protected]>"]
[dependencies]
rocket = "0.3.6"
rocket_codegen = "0.3.6"
serde = "1.0"
serde_derive = "1.0"

[dependencies.rocket_contrib]
version = "*"
Expand Down
56 changes: 45 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,67 @@
#![feature(plugin)]
#![plugin(rocket_codegen)]

extern crate rocket_contrib;
extern crate rocket;

extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;

use std::io;
use std::path::{Path, PathBuf};

use rocket_contrib::Template;
use rocket::response::NamedFile;

#[derive(Serialize)]
struct Context {
page: String,
title: String,
parent: String,
}

#[get("/")]
fn index() -> Template {
let context = {};
Template::render("index", &context)
let page = "index".to_string();
let title = format!("Rust - {}", page).to_string();
let context = Context {
page: "index".to_string(),
title: title,
parent: "layout".to_string(),
};
Template::render(page, &context)
}

#[get("/static/<file..>", rank = 1)]
fn files(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(file)).ok()
}

#[get("/<category>")]
fn category(category: String) -> Template {
let context = {};
let path = format!("{}/index", category.as_str());
Template::render(path, &context)
let page = format!("{}/index", category.as_str()).to_string();
let title = format!("Rust - {}", page).to_string();
let context = Context {
page: category,
title: title,
parent: "layout".to_string(),
};
Template::render(page, &context)
}

#[get("/<category>/<subject>")]
#[get("/<category>/<subject>", rank = 2)]
fn subject(category: String, subject: String) -> Template {
let context = {};
let path = format!("{}/{}", category.as_str(), subject.as_str());
Template::render(path, &context)
let page = format!("{}/{}", category.as_str(), subject.as_str()).to_string();
let title = format!("Rust - {}", page).to_string();
let context = Context {
page: subject,
title: title,
parent: "layout".to_string(),
};
Template::render(page, &context)
}

fn main() {
rocket::ignite()
.attach(Template::fairing())
.mount("/", routes![index, category, subject]).launch();
.mount("/", routes![index, category, subject, files]).launch();
}
Binary file added static/favicon.ico
Binary file not shown.
30 changes: 30 additions & 0 deletions static/skeleton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
body {
font-family: sans-serif;
}

section, header, footer, nav {
border: 1px dashed black;
padding: 10px;
margin: 10px auto;
width: 80%;
}

header, footer {
background: black;
color: white;
}

nav {
background: grey;
color: white;
}

header .subtitle {
font-style: italic;
}

div {
border: 1px dotted grey;
padding: 5px;
margin: 5px;
}
9 changes: 7 additions & 2 deletions templates/community/content.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a href="/community">⬅️ back to Community</a>
{{#* inline "page"}}

<h1>Content</h1>
<section>
<h1>Content</h1>
</section>

{{/inline}}
{{~> (parent)~}}
9 changes: 7 additions & 2 deletions templates/community/events.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a href="/community">⬅️ back to Community</a>
{{#* inline "page"}}

<h1>Events</h1>
<section>
<h1>Events</h1>
</section>

{{/inline}}
{{~> (parent)~}}
17 changes: 9 additions & 8 deletions templates/community/index.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<a href="/">⬅️ back to Home</a>
{{#*inline "page"}}

<h1>Community</h1>
<header>
<h1>Community</h1>
</header>

<section id="events">
<h2>Events</h2>
<p>teaser copy</p>
<h3><a href="/community/events">Learn More</a></h3>
<section>

<hr/>
</section>

<section id="content">
<h2>Content</h2>
<p>teaser copy</p>
<h3><a href="/community/content">Learn More</a></h3>
</section>

<hr/>

<section id="rustbridge">
<h2>Rust Bridge</h2>
<p>teaser copy</p>
<h3><a href="/learn/rustbridge">Learn More</a></h3>
<section>
</section>

{{/inline}}
{{~> (parent)~}}
21 changes: 12 additions & 9 deletions templates/contribute/index.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<a href="/">⬅️ back to Home</a>
{{#*inline "page"}}

<h1>Contribute</h1>
<header>
<h1>Contribute</h1>
</header>

<p>Copy about getting involved</p>
<p>Learn more about Rust's <a href="/governance">governance</a>
<p>Learn more about Rust's <a href="/policies/code-of-conduct">Code of Conduct</a>

<hr/>
<section>
<p>Copy about getting involved</p>
<p>Learn more about Rust's <a href="/governance">governance</a>
<p>Learn more about Rust's <a href="/policies/code-of-conduct">Code of Conduct</a>
</section>

<section id="talk">
<h2>Where to Talk</h2>
Expand All @@ -18,11 +20,12 @@
<a href="#">Gitter</a>
</section>

<hr/>

<section id="code">
<h2>Where to Code</h2>
<p>copy</p>
<a href="/contribute/nursery">Rust Nursey</a>
<a href="#">Rust Github</a>
</section>

{{/inline}}
{{~> (parent)~}}
8 changes: 8 additions & 0 deletions templates/contribute/nursery.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#*inline "page"}}

<section>
<h1>Nursery</h1>
</section>

{{/inline}}
{{~> (parent)~}}
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions templates/footer.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<footer>
<a href="#">footer links and stuff</a>
<a href="/policies/code-of-conduct">Code of Conduct</a>
<a href="/policies/code-of-conduct">Security</a>
</footer>
22 changes: 10 additions & 12 deletions templates/governance/index.hbs
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
<a href="/">⬅️ back to Home</a>
{{#*inline "page"}}

<h1>Governance</h1>
<header>
<h1>Governance</h1>
</header>

<section id="governance">
<h2>Governance</h2>
<p>copy about how rust is governed</p>
</section>

</hr>

<section id="teams">
<h2>Teams</h2>
<p>teaser copy</p>
<div id="core-team">
<h3>Core Team</h3>
</div>
<div id="teams">
<h3>All the other teams</h3>
<p>link to each team's page</p>
<h3><a href="/governance/teams">Teams</a></h3>
</div>
<section>

</hr>
</section>

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

</hr>

<section id="code-of-conduct">
<h2>Code of Conduct</h2>
<p>Maybe talk about leadership values here</p>
<h3><a href="/policies/code-of-conduct">Code of Conduct</a></h3>
</section>

{{/inline}}
{{~> (parent)~}}
8 changes: 8 additions & 0 deletions templates/governance/roadmap.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#*inline "page"}}

<section>
<h1>Roadmap</h1>
</section>

{{/inline}}
{{~> (parent)~}}
Loading