Rename function to avoid confusion

This commit is contained in:
Magnus Hovland Hoff 2018-09-19 08:20:43 +02:00
parent 6118f14bb0
commit f961699f0f
5 changed files with 7 additions and 7 deletions

View file

@ -103,7 +103,7 @@ impl Resource for ArticleResource {
.with_body(Layout { .with_body(Layout {
base: None, // Hmm, should perhaps accept `base` as argument base: None, // Hmm, should perhaps accept `base` as argument
title: &data.title, title: &data.title,
theme: theme::theme_from_str(&data.title), theme: theme::theme_from_str_hash(&data.title),
body: &Template { body: &Template {
revision: data.revision, revision: data.revision,
last_updated: Some(&last_updated( last_updated: Some(&last_updated(
@ -240,7 +240,7 @@ impl Resource for ArticleResource {
.with_body(Layout { .with_body(Layout {
base: None, base: None,
title: &title, title: &title,
theme: theme::theme_from_str(&title), theme: theme::theme_from_str_hash(&title),
body: &Template { body: &Template {
revision: base_article.revision, revision: base_article.revision,
last_updated: Some(&last_updated( last_updated: Some(&last_updated(

View file

@ -123,7 +123,7 @@ impl Resource for DiffResource {
.with_body(Layout { .with_body(Layout {
base: Some("../"), // Hmm, should perhaps accept `base` as argument base: Some("../"), // Hmm, should perhaps accept `base` as argument
title: "Difference", title: "Difference",
theme: theme::theme_from_str("Difference"), theme: theme::theme_from_str_hash("Difference"),
body: &Template { body: &Template {
consecutive: self.to.revision - self.from.revision == 1, consecutive: self.to.revision - self.from.revision == 1,
article_id: self.from.article_id as u32, article_id: self.from.article_id as u32,

View file

@ -84,7 +84,7 @@ impl Resource for NewArticleResource {
.with_body(Layout { .with_body(Layout {
base: None, // Hmm, should perhaps accept `base` as argument base: None, // Hmm, should perhaps accept `base` as argument
title: &title, title: &title,
theme: theme::theme_from_str(&title), theme: theme::theme_from_str_hash(&title),
body: &Template { body: &Template {
revision: NEW, revision: NEW,
last_updated: None, last_updated: None,

View file

@ -56,7 +56,7 @@ where
Layout { Layout {
base, base,
title, title,
theme: theme::theme_from_str(title), theme: theme::theme_from_str_hash(title),
body: SystemPageLayout { body: SystemPageLayout {
title, title,
html_body: body, html_body: body,

View file

@ -32,7 +32,7 @@ pub const THEMES: [Theme; 19] = [Red, Pink, Purple, DeepPurple, Indigo, Blue,
LightBlue, Cyan, Teal, Green, LightGreen, Lime, Yellow, Amber, Orange, LightBlue, Cyan, Teal, Green, LightGreen, Lime, Yellow, Amber, Orange,
DeepOrange, Brown, Gray, BlueGray]; DeepOrange, Brown, Gray, BlueGray];
pub fn theme_from_str(x: &str) -> Theme { pub fn theme_from_str_hash(x: &str) -> Theme {
let hash = seahash::hash(x.as_bytes()) as usize; let hash = seahash::hash(x.as_bytes()) as usize;
let choice = hash % THEMES.len(); let choice = hash % THEMES.len();
THEMES[choice] THEMES[choice]
@ -88,7 +88,7 @@ mod test {
#[test] #[test]
fn from_str() { fn from_str() {
assert_eq!(theme_from_str("Bartefjes"), Theme::Orange); assert_eq!(theme_from_str_hash("Bartefjes"), Theme::Orange);
} }
#[test] #[test]