-
-
Save timo/9ee7926c2695f4b9a38f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.2 | |
import subprocess, re | |
matchers = { | |
'../scripts/public-add': re.compile('[AM]\tpublic/[\w.]'), | |
'../scripts/public-del': re.compile('D\tpublic/[\w.]'), | |
} | |
for line in subprocess.check_output(["git", "show", "--name-status"]).decode().split('\n')[4:-1]: | |
for k, v in matchers.items(): | |
if v.match(line): | |
subprocess.call([k, line[2:]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.2 | |
import sys, subprocess, tempfile | |
to_dir = '../../public/serve/' | |
muformat = 'markdown' | |
date = '' | |
categories = tuple() | |
tags = tuple() | |
title = 'Paste' | |
i = 0 | |
if (len(sys.argv) > 1): | |
filename = sys.argv[1] | |
if (filename.endswith('.page')): | |
file = open(filename) | |
lines = file.readlines() | |
last_yaml_line = 0 | |
if (lines[0] == '---\n'): | |
for i, line in enumerate(lines): | |
if (line == '...\n'): | |
last_yaml_line = i | |
break | |
key, _, value = line.partition(": ") | |
if (key == 'format'): | |
muformat = value | |
elif (key == 'date'): | |
date = value | |
elif (key == 'categories'): | |
categories = tuple(value.split(' ')) | |
elif (key =='tags')): | |
tags = tuple(value.split(' ')) | |
elif (key == 'title'): | |
title = value | |
temp = tempfile.NamedTemporaryFile(mode='w+t', delete=False) | |
temp.writelines(lines[last_yaml_line+1:]) | |
temp.close() | |
subprocess.call([ | |
'pandoc', '-s', '-V', 'pagetitle=' + title, '-f', muformat, '-t', 'html', | |
'-o', to_dir + filename[7:-5] + '.html', temp.name | |
]) | |
else: | |
subprocess.call(['cp', filename, to_dir]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.2 | |
import sys, subprocess | |
to_dir = '../../public/serve/' | |
if (len(sys.argv) > 1): | |
filename = sys.argv[1] | |
if (filename.endswith('.page')): | |
subprocess.call(['rm', to_dir + filename[7:-5] + '.html']) | |
else: | |
subprocess.call(['rm', to_dir + filename[7:]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment