allow separate title in gallery e.g. to avoid spoilers
This commit is contained in:
parent
ca647f33c1
commit
32f308d7f6
2 changed files with 26 additions and 21 deletions
|
@ -13,6 +13,7 @@ import qualified Data.HashMap.Strict as HashMap
|
||||||
import Data.HashSet (HashSet)
|
import Data.HashSet (HashSet)
|
||||||
import qualified Data.HashSet as HashSet
|
import qualified Data.HashSet as HashSet
|
||||||
import Data.List (intersperse, groupBy, sortBy, sortOn)
|
import Data.List (intersperse, groupBy, sortBy, sortOn)
|
||||||
|
import Data.Maybe
|
||||||
import qualified Data.Text.Lazy as Lazy
|
import qualified Data.Text.Lazy as Lazy
|
||||||
import System.FilePath (takeDirectory, joinPath, splitPath)
|
import System.FilePath (takeDirectory, joinPath, splitPath)
|
||||||
import GHC.Exts (Down (..), the)
|
import GHC.Exts (Down (..), the)
|
||||||
|
@ -145,7 +146,7 @@ makeYearItems nsfw year infos = [b|@0
|
||||||
year' = show year & foldMap \c -> [b|<span class=y>$c</span>|]
|
year' = show year & foldMap \c -> [b|<span class=y>$c</span>|]
|
||||||
|
|
||||||
makeItem :: Bool -> FilePath -> Info -> Builder
|
makeItem :: Bool -> FilePath -> Info -> Builder
|
||||||
makeItem nsfw file info@(Info {title, bg}) = [b|@0
|
makeItem nsfw file info@(Info {bg}) = [b|@0
|
||||||
<li class="item post$nsfw'" data-date="$date'" data-year=$year'
|
<li class="item post$nsfw'" data-date="$date'" data-year=$year'
|
||||||
data-updated="$updated'"
|
data-updated="$updated'"
|
||||||
data-tags="$tags'">
|
data-tags="$tags'">
|
||||||
|
@ -160,6 +161,7 @@ makeItem nsfw file info@(Info {title, bg}) = [b|@0
|
||||||
</figure>
|
</figure>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
|
title = fromMaybe (#title info) $ #galleryTitle info
|
||||||
dir = takeDirectory file
|
dir = takeDirectory file
|
||||||
thumb = getThumb dir info
|
thumb = getThumb dir info
|
||||||
nsfw' = if nsfw && #anyNsfw info then [b| nsfw|] else ""
|
nsfw' = if nsfw && #anyNsfw info then [b| nsfw|] else ""
|
||||||
|
|
|
@ -50,6 +50,7 @@ data Info =
|
||||||
-- | hide from gallery view
|
-- | hide from gallery view
|
||||||
unlisted :: !Bool,
|
unlisted :: !Bool,
|
||||||
title :: !Text,
|
title :: !Text,
|
||||||
|
galleryTitle :: !(Maybe Text),
|
||||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||||
nsfwOnly :: !Bool,
|
nsfwOnly :: !Bool,
|
||||||
tags :: ![Text],
|
tags :: ![Text],
|
||||||
|
@ -257,15 +258,17 @@ checkKeys mapping wanted = do
|
||||||
|
|
||||||
instance FromYAML Info where
|
instance FromYAML Info where
|
||||||
parseYAML = YAML.withMap "info" \m -> do
|
parseYAML = YAML.withMap "info" \m -> do
|
||||||
checkKeys m ["date", "sort", "updates", "show-updated", "unlisted", "title",
|
checkKeys m ["date", "sort", "updates", "show-updated", "unlisted",
|
||||||
"artist", "nsfw-only", "tags", "nsfw-tags", "desc",
|
"gallery-title", "title", "artist", "nsfw-only", "tags",
|
||||||
"nsfw-desc", "bg", "images", "thumb", "links", "extras"]
|
"nsfw-tags", "desc", "nsfw-desc", "bg", "images", "thumb",
|
||||||
|
"links", "extras"]
|
||||||
Info <$> m .: "date"
|
Info <$> m .: "date"
|
||||||
<*> m .:? "sort" .!= ""
|
<*> m .:? "sort" .!= ""
|
||||||
<*> (m .:? "updates" >>= updateList)
|
<*> (m .:? "updates" >>= updateList)
|
||||||
<*> m .:? "show-updated" .!= True
|
<*> m .:? "show-updated" .!= True
|
||||||
<*> m .:? "unlisted" .!= False
|
<*> m .:? "unlisted" .!= False
|
||||||
<*> m .: "title"
|
<*> m .: "title"
|
||||||
|
<*> m .:? "gallery-title"
|
||||||
<*> m .:? "artist"
|
<*> m .:? "artist"
|
||||||
<*> m .:? "nsfw-only" .!= False
|
<*> m .:? "nsfw-only" .!= False
|
||||||
<*> m .:? "tags" .!= []
|
<*> m .:? "tags" .!= []
|
||||||
|
|
Loading…
Reference in a new issue