diff --git a/src/resources/article_resource.rs b/src/resources/article_resource.rs index 25a5d32..6221c8f 100644 --- a/src/resources/article_resource.rs +++ b/src/resources/article_resource.rs @@ -103,7 +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), + theme: theme::theme_from_str_hash(&data.title), body: &Template { revision: data.revision, last_updated: Some(&last_updated( @@ -240,7 +240,7 @@ impl Resource for ArticleResource { .with_body(Layout { base: None, title: &title, - theme: theme::theme_from_str(&title), + theme: theme::theme_from_str_hash(&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 7f79e58..6f2a18a 100644 --- a/src/resources/diff_resource.rs +++ b/src/resources/diff_resource.rs @@ -123,7 +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"), + theme: theme::theme_from_str_hash("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 63a2511..937d08f 100644 --- a/src/resources/new_article_resource.rs +++ b/src/resources/new_article_resource.rs @@ -84,7 +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), + theme: theme::theme_from_str_hash(&title), body: &Template { revision: NEW, last_updated: None, diff --git a/src/site.rs b/src/site.rs index a84df0a..fc71b14 100644 --- a/src/site.rs +++ b/src/site.rs @@ -56,7 +56,7 @@ where Layout { base, title, - theme: theme::theme_from_str(title), + theme: theme::theme_from_str_hash(title), body: SystemPageLayout { title, html_body: body, diff --git a/src/theme.rs b/src/theme.rs index 847c143..9def318 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -32,7 +32,7 @@ pub const THEMES: [Theme; 19] = [Red, Pink, Purple, DeepPurple, Indigo, Blue, LightBlue, Cyan, Teal, Green, LightGreen, Lime, Yellow, Amber, Orange, 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 choice = hash % THEMES.len(); THEMES[choice] @@ -88,7 +88,7 @@ mod test { #[test] fn from_str() { - assert_eq!(theme_from_str("Bartefjes"), Theme::Orange); + assert_eq!(theme_from_str_hash("Bartefjes"), Theme::Orange); } #[test]