diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 42ff82c..b3ad587 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -12,12 +12,13 @@ where import Records import Control.Applicative +import Control.Monad import Data.Foldable (find) import Data.Hashable (Hashable) import Data.HashSet (HashSet) import qualified Data.HashSet as HashSet import qualified Data.Map.Strict as Map -import Data.Maybe (isJust, isNothing, fromMaybe) +import Data.Maybe (isJust, isNothing) import Data.Ord (comparing) import Data.String (IsString) import Data.Text (Text) @@ -99,9 +100,8 @@ instance HasField "year" Info Integer where getField = #first . #dmy instance HasField "month" Info Int where getField = #second . #dmy instance HasField "day" Info Int where getField = #third . #dmy -descFor :: Bool -> Info -> Text -descFor nsfw i = if nsfw then desc <> "\n" <> nsfwDesc else desc - where desc = fromMaybe "" $ #desc i; nsfwDesc = fromMaybe "" $ #nsfwDesc i +descFor :: Bool -> Info -> Maybe Text +descFor nsfw (Info {desc, nsfwDesc}) = desc <> (guard nsfw *> nsfwDesc) tagsFor :: Bool -> Info -> [Text] tagsFor nsfw i = if nsfw then #tags i <> #nsfwTags i else #tags i diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index f6328f7..b1dbda4 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -104,8 +104,8 @@ makeArtist (Artist {name, url}) = Just u -> [b|$*name|] Nothing -> [b|$*name|] -makeDesc :: Strict.Text -> Builder -makeDesc desc = [b|@4 +makeDesc :: Maybe Strict.Text -> Builder +makeDesc mdesc = ifJust mdesc \desc -> [b|@4

about