51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
# AAIA feed generator
|
|
# Expects pup JSON output holding <tr> tags, outputs xmltodict-compatible JSON
|
|
# WARNING: Dates are locale-sensitive; the RSS feed might not generate correctly with another locale.
|
|
# Expected variables:
|
|
# $lang: Language code, without the country code (en/zh-Hans/zh-Hant).
|
|
# $link: Link to the investigation list.
|
|
import "./helpers" as helpers;
|
|
|
|
{
|
|
"rss": {
|
|
"@version": "2.0",
|
|
"channel": {
|
|
"title": "AAIA (\($lang))",
|
|
"description": "Air Accident Investigation Authority reports",
|
|
"link": $link,
|
|
"language": "\($lang)-HK",
|
|
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
|
|
"docs": "https://www.rssboard.org/rss-specification",
|
|
"ttl": 1440,
|
|
"generator": "ITSB",
|
|
"item": [
|
|
.[].children // []
|
|
# Ignore empty lines
|
|
| select(length)
|
|
| . as $data
|
|
# Grab all the report links, as we will use the last one as the link and put all of them in the description
|
|
| [
|
|
.[2:][].children
|
|
| ..
|
|
| select(.tag? == "a")
|
|
| .href |= helpers::urlresolve($link)
|
|
]
|
|
| {
|
|
"title": ($data[1].text // $data[1].children[0].text),
|
|
"link": .[-1].href,
|
|
"description": (
|
|
[.[] | "<li><a href=\"\(.href)\" target=\"_blank\">\(.text)</a></li>"]
|
|
| join("")
|
|
| "<ul>\(.)</ul>"
|
|
),
|
|
"pubDate": (
|
|
$data[0].text // $data[0].children[0].text
|
|
| if $lang == "en" then strptime("%d %B %Y") | mktime else helpers::parse_chinese_date end
|
|
| strftime("%a, %d %b %Y %T %z")
|
|
)
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|