rsrsss/xquery/opml/wikimedia.xqy

42 lines
1.4 KiB
Plaintext

declare function local:get-feeds($url as xs:anyURI, $language as xs:string) as node()* {
doc(resolve-uri('./w/index.php?title=Special:SiteMatrix', $url))//link[@rel = 'alternate'][@type = 'application/rss+xml' or @type = 'application/atom+xml']
! <outline
type="rss"
text="{@title}"
version="{if (@type = 'application/atom+xml') then 'ATOM' else 'RSS'}"
xmlUrl="{resolve-uri(@href, $url)}"
htmlUrl="{$url}"
language="{$language}"
/>
};
doc('https://commons.wikimedia.org/w/api.php?action=sitematrix&amp;format=xml')//sitematrix
! <opml version="2.0">
<head>
<title>Wikimedia RSS 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 $language in ./language
return <outline text="{$language/@localname}">
{
$language/site/site[not(@private)]
! local:get-feeds(@url, $language/@code)
}
</outline>
}
<outline text="Specials">
{
./specials/special[not(@private)]
! local:get-feeds(@url, @lang)
}
</outline>
</body>
</opml>