From 6e86eee5fca769fcabb4a8fc1059e8844b4ca3b2 Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Mon, 5 Apr 2021 22:59:33 +0200 Subject: [PATCH] Add RSS 3.0 support --- img/rss3.gif | Bin 0 -> 935 bytes jq/convert/rss2rss3.jq | 35 +++++++++++++++++++++++++++++++++++ xslt/itsb.xsl | 10 +++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 img/rss3.gif create mode 100644 jq/convert/rss2rss3.jq diff --git a/img/rss3.gif b/img/rss3.gif new file mode 100644 index 0000000000000000000000000000000000000000..9b1fc636dc4c7810f3ca2317fd96b32cf81d762e GIT binary patch literal 935 zcmZ?wbhEHbRAJy__|Cwf$j4|e#aL_1G~bc=e;UJ+a=rhv!vCLG^8eY@|Ns9pjDpb+ z7}g=6_>+Z^f#E-c4#=0FJi)-x!XPLk;jv-C!DbGAF$0GM3lFyoD0}s2G(0@gEuk5e zGh;!rd%K))!xxL7Cx^TE?S+1B z7kCt()8P_+bZ&-b>$euJtxwNR4_~R*8zsELcaFQP-&v2aM>jTQr1Nnc*tYie_JYTU JSOo+atN{-uPm=%u literal 0 HcmV?d00001 diff --git a/jq/convert/rss2rss3.jq b/jq/convert/rss2rss3.jq new file mode 100644 index 0000000..868c987 --- /dev/null +++ b/jq/convert/rss2rss3.jq @@ -0,0 +1,35 @@ +# RSS 2.0 to RSS 3.0 converter +# Expects xmltodict JSON output, returns an RSS 3.0 feed + +def ensure_array: (. // []) | if type == "array" then . else [.] end; +def ensure_string: if type == "array" then .[0] else . end | if type == "object" then .["#text"] else . end; + +.rss.channel +| [{ + "title": .title, + "link": .link, + "description": .description, + "generator": .generator, + "last-modified": .pubDate, + "language": .language, + "rights": .copyright, + "creator": (.managingEditor // .webMaster), + "errorsto": "lucidiot@brainshit.fr" +}] + [.item | ensure_array[] | { + "title": .title, + "link": .link, + "description": .description, + "creator": .author, + "last-modified": .pubDate, + "guid": .guid, + "uri": (if (.guid|type) == "string" or .guid?["@isPermaLink"] != "false" then .guid else null end) +}] +| map([ + map_values(ensure_string) + | to_entries[] + | select(.value | . != null and length) + | "\(.key): \(.value)" + # Ensure there are spaces after all newlines + | gsub("\n"; "\n ") +] | join("\n")) +| join("\n\n") diff --git a/xslt/itsb.xsl b/xslt/itsb.xsl index 3bfa3f7..3d06cbb 100644 --- a/xslt/itsb.xsl +++ b/xslt/itsb.xsl @@ -102,6 +102,10 @@ + + + + @@ -182,9 +186,13 @@ .json + + + true + - +