Explicitly set theme for layout.
Refactoring in anticipation of letting the user choose theme
This commit is contained in:
parent
c1dcb1de64
commit
6118f14bb0
5 changed files with 10 additions and 3 deletions
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<link href="_assets/{{style_css()}}" rel="stylesheet">
|
||||
<meta name="generator" content="{{project_name()}} {{version()}}" />
|
||||
</head>
|
||||
<body class="{{#theme().}}{{.css_class()}}{{/theme()}}">
|
||||
<body class="{{theme.css_class()}}">
|
||||
{{>search_input.html}}
|
||||
{{{body}}}
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue