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