Ignore non-standard languages in Wikimedia OPML generator

This commit is contained in:
~lucidiot 2023-11-19 20:26:08 +01:00
parent 89e1f93edf
commit e8c1b81751
1 changed files with 11 additions and 8 deletions

View File

@ -1,13 +1,16 @@
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}"
/>
! element outline {
attribute type { "rss" },
attribute text { @title },
attribute version { if (@type = 'application/atom+xml') then 'ATOM' else 'RSS' },
attribute xmlUrl { resolve-uri(@href, $url) },
attribute htmlUrl { $url },
(: Some languages are not actual language codes, like `wikidata` or `labs` or `wikimania2008`, so we do not include them :)
if (fn:matches($language, "\d|^\w{4,}"))
then ()
else attribute { "language" } { $language }
}
};
doc('https://commons.wikimedia.org/w/api.php?action=sitematrix&amp;format=xml')//sitematrix