feeds: include "title" in the output OPML -- when it exists
This commit is contained in:
@@ -41,6 +41,8 @@ let
|
|||||||
);
|
);
|
||||||
} // lib.optionalAttrs (raw.is_podcast or false) {
|
} // lib.optionalAttrs (raw.is_podcast or false) {
|
||||||
format = "podcast";
|
format = "podcast";
|
||||||
|
} // lib.optionalAttrs (raw.title or "" != "") {
|
||||||
|
title = lib.mkDefault raw.title;
|
||||||
};
|
};
|
||||||
|
|
||||||
podcasts = [
|
podcasts = [
|
||||||
|
@@ -16,6 +16,10 @@ let
|
|||||||
type = types.enum [ "text" "image" "podcast" ];
|
type = types.enum [ "text" "image" "podcast" ];
|
||||||
default = "text";
|
default = "text";
|
||||||
};
|
};
|
||||||
|
title = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
url = mkOption {
|
url = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = ''
|
description = ''
|
||||||
|
@@ -12,8 +12,24 @@ rec {
|
|||||||
# transform a list of feeds into an attrs mapping cat => [ feed0 feed1 ... ]
|
# transform a list of feeds into an attrs mapping cat => [ feed0 feed1 ... ]
|
||||||
partitionByCat = feeds: builtins.groupBy (f: f.cat) feeds;
|
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.
|
# 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.
|
# a list of RSS feeds.
|
||||||
opmlTerminals = feeds: lib.concatStringsSep "\n" (builtins.map opmlTerminal feeds);
|
opmlTerminals = feeds: lib.concatStringsSep "\n" (builtins.map opmlTerminal feeds);
|
||||||
# one node which packages some flat grouping of terminals.
|
# one node which packages some flat grouping of terminals.
|
||||||
|
Reference in New Issue
Block a user