-
Notifications
You must be signed in to change notification settings - Fork 0
/
diapo.php
81 lines (71 loc) · 1.95 KB
/
diapo.php
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
<?php
$currentDir = basename(__DIR__);
chdir('media');
$files = glob('*.{webp,webm}', GLOB_BRACE);
sort($files);
$total = count($files);
$indexMax = $total - 1;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $currentDir ?></title>
<link rel="stylesheet" href="diapo.css">
<meta name="generator" content="https://github.com/vincent-peugnet/diapo">
</head>
<body>
<nav>
<h1>
<?= $currentDir ?>
</h1>
<p>
<?= $total ?> files
</p>
<ul>
<?php foreach ($files as $file) {
?>
<li>
<a href="#<?= $file ?>">
<img src="media/thumbnail/<?= pathinfo($file, PATHINFO_FILENAME) ?>.webp" alt="" loading="lazy">
</a>
</li>
<?php
} ?>
</ul>
</nav>
<main dir="ltr">
<?php foreach ($files as $key => $file) {
if ($key == 0) {
$prev = $files[$indexMax];
} else {
$prev = $files[$key - 1];
}
if ($key == $indexMax) {
$next = $files[0];
} else {
$next = $files[$key + 1];
}
echo "<div id=\"$file\">";
echo "<a class=\"dir prev\" href=\"#$prev\"></a>";
switch (pathinfo($file, PATHINFO_EXTENSION)) {
case 'webm':
?>
<video controls preload="none" poster="media/poster/<?= pathinfo($file, PATHINFO_FILENAME) ?>.webp" class="media">
<source src="media/<?= $file ?>" type="video/webm">
</video>
<?php
break;
default:
?>
<img src="media/<?= $file ?>" alt="" loading="lazy" class="media">
<?php
break;
}
echo "<a class=\"dir next\" href=\"#$next\"></a>";
echo '</div>';
} ?>
</main>
</body>
</html>