From d9cadd8f63c7ae848be5291967797eb6c9b832aa Mon Sep 17 00:00:00 2001 From: Shoofle Munroe Date: Mon, 12 Dec 2022 18:40:48 -0500 Subject: [PATCH] the static site generator, generate.ignore.py, is done --- finalized/articles/article.template.html | 18 ------- finalized/articles/article.zip.template.html | 21 -------- .../{auriga.article.html => auriga.html} | 0 ...script.article.html => circle_script.html} | 0 ...icle.html => circle_script_generator.html} | 0 ...ticle.html => comic_layout_generator.html} | 0 ...article.html => distributed_speakers.html} | 0 ...sts.article.html => dont_write_tests.html} | 0 ...cle.html => dynamic_systems_in_games.html} | 0 ...e.html => easy_peasy_state_machinesy.html} | 0 ...ame_diary.article.html => game_diary.html} | 0 .../{game_log.article.html => game_log.html} | 0 ...rticle.html => identities_and_spaces.html} | 0 .../articles/language_for_games.template.html | 15 ------ .../language_for_games.zip.template.html | 16 ------ ...gine.article.html => mindjail_engine.html} | 0 ....article.html => nintendo_summarized.html} | 0 .../{oauth.article.html => oauth.html} | 0 ....html => object_oriented_programming.html} | 0 ...lay_for_x.article.html => play_for_x.html} | 0 ...ticle.html => shoof_shoof_revolution.html} | 0 ...n.article.html => snorlax_evaluation.html} | 0 ...r.article.html => something_or_other.html} | 0 .../{spinning.article.html => spinning.html} | 0 ...{splatling.article.html => splatling.html} | 0 .../{tamari.article.html => tamari.html} | 0 ...ents.article.html => tattoo_elements.html} | 0 ...=> text_editors_with_contenteditable.html} | 0 ...ion.article.html => time_integration.html} | 0 ...enting.article.html => vim_indenting.html} | 0 ...{web_420.0.article.html => web_420.0.html} | 0 finalized/static/WHA.epub | Bin finalized/static/sleepy.html | 0 .../static/templates_old/auriga.template.html | 9 ---- .../distributed_speakers.template.html | 9 ---- .../templates_old/game_log.template.html | 9 ---- .../language_for_games.template.html | 15 ------ .../mindjail_engine.template.html | 9 ---- .../static/templates_old/oauth.template.html | 9 ---- .../templates_old/play_for_x.template.html | 9 ---- .../shoof_shoof_revolution.template.html | 9 ---- .../templates_old/spinning.template.html | 9 ---- .../static/templates_old/tamari.template.html | 9 ---- ...editors_with_contenteditable.template.html | 9 ---- generate.py | 50 ++++++++++++------ 45 files changed, 35 insertions(+), 190 deletions(-) delete mode 100644 finalized/articles/article.template.html delete mode 100644 finalized/articles/article.zip.template.html rename finalized/articles/{auriga.article.html => auriga.html} (100%) rename finalized/articles/{circle_script.article.html => circle_script.html} (100%) rename finalized/articles/{circle_script_generator.article.html => circle_script_generator.html} (100%) rename finalized/articles/{comic_layout_generator.article.html => comic_layout_generator.html} (100%) rename finalized/articles/{distributed_speakers.article.html => distributed_speakers.html} (100%) rename finalized/articles/{dont_write_tests.article.html => dont_write_tests.html} (100%) rename finalized/articles/{dynamic_systems_in_games.article.html => dynamic_systems_in_games.html} (100%) rename finalized/articles/{easy_peasy_state_machinesy.article.html => easy_peasy_state_machinesy.html} (100%) rename finalized/articles/{game_diary.article.html => game_diary.html} (100%) rename finalized/articles/{game_log.article.html => game_log.html} (100%) rename finalized/articles/{identities_and_spaces.article.html => identities_and_spaces.html} (100%) delete mode 100644 finalized/articles/language_for_games.template.html delete mode 100644 finalized/articles/language_for_games.zip.template.html rename finalized/articles/{mindjail_engine.article.html => mindjail_engine.html} (100%) rename finalized/articles/{nintendo_summarized.article.html => nintendo_summarized.html} (100%) rename finalized/articles/{oauth.article.html => oauth.html} (100%) rename finalized/articles/{object_oriented_programming.article.html => object_oriented_programming.html} (100%) rename finalized/articles/{play_for_x.article.html => play_for_x.html} (100%) rename finalized/articles/{shoof_shoof_revolution.article.html => shoof_shoof_revolution.html} (100%) rename finalized/articles/{snorlax_evaluation.article.html => snorlax_evaluation.html} (100%) rename finalized/articles/{something_or_other.article.html => something_or_other.html} (100%) rename finalized/articles/{spinning.article.html => spinning.html} (100%) rename finalized/articles/{splatling.article.html => splatling.html} (100%) rename finalized/articles/{tamari.article.html => tamari.html} (100%) rename finalized/articles/{tattoo_elements.article.html => tattoo_elements.html} (100%) rename finalized/articles/{text_editors_with_contenteditable.article.html => text_editors_with_contenteditable.html} (100%) rename finalized/articles/{time_integration.article.html => time_integration.html} (100%) rename finalized/articles/{vim_indenting.article.html => vim_indenting.html} (100%) rename finalized/articles/{web_420.0.article.html => web_420.0.html} (100%) mode change 100755 => 100644 finalized/static/WHA.epub mode change 100755 => 100644 finalized/static/sleepy.html delete mode 100644 finalized/static/templates_old/auriga.template.html delete mode 100644 finalized/static/templates_old/distributed_speakers.template.html delete mode 100644 finalized/static/templates_old/game_log.template.html delete mode 100644 finalized/static/templates_old/language_for_games.template.html delete mode 100644 finalized/static/templates_old/mindjail_engine.template.html delete mode 100644 finalized/static/templates_old/oauth.template.html delete mode 100644 finalized/static/templates_old/play_for_x.template.html delete mode 100644 finalized/static/templates_old/shoof_shoof_revolution.template.html delete mode 100644 finalized/static/templates_old/spinning.template.html delete mode 100644 finalized/static/templates_old/tamari.template.html delete mode 100644 finalized/static/templates_old/text_editors_with_contenteditable.template.html diff --git a/finalized/articles/article.template.html b/finalized/articles/article.template.html deleted file mode 100644 index fb094a0..0000000 --- a/finalized/articles/article.template.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - {% block head %} - - {% block title %}Writings by Shoofle{% endblock %} - - - - - {% endblock %} - - - {% block body -%} - {%- include target -%} - {%- endblock %} - - diff --git a/finalized/articles/article.zip.template.html b/finalized/articles/article.zip.template.html deleted file mode 100644 index b4b3db4..0000000 --- a/finalized/articles/article.zip.template.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - {% block head %} - - {% block title %}Writings by Shoofle{% endblock %} - - - - - - {% endblock %} - - - {% block body -%} - {%- include target -%} - {%- endblock %} - - diff --git a/finalized/articles/auriga.article.html b/finalized/articles/auriga.html similarity index 100% rename from finalized/articles/auriga.article.html rename to finalized/articles/auriga.html diff --git a/finalized/articles/circle_script.article.html b/finalized/articles/circle_script.html similarity index 100% rename from finalized/articles/circle_script.article.html rename to finalized/articles/circle_script.html diff --git a/finalized/articles/circle_script_generator.article.html b/finalized/articles/circle_script_generator.html similarity index 100% rename from finalized/articles/circle_script_generator.article.html rename to finalized/articles/circle_script_generator.html diff --git a/finalized/articles/comic_layout_generator.article.html b/finalized/articles/comic_layout_generator.html similarity index 100% rename from finalized/articles/comic_layout_generator.article.html rename to finalized/articles/comic_layout_generator.html diff --git a/finalized/articles/distributed_speakers.article.html b/finalized/articles/distributed_speakers.html similarity index 100% rename from finalized/articles/distributed_speakers.article.html rename to finalized/articles/distributed_speakers.html diff --git a/finalized/articles/dont_write_tests.article.html b/finalized/articles/dont_write_tests.html similarity index 100% rename from finalized/articles/dont_write_tests.article.html rename to finalized/articles/dont_write_tests.html diff --git a/finalized/articles/dynamic_systems_in_games.article.html b/finalized/articles/dynamic_systems_in_games.html similarity index 100% rename from finalized/articles/dynamic_systems_in_games.article.html rename to finalized/articles/dynamic_systems_in_games.html diff --git a/finalized/articles/easy_peasy_state_machinesy.article.html b/finalized/articles/easy_peasy_state_machinesy.html similarity index 100% rename from finalized/articles/easy_peasy_state_machinesy.article.html rename to finalized/articles/easy_peasy_state_machinesy.html diff --git a/finalized/articles/game_diary.article.html b/finalized/articles/game_diary.html similarity index 100% rename from finalized/articles/game_diary.article.html rename to finalized/articles/game_diary.html diff --git a/finalized/articles/game_log.article.html b/finalized/articles/game_log.html similarity index 100% rename from finalized/articles/game_log.article.html rename to finalized/articles/game_log.html diff --git a/finalized/articles/identities_and_spaces.article.html b/finalized/articles/identities_and_spaces.html similarity index 100% rename from finalized/articles/identities_and_spaces.article.html rename to finalized/articles/identities_and_spaces.html diff --git a/finalized/articles/language_for_games.template.html b/finalized/articles/language_for_games.template.html deleted file mode 100644 index 9a12a25..0000000 --- a/finalized/articles/language_for_games.template.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Features for a game-focused programming language or library -{%- endblock %} - -{% block body -%} -

I like making games but sometimes I spend a lot of time doing stuff that is just annoying. What if a language or environment were designed to make those things easy?

-
-{%- include "articles/snorlax_evaluation.article.html" -%} -
-{%- include "articles/time_integration.article.html" -%} -
-{%- include "articles/easy_peasy_state_machinesy.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/articles/language_for_games.zip.template.html b/finalized/articles/language_for_games.zip.template.html deleted file mode 100644 index 9ffcc49..0000000 --- a/finalized/articles/language_for_games.zip.template.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Features for a game-focused programming language or library -{%- endblock %} - -{% block body -%} - -

I like making games but sometimes I spend a lot of time doing stuff that is just annoying. What if a language or environment were designed to make those things easy?

-
-{%- include "articles/snorlax_evaluation.article.html" -%} -
-{%- include "articles/time_integration.article.html" -%} -
-{%- include "articles/easy_peasy_state_machinesy.article.html" -%} -{%- endblock %} diff --git a/finalized/articles/mindjail_engine.article.html b/finalized/articles/mindjail_engine.html similarity index 100% rename from finalized/articles/mindjail_engine.article.html rename to finalized/articles/mindjail_engine.html diff --git a/finalized/articles/nintendo_summarized.article.html b/finalized/articles/nintendo_summarized.html similarity index 100% rename from finalized/articles/nintendo_summarized.article.html rename to finalized/articles/nintendo_summarized.html diff --git a/finalized/articles/oauth.article.html b/finalized/articles/oauth.html similarity index 100% rename from finalized/articles/oauth.article.html rename to finalized/articles/oauth.html diff --git a/finalized/articles/object_oriented_programming.article.html b/finalized/articles/object_oriented_programming.html similarity index 100% rename from finalized/articles/object_oriented_programming.article.html rename to finalized/articles/object_oriented_programming.html diff --git a/finalized/articles/play_for_x.article.html b/finalized/articles/play_for_x.html similarity index 100% rename from finalized/articles/play_for_x.article.html rename to finalized/articles/play_for_x.html diff --git a/finalized/articles/shoof_shoof_revolution.article.html b/finalized/articles/shoof_shoof_revolution.html similarity index 100% rename from finalized/articles/shoof_shoof_revolution.article.html rename to finalized/articles/shoof_shoof_revolution.html diff --git a/finalized/articles/snorlax_evaluation.article.html b/finalized/articles/snorlax_evaluation.html similarity index 100% rename from finalized/articles/snorlax_evaluation.article.html rename to finalized/articles/snorlax_evaluation.html diff --git a/finalized/articles/something_or_other.article.html b/finalized/articles/something_or_other.html similarity index 100% rename from finalized/articles/something_or_other.article.html rename to finalized/articles/something_or_other.html diff --git a/finalized/articles/spinning.article.html b/finalized/articles/spinning.html similarity index 100% rename from finalized/articles/spinning.article.html rename to finalized/articles/spinning.html diff --git a/finalized/articles/splatling.article.html b/finalized/articles/splatling.html similarity index 100% rename from finalized/articles/splatling.article.html rename to finalized/articles/splatling.html diff --git a/finalized/articles/tamari.article.html b/finalized/articles/tamari.html similarity index 100% rename from finalized/articles/tamari.article.html rename to finalized/articles/tamari.html diff --git a/finalized/articles/tattoo_elements.article.html b/finalized/articles/tattoo_elements.html similarity index 100% rename from finalized/articles/tattoo_elements.article.html rename to finalized/articles/tattoo_elements.html diff --git a/finalized/articles/text_editors_with_contenteditable.article.html b/finalized/articles/text_editors_with_contenteditable.html similarity index 100% rename from finalized/articles/text_editors_with_contenteditable.article.html rename to finalized/articles/text_editors_with_contenteditable.html diff --git a/finalized/articles/time_integration.article.html b/finalized/articles/time_integration.html similarity index 100% rename from finalized/articles/time_integration.article.html rename to finalized/articles/time_integration.html diff --git a/finalized/articles/vim_indenting.article.html b/finalized/articles/vim_indenting.html similarity index 100% rename from finalized/articles/vim_indenting.article.html rename to finalized/articles/vim_indenting.html diff --git a/finalized/articles/web_420.0.article.html b/finalized/articles/web_420.0.html similarity index 100% rename from finalized/articles/web_420.0.article.html rename to finalized/articles/web_420.0.html diff --git a/finalized/static/WHA.epub b/finalized/static/WHA.epub old mode 100755 new mode 100644 diff --git a/finalized/static/sleepy.html b/finalized/static/sleepy.html old mode 100755 new mode 100644 diff --git a/finalized/static/templates_old/auriga.template.html b/finalized/static/templates_old/auriga.template.html deleted file mode 100644 index 03a0b2b..0000000 --- a/finalized/static/templates_old/auriga.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -How should this website be laid out? -{%- endblock %} - -{% block body -%} -{%- include "articles/auriga.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/distributed_speakers.template.html b/finalized/static/templates_old/distributed_speakers.template.html deleted file mode 100644 index 18ee10a..0000000 --- a/finalized/static/templates_old/distributed_speakers.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Impromptu Soundsystems would be a good name for a band. -{%- endblock %} - -{% block body -%} -{%- include "articles/distributed_speakers.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/game_log.template.html b/finalized/static/templates_old/game_log.template.html deleted file mode 100644 index 29b1661..0000000 --- a/finalized/static/templates_old/game_log.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -I occasionally play some videogames. -{%- endblock %} - -{% block body -%} -{%- include "articles/game_log.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/language_for_games.template.html b/finalized/static/templates_old/language_for_games.template.html deleted file mode 100644 index 9a12a25..0000000 --- a/finalized/static/templates_old/language_for_games.template.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Features for a game-focused programming language or library -{%- endblock %} - -{% block body -%} -

I like making games but sometimes I spend a lot of time doing stuff that is just annoying. What if a language or environment were designed to make those things easy?

-
-{%- include "articles/snorlax_evaluation.article.html" -%} -
-{%- include "articles/time_integration.article.html" -%} -
-{%- include "articles/easy_peasy_state_machinesy.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/mindjail_engine.template.html b/finalized/static/templates_old/mindjail_engine.template.html deleted file mode 100644 index adb5f78..0000000 --- a/finalized/static/templates_old/mindjail_engine.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -The Mindjail Engine! -{%- endblock %} - -{% block body -%} -{%- include "articles/mindjail_engine.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/oauth.template.html b/finalized/static/templates_old/oauth.template.html deleted file mode 100644 index c9a785b..0000000 --- a/finalized/static/templates_old/oauth.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -I have used OAuth, and lived to tell the tale. -{%- endblock %} - -{% block body -%} -{%- include "articles/oauth.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/play_for_x.template.html b/finalized/static/templates_old/play_for_x.template.html deleted file mode 100644 index f0a942e..0000000 --- a/finalized/static/templates_old/play_for_x.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Play For X -{%- endblock %} - -{% block body -%} -{%- include "articles/play_for_x.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/shoof_shoof_revolution.template.html b/finalized/static/templates_old/shoof_shoof_revolution.template.html deleted file mode 100644 index 7bf7c69..0000000 --- a/finalized/static/templates_old/shoof_shoof_revolution.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Javascript DDR Clone -{%- endblock %} - -{% block body -%} -{%- include "articles/shoof_shoof_revolution.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/spinning.template.html b/finalized/static/templates_old/spinning.template.html deleted file mode 100644 index d4e824f..0000000 --- a/finalized/static/templates_old/spinning.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -I spin things around! -{%- endblock %} - -{% block body -%} -{%- include "articles/spinning.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/tamari.template.html b/finalized/static/templates_old/tamari.template.html deleted file mode 100644 index 8a25fec..0000000 --- a/finalized/static/templates_old/tamari.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -Tamari Lattices: very pretty. -{%- endblock %} - -{% block body -%} -{%- include "articles/tamari.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/finalized/static/templates_old/text_editors_with_contenteditable.template.html b/finalized/static/templates_old/text_editors_with_contenteditable.template.html deleted file mode 100644 index ba0ca4e..0000000 --- a/finalized/static/templates_old/text_editors_with_contenteditable.template.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "articles/article.template.html" %} - -{% block title -%} -contentEditable: Text Editors Made Easy? -{%- endblock %} - -{% block body -%} -{%- include "articles/text_editors_with_contenteditable.article.html" -%} -{%- endblock %} \ No newline at end of file diff --git a/generate.py b/generate.py index 2d46b9b..8c1f0b0 100644 --- a/generate.py +++ b/generate.py @@ -5,14 +5,12 @@ import shutil import argparse parser = argparse.ArgumentParser() -parser.add_argument("destination", help="where to put the rendered site") +parser.add_argument("-i", "--input", type=Path, help="source materials") +parser.add_argument("-o", "--output", type=Path, help="where to put the rendered site") args = parser.parse_args() -root_folder = Path(__file__).parent -source = root_folder / "source" -finals = root_folder / "finalized" -if args.destination: - finals = args.destination() +source = args.input +finals = args.output env = Environment( loader=FileSystemLoader(source), @@ -20,14 +18,36 @@ env = Environment( # clear out the folder finalized -shutil.copytree(source, finals) - # walk the source directory and make all the corresponding files into finalized -for path_to_file in (source / "articles").glob("*"): - rel_path = path_to_file.relative_to(source) - - if ".article.html" in str(path_to_file): - with open(finals / rel_path, "w") as output: - article_template = env.get_template("articles/article.template.html") - output.write(article_template.render(title="Article", target=str(path_to_file.relative_to(source)))) +article_template = env.get_template("articles/article.template.html") + +for path_to_source in source.glob("**/*"): + rel_path = path_to_source.relative_to(source) + path_to_output = finals / rel_path + + if ".ignore" in str(rel_path): + continue + + if path_to_source.is_dir(): + pass + + elif ".article.html" in str(path_to_source): + path_to_output = path_to_output.parent / path_to_output.name.replace(".article","") + with open(path_to_output, "w") as output_file: + os.makedirs(path_to_output.parent, exist_ok=True) + output_file.write(article_template.render(title="Article", target=str(rel_path))) + + elif ".renderme" in str(path_to_source): + path_to_output = path_to_output.parent / path_to_output.name.replace(".renderme","") + with open(path_to_output, "w") as output_file: + os.makedirs(path_to_output.parent, exist_ok=True) + output_file.write(env.get_template(rel_path).render()) + + elif ".template.html" in str(path_to_source): + pass + + else: + os.makedirs(path_to_output.parent, exist_ok=True) + shutil.copy(path_to_source, path_to_output) +