diff --git a/src/resources/article_resource.rs b/src/resources/article_resource.rs index fd39f60..25a5d32 100644 --- a/src/resources/article_resource.rs +++ b/src/resources/article_resource.rs @@ -11,6 +11,7 @@ use mimes::*; use rendering::render_markdown; use site::Layout; use state::{State, UpdateResult, RebaseConflict}; +use theme; use web::{Resource, ResponseFuture}; use super::changes_resource::QueryParameters; @@ -102,6 +103,7 @@ impl Resource for ArticleResource { .with_body(Layout { base: None, // Hmm, should perhaps accept `base` as argument title: &data.title, + theme: theme::theme_from_str(&data.title), body: &Template { revision: data.revision, last_updated: Some(&last_updated( @@ -238,6 +240,7 @@ impl Resource for ArticleResource { .with_body(Layout { base: None, title: &title, + theme: theme::theme_from_str(&title), body: &Template { revision: base_article.revision, last_updated: Some(&last_updated( diff --git a/src/resources/diff_resource.rs b/src/resources/diff_resource.rs index 2a0bdb6..7f79e58 100644 --- a/src/resources/diff_resource.rs +++ b/src/resources/diff_resource.rs @@ -12,6 +12,7 @@ use mimes::*; use models::ArticleRevision; use site::Layout; use state::State; +use theme; use web::{Resource, ResponseFuture}; use super::changes_resource; @@ -122,6 +123,7 @@ impl Resource for DiffResource { .with_body(Layout { base: Some("../"), // Hmm, should perhaps accept `base` as argument title: "Difference", + theme: theme::theme_from_str("Difference"), body: &Template { consecutive: self.to.revision - self.from.revision == 1, article_id: self.from.article_id as u32, diff --git a/src/resources/new_article_resource.rs b/src/resources/new_article_resource.rs index 9f3964e..63a2511 100644 --- a/src/resources/new_article_resource.rs +++ b/src/resources/new_article_resource.rs @@ -10,6 +10,7 @@ use mimes::*; use rendering::render_markdown; use site::Layout; use state::State; +use theme; use web::{Resource, ResponseFuture}; const NEW: &str = "NEW"; @@ -83,6 +84,7 @@ impl Resource for NewArticleResource { .with_body(Layout { base: None, // Hmm, should perhaps accept `base` as argument title: &title, + theme: theme::theme_from_str(&title), body: &Template { revision: NEW, last_updated: None, diff --git a/src/site.rs b/src/site.rs index 4279ede..a84df0a 100644 --- a/src/site.rs +++ b/src/site.rs @@ -28,12 +28,11 @@ header! { (XIdentity, "X-Identity") => [String] } pub struct Layout<'a, T: 'a + fmt::Display> { pub base: Option<&'a str>, pub title: &'a str, + pub theme: theme::Theme, pub body: T, } impl<'a, T: 'a + fmt::Display> Layout<'a, T> { - pub fn theme(&self) -> theme::Theme { theme::theme_from_str(self.title) } - pub fn themes_css(&self) -> &str { ThemesCss::resource_name() } pub fn style_css(&self) -> &str { StyleCss::resource_name() } pub fn search_js(&self) -> &str { SearchJs::resource_name() } @@ -57,6 +56,7 @@ where Layout { base, title, + theme: theme::theme_from_str(title), body: SystemPageLayout { title, html_body: body, diff --git a/templates/layout.html b/templates/layout.html index e1c8ee3..efdb72e 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -9,7 +9,7 @@ - + {{>search_input.html}} {{{body}}}