diff options
author | kdx <kikoodx@paranoici.org> | 2024-04-06 08:53:29 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2024-04-06 08:53:29 +0200 |
commit | 91be0a8baca17547b8346d4059704f12a8c04241 (patch) | |
tree | 5c13e29684cab1bd46790ffa349b7a7be0da9454 | |
parent | 04b46a080222e6093e4bfc005af4645b67d41d88 (diff) | |
download | gallery-gen-91be0a8baca17547b8346d4059704f12a8c04241.tar.gz |
autogen index
-rwxr-xr-x | index.py | 27 | ||||
-rwxr-xr-x | run.sh | 1 |
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>""") @@ -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 |