Compare commits

..

7 Commits

Author SHA1 Message Date
ktyl 1cc66385ab feat(rss): generate unformatted file titles
continuous-integration/drone/push Build is failing Details
2023-11-15 01:18:53 +00:00
ktyl 17c12cadf4 feat: add journal as submodule 2023-11-15 01:18:53 +00:00
ktyl a76793e961 ci(garden): add rule file requirements
continuous-integration/drone/push Build is passing Details
2023-11-15 01:18:08 +00:00
ktyl 5b938fe2fa ci(garden): build garden site files 2023-11-15 01:17:12 +00:00
ktyl 7f4cc152ca feat: add navigation 2023-11-12 02:30:03 +00:00
ktyl 9849fff782 build: add make targets 2023-11-12 02:30:03 +00:00
ktyl 6ed995de6c feat(garden): generate rss 2023-11-12 02:29:55 +00:00
4 changed files with 41 additions and 16 deletions

View File

@ -15,6 +15,9 @@ BLOG_BUILD_DIR = $(BLOG_BASE_DIR)out/html/
BLOG_OUT_DIR = $(OUT_DIR)/blog BLOG_OUT_DIR = $(OUT_DIR)/blog
BLOG_INDEX = $(BLOG_BUILD_DIR)/index.html BLOG_INDEX = $(BLOG_BUILD_DIR)/index.html
GARDEN_BASE_DIR = $(SRC_DIR)/garden/
GARDEN_BUILD_DIR = $(GARDEN_BASE_DIR)html
PAGES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.html") PAGES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.html")
STYLES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.css") STYLES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.css")
IMAGES = $(shell find $(IMG_DIR) -wholename "$(IMG_DIR)/*.png") IMAGES = $(shell find $(IMG_DIR) -wholename "$(IMG_DIR)/*.png")
@ -26,7 +29,8 @@ HTML_TARGETS = $(PAGES:$(ROOT_DIR)/%.html=$(OUT_DIR)/%.html)
CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css) CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css)
PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png
all: html blog | $(OUT_DIR) all: html blog garden | $(OUT_DIR)
cp -r src/garden/html $(OUT_DIR)/garden
html: $(HTML_TARGETS) $(CSS_TARGETS) | $(OUT_DIR) html: $(HTML_TARGETS) $(CSS_TARGETS) | $(OUT_DIR)
cp $(IMG_DIR)/*.png $(OUT_DIR)/ cp $(IMG_DIR)/*.png $(OUT_DIR)/
@ -62,8 +66,12 @@ blog: $(HTML_INCLUDES) $(CSS_TARGETS)
cp $(CSS_TARGETS) `dirname $$page` ; \ cp $(CSS_TARGETS) `dirname $$page` ; \
done done
garden:
make --directory $(GARDEN_BASE_DIR) html
clean: clean:
make --directory $(GARDEN_BASE_DIR) clean
make --directory $(BLOG_BASE_DIR) clean make --directory $(BLOG_BASE_DIR) clean
rm -rf $(OUT_DIR) rm -rf $(OUT_DIR)
.PHONY: blog .PHONY: blog garden

View File

@ -1,6 +1,18 @@
html: feed.py Makefile
mkdir html
cp feed.py Makefile html
cp *.md html
clean-html:
[[ -d html ]] && rm -r html
.PHONY: clean-html
feed: feed:
python feed.py `pwd` python feed.py `pwd`
rss: feed rss: feed
.PHONY: feed clean: clean-html
.PHONY: feed clean

View File

@ -5,21 +5,20 @@ import pathlib
import sys import sys
import re import re
import glob import glob
import os
def print_usage(): def print_usage():
print("\nusage: python feed.py ROOT\n") print("\nusage: python feed.py ROOT\n")
print("\n") print("\n")
print("\t\ROOT\tbase folder") print("\t\ROOT\tbase folder")
def validate(): # check args for at most one file paths
# check args for at least one file path if len(sys.argv) > 2:
if len(sys.argv) < 2:
print_usage() print_usage()
sys.exit(1) sys.exit(1)
validate() base_folder = sys.argv[1] if len(sys.argv) == 2 else os.getcwd()
print(base_folder)
base_folder = sys.argv[1]
def get_paths() -> [str]: def get_paths() -> [str]:
return [x for x in glob.glob(f"{base_folder}/*.md")] return [x for x in glob.glob(f"{base_folder}/*.md")]
@ -31,14 +30,20 @@ def get_text(path):
#def to_html(md : str) -> str: #def to_html(md : str) -> str:
# return markdown.markdown(md, extensions=["fenced_code"]) # return markdown.markdown(md, extensions=["fenced_code"])
def get_title(md):
m = re.compile(r"^# (.+)\n").match(md)
if m is not None:
return m.groups(1)[0]
# truncated first line of file for auto-title
return md.splitlines()[0][0:30]
def get_entry(path): def get_entry(path):
return get_title(get_text(path)) return get_title(get_text(path))
def get_title(md):
return re.compile(r"^# (.+)\n").match(md).group(1)
def get_entries() -> [str]: def get_entries() -> [str]:
return "\n\n".join([get_entry(p) for p in get_paths()]) entries = [get_entry(p) for p in get_paths()]
return "\n\n".join(entries)
def get_header() -> str: def get_header() -> str:
return """<?xml version="1.0" encoding="utf-8" ?> return """<?xml version="1.0" encoding="utf-8" ?>

@ -1 +1 @@
Subproject commit e391e5eaf7137eda3765dab7b2f5cdc17f97afa0 Subproject commit 6249b069e3c6f5a740141db60d7aac41ad50c11f