diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index b1e551a..61da17d 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -31,7 +31,7 @@ make nsfw dir = toLazyText . make' nsfw dir make' :: Bool -> FilePath -> Info -> Builder make' nsfw dir (Info {date, title, artist, tags, nsfwTags, - desc, nsfwDesc, images, links}) = [b|@0 + desc, nsfwDesc, images = allImages, links}) = [b|@0 @@ -76,9 +76,12 @@ make' nsfw dir (Info {date, title, artist, tags, nsfwTags, where artistTag = ifJust artist makeArtist + images | nsfw = allImages + | otherwise = filter #sfw allImages + formattedDate = formatDate date - buttonBar = makeButtonBar title nsfw images + buttonBar = makeButtonBar title images image0 = head images path0 = #path image0 download0 = fromMaybe path0 (#download image0) @@ -121,8 +124,8 @@ formatDate :: Day -> Builder formatDate d = let str = formatTime defaultTimeLocale "%e %#B %Y" d in [b|$@str|] -makeButtonBar :: Strict.Text -> Bool -> [Image] -> Builder -makeButtonBar title nsfw allImages = +makeButtonBar :: Strict.Text -> [Image] -> Builder +makeButtonBar title images = case length images of 0 -> throw $ NoEligibleImages title 1 -> "" @@ -133,10 +136,7 @@ makeButtonBar title nsfw allImages = |] - where - images | nsfw = allImages - | otherwise = filter #sfw allImages - alts = map (uncurry altButton) $ zip [0..] images + where alts = map (uncurry altButton) $ zip [0..] images altButton :: Int -> Image -> Builder altButton i (Image {label, path, nsfw, warning}) = [b|@6