blog-site

https://lin.moe

git clone git://git.lin.moe/blog-site.git

 1#+Title: Lindsay
 2#+SUBTITLE:
 3#+OPTIONS: toc:nil
 4#+HTML_LINK_UP:
 5#+HTML_LINK_HOME:
 6
 7* Writings
 8+ [[./blog][Blog]]
 9+ [[https://nya.one/@lindsay][Fediverse]]
10
11* Contact
12|------------+----------------------|
13| Email      | [[mailto:Linsen Zhou <i@lin.moe>][i@lin.moe]]            |
14| IRC        | lindsay@irc.oftc.net |
15| PGP Pubkey | [[./pubkey.txt][7EB223B9B0D814B9]]     |
16
17* Friends
18+ [[https://kaix.in/][KAIX.IN]]
19+ [[https://qaq.land][qaqland's site]]
20
21* Articles from blog I follow
22#+NAME: rssfeeds
23#+begin_src elisp :exports none
24'("https://7ji.github.io/feed.xml"
25  "https://emersion.fr/blog/atom.xml"
26  "https://eli.thegreenplace.net/feeds/all.atom.xml"
27  "https://herbsutter.com/feed/"
28  "https://shansing.com/feed/")
29#+end_src
30
31#+begin_src python :exports results :eval yes :results raw :var feeds=rssfeeds
32import asyncio
33import aiohttp
34import feedparser
35
36docs=[]
37
38async def rss_feed_to_orgdoc(session: aiohttp.ClientSession, feed_url:str, limit:int=3):
39    async with session.get(feed_url) as response:
40        text = await response.text()
41        feed = feedparser.parse(text)
42        entries = []
43
44        for entry in feed.entries:
45            if entry.link: entries.append((entry.published_parsed, f"| [[{entry.link}][{entry.title}]] | [[{feed['feed']['link']}][{feed['feed']['title']}]]|"))
46        return entries[:limit]
47
48async def main():
49    tasks: list[asyncio.Task[object]] = []
50    async with aiohttp.ClientSession() as session:
51        async with asyncio.TaskGroup() as tg:
52            for i in feeds:
53                task = tg.create_task(rss_feed_to_orgdoc(session, i))
54                tasks.append(task)
55    docs=[]
56    for t in tasks:
57        docs += t.result()
58    docs.sort(key=lambda i: i[0], reverse=True)
59    docs = docs[:15]
60    return '| Title | Site|\n|------------+----------------------|\n' + '\n'.join([i[1] for i in docs])
61
62return asyncio.run(main())
63#+end_src