add nsfw class to relevant gallery items
but only on galleries showing nsfw at all
This commit is contained in:
parent
0ffebd2a00
commit
4a08a6bb9a
4 changed files with 23 additions and 11 deletions
|
@ -16,11 +16,14 @@ newtype NoThumb = NoThumb FilePath
|
|||
deriving stock Eq deriving anyclass Exception
|
||||
instance Show NoThumb where show (NoThumb dir) = "no thumbnail for " ++ dir
|
||||
|
||||
make :: Text -> [(FilePath, Info)] -> Lazy.Text
|
||||
make title infos = toLazyText $ make' title infos
|
||||
make :: Text -- ^ title
|
||||
-> Bool -- ^ nsfw is included?
|
||||
-> [(FilePath, Info)]
|
||||
-> Lazy.Text
|
||||
make title nsfw infos = toLazyText $ make' title nsfw infos
|
||||
|
||||
make' :: Text -> [(FilePath, Info)] -> Builder
|
||||
make' title infos' = [b|@0
|
||||
make' :: Text -> Bool -> [(FilePath, Info)] -> Builder
|
||||
make' title nsfw infos = [b|@0
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
|
@ -43,9 +46,9 @@ make' title infos' = [b|@0
|
|||
infos = sortBy (cmpInfo `on` snd) infos'
|
||||
cmpInfo = flip (comparing #date) <> comparing #title
|
||||
|
||||
makeItem :: FilePath -> Info -> Builder
|
||||
makeItem file info = [b|@4
|
||||
<li class=item>
|
||||
makeItem :: Bool -> FilePath -> Info -> Builder
|
||||
makeItem nsfw file info = [b|@4
|
||||
<li $cls>
|
||||
<figure>
|
||||
<a href="$@dir">
|
||||
<img src="$@thumb">
|
||||
|
@ -62,3 +65,5 @@ makeItem file info = [b|@4
|
|||
$*t
|
||||
</figcaption>
|
||||
|]
|
||||
cls | nsfw && #anyNsfw info = [b|class="item nsfw"|]
|
||||
| otherwise = [b|class=item|]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue