summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 5879f83..006ed58 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -30,6 +30,10 @@ impl page::Page for Data {
h3 {
(story.name)
}
+ @if let Some(content_warnings) = story.render_content_warnings() {
+ (content_warnings)
+ }
+
p { (story.description) }
ul lang="en" {
li { "Language: " (story.language) }
@@ -85,6 +89,13 @@ ul {
list-style: none;
}
+.content-warning {
+ background-color: #EC7981;
+ margin: 2rem 0;
+ padding: 0.3rem;
+ width: fit-content;
+}
+
"""
)
}
@@ -157,10 +168,22 @@ hr {
hr {
margin: 2rem 0;
}
+
+ p {
+ margin-top: 1rem;
+ }
+
padding: 3rem;
margin: 3rem;
background-color: #ffd1a3;
border-bottom: 0.1rem dotted black;
+
+ .content-warning {
+ background-color: #EC7981;
+ margin: 2rem 0;
+ padding: 0.3rem;
+ width: fit-content;
+ }
}
"""
)
@@ -187,6 +210,7 @@ struct Story {
upload_date: Date,
update_date: Option<Date>,
path: String,
+ warnings: Option<Vec<String>>,
}
impl Story {
@@ -194,6 +218,9 @@ impl Story {
html!(div class="story-card" lang=(self.html_lang_value()) {
card {
h2 { (self.name) }
+ @if let Some(content_warnings) = &self.render_content_warnings() {
+ (content_warnings)
+ }
p { (self.description) }
hr {}
ul lang="en" {
@@ -228,6 +255,32 @@ impl Story {
StoryLanguage::English => String::from("en"),
}
}
+
+ fn render_content_warnings(&self) -> Option<Markup> {
+ if let Some(warnings) = &self.warnings {
+ let (summary, prefix) = match self.language {
+ StoryLanguage::German => (
+ String::from("Vorsicht ist geboten."),
+ String::from("Die Geschichte beinhaltet: "),
+ ),
+ StoryLanguage::English => (
+ String::from("Reader discretion is advised."),
+ String::from("The story contains: "),
+ ),
+ };
+ let details = format!("{}{}", prefix, warnings.join(", "));
+ Some(html!(
+ details {
+ summary {
+ strong { (summary) }
+ }
+ p class="content-warning" { (details) }
+ }
+ ))
+ } else {
+ None
+ }
+ }
}
fn main() -> Result<()> {