Compare commits
3 Commits
570cefafbb
...
f72c3e7f35
Author | SHA1 | Date |
---|---|---|
ktyl | f72c3e7f35 | |
ktyl | 1cc66385ab | |
ktyl | 17c12cadf4 |
|
@ -4,3 +4,12 @@
|
||||||
[submodule "blog"]
|
[submodule "blog"]
|
||||||
path = blog
|
path = blog
|
||||||
url = https://sauce.pizzawednes.day/ktyl/blog.git
|
url = https://sauce.pizzawednes.day/ktyl/blog.git
|
||||||
|
[submodule "journal"]
|
||||||
|
path = sr/garden/journal
|
||||||
|
url = git@sauce.pizzawednes.day:ktyl/journal.git
|
||||||
|
[submodule "src/garden/period3.xyz"]
|
||||||
|
path = src/garden/period3.xyz
|
||||||
|
url = git@sauce.pizzawedney.day:ktyl/period3.xyz
|
||||||
|
[submodule "src/garden/journal"]
|
||||||
|
path = src/garden/journal
|
||||||
|
url = git@sauce.pizzawednes.day:ktyl/journal
|
||||||
|
|
|
@ -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" ?>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 75d9edd04dbd5d0ae7c79244779b1ed364d94e5a
|
Loading…
Reference in New Issue