Compare commits
3 Commits
b2509a3c48
...
4395dea1fd
Author | SHA1 | Date | |
---|---|---|---|
4395dea1fd | |||
795005c878 | |||
31de537153 |
39
build.py
39
build.py
@ -22,6 +22,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
input_directory = 'content'
|
input_directory = 'content'
|
||||||
static_directory = 'static'
|
static_directory = 'static'
|
||||||
output_directory = 'output'
|
output_directory = 'output'
|
||||||
@ -32,10 +33,8 @@ md_extensions = ['fenced_code', 'codehilite', 'nl2br', 'toc', 'smarty', 'tables'
|
|||||||
def print_file(in_file, out_file):
|
def print_file(in_file, out_file):
|
||||||
print('%-62s -> %s' % (in_file, out_file))
|
print('%-62s -> %s' % (in_file, out_file))
|
||||||
|
|
||||||
template = open('template.html').read()
|
|
||||||
|
|
||||||
os.makedirs(output_directory, exist_ok=True)
|
|
||||||
|
|
||||||
|
def copy_static_files():
|
||||||
for (dirpath, _, filenames) in os.walk(static_directory):
|
for (dirpath, _, filenames) in os.walk(static_directory):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
source = os.path.join(dirpath, filename)
|
source = os.path.join(dirpath, filename)
|
||||||
@ -48,6 +47,8 @@ for (dirpath, _, filenames) in os.walk(static_directory):
|
|||||||
shutil.copy2(source, dest)
|
shutil.copy2(source, dest)
|
||||||
|
|
||||||
|
|
||||||
|
def process_markdown_files():
|
||||||
|
template = open('template.html').read()
|
||||||
for (dirpath, _, filenames) in os.walk(input_directory):
|
for (dirpath, _, filenames) in os.walk(input_directory):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
markdown_filename = os.path.join(dirpath, filename)
|
markdown_filename = os.path.join(dirpath, filename)
|
||||||
@ -90,10 +91,28 @@ for (dirpath, _, filenames) in os.walk(input_directory):
|
|||||||
out_file.write(output)
|
out_file.write(output)
|
||||||
out_file.close()
|
out_file.close()
|
||||||
|
|
||||||
# TODO: make a sitemap / RSS?
|
|
||||||
#index_filename = os.path.join(output_directory, 'index.html')
|
def make_sitemap():
|
||||||
#print_file('', index_filename)
|
sitemap_command = ' '.join("""
|
||||||
#index = open(index_filename, 'w')
|
find output -regextype posix-extended -regex '.*.(html|pdf)$' |
|
||||||
#for f in out_filenames:
|
grep -v ^output/google |
|
||||||
# index.write('<a href="%s">%s</a><br>' % (f, f))
|
grep -v ^output/drafts |
|
||||||
#index.close()
|
perl -pe 's|output|https://www.mcmillen.dev|'
|
||||||
|
> output/sitemap.txt""".split('\n'))
|
||||||
|
os.system(sitemap_command)
|
||||||
|
|
||||||
|
|
||||||
|
def make_rss(): # TODO: implement.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.makedirs(output_directory, exist_ok=True)
|
||||||
|
copy_static_files()
|
||||||
|
process_markdown_files()
|
||||||
|
make_sitemap()
|
||||||
|
make_rss()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
https://www.mcmillen.dev
|
|
||||||
https://www.mcmillen.dev/language_checklist.html
|
|
||||||
https://www.mcmillen.dev/publications.html
|
|
||||||
https://www.mcmillen.dev/resume.html
|
|
||||||
https://www.mcmillen.dev/sigbovik/
|
|
||||||
https://www.mcmillen.dev/sigbovik/2019.pdf
|
|
||||||
https://www.mcmillen.dev/sigbovik/splatters.html
|
|
Loading…
Reference in New Issue
Block a user