use nsfw-desc in rss where appropriate

This commit is contained in:
Rhiannon Morris 2021-03-07 22:07:02 +01:00
parent c1d588f702
commit 519a50489f

View file

@ -39,14 +39,14 @@ make' root ginfo@(GalleryInfo {title, desc, prefix}) output infos = [b|@0
where where
link = [b|$root/$prefix|] link = [b|$root/$prefix|]
nsfw = #nsfw ginfo nsfw = #nsfw ginfo
items = map (uncurry $ makeItem root prefix) $ items = map (uncurry $ makeItem root prefix nsfw) $
sortBy (flip (compareFor nsfw `on` #second)) infos sortBy (flip (compareFor nsfw `on` #second)) infos
selflink = case output of selflink = case output of
Nothing -> "" Nothing -> ""
Just o -> [b|<atom:link href="$link/$o" rel="self" />|] Just o -> [b|<atom:link href="$link/$o" rel="self" />|]
makeItem :: Strict.Text -> FilePath -> FilePath -> Info -> Builder makeItem :: Strict.Text -> FilePath -> Bool -> FilePath -> Info -> Builder
makeItem root prefix path (Info {title, desc, date, artist}) = [b|@4 makeItem root prefix nsfw path i@(Info {title, date, artist}) = [b|@4
<item> <item>
<title>$title</title> <title>$title</title>
<link>$link</link> <link>$link</link>
@ -61,12 +61,13 @@ makeItem root prefix path (Info {title, desc, date, artist}) = [b|@4
artist' = ifJust artist \case artist' = ifJust artist \case
Artist {name, url = Nothing} -> [b|<p>by $name|] Artist {name, url = Nothing} -> [b|<p>by $name|]
Artist {name, url = Just url} -> [b|<p>by <a href=$url>$name</a>|] Artist {name, url = Just url} -> [b|<p>by <a href=$url>$name</a>|]
desc = descFor nsfw i
desc' = ifJust desc \d -> [b|$10.d|] desc' = ifJust desc \d -> [b|$10.d|]
descArtist' = if isJust desc || isJust artist then [b|@6 descArtist' = if isJust desc || isJust artist then [b|@6
<description> <description>
<![CDATA[ <![CDATA[
$desc' $10.desc'
$artist' $10.artist'
]]> ]]>
</description> </description>
|] |]