Rewrite the OPML generator in XQuery
This commit is contained in:
parent
79daa5d690
commit
c3ae653194
8
Makefile
8
Makefile
|
@ -1,11 +1,11 @@
|
|||
.PHONY: all
|
||||
all: css/sprites.css opml/feeds.opml opml/nhc.opml
|
||||
|
||||
opml/feeds.opml: feed.xml xsl/opml.xsl
|
||||
xsltproc --stringparam current-date "$(shell date -R)" -o $@ xsl/opml.xsl feed.xml
|
||||
opml/feeds.opml: feed.xml xquery/feeds_opml.xqy
|
||||
xidel --silent feed.xml --extract-kind=xquery3 --extract-file=xquery/feeds_opml.xqy --output-format=xml > $@
|
||||
chmod a+r $@
|
||||
|
||||
opml/nhc.opml: bin/build_nhc_opml
|
||||
opml/nhc.opml: bin/build_nhc_opml xquery/nhc_opml.xqy
|
||||
bin/build_nhc_opml > $@
|
||||
chmod a+r $@
|
||||
|
||||
|
@ -15,6 +15,6 @@ img/sprites.png: $(sprites)
|
|||
convert $(sprites) +append $@
|
||||
chmod a+r $@
|
||||
|
||||
css/sprites.css: img/sprites.png
|
||||
css/sprites.css: img/sprites.png xquery/build_sprites_css.xqy
|
||||
xidel --silent --extract-kind=xquery3 --extract-file=xquery/build_sprites_css.xqy > $@
|
||||
chmod a+r $@
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
xquery version "3.0" encoding "utf-8";
|
||||
<opml version="2.0">
|
||||
<head>
|
||||
<title>RSRSSS curated feeds</title>
|
||||
<dateModified>{format-dateTime(adjust-dateTime-to-timezone(current-dateTime(), xs:dayTimeDuration("PT0S")), "[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] GMT")}</dateModified>
|
||||
<ownerName>lucidiot</ownerName>
|
||||
<ownerEmail>lucidiot@envs.net</ownerEmail>
|
||||
<ownerId>https://tilde.town/~lucidiot/contact.html</ownerId>
|
||||
<docs>http://dev.opml.org/spec2.html</docs>
|
||||
</head>
|
||||
<body>
|
||||
{
|
||||
for $item in /rss/channel/item[category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='Feed' or text()='OPML')] and link]
|
||||
return element outline {
|
||||
attribute type {
|
||||
if (exists($item/category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='OPML')]))
|
||||
then 'include'
|
||||
else 'rss'
|
||||
},
|
||||
attribute text {$item/title},
|
||||
attribute title {$item/title},
|
||||
attribute xmlUrl {$item/link},
|
||||
if (exists($item/description)) then attribute description {normalize-space($item/description)} else (),
|
||||
if (exists($item/pubDate)) then attribute created {$item/pubDate} else (),
|
||||
let $categories := string-join(
|
||||
$item/category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()!='OPML' and text()!='Feed')]/text()
|
||||
! concat('/', .),
|
||||
','
|
||||
)
|
||||
return if (string-length($categories) > 0)
|
||||
then attribute category {$categories}
|
||||
else ()
|
||||
}
|
||||
}
|
||||
</body>
|
||||
</opml>
|
74
xsl/opml.xsl
74
xsl/opml.xsl
|
@ -1,74 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="xml" indent="yes" />
|
||||
<xsl:param name="current-date" />
|
||||
|
||||
<xsl:template match="channel">
|
||||
<opml version="2.0">
|
||||
<head>
|
||||
<title>RSRSSS curated feeds</title>
|
||||
<xsl:if test="$current-date">
|
||||
<dateModified>
|
||||
<xsl:value-of select="$current-date" />
|
||||
</dateModified>
|
||||
</xsl:if>
|
||||
<ownerName>lucidiot</ownerName>
|
||||
<ownerEmail>lucidiot@envs.net</ownerEmail>
|
||||
<ownerId>https://tilde.town/~lucidiot/contact.html</ownerId>
|
||||
<docs>http://dev.opml.org/spec2.html</docs>
|
||||
</head>
|
||||
<body>
|
||||
<xsl:apply-templates select="item[category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='Feed' or text()='OPML')] and link]" />
|
||||
</body>
|
||||
</opml>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="item[category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='Feed' or text()='OPML')] and link]">
|
||||
<xsl:element name="outline">
|
||||
<xsl:attribute name="type">
|
||||
<xsl:choose>
|
||||
<xsl:when test="category[@domain='https://envs.net/~lucidiot/rsrsss/' and text()='OPML']">
|
||||
<xsl:text>include</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>rss</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:attribute name="text">
|
||||
<xsl:value-of select="title" />
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="title">
|
||||
<xsl:value-of select="title" />
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="xmlUrl">
|
||||
<xsl:value-of select="link" />
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:if test="description">
|
||||
<xsl:attribute name="description">
|
||||
<xsl:value-of select="normalize-space(description)" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="pubDate">
|
||||
<xsl:attribute name="created">
|
||||
<xsl:value-of select="pubDate" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="category[@domain='https://envs.net/~lucidiot/rsrsss/' and text()!='Feed' and text()!='OPML']">
|
||||
<xsl:attribute name="category">
|
||||
<xsl:for-each select="category[@domain='https://envs.net/~lucidiot/rsrsss/' and text()!='Feed' and text()!='OPML']">
|
||||
<xsl:text>/</xsl:text>
|
||||
<xsl:value-of select="." />
|
||||
<xsl:if test="position() != last()">,</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue