RSS: dc:creator, more cdata wrappers, different desc formatting

This commit is contained in:
rhiannon morris 2024-08-21 08:30:51 +02:00
parent 07011227bc
commit 9d0b1a5eb3

View file

@ -26,11 +26,12 @@ make' :: Strict.Text -> Strict.Text -> GalleryInfo
-> Maybe FilePath -> [(FilePath, Info)] -> Builder
make' root name ginfo@(GalleryInfo {title, desc, prefix}) output infos = [b|
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>$name$title</title>
<title><![CDATA[$name$title]]></title>
<link>$link</link>
<description>$desc</description>
<description><![CDATA[$desc]]></description>
$selflink
$items
@ -50,11 +51,12 @@ make' root name ginfo@(GalleryInfo {title, desc, prefix}) output infos = [b|
makeItem :: Strict.Text -> FilePath -> Bool -> FilePath -> Info -> Builder
makeItem root prefix nsfw path info@(Info {title}) = [b|
<item>
<title>$title$suffix</title>
<title><![CDATA[$title$suffix]]></title>
<link>$link</link>
<guid>$link</guid>
$body
<dc:creator><![CDATA[$creator]]></dc:creator>
<pubDate>$date</pubDate>
$body
</item>
|]
where
@ -77,6 +79,8 @@ makeItem root prefix nsfw path info@(Info {title}) = [b|
dir = takeDirectory path
link = [b|$root/$prefix/$dir|]
creator = maybe "niss" (.name) info.artist
date = formatRSS $ latestDateFor nsfw info
artist = ifJust info.artist \case
Artist name Nothing -> [b|<p>by $name|]
@ -92,5 +96,9 @@ makeItem root prefix nsfw path info@(Info {title}) = [b|
makeDesc :: Desc -> Builder
makeDesc NoDesc = ""
makeDesc (TextDesc txt) = [b|$txt|]
makeDesc (LongDesc fs) = [b|<dl>$fields</dl>|]
where fields = map (\(DescField {name, text}) -> [b|<dt>$name <dd>$text|]) fs
makeDesc (LongDesc fs) = [b|<ul>$fields</ul>|] where
fields = map mkField fs
mkField (DescField {name, text}) = [b|
<li> <b>$name</b>:
$text
|]