summaryrefslogtreecommitdiff
path: root/src/data.rs
blob: 2e5b3d1e163a9a214043a9fa725312cda9c428d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use crate::page;
use crate::story;
use maud::{html, Markup};
use serde::Deserialize;

#[derive(Deserialize)]
pub struct Data {
    pub stories: Vec<story::Story>,
}

impl page::Page for Data {
    fn page_title() -> String {
        String::from("Home")
    }

    fn alternative_htmlfilename() -> Option<String> {
        Some(String::from("index"))
    }

    fn render_content(&self) -> Markup {
        let last_story = self.stories.first();
        html!(
            @if let Some(story) = last_story {
                div class="latest-story" lang=(story.html_lang_value()) {
                    h2 lang="en" { "Latest Story" }
                    h3 {
                        (story.name)
                    }
                    @if let Some(content_warnings) = story.render_content_warnings() {
                        (content_warnings)
                    }

                    p { (story.description) }
                    ul lang="en" {
                        li { "Language: " (story.language) }
                        li {
                            a href=(&story.format_pdf_path()) download
                            {
                                "PDF"
                            }
                        }
                    }

                }
            }
        )
    }

    fn content_style() -> Markup {
        html!(
        """
h2 {
    font-size: 2.5rem;
    color: #2F3C57;
    text-decoration: 0.1rem solid underline black;
}

h3 {
    font-size: 1.8rem;
    color: #2F3C57;
    padding: 2rem 0;
}

.latest-story {
    padding: 3rem;
    margin: 3rem;
    text-align: left;
    background-color: #FFD1A3;
    hyphens: auto;
    * {
        margin: 1rem 0;
    }

    p {
        font-size: 1.2rem;
    }
}

a {
    text-decoration: underline;
    color: #3D1D49;
}

ul {
    list-style: none;
}

.content-warning {
    background-color: #EC7981;
    margin: 2rem 0;
    padding: 0.3rem;
    width: fit-content;
}

        """
        )
    }
}