summaryrefslogtreecommitdiff
path: root/views/pages/blog-page.html
blob: 330a1acd4cbaab30887bb33b35949421915c8361 (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
{{ define "header" }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.8.3/css/lightgallery.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.8.3/css/lg-zoom.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.8.3/css/lg-thumbnail.min.css">
{{- if .MapLocationX }}
<link rel="stylesheet" href="https://f003.backblazeb2.com/file/sayana-static/libs/leaflet/1.9.4/leaflet.css">
{{- end }}

<style>
    .map-container .leaflet-container {
        width: 100% !important;
        height: 100% !important;
    }
</style>
{{ end }}

{{ define "body" }}
<div class="bg-background-light flex flex-col grow overflow-y-auto inset-shadow p-[2.4vmin] max-h-[calc(100%-7vmax)] ar-lt-0.8:max-h-[calc(100%-25vh)]">
    {{ .ParsedMarkdown }}
{{- if .MapLocationX }}
    <hr class="border-t-4 border-dotted border-main-dark mt-[0.8vmin] mb-[0.8vmin] w-[80%] ml-auto mr-auto">
    <div id="location-map" class="relative p-[0.8vmin] flex-none ml-auto mr-auto w-[60%] ar-lt-0.8:w-[80%] h-[40vh] ar-lt-0.8:h-[30vh]"></div>
    <hr class="border-t-4 border-dotted border-main-dark mt-[0.8vmin] mb-[0.8vmin] w-[80%] ml-auto mr-auto">
{{- end }}
</div>
{{ end }}

{{ define "footer" }}
<script src="https://f003.backblazeb2.com/file/sayana-static/libs/lightgallery/2.8.3/lightgallery.min.js"></script>
<script src="https://f003.backblazeb2.com/file/sayana-static/libs/lightgallery/2.8.3/plugins/lg-zoom.min.js"></script>
<script src="https://f003.backblazeb2.com/file/sayana-static/libs/lightgallery/2.8.3/plugins/lg-thumbnail.min.js"></script>
{{- if .MapLocationX }}
<script src="https://f003.backblazeb2.com/file/sayana-static/libs/leaflet/1.9.4/leaflet.js"></script>

<script>
    function initLocationMap(id, x, y, relativeErrorMeters = 0) {
        var map = L.map(id).setView([x, y], 8);

        L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
            maxZoom: 18,
            attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
        }).addTo(map);

        if (relativeErrorMeters != 0) {
            var circle = L.circle([x, y], {
                color: '#8a9d8a',
                fillColor: '#8a9d8a',
                fillOpacity: 0.15,
                radius: relativeErrorMeters
            }).addTo(map);
        }

        var marker = L.marker([x, y], {
            title: '{{ .Title }}',
        }).addTo(map)
            .bindPopup('<span><b>{{ .Title }}</b><br><a href="https://www.openstreetmap.org/#map=13/{{ .MapLocationX }}/{{ .MapLocationY }}">{{ .MapLocationX }}, {{ .MapLocationY }}</a></span>')
            .openPopup();
    }

    document.addEventListener('DOMContentLoaded', () => {initLocationMap(
        'location-map',
        {{ .MapLocationX }},
        {{ .MapLocationY }},
        {{ .MapLocationAreaMeters }}
    )});

    window.addEventListener('resize', function() {
        setTimeout(() => {
            if (window.location-map) window.location-map.invalidateSize();
        }, 100);
    });
</script>
{{- end }}
{{ end }}