From 1d699fdc5c606924c8d45762afadcb6ac9da4542 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 11 Aug 2020 00:15:42 +0100 Subject: refactor(tazjin/atom-feed): Make content optional This allows for adding feed entries which only have an alternate representation (i.e. URL that points somewhere else). These entries will still have a summary, in my use-case. Change-Id: I149838c5f59c66e8169b97f35b378aefe9763a84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1714 Tested-by: BuildkiteCI Reviewed-by: tazjin --- users/tazjin/atom-feed/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/users/tazjin/atom-feed/default.nix b/users/tazjin/atom-feed/default.nix index 369295da28..cd189b8675 100644 --- a/users/tazjin/atom-feed/default.nix +++ b/users/tazjin/atom-feed/default.nix @@ -29,10 +29,8 @@ let # not be blank. title = string; - # Content of the entry. This element is technically optional, but - # only if an alternate link is provided. In practice it should - # always be present in the feeds generated by this code. - content = string; + # Content of the entry. + content = option string; # Indicates the last time the entry was modified in a significant # way (in seconds since epoch). @@ -113,7 +111,11 @@ let ${elem "title" e.title} ${elem "id" e.id} ${elem "updated" (renderEpoch e.updated)} - ${escape e.content} + ${if e ? content + then ''${escape e.content}'' + else "" + } + ${if e ? summary then elem "summary" e.summary else ""} ${concatStrings (map renderAuthor (e.authors or []))} ${if e ? subtitle then elem "subtitle" e.subtitle else ""} ${if e ? rights then elem "rights" e.rights else ""} -- cgit 1.4.1