Add RSS 3.0 support
This commit is contained in:
parent
45e5be4ef4
commit
6e86eee5fc
Binary file not shown.
After Width: | Height: | Size: 935 B |
|
@ -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")
|
|
@ -102,6 +102,10 @@
|
|||
<xsl:with-param name="format" select="'echo'" />
|
||||
<xsl:with-param name="extension" select="'xml'" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="converter">
|
||||
<xsl:with-param name="format" select="'rss3'" />
|
||||
<xsl:with-param name="extension" select="'txt'" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="converter">
|
||||
|
@ -182,9 +186,13 @@
|
|||
<xsl:text>.json</xsl:text>
|
||||
</arg>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$format = 'rss3'">
|
||||
<xsl:attribute name="raw-output">true</xsl:attribute>
|
||||
</xsl:if>
|
||||
</jq>
|
||||
|
||||
<xsl:if test="$format != 'json'">
|
||||
<xsl:if test="$format != 'json' and $format != 'rss3'">
|
||||
<json2xml short-empty="true" />
|
||||
</xsl:if>
|
||||
|
||||
|
|
Loading…
Reference in New Issue