support for no background at all

This commit is contained in:
rhiannon morris 2023-03-07 16:14:42 +01:00
parent 57627e2af6
commit 474276e6a1
3 changed files with 29 additions and 7 deletions

View file

@ -176,4 +176,4 @@ makeItem nsfw file info@(Info {bg}) = [b|@0
date' = formatShort date
year' = #year date
updated' = if #updated info nsfw then [b|true|] else [b|false|]
bgStyle = ifJust bg \col -> [b| style="background: $col"|]
bgStyle = case bg of Other col -> [b| style="background: $col"|]; _ -> ""

View file

@ -1,9 +1,11 @@
{-# OPTIONS_GHC -fdefer-typed-holes #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Info
(Info (..),
tagsFor, descFor, imagesFor, linksFor, updatesFor, compareFor, sortFor,
Artist (..), Images' (..), Images, Image (..), Desc (..), DescField (..),
Link (..), Update (..),
Link (..), Update (..), Bg (..),
GalleryInfo (..), GalleryFilters (..), ArtistFilter (..), NsfwFilter (..),
IndexInfo (..),
readArtistFilter, matchArtist, readNsfwFilter, matchNsfw, matchFilters,
@ -57,7 +59,7 @@ data Info =
nsfwTags :: ![Text],
desc :: !Desc,
nsfwDesc :: !Desc,
bg :: !(Maybe Text),
bg :: !Bg,
images :: !Images,
thumb' :: !(Maybe FilePath),
links :: ![Link],
@ -65,6 +67,9 @@ data Info =
}
deriving (Eq, Show)
data Bg = Default | NoBorder | Other !Text
deriving (Eq, Show)
data Desc =
NoDesc
| TextDesc !Text
@ -279,12 +284,18 @@ instance FromYAML Info where
<*> m .:? "nsfw-tags" .!= []
<*> m .:? "desc" .!= NoDesc
<*> m .:? "nsfw-desc" .!= NoDesc
<*> m .:? "bg"
<*> m .:? "bg" .!= Default
<*> m .: "images"
<*> m .:? "thumb"
<*> m .:? "links" .!= []
<*> m .:? "extras" .!= []
instance FromYAML Bg where
parseYAML y =
YAML.withNull "default value" (pure Default) y
<|> YAML.withStr "css <image> or \"noborder\""
(\str -> pure if str == "noborder" then NoBorder else Other str) y
instance FromYAML Artist where
parseYAML y = justName y <|> withUrl y where
justName = YAML.withStr "name" \name -> pure $ Artist {name, url = Nothing}

View file

@ -84,9 +84,20 @@ make' root siteName prefix nsfw _dataDir dir
| otherwise = mempty
let warningT = makeWarning [b|.|]
let bgStyle = ifJust bg \col -> [b|@0
<style> #mainfig { background: $col; } </style>
|]
let bgStyle = case bg of
Default -> ""
NoBorder -> [b|@0
<style>
#mainfig {
background: transparent;
border: none;
box-shadow: none;
}
</style>
|]
Other col -> [b|@0
<style> #mainfig { background: $col; } </style>
|]
let url = [b|$root/$prefix/$dir|]
let desc = case artist of