This commit is contained in:
parent
cb680241a4
commit
52cb376335
2 changed files with 13 additions and 3 deletions
|
|
@ -7,3 +7,8 @@ kind = "Atom"
|
||||||
[[feeds]]
|
[[feeds]]
|
||||||
url = "https://github.com/fatedier/frp/releases.atom"
|
url = "https://github.com/fatedier/frp/releases.atom"
|
||||||
kind = "Atom"
|
kind = "Atom"
|
||||||
|
|
||||||
|
[[feeds]]
|
||||||
|
url = "https://forgejo.org/releases/rss.xml"
|
||||||
|
kind = "RSSv2"
|
||||||
|
timeFormat = "ddd',' dd MMM yyyy HH:mm:ss 'GMT'"
|
||||||
|
|
@ -5,9 +5,10 @@ const
|
||||||
atomTimeFormat* {.strdefine.} = "yyyy-MM-dd'T'HH:mm:ss'Z'"
|
atomTimeFormat* {.strdefine.} = "yyyy-MM-dd'T'HH:mm:ss'Z'"
|
||||||
rssv2TimeFormat* {.strdefine.} = "ddd',' dd MMM yyyy HH:mm:ss ZZZ"
|
rssv2TimeFormat* {.strdefine.} = "ddd',' dd MMM yyyy HH:mm:ss ZZZ"
|
||||||
|
|
||||||
type RssFeed* = object # name:string
|
type RssFeed* = object
|
||||||
url*: string
|
url*: string
|
||||||
kind*: FeedType
|
kind*: FeedType
|
||||||
|
timeFormat*: string
|
||||||
|
|
||||||
proc parseAtomTime(s: string): DateTime =
|
proc parseAtomTime(s: string): DateTime =
|
||||||
parse(s, atomTimeFormat)
|
parse(s, atomTimeFormat)
|
||||||
|
|
@ -48,6 +49,10 @@ proc mixRssFeeds*(feeds: seq[RssFeed], name, id, link, authorName, description:s
|
||||||
entries[^1].items = entries[^1].items.mapIt(
|
entries[^1].items = entries[^1].items.mapIt(
|
||||||
block:
|
block:
|
||||||
var item = it
|
var item = it
|
||||||
|
if feed.timeFormat.len != 0 and item.pubDate.isSome():
|
||||||
|
# if the IDE screams at you here, ignore it
|
||||||
|
item.pubdate = some(parse(item.pubDate.get(), feed.timeFormat).format(atomTimeFormat))
|
||||||
|
else:
|
||||||
item.pubdate = some(getRssv2Time(item).format(atomTimeFormat))
|
item.pubdate = some(getRssv2Time(item).format(atomTimeFormat))
|
||||||
item
|
item
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue