title prefix support
All checks were successful
/ build (push) Successful in 1m45s

This commit is contained in:
mr-boneman 2024-08-20 17:50:20 +02:00
parent 52cb376335
commit ab85f65044
2 changed files with 19 additions and 1 deletions

View file

@ -3,12 +3,20 @@ name = "releases"
[[feeds]] [[feeds]]
url = "https://github.com/nim-lang/Nim/releases.atom" url = "https://github.com/nim-lang/Nim/releases.atom"
kind = "Atom" kind = "Atom"
titlePrefix = "Nim: "
[[feeds]] [[feeds]]
url = "https://github.com/fatedier/frp/releases.atom" url = "https://github.com/fatedier/frp/releases.atom"
kind = "Atom" kind = "Atom"
titlePrefix = "frp: "
[[feeds]] [[feeds]]
url = "https://forgejo.org/releases/rss.xml" url = "https://forgejo.org/releases/rss.xml"
kind = "RSSv2" kind = "RSSv2"
titlePrefix = "Forgejo: "
timeFormat = "ddd',' dd MMM yyyy HH:mm:ss 'GMT'" timeFormat = "ddd',' dd MMM yyyy HH:mm:ss 'GMT'"
[[feeds]]
url = "https://github.com/project-zot/zot/releases.atom"
titlePrefix = "zot: "
kind = "Atom"

View file

@ -9,6 +9,7 @@ type RssFeed* = object
url*: string url*: string
kind*: FeedType kind*: FeedType
timeFormat*: string timeFormat*: string
titlePrefix*: string
proc parseAtomTime(s: string): DateTime = proc parseAtomTime(s: string): DateTime =
parse(s, atomTimeFormat) parse(s, atomTimeFormat)
@ -57,6 +58,15 @@ proc mixRssFeeds*(feeds: seq[RssFeed], name, id, link, authorName, description:s
item item
) )
if feed.titlePrefix.len > 0:
entries[^1].items = entries[^1].items.mapIt(
block:
var item = it
if item.title.isSome():
item.title = some(feed.titlePrefix&item.title.get())
item
)
for feed in entries: for feed in entries:
result.items.add feed.items result.items.add feed.items