~mort/coffeepaste

ref: 1c00b974ba02d62934c2491382233346535ac414 coffeepaste/web/album.html -rw-r--r-- 2.3 KiB
1c00b974Martin Dørum upgrade dependencies 1 year, 1 month ago
                                                                                
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
<html>
<head>
    <meta charset="utf-8">
    <title>Coffeepaste</title>
<style>
img {
    width: 100%;
    margin: auto;
}
@media screen and (min-width: 800px) {
    img {
        width: 50%;
    }
}
#images {
    position: relative;
}
</style>
</head>
<body>
    <noscript>
        Sorry, album view currently requires JavaScript.
    </noscript>

    <pre id="usage">
COFFEEPASTE ALBUM(1)             User Commands             COFFEEPASTE ALBUM(1)

<b>NAME</b>
        coffeepaste /a/ - show an album of images

<b>SYNOPSYS</b>
        <b>GET</b> <u>/a/IMAGES.EXT</u>

<b>DESCRIPTION</b>
        View a list of images. Image IDs are separated by <u>&amp;</u>.
        For example, to view images foo.jpg, bar.jpg and baz.jpg,
        <b>GET /a/a&amp;b&amp;c.jpg</b>.

        Images use the first extension to their right. If <b>a</b> and <b>b</b>
        are PNGs and <b>c</b> is a JPEG, you can
        <b>GET /a/a&amp;b.png&amp;c.jpg</b>.

<b>AUTHOR</b>
        Written by Martin Dørum.

<b>WWW</b>
        <a href="https://sr.ht/~mort/coffeepaste/">https://sr.ht/~mort/coffeepaste/</a>

<b>REPORTING BUGS</b>
        Submit bug reports to
        <a href="https://todo.sr.ht/~mort/coffeepaste">https://todo.sr.ht/~mort/coffeepaste</a>.

coffeepaste 1.3.0                October 2020              COFFEEPASTE ALBUM(1)
    </pre>

    <div id="images"></div>

<script>
var images = document.getElementById("images");
var usage = document.getElementById("usage");

var sections = location.pathname.substr(1).split("/")[1].split("&");

// Parse album string and put images into 'imgs'
var imgs = []
var curr = []
for (var i in sections) {
    if (sections[i].length == 0) {
        continue;
    }

    var parts = sections[i].split(".");
    curr.push(parts[0])
    if (parts.length > 1) {
        var ext = parts[1]
        for (var j in curr) {
            imgs.push("/" + curr[j] + "." + ext);
        }

        curr = [];
    }
}

// Images without extension? Ok...
for (var i in curr) {
    imgs.push(curr[i]);
}

if (imgs.length > 0) {
    usage.style.display = "none";
}

for (var i in imgs) {
    var a = document.createElement("a");
    a.href = imgs[i];
    var img = document.createElement("img");
    img.src = imgs[i];
    a.appendChild(img);
    images.appendChild(a);
}
</script>
</body>
</html>