4 #| This program pulls out the changelog URLs in package metadata.xml and spits out an OPML file.
5 #| In this repository it's assumed <changelog>s all point to a valid feed file. That's not
6 #| mandated by the metadata.xml spec, but I have higher standards.
7 sub MAIN(IO::Path() $repo-root where *.d = $*PROGRAM.parent.parent);
9 my $cat-dir = { .IO.d and .contains('-') };
10 my $pkg-dir = none(<. .. metadata.xml>);
12 # OPML is a shit mid-2000s XML format, underspecced, no validators, useless wikipedia page.
13 # Everything that *implements* it gets it wrong too. Liferea dumps this into a flat list.
14 # Someone needs to make something better than this.
18 <title>Overlay package changelogs</title>
19 <dateCreated>{DateTime.now}</dateCreated>
20 <docs>http://dev.opml.org/spec2.html</docs>
23 <outline type="folder" text="{$repo-root.child('profiles/repo_name').lines} repository">
26 for $repo-root.dir(test => $cat-dir) -> $cat {
27 my Bool $has-contents = False; #= Don't create empty folders
29 for $cat.map(*.dir(test => $pkg-dir)).flat -> $pkg {
30 with $pkg.child('metadata.xml').slurp ~~ /'<changelog>' <(.*?)> '</changelog>'/ -> $uri {
31 put qq{<outline type="folder" text="$cat">}.indent(6) unless $has-contents;
33 put qq{<outline type="rss" text="$pkg.basename()" xmlUrl="$uri"/>}.indent(8);
37 put qq{</outline>}.indent(6) if $has-contents;