diff --git a/blog b/blog index 865a2f7..a909feb 160000 --- a/blog +++ b/blog @@ -1 +1 @@ -Subproject commit 865a2f7ca90d28bec65f591dc54ee30e2ef24bc7 +Subproject commit a909feba613d3a2e4cdc027c9e11c390f924a799 diff --git a/makefile b/makefile index a95139e..8841097 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,9 @@ OUT_DIR = site ROOT_DIR = $(SRC_DIR)/root -BLOG_SRC_DIR = blog/blogs +BLOG_BASE_DIR = blog/ +BLOG_BUILD_DIR = $(BLOG_BASE_DIR)out/html/ +BLOG_SRC_DIR = $(BLOG_BASE_DIR)blogs BLOG_OUT_DIR = $(OUT_DIR)/blog BLOG_TMP_DIR = .blogtmp @@ -65,8 +67,9 @@ $(BLOG_OUT_DIR)/%.jpg: $(BLOG_SRC_DIR)/%.jpg blog: $(BLOG_TARGETS) $(BLOG_PNG_TARGETS) $(BLOG_JPG_TARGETS) $(BLOG_RSS) | $(BLOG_TMP_DIR) -$(BLOG_RSS): $(BLOG_PAGES) - pipenv run python scripts/mkblogrss.py $(BLOG_PAGES) > $@ +$(BLOG_RSS): + make --directory $(BLOG_BASE_DIR) html + cp $(BLOG_BUILD_DIR)/index.xml $@ $(BLOG_INDEX_LINKS): $(BLOG_TARGETS) | $(BLOG_TMP_DIR) pipenv run python scripts/mkblogindex.py $(BLOG_TARGETS) > $@ diff --git a/scripts/mkblogrss.py b/scripts/mkblogrss.py deleted file mode 100644 index 4922fe5..0000000 --- a/scripts/mkblogrss.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 - -import markdown -import pathlib -import sys -import re - -def print_usage(): - print("\nusage: python mkblogrss.py POSTS\n") - print("\n") - print("\t\tPOSTS\tfilepaths of blog posts") - -# check args for at least one file path -if len(sys.argv) < 2: - print_usage() - sys.exit(1) - -# posts are arguments from index 1 onwards -posts = sys.argv[1:] - -# header and footer to enclose feed items -header = """ - - - ktyl.dev - https://ktyl.dev/blog/index.html - mostly computer stuff! - - """ -footer = "" - -# regex patterns -title_pattern = re.compile("

(.+)

") -path_pattern = re.compile("(.+)\/(\d{4})\/(\d{1,2})\/(\d{1,2})\/(.+).md") - -def make_item(path): - str = "\n" - - # get the HTML version of the file - text = "" - with open(path) as f: - text = f.read() - html = markdown.markdown(text, extensions=["fenced_code"]) - - # title - title = "" - m = title_pattern.match(html) - title = m.group(1) - str += f"{title}\n" - - # link - url = "/".join(pathlib.Path(path).parts[2:]) - url = url.replace(".md", ".html") - link = f"https://ktyl.dev/blog/{url}" - str += f"{link}\n" - - # content - description = html - description = re.sub('<', '<', description) - description = re.sub('>', '>', description) - str += f"{description}\n" - - # pub date - date = re.sub(path_pattern, r'\2-\3-\4', path) - str += f"{date}\n" - - str += "" - - return str - -# print everything! -print(header) -for p in posts: - print(make_item(p)) -print(footer) -