blob: 58e0ced82bb343dc39569bdcd4e3bbe58f9beffd (
plain)
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
|
#!/usr/bin/env python
# vim: set fileencoding=utf8 :
"""
Create HTML directory index
"""
if __name__ == '__main__':
import sys, os
from jinja2 import Template
tpl = Template("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="stylesheet" href="/style.min.css" type="text/css" />
<title>Index of {{ name }}</title>
</head>
<body>
<h1>Index of {{ name }}</h1>
<p><a href="{{ root }}">Back</a>.</p>
<ul>
{% for f in files %}
<li><a href="{{ f }}">{{ f.rsplit('.',1)[0] }}</a></li>
{% endfor %}
</ul>
</body></html>""")
files = map (str.strip, sys.stdin.readlines ())
name = sys.argv[1]
tpl.stream(files=files, name=name, root=os.path.relpath('.', name)).dump (sys.stdout)
|