From 24b5ccd6cdf7ddb147e05acbf616c902acce2f4f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 18 Feb 2024 21:09:47 +0000 Subject: [PATCH] Add notes to profile --- README.md | 13 ++++++++++++- README.md.j2 | 10 +++++++++- build.py | 21 ++++++++++++++++++--- requirements.txt | 1 + 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 143905a..4044127 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,15 @@ - [State of the Server 2024](https://theorangeone.net/posts/state-of-the-server-2024/) (2024-01-01) - [Forcing dark mode in Android Auto Maps](https://theorangeone.net/posts/dark-android-auto-maps/) (2023-12-18) -:globe_with_meridians: View more: [theorangeone.net/posts](https://theorangeone.net/posts/) \ No newline at end of file +:globe_with_meridians: View more: [theorangeone.net/posts](https://theorangeone.net/posts/) + +## Recent notes + + +- [Navigate mkdocs by tag](https://notes.theorangeone.net/notes/mkdocs-nav-by-tag/) `Mkdocs` - (2024-02-17) +- [Stop saving bash history](https://notes.theorangeone.net/notes/shell/stop-saving-history/) `Shell` - (2022-11-02) +- [Monitor redis commands](https://notes.theorangeone.net/notes/database/redis-monitor/) `Redis` - (2022-09-30) +- [Get credentials for an assumed role](https://notes.theorangeone.net/notes/infrastructure/assume-role-credentials/) `AWS` - (2022-09-13) +- [Downmixing audio channels](https://notes.theorangeone.net/notes/shell/ffmpeg-downmixing-audio/) `Media` - (2021-10-27) + +:pencil2: View more: [notes.theorangeone.net](https://notes.theorangeone.net/) diff --git a/README.md.j2 b/README.md.j2 index b8a6b70..83a7181 100644 --- a/README.md.j2 +++ b/README.md.j2 @@ -11,7 +11,15 @@ ## Recent posts {% for post in latest_posts %} -- [{{ post.title }}]({{ post.full_url }}) ({{ post.date}}) +- [{{ post.title }}]({{ post.full_url }}) ({{ post.date }}) {%- endfor %} :globe_with_meridians: View more: [theorangeone.net/posts](https://theorangeone.net/posts/) + +## Recent notes + +{% for note in recent_notes %} +- [{{ note.title }}]({{ note.link }}) {% for tag in note.tags %}`{{ tag }}`{% if not loop.last %} {% endif %}{% endfor %} - ({{ note.published }}) +{%- endfor %} + +:pencil2: View more: [note.theorangeone.net](https://notes.theorangeone.net/) diff --git a/build.py b/build.py index 0d8cb7f..4e63cdc 100755 --- a/build.py +++ b/build.py @@ -3,6 +3,10 @@ import jinja2 from pathlib import Path import requests +import feedparser +from datetime import date +import time +from operator import itemgetter PROJECT_DIR = Path(__file__).resolve().parent @@ -15,16 +19,27 @@ def get_posts() -> list[dict]: response.raise_for_status() return response.json()["results"] +def get_notes() -> list[dict]: + notes = [] + for note in feedparser.parse("https://notes.theorangeone.net/feed_rss_created.xml")["entries"]: + notes.append({ + "title": note.title, + "link": note.link, + "published": date.fromtimestamp(time.mktime(note.published_parsed)), + "tags": sorted([tag.term for tag in getattr(note, "tags", [])]) + }) + + return sorted(notes, key=itemgetter("published"), reverse=True)[:5] + def main(): template = jinja2.Template(TEMPLATE_FILE.read_text()) new_readme = template.render( - latest_posts=get_posts() + latest_posts=get_posts(), + recent_notes=get_notes() ) - print(new_readme) - OUTPUT_FILE.write_text(new_readme) if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index b93a7b1..03f3a1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ jinja2 requests +feedparser