diff --git a/src/main.rs b/src/main.rs index 1d24bf109..8d6724475 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,6 +62,8 @@ struct UsersContext { data: Vec>, } +static LAYOUT: &str = "components/layout"; + fn get_title(page_name: &str) -> String { let mut v: Vec = page_name.replace("-", " ").chars().collect(); v[0] = v[0].to_uppercase().nth(0).unwrap(); @@ -86,7 +88,7 @@ fn index() -> Template { let context = Context { page: page.clone(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: true, rust_version: rust_version::rust_version() .map_or(String::new(), |v| format!("Version {}", v)), @@ -94,6 +96,11 @@ fn index() -> Template { Template::render(page, &context) } +#[get("/components/<_file..>", rank = 1)] +fn components(_file: PathBuf) -> Template { + not_found() +} + #[get("/logos/", rank = 1)] fn logos(file: PathBuf) -> Option { NamedFile::open(Path::new("static/logos").join(file)).ok() @@ -111,7 +118,7 @@ fn category(category: Category) -> Template { let context = Context { page: category.name().to_string(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, }; Template::render(page, &context) @@ -124,7 +131,7 @@ fn governance() -> Template { let context = GroupContext { page: page.clone(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, data: load_governance_data(), }; @@ -152,7 +159,7 @@ fn team(t: String, subject: String) -> Template { let context = GroupContext { page: page.clone(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, data: load_group_data(t, &subject), }; @@ -195,7 +202,7 @@ fn production() -> Template { let context = UsersContext { page: page.clone(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, data: load_users_data(), }; @@ -216,7 +223,7 @@ fn subject(category: Category, subject: String) -> Template { let context = Context { page: subject, title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, }; Template::render(page, &context) @@ -245,7 +252,7 @@ fn not_found() -> Template { let context = Context { page: "404".to_string(), title, - parent: "layout".to_string(), + parent: LAYOUT.to_string(), is_landing: false, }; Template::render(page, &context) @@ -296,6 +303,7 @@ fn main() { subject, files, logos, + components, redirect, redirect_en_us, redirect_locale diff --git a/templates/edition-banner.hbs b/templates/components/edition-banner.hbs similarity index 100% rename from templates/edition-banner.hbs rename to templates/components/edition-banner.hbs diff --git a/templates/footer.hbs b/templates/components/footer.hbs similarity index 97% rename from templates/footer.hbs rename to templates/components/footer.hbs index 472442e29..0ec5ff2d7 100644 --- a/templates/footer.hbs +++ b/templates/components/footer.hbs @@ -9,7 +9,7 @@
  • Check Website Status
  • - {{> languages-dropdown }} + {{> components/languages-dropdown }}
    diff --git a/templates/languages-dropdown.hbs b/templates/components/languages-dropdown.hbs similarity index 100% rename from templates/languages-dropdown.hbs rename to templates/components/languages-dropdown.hbs diff --git a/templates/layout.hbs b/templates/components/layout.hbs similarity index 98% rename from templates/layout.hbs rename to templates/components/layout.hbs index 837a3fe9d..b67ea4272 100644 --- a/templates/layout.hbs +++ b/templates/components/layout.hbs @@ -47,10 +47,10 @@ - {{> nav}} + {{> components/nav}}
    {{~> page}}
    - {{> footer}} + {{> components/footer}} diff --git a/templates/nav.hbs b/templates/components/nav.hbs similarity index 96% rename from templates/nav.hbs rename to templates/components/nav.hbs index 95ccc2923..a283a17f9 100644 --- a/templates/nav.hbs +++ b/templates/components/nav.hbs @@ -18,7 +18,7 @@
    - {{> languages-dropdown}} + {{> components/languages-dropdown}}
    diff --git a/templates/panels/domains.hbs b/templates/components/panels/domains.hbs similarity index 100% rename from templates/panels/domains.hbs rename to templates/components/panels/domains.hbs diff --git a/templates/panels/get-involved.hbs b/templates/components/panels/get-involved.hbs similarity index 100% rename from templates/panels/get-involved.hbs rename to templates/components/panels/get-involved.hbs diff --git a/templates/panels/language-values.hbs b/templates/components/panels/language-values.hbs similarity index 100% rename from templates/panels/language-values.hbs rename to templates/components/panels/language-values.hbs diff --git a/templates/panels/production.hbs b/templates/components/panels/production.hbs similarity index 100% rename from templates/panels/production.hbs rename to templates/components/panels/production.hbs diff --git a/templates/tools/editors.hbs b/templates/components/tools/editors.hbs similarity index 100% rename from templates/tools/editors.hbs rename to templates/components/tools/editors.hbs diff --git a/templates/tools/install-script.hbs b/templates/components/tools/install-script.hbs similarity index 100% rename from templates/tools/install-script.hbs rename to templates/components/tools/install-script.hbs diff --git a/templates/tools/rustup.hbs b/templates/components/tools/rustup.hbs similarity index 100% rename from templates/tools/rustup.hbs rename to templates/components/tools/rustup.hbs diff --git a/templates/what/cli/code-inputs.hbs b/templates/components/what/cli/code-inputs.hbs similarity index 100% rename from templates/what/cli/code-inputs.hbs rename to templates/components/what/cli/code-inputs.hbs diff --git a/templates/what/cli/code-main.hbs b/templates/components/what/cli/code-main.hbs similarity index 100% rename from templates/what/cli/code-main.hbs rename to templates/components/what/cli/code-main.hbs diff --git a/templates/what/cli/example.hbs b/templates/components/what/cli/example.hbs similarity index 83% rename from templates/what/cli/example.hbs rename to templates/components/what/cli/example.hbs index e3843af2e..34e4aa746 100644 --- a/templates/what/cli/example.hbs +++ b/templates/components/what/cli/example.hbs @@ -13,12 +13,12 @@

    Define your inputs

    -
    {{> what/cli/code-inputs }}
    +
    {{> components/what/cli/code-inputs }}

    Write your tool

    -
    {{> what/cli/code-main }}
    +
    {{> components/what/cli/code-main }}
    diff --git a/templates/what/cli/maintainable.hbs b/templates/components/what/cli/maintainable.hbs similarity index 100% rename from templates/what/cli/maintainable.hbs rename to templates/components/what/cli/maintainable.hbs diff --git a/templates/what/cli/pitch.hbs b/templates/components/what/cli/pitch.hbs similarity index 100% rename from templates/what/cli/pitch.hbs rename to templates/components/what/cli/pitch.hbs diff --git a/templates/what/cli/production.hbs b/templates/components/what/cli/production.hbs similarity index 100% rename from templates/what/cli/production.hbs rename to templates/components/what/cli/production.hbs diff --git a/templates/what/embedded/get-started.hbs b/templates/components/what/embedded/get-started.hbs similarity index 100% rename from templates/what/embedded/get-started.hbs rename to templates/components/what/embedded/get-started.hbs diff --git a/templates/what/embedded/pitch.hbs b/templates/components/what/embedded/pitch.hbs similarity index 100% rename from templates/what/embedded/pitch.hbs rename to templates/components/what/embedded/pitch.hbs diff --git a/templates/what/embedded/showcase.hbs b/templates/components/what/embedded/showcase.hbs similarity index 100% rename from templates/what/embedded/showcase.hbs rename to templates/components/what/embedded/showcase.hbs diff --git a/templates/what/embedded/testimonials.hbs b/templates/components/what/embedded/testimonials.hbs similarity index 100% rename from templates/what/embedded/testimonials.hbs rename to templates/components/what/embedded/testimonials.hbs diff --git a/templates/what/networking/get-started.hbs b/templates/components/what/networking/get-started.hbs similarity index 83% rename from templates/what/networking/get-started.hbs rename to templates/components/what/networking/get-started.hbs index 938af290c..3272b6fc0 100644 --- a/templates/what/networking/get-started.hbs +++ b/templates/components/what/networking/get-started.hbs @@ -13,14 +13,14 @@

    POST some JSON

    -
    {{> what/networking/post-json }}
    +
    {{> components/what/networking/post-json }}
    Learn more about reqwest

    Handle a JSON POST

    -
    {{> what/networking/take-json }}
    +
    {{> components/what/networking/take-json }}
    Learn more about Rocket
    diff --git a/templates/what/networking/pitch.hbs b/templates/components/what/networking/pitch.hbs similarity index 100% rename from templates/what/networking/pitch.hbs rename to templates/components/what/networking/pitch.hbs diff --git a/templates/what/networking/post-json.hbs b/templates/components/what/networking/post-json.hbs similarity index 100% rename from templates/what/networking/post-json.hbs rename to templates/components/what/networking/post-json.hbs diff --git a/templates/what/networking/production.hbs b/templates/components/what/networking/production.hbs similarity index 100% rename from templates/what/networking/production.hbs rename to templates/components/what/networking/production.hbs diff --git a/templates/what/networking/take-json.hbs b/templates/components/what/networking/take-json.hbs similarity index 100% rename from templates/what/networking/take-json.hbs rename to templates/components/what/networking/take-json.hbs diff --git a/templates/what/wasm/get-started.hbs b/templates/components/what/wasm/get-started.hbs similarity index 100% rename from templates/what/wasm/get-started.hbs rename to templates/components/what/wasm/get-started.hbs diff --git a/templates/what/wasm/js.hbs b/templates/components/what/wasm/js.hbs similarity index 100% rename from templates/what/wasm/js.hbs rename to templates/components/what/wasm/js.hbs diff --git a/templates/what/wasm/pitch.hbs b/templates/components/what/wasm/pitch.hbs similarity index 100% rename from templates/what/wasm/pitch.hbs rename to templates/components/what/wasm/pitch.hbs diff --git a/templates/what/wasm/production.hbs b/templates/components/what/wasm/production.hbs similarity index 100% rename from templates/what/wasm/production.hbs rename to templates/components/what/wasm/production.hbs diff --git a/templates/index.hbs b/templates/index.hbs index 30ac70dcf..9c80ad09f 100644 --- a/templates/index.hbs +++ b/templates/index.hbs @@ -18,11 +18,11 @@
    -{{> edition-banner }} -{{> panels/language-values }} -{{> panels/domains }} -{{> panels/production }} -{{> panels/get-involved }} +{{> components/edition-banner }} +{{> components/panels/language-values }} +{{> components/panels/domains }} +{{> components/panels/production }} +{{> components/panels/get-involved }} {{/inline}} {{~> (parent)~}} diff --git a/templates/learn/get-started.hbs b/templates/learn/get-started.hbs index af8d238c0..c7e2f74f5 100644 --- a/templates/learn/get-started.hbs +++ b/templates/learn/get-started.hbs @@ -20,7 +20,7 @@

    Rustup: the Rust installer and version management tool

    The primary way that folks install Rust is through a tool called Rustup, which is a Rust installer and version management tool.

    - {{> tools/rustup }} + {{> components/tools/rustup }}

    Learn more about installation
    @@ -43,7 +43,7 @@

    Other tools

    Rust support is available in many editors:

    - {{> tools/editors }} + {{> components/tools/editors }}

    You can install a code formatting tool (Rustfmt) with rustup component add rustfmt, and a linting tool (Clippy) with rustup component add clippy.

    @@ -177,6 +177,6 @@ fn main() { a gif of ferris scurrying side to side
    -{{> tools/install-script }} +{{> components/tools/install-script }} {{/inline}} {{~> (parent)~}} diff --git a/templates/tools/index.hbs b/templates/tools/index.hbs index 722e00b90..69aea7148 100644 --- a/templates/tools/index.hbs +++ b/templates/tools/index.hbs @@ -23,7 +23,7 @@ Rust Language Server. - {{> tools/editors }} + {{> components/tools/editors }} diff --git a/templates/tools/install.hbs b/templates/tools/install.hbs index 9c3ba8758..cf70e1a2b 100644 --- a/templates/tools/install.hbs +++ b/templates/tools/install.hbs @@ -12,7 +12,7 @@

    Using rustup (Recommended)

    - {{> tools/rustup }} + {{> components/tools/rustup }} @@ -117,7 +117,7 @@ Learn more -{{> tools/install-script }} +{{> components/tools/install-script }} {{/inline}} {{~> (parent)~}} diff --git a/templates/what/cli.hbs b/templates/what/cli.hbs index cb43190f7..2492e46bb 100644 --- a/templates/what/cli.hbs +++ b/templates/what/cli.hbs @@ -6,9 +6,9 @@ -{{> what/cli/pitch }} -{{> what/cli/maintainable }} -{{> what/cli/example }} -{{> what/cli/production }} +{{> components/what/cli/pitch }} +{{> components/what/cli/maintainable }} +{{> components/what/cli/example }} +{{> components/what/cli/production }} {{/inline}} {{~> (parent)~}} diff --git a/templates/what/embedded.hbs b/templates/what/embedded.hbs index eb45e4a04..7fa5aae9f 100644 --- a/templates/what/embedded.hbs +++ b/templates/what/embedded.hbs @@ -6,10 +6,10 @@ -{{> what/embedded/pitch }} -{{> what/embedded/showcase }} -{{> what/embedded/get-started }} -{{> what/embedded/testimonials }} +{{> components/what/embedded/pitch }} +{{> components/what/embedded/showcase }} +{{> components/what/embedded/get-started }} +{{> components/what/embedded/testimonials }} {{/inline}} {{~> (parent)~}} diff --git a/templates/what/index.hbs b/templates/what/index.hbs index 64377ed82..a5523c701 100644 --- a/templates/what/index.hbs +++ b/templates/what/index.hbs @@ -6,7 +6,7 @@ -{{> panels/domains }} +{{> components/panels/domains }} {{/inline}} {{~> (parent)~}} diff --git a/templates/what/networking.hbs b/templates/what/networking.hbs index c761688bc..145f7ae43 100644 --- a/templates/what/networking.hbs +++ b/templates/what/networking.hbs @@ -6,9 +6,9 @@ -{{> what/networking/pitch }} -{{> what/networking/get-started }} -{{> what/networking/production }} +{{> components/what/networking/pitch }} +{{> components/what/networking/get-started }} +{{> components/what/networking/production }} {{/inline}} {{~> (parent)~}} \ No newline at end of file diff --git a/templates/what/wasm.hbs b/templates/what/wasm.hbs index f10b60871..b60b1b93b 100644 --- a/templates/what/wasm.hbs +++ b/templates/what/wasm.hbs @@ -6,10 +6,10 @@ -{{> what/wasm/pitch }} -{{> what/wasm/get-started }} -{{> what/wasm/js }} -{{> what/wasm/production }} +{{> components/what/wasm/pitch }} +{{> components/what/wasm/get-started }} +{{> components/what/wasm/js }} +{{> components/what/wasm/production }} {{/inline}} {{~> (parent)~}}