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 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

View File

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