-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.py
More file actions
33 lines (27 loc) · 895 Bytes
/
publish.py
File metadata and controls
33 lines (27 loc) · 895 Bytes
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
import os
import shutil
import subprocess
import sys
PUB = 'published'
def shell(*args):
"""Call shell command and return its stdout. args are space-separated."""
cmd = ' '.join(args)
print('$', cmd)
stdout = subprocess.check_output(cmd, shell=True, executable='/bin/bash')
stdout_str = stdout.decode('utf-8').strip()
print(stdout_str)
return stdout_str
def templar(html, md, out):
out = os.path.join(PUB, out)
shell('templar', 'compile', html, '-s', md, '-m', '-d', out)
def main():
if not os.path.exists(PUB):
os.mkdir(PUB)
templar('page.html', 'content/about.md', 'about.html')
templar('page.html', 'content/readings.md', 'index.html')
pub_assets = os.path.join(PUB, 'assets')
if os.path.exists(pub_assets):
shutil.rmtree(pub_assets)
shutil.copytree('assets', pub_assets)
if __name__ == '__main__':
main()