feat(garden): generate rss

This commit is contained in:
ktyl 2023-10-04 00:45:09 +01:00
parent cb39047ee9
commit 6ed995de6c
4 changed files with 98 additions and 6 deletions

58
src/garden/feed.py Normal file
View File

@ -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 """<?xml version="1.0" encoding="utf-8" ?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title></title>
<link>https://ktyl.dev/garden</link>
<description></description>
<atom:link href="https://ktyl.dev/garden/feed.xml" rel="self" type="application/rss+xml"/>
"""
def get_footer() -> str:
return "\n</channel></rss>"
print(get_header())
print(get_entries())
print(get_footer())

15
src/garden/feed.xml Normal file
View File

@ -0,0 +1,15 @@
python feed.py `pwd`
<?xml version="1.0" encoding="utf-8" ?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title></title>
<link>https://ktyl.dev/garden</link>
<description></description>
<atom:link href="https://ktyl.dev/garden/feed.xml" rel="self" type="application/rss+xml"/>
Digital Gardens
RSS
</channel></rss>

5
src/garden/gardens.md Normal file
View File

@ -0,0 +1,5 @@
# Digital Gardens
* Obsidian
* Notion
* Git

View File

@ -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