aboutsummaryrefslogtreecommitdiffstats
path: root/templates/gallery.html
blob: f33c422280db2df4908574f13988f4665f2eee7e (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
99
100
101
102
103
104
105
<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta
            name="description"
            content="A photography portfolio by {{ author }}."
        />
        <meta name="keywords" content="photography, portfolio, gallery" />
        <meta name="author" content="{{ author }}" />
        <meta property="og:title" content="{{ author }}" />
        <meta
            property="og:description"
            content="A photography portfolio by {{ author }}."
        />
        <meta property="og:image" content="{{ cover_img_url }}" />
        <meta property="og:url" content="{{ base_url }}" />
        <meta property="og:type" content="website" />

        <title>Leo Lalla</title>
        <link
            rel="stylesheet"
            href="{{ url_for('static', filename='style.css') }}"
        />

        <script>
            function layout() {
                const isMobile =
                    window.matchMedia("(max-width: 600px)").matches;

                document.querySelectorAll(".gallery-item").forEach((item) => {
                    const img = item.querySelector("img");
                    if (!img) return;

                    const cleanup = () => img.classList.remove("loading");

                    if (img.complete) {
                        cleanup();
                    } else {
                        img.addEventListener("load", cleanup, { once: true });
                    }

                    if (isMobile) {
                        item.style.width = "";
                        return;
                    }

                    const setWidth = () => {
                        item.style.width = img.offsetWidth + "px";
                    };

                    if (img.complete) {
                        setWidth();
                    } else {
                        img.addEventListener("load", setWidth, { once: true });
                    }
                });
            }

            document.addEventListener("DOMContentLoaded", layout);
            window.addEventListener("resize", layout);
        </script>
    </head>

    <body>
        <h1>
            {{ author }} {% if ig_link %}
            <a href="{{ ig_link }}" target="_blank" class="ig-link">
                <img
                    src="{{ url_for('static', filename='ig.svg') }}"
                    alt="Instagram"
                    width="30"
                    height="30"
                />
            </a>
            {% endif %}
        </h1>

        {% for date in dates %}
        <h2>{{ date }}</h2>
        <div class="gallery">
            {% for f in grouped[date] %}
            <div class="gallery-item">
                <a
                    href="https://drive.google.com/file/d/{{ f.id }}/view"
                    target="_blank"
                >
                    <img
                        src="{{ url_for('serve_thumbnail', filename=f.thumbnail.split('/')[-1]) }}"
                        loading="lazy"
                        class="loading"
                    />
                </a>
                {% if f.description %}
                <p>{{ f.description }}</p>
                {% endif %}
            </div>
            {% endfor %}
        </div>
        {% endfor %} {% if dates|length == 0 %}
        <p>No photos yet.</p>
        {% endif %}
    </body>
</html>