add bg property for displaying transparent images
This commit is contained in:
parent
1e0b955029
commit
8865b951fa
3 changed files with 12 additions and 4 deletions
|
@ -122,11 +122,11 @@ makeYearItems nsfw year infos = [b|@4
|
||||||
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}) = [b|@4
|
makeItem nsfw file info@(Info {title, bg}) = [b|@4
|
||||||
<li class="item post$nsfw'" data-tags="$tags'">
|
<li class="item post$nsfw'" data-tags="$tags'">
|
||||||
<figure>
|
<figure>
|
||||||
<a href="$@dir">
|
<a href="$@dir">
|
||||||
<img src="$@thumb">
|
<img src="$@thumb"$bgStyle>
|
||||||
</a>
|
</a>
|
||||||
<figcaption>$*title</figcaption>
|
<figcaption>$*title</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
@ -136,3 +136,4 @@ makeItem nsfw file info@(Info {title}) = [b|@4
|
||||||
thumb = maybe (throw $ NoThumb dir) (\t -> dir </> thumbFile t) $ #thumb info
|
thumb = maybe (throw $ NoThumb dir) (\t -> dir </> thumbFile t) $ #thumb info
|
||||||
nsfw' = if nsfw && #anyNsfw info then " nsfw" else ""
|
nsfw' = if nsfw && #anyNsfw info then " nsfw" else ""
|
||||||
tags' = fold $ intersperse ";" $ map fromText $ tagsFor nsfw info
|
tags' = fold $ intersperse ";" $ map fromText $ tagsFor nsfw info
|
||||||
|
bgStyle = ifJust bg \col -> [b| style="background: $*col"|]
|
||||||
|
|
|
@ -39,6 +39,7 @@ data Info =
|
||||||
nsfwTags :: ![Text],
|
nsfwTags :: ![Text],
|
||||||
desc :: !(Maybe Text),
|
desc :: !(Maybe Text),
|
||||||
nsfwDesc :: !(Maybe Text),
|
nsfwDesc :: !(Maybe Text),
|
||||||
|
bg :: !(Maybe Text),
|
||||||
images :: ![Image],
|
images :: ![Image],
|
||||||
thumb' :: !(Maybe FilePath),
|
thumb' :: !(Maybe FilePath),
|
||||||
links :: ![Link],
|
links :: ![Link],
|
||||||
|
@ -125,6 +126,7 @@ instance FromYAML Info where
|
||||||
<*> m .:? "nsfw-tags" .!= []
|
<*> m .:? "nsfw-tags" .!= []
|
||||||
<*> m .:? "desc"
|
<*> m .:? "desc"
|
||||||
<*> m .:? "nsfw-desc"
|
<*> m .:? "nsfw-desc"
|
||||||
|
<*> m .:? "bg"
|
||||||
<*> (m .: "images" >>= imageList)
|
<*> (m .: "images" >>= imageList)
|
||||||
<*> m .:? "thumb"
|
<*> m .:? "thumb"
|
||||||
<*> m .:? "links" .!= []
|
<*> m .:? "links" .!= []
|
||||||
|
|
|
@ -32,7 +32,7 @@ make :: Bool -- ^ nsfw?
|
||||||
make nsfw dataDir dir info = toLazyText <$> make' nsfw dataDir dir info
|
make nsfw dataDir dir info = toLazyText <$> make' nsfw dataDir dir info
|
||||||
|
|
||||||
make' :: Bool -> FilePath -> FilePath -> Info -> IO Builder
|
make' :: Bool -> FilePath -> FilePath -> Info -> IO Builder
|
||||||
make' nsfw dataDir dir info@(Info {date, title, artist}) = do
|
make' nsfw dataDir dir info@(Info {date, title, artist, bg}) = do
|
||||||
images <- withSizes (dataDir </> dir) $ imagesFor nsfw info
|
images <- withSizes (dataDir </> dir) $ imagesFor nsfw info
|
||||||
|
|
||||||
let undir = joinPath (replicate (length (splitPath dir)) "..")
|
let undir = joinPath (replicate (length (splitPath dir)) "..")
|
||||||
|
@ -59,7 +59,11 @@ make' nsfw dataDir dir info@(Info {date, title, artist}) = do
|
||||||
<figcaption id=cw aria-role=button tabindex=0>
|
<figcaption id=cw aria-role=button tabindex=0>
|
||||||
<span id=cw-text>cw: <b>$*w</b></span>
|
<span id=cw-text>cw: <b>$*w</b></span>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
|]
|
|]
|
||||||
|
|
||||||
|
let bgStyle = ifJust bg \col -> [b|@0
|
||||||
|
<style> #mainfig { background: $*col; } </style>
|
||||||
|
|]
|
||||||
|
|
||||||
pure [b|@0
|
pure [b|@0
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -70,6 +74,7 @@ make' nsfw dataDir dir info@(Info {date, title, artist}) = do
|
||||||
<link rel=icon href=/style/niss.svg>
|
<link rel=icon href=/style/niss.svg>
|
||||||
|
|
||||||
<script src=/script/single.js></script>
|
<script src=/script/single.js></script>
|
||||||
|
$bgStyle
|
||||||
|
|
||||||
$0.prefetches
|
$0.prefetches
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue