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.
73 lines
1.6 KiB
Plaintext
73 lines
1.6 KiB
Plaintext
8 years ago
|
#!/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)
|
||
8 years ago
|
ff = os.listdir("clips")
|
||
|
tpat = re.compile(r"^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)")
|
||
8 years ago
|
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)]
|
||
8 years ago
|
for i in items[10:]:
|
||
8 years ago
|
for f in i.items():
|
||
|
print "deleting ", f
|
||
8 years ago
|
# 10 os.unlink(f)
|
||
8 years ago
|
# dump the data (debugging)
|
||
8 years ago
|
# 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>
|
||
8 years ago
|
<link rel="stylesheet" type="text/css" href="../styles/main.css">
|
||
8 years ago
|
</head>
|
||
8 years ago
|
<body>
|
||
|
<div id="wrappper">
|
||
|
|
||
|
<header>
|
||
|
<img src="../images/headertr3.png" width="100%"/>
|
||
|
</header>
|
||
|
|
||
|
<div class="firstline">
|
||
|
<p> Here you can find footage of your walks.</p>
|
||
|
</div>
|
||
|
|
||
|
<img src="../images/camera.png" />
|
||
|
|
||
|
<div class="secondline">
|
||
|
<p> Steal a walk from another person's video. Download it. </p>
|
||
|
</div>
|
||
8 years ago
|
|
||
8 years ago
|
|
||
8 years ago
|
<div class="thirdline">
|
||
|
<p> Promise me, you're gonna start using this walk for the rest of the day. </p>
|
||
|
</div>
|
||
|
|
||
|
<img src="../images/cover.png" />
|
||
|
|
||
|
|
||
|
<div class="movies">
|
||
|
{% for i in items %}
|
||
|
<a href="../clips/{{i.mp4}}"><img src="../clips/{{i.jpg}}" /></a>
|
||
|
<p>{{i.mp4}}</p>
|
||
|
{% endfor %}
|
||
|
</div>
|
||
8 years ago
|
|
||
8 years ago
|
</div>
|
||
8 years ago
|
</body>
|
||
8 years ago
|
</html>""").render(items=items).encode("utf-8")
|