From d0e08324e8e57bd434c4689a71486274b2dd1f98 Mon Sep 17 00:00:00 2001 From: ktyl Date: Wed, 4 Oct 2023 00:45:09 +0100 Subject: [PATCH] feat(garden): generate rss --- src/garden/feed.py | 58 +++++++++++++++++++++++++++++++++++++++++++ src/garden/feed.xml | 15 +++++++++++ src/garden/gardens.md | 5 ++++ src/garden/rss.md | 26 ++++++++++++++----- 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 src/garden/feed.py create mode 100644 src/garden/feed.xml create mode 100644 src/garden/gardens.md diff --git a/src/garden/feed.py b/src/garden/feed.py new file mode 100644 index 0000000..3b06350 --- /dev/null +++ b/src/garden/feed.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import markdown +import pathlib +import sys +import re +import glob + +def print_usage(): + print("\nusage: python feed.py ROOT\n") + print("\n") + print("\t\ROOT\tbase folder") + +def validate(): + # check args for at least one file path + if len(sys.argv) < 2: + print_usage() + sys.exit(1) + +validate() + +base_folder = sys.argv[1] + +def get_paths() -> [str]: + return [x for x in glob.glob(f"{base_folder}/*.md")] + +def get_text(path): + with open(path) as f: + return f.read() + +#def to_html(md : str) -> str: +# return markdown.markdown(md, extensions=["fenced_code"]) + +def get_entry(path): + return get_title(get_text(path)) + +def get_title(md): + return re.compile(r"^# (.+)\n").match(md).group(1) + +def get_entries() -> [str]: + return "\n\n".join([get_entry(p) for p in get_paths()]) + +def get_header() -> str: + return """ + + + + https://ktyl.dev/garden + + +""" + +def get_footer() -> str: + return "\n" + +print(get_header()) +print(get_entries()) +print(get_footer()) diff --git a/src/garden/feed.xml b/src/garden/feed.xml new file mode 100644 index 0000000..6a3cc83 --- /dev/null +++ b/src/garden/feed.xml @@ -0,0 +1,15 @@ + +python feed.py `pwd` + + + + + https://ktyl.dev/garden + + + +Digital Gardens + +RSS + + diff --git a/src/garden/gardens.md b/src/garden/gardens.md new file mode 100644 index 0000000..0c5a470 --- /dev/null +++ b/src/garden/gardens.md @@ -0,0 +1,5 @@ +# Digital Gardens + +* Obsidian +* Notion +* Git diff --git a/src/garden/rss.md b/src/garden/rss.md index 7ed2589..47390ec 100644 --- a/src/garden/rss.md +++ b/src/garden/rss.md @@ -1,16 +1,30 @@ # RSS -Really Simple Syndication (RSS) is a an ancient file format for communicating updates over the Web. +Really Simple Syndication (RSS) is an ancient file format for communicating updates over the Web, and my personal favourite. -## Stubs: +* [It's Time for an RSS Revival](https://www.wired.com/story/rss-readers-feedly-inoreader-old-reader/) -* readers -* feed generation +### Stubs: -## YouTube Subscriptions +* my curated feeds +* reader applications + +## Technical Simplicity + +From a technical perspective, like [Gemini](gemini://gemini.circumlunar.space) [\(HTTP\)](https://gemini.circumlunar.space/) it's grokkable with a couple good reads of the specification. +I wrote [a simple generator](https://ktyl.dev/blog/2022/6/3/rss.md)] for my blog posts, and am now working on [a simpler one](./feed.py) for the garden. +To start with, I'd like to generate it as simply as possible, from just a directory structure, but I can already see I'd like to do more with it. + +I work predominantly in [Git](https://git-scm.com/) repositories, which, like a directory, or a garden, is tree-based. +My blog's feed has a chronological hierarchy, but at present it's based on manually creating and naming folders. +It's also very much a _published_ format, rather than a living one. +This is silly! +Instead, I'd like to structure my feed around a Git repository, as I think it'd be a much better descriptor of activity. + +## Managing YouTube Subscriptions There are many reasons to avoid the YouTube homepage, such as recommended videos or the accursed Shorts. -Since RSS feeds are published per-channel, it's totally possible to circumvent its subscription system entirely - including having to make an account - and keep track of channels one enjoys with RSS feeds instead. +YouTube publishes channel-specific RSS feeds, making it totally possible to circumvent its subscription system entirely - including having to make an account - and keep track of channels one enjoys with RSS feeds instead. Get a channel's ID: 1. Go to the channel's page