You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB
Plaintext

#!/usr/bin/env python
import cgi, jinja2, os, json, re
import cgitb; cgitb.enable()
from jinja2 import Template
# Directory => ITEMS list (all files with a timestamp name, grouped)
ff = os.listdir("clips")
tpat = re.compile(r"^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)")
items = {}
for f in ff:
base, ext = os.path.splitext(f)
ext = ext[1:]
m = tpat.match(f)
if m:
t = m.group(0)
if t not in items:
items[t] = {}
items[t][ext] = f
items = [items[key] for key in sorted(items, reverse=True)]
for i in items[1:]:
for f in i.items():
print "deleting ", f
# dump the data (debugging)
# print "Content-type: text/plain"
# print ""
# print json.dumps(items, indent=2)
# Output template with items
print "Content-type: text/html"
print ""
print Template(u"""<html>
<head>
8 years ago
<title>ADOPT A WALK</title>
<style type="text/css">
div.movie {
8 years ago
border: 20px solid black;
display: inline-block;
}
div.movie img {
width: 400px;
}
</style>
</head>
8 years ago
<body>
<header>
<p>head<p>
<img src="../images/header.png" width="100%"/>
</header>
8 years ago
{% for i in items %}
<div class="movie"><a href="../clips/{{i.mp4}}"><img src="../clips/{{i.jpg}}" /></a> </div>
{% endfor %}
8 years ago
<div>
8 years ago
</div>
</body>
</html>""").render(items=items).encode("utf-8")