diff --git a/make-pages/RSS.hs b/make-pages/RSS.hs
index ba12587..87a0305 100644
--- a/make-pages/RSS.hs
+++ b/make-pages/RSS.hs
@@ -10,6 +10,7 @@ import Data.Function (on)
import qualified Data.Text as Strict
import qualified Data.Text.Lazy as Lazy
import System.FilePath (takeDirectory)
+import Control.Monad
make :: Strict.Text -- ^ website root e.g. @https://gallery.niss.website@
@@ -47,9 +48,9 @@ make' root name ginfo@(GalleryInfo {title, desc, prefix}) output infos = [b|@0
Just o -> [b||]
makeItem :: Strict.Text -> FilePath -> Bool -> FilePath -> Info -> Builder
-makeItem root prefix nsfw path i@(Info {title, artist}) = [b|@4
+makeItem root prefix nsfw path info@(Info {title}) = [b|@4
- $title$suf
+ $title$suffix
$link
$link
$body
@@ -57,46 +58,39 @@ makeItem root prefix nsfw path i@(Info {title, artist}) = [b|@4
|]
where
- suf = let parts = catMaybes [o18, cnt, up] in
- if null parts then ""
- else " (" <> mconcat (intersperse ", " parts) <> ")"
- up = if hasUpdatesFor nsfw i then Just "updated" else Nothing
- o18 = if nsfw && anyNsfw i then Just "🔞" else Nothing
- cnt = let len = maybe 0 length $ allImages <$> imagesFor nsfw i in
- if len == 1 then Nothing else Just [b|$len images|]
+ body = [b|@6
+
+ |]
+
+ suffix = if null parts then ""
+ else " (" <> mconcat (intersperse ", " parts) <> ")"
+ parts = catMaybes [o18, cnt, up]
+ up = do guard $ hasUpdatesFor nsfw info; Just "updated"
+ o18 = do guard $ nsfw && anyNsfw info; Just "🔞"
+ cnt = do let len = maybe 0 length $ allImages <$> imagesFor nsfw info
+ guard $ len /= 1; Just [b|$len images|]
dir = takeDirectory path
link = [b|$root/$prefix/$dir|]
- date = formatRSS $ latestDateFor nsfw i
- artist' = ifJust artist \case
- Artist {name, url = Nothing} -> [b|
by $name|]
- Artist {name, url = Just url} -> [b|
by $name|]
- desc = descFor nsfw i
- desc' = makeDesc desc
+ date = formatRSS $ latestDateFor nsfw info
+ artist = ifJust info.artist \case
+ Artist name Nothing -> [b|
by $name|]
+ Artist name (Just url) -> [b|
by $name|]
+ desc = makeDesc $ descFor nsfw info
- body = [b|@6
-
- |]
-
- image = case previewImage i of
- Just (PFull img) -> go $ pageFile img
- Just (PThumb th) -> go $ thumbFile th
- Nothing -> ""
- where go p = [b|@0
-
- |]
+ image = case previewImage info of
+ Just (PFull img) -> figure $ pageFile img
+ Just (PThumb th) -> figure $ thumbFile th
+ Nothing -> ""
+ figure p = [b||]
makeDesc :: Desc -> Builder
makeDesc NoDesc = ""
makeDesc (TextDesc txt) = [b|$txt|]
makeDesc (LongDesc fs) = [b|