From 795005c87810ae4e977e4eed9561777cb08e49b8 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 30 Jun 2021 15:17:28 -0400 Subject: [PATCH] remove sitemap.txt from static/ and build it with build.py --- build.py | 33 ++++++++++++++++++++++++--------- static/sitemap.txt | 7 ------- 2 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 static/sitemap.txt diff --git a/build.py b/build.py index 58266ab..0659462 100644 --- a/build.py +++ b/build.py @@ -22,6 +22,7 @@ import os import re import shutil + input_directory = 'content' static_directory = 'static' output_directory = 'output' @@ -32,8 +33,6 @@ md_extensions = ['fenced_code', 'codehilite', 'nl2br', 'toc', 'smarty', 'tables' def print_file(in_file, out_file): print('%-62s -> %s' % (in_file, out_file)) -template = open('template.html').read() - os.makedirs(output_directory, exist_ok=True) for (dirpath, _, filenames) in os.walk(static_directory): @@ -48,6 +47,7 @@ for (dirpath, _, filenames) in os.walk(static_directory): shutil.copy2(source, dest) +template = open('template.html').read() for (dirpath, _, filenames) in os.walk(input_directory): for filename in filenames: markdown_filename = os.path.join(dirpath, filename) @@ -90,10 +90,25 @@ for (dirpath, _, filenames) in os.walk(input_directory): out_file.write(output) out_file.close() -# TODO: make a sitemap / RSS? -#index_filename = os.path.join(output_directory, 'index.html') -#print_file('', index_filename) -#index = open(index_filename, 'w') -#for f in out_filenames: -# index.write('%s
' % (f, f)) -#index.close() + +def make_sitemap(): + sitemap_command = ' '.join(""" +find output -regextype posix-extended -regex '.*.(html|pdf)$' | +grep -v ^output/google | +grep -v ^output/drafts | +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(): + make_sitemap() + make_rss() + + +if __name__ == '__main__': + main() diff --git a/static/sitemap.txt b/static/sitemap.txt deleted file mode 100644 index 461ea1d..0000000 --- a/static/sitemap.txt +++ /dev/null @@ -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