feeds: include "title" in the output OPML -- when it exists
This commit is contained in:
parent
a829a8e027
commit
b1741a18e1
|
@ -41,6 +41,8 @@ let
|
|||
);
|
||||
} // lib.optionalAttrs (raw.is_podcast or false) {
|
||||
format = "podcast";
|
||||
} // lib.optionalAttrs (raw.title or "" != "") {
|
||||
title = lib.mkDefault raw.title;
|
||||
};
|
||||
|
||||
podcasts = [
|
||||
|
|
|
@ -16,6 +16,10 @@ let
|
|||
type = types.enum [ "text" "image" "podcast" ];
|
||||
default = "text";
|
||||
};
|
||||
title = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
url = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
|
|
|
@ -12,8 +12,24 @@ rec {
|
|||
# transform a list of feeds into an attrs mapping cat => [ feed0 feed1 ... ]
|
||||
partitionByCat = feeds: builtins.groupBy (f: f.cat) feeds;
|
||||
|
||||
xmlTag = tag: close: attrs:
|
||||
let
|
||||
fmt-attrs = builtins.concatStringsSep
|
||||
" "
|
||||
(lib.mapAttrsToList (name: value: ''${lib.escapeXML name}="${lib.escapeXML value}"'') attrs);
|
||||
fmt-close = if close then "/" else "";
|
||||
in
|
||||
''<${tag} ${fmt-attrs} ${fmt-close}>'';
|
||||
|
||||
# represents a single RSS feed.
|
||||
opmlTerminal = feed: ''<outline xmlUrl="${feed.url}" type="rss"/>'';
|
||||
opmlTerminal = feed: xmlTag "outline" true (
|
||||
{
|
||||
xmlUrl = feed.url;
|
||||
type = "rss";
|
||||
} // lib.optionalAttrs (feed.title != null) {
|
||||
title = feed.title;
|
||||
}
|
||||
);
|
||||
# a list of RSS feeds.
|
||||
opmlTerminals = feeds: lib.concatStringsSep "\n" (builtins.map opmlTerminal feeds);
|
||||
# one node which packages some flat grouping of terminals.
|
||||
|
|
Loading…
Reference in New Issue