fix desc field showing up without desc

This commit is contained in:
Rhiannon Morris 2020-08-09 01:20:34 +02:00
parent 61adebd4ab
commit d8c22fef0f
2 changed files with 6 additions and 6 deletions

View file

@ -12,12 +12,13 @@ where
import Records import Records
import Control.Applicative import Control.Applicative
import Control.Monad
import Data.Foldable (find) import Data.Foldable (find)
import Data.Hashable (Hashable) import Data.Hashable (Hashable)
import Data.HashSet (HashSet) import Data.HashSet (HashSet)
import qualified Data.HashSet as HashSet import qualified Data.HashSet as HashSet
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Data.Maybe (isJust, isNothing, fromMaybe) import Data.Maybe (isJust, isNothing)
import Data.Ord (comparing) import Data.Ord (comparing)
import Data.String (IsString) import Data.String (IsString)
import Data.Text (Text) 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 "month" Info Int where getField = #second . #dmy
instance HasField "day" Info Int where getField = #third . #dmy instance HasField "day" Info Int where getField = #third . #dmy
descFor :: Bool -> Info -> Text descFor :: Bool -> Info -> Maybe Text
descFor nsfw i = if nsfw then desc <> "\n" <> nsfwDesc else desc descFor nsfw (Info {desc, nsfwDesc}) = desc <> (guard nsfw *> nsfwDesc)
where desc = fromMaybe "" $ #desc i; nsfwDesc = fromMaybe "" $ #nsfwDesc i
tagsFor :: Bool -> Info -> [Text] tagsFor :: Bool -> Info -> [Text]
tagsFor nsfw i = if nsfw then #tags i <> #nsfwTags i else #tags i tagsFor nsfw i = if nsfw then #tags i <> #nsfwTags i else #tags i

View file

@ -104,8 +104,8 @@ makeArtist (Artist {name, url}) =
Just u -> [b|<a href="$*u">$*name</a>|] Just u -> [b|<a href="$*u">$*name</a>|]
Nothing -> [b|$*name|] Nothing -> [b|$*name|]
makeDesc :: Strict.Text -> Builder makeDesc :: Maybe Strict.Text -> Builder
makeDesc desc = [b|@4 makeDesc mdesc = ifJust mdesc \desc -> [b|@4
<section id=desc class=info-section> <section id=desc class=info-section>
<h2>about</h2> <h2>about</h2>
<div> <div>