summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2024-04-06 08:53:29 +0200
committerkdx <kikoodx@paranoici.org>2024-04-06 08:53:29 +0200
commit91be0a8baca17547b8346d4059704f12a8c04241 (patch)
tree5c13e29684cab1bd46790ffa349b7a7be0da9454
parent04b46a080222e6093e4bfc005af4645b67d41d88 (diff)
downloadgallery-gen-91be0a8baca17547b8346d4059704f12a8c04241.tar.gz
autogen index
-rwxr-xr-xindex.py27
-rwxr-xr-xrun.sh1
2 files changed, 28 insertions, 0 deletions
diff --git a/index.py b/index.py
new file mode 100755
index 0000000..e731b5a
--- /dev/null
+++ b/index.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+from sys import argv
+
+data = ''
+with open(argv[1], 'rb') as f:
+ data = f.read().decode("utf-8")
+
+print("""<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="/theme.css" />
+</head>
+<body>
+<h1><a href="/">~kdx</a>/gallery</h1>""")
+
+for line in data.splitlines():
+ line = line.split(' ')
+ line = [e for e in line if e != '']
+ if len(line) == 1:
+ line.insert(0, '')
+ img = line[1] if len(line) == 2 else line[0]
+ print(f"""<p><a href="/gallery/{img}">""")
+ print(f"""<img src="/gallery/thumb.{img}.jpg" /></a><br />""")
+ print(f"""<a href="/gallery/{img}">""")
+ print(f"""<code>{img}</code></a></p>""")
+
+print("""<p><a href="dump">image dump</a></body></html>""")
diff --git a/run.sh b/run.sh
index db231f9..2ee1af8 100755
--- a/run.sh
+++ b/run.sh
@@ -3,5 +3,6 @@ zig build || exit 1
CWD="$(pwd)"
cd ~/projects/kdx.re/gallery || exit 1
"$CWD"/zig-out/bin/gallery-gen || exit 1
+"$CWD"/index.py list >index.html || exit 1
cd .. || exit 1
make