mirror of
https://github.com/RealOrangeOne/RealOrangeOne.git
synced 2024-11-21 12:39:30 +00:00
Add notes to profile
This commit is contained in:
parent
16ee7dbb27
commit
24b5ccd6cd
4 changed files with 40 additions and 5 deletions
11
README.md
11
README.md
|
@ -18,3 +18,14 @@
|
|||
- [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/)
|
||||
|
||||
## 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/)
|
||||
|
|
10
README.md.j2
10
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/)
|
||||
|
|
21
build.py
21
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__":
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
jinja2
|
||||
requests
|
||||
feedparser
|
||||
|
|
Loading…
Reference in a new issue