-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite
executable file
·38 lines (29 loc) · 890 Bytes
/
site
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
35
36
37
38
#!/usr/bin/env python
import sys
import glob
import datetime
import os
import shutil
from quik import FileLoader
import json
def modified_at(path):
return datetime.datetime.fromtimestamp(os.path.getmtime(path))
def build():
print("building site...")
with open('data.json') as data_file:
data = json.load(data_file)
# data['files'] = []
# for path in glob.glob('./public/files/*'):
# f = path.replace('./public/files/', '').split('_')
# data['files'].append({ 'url': path, 'category': f[0] , 'basename': f[1], 'date': modified_at(path) })
#
# data['files'].sort(key = lambda k: k['date'])
tpl = FileLoader('./').load_template('layout.html')
out = bytes(tpl.render(data), 'utf-8')
open('./index.html', 'wb').write(out)
print("Done!")
# CLI interface
commands = {
'build': build
}
commands[sys.argv[1]]()