support initially-hidden tags
This commit is contained in:
parent
28fc9db3e0
commit
e8bd20c896
3 changed files with 26 additions and 13 deletions
|
@ -5,6 +5,8 @@ import Control.Exception
|
|||
import Data.Foldable
|
||||
import Data.Function (on, (&))
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import Data.HashSet (HashSet)
|
||||
import qualified Data.HashSet as HashSet
|
||||
import Data.List (intersperse, groupBy, sortOn)
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import System.FilePath ((</>), takeDirectory, joinPath, splitPath)
|
||||
|
@ -23,7 +25,7 @@ make ginfo infos = toLazyText $ make' ginfo infos
|
|||
|
||||
|
||||
make' :: GalleryInfo -> [(FilePath, Info)] -> Builder
|
||||
make' (GalleryInfo {title, prefix, filters}) infos = [b|@0
|
||||
make' (GalleryInfo {title, prefix, filters, hidden}) infos = [b|@0
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
|
@ -89,18 +91,22 @@ make' (GalleryInfo {title, prefix, filters}) infos = [b|@0
|
|||
& concatMap (map (,1) . tagsFor nsfw . #second)
|
||||
& HashMap.fromListWith (+) & HashMap.toList
|
||||
& sortOn (\(tag, count) -> (Down count, tag))
|
||||
requireFilters = map (uncurry $ makeFilter "require") allTags
|
||||
excludeFilters = map (uncurry $ makeFilter "exclude") allTags
|
||||
|
||||
requireFilters = map (uncurry $ makeFilter "require" mempty) allTags
|
||||
excludeFilters = map (uncurry $ makeFilter "exclude" hidden) allTags
|
||||
|
||||
nsfw = #nsfw filters /= NoNsfw
|
||||
|
||||
makeFilter :: Text -> Text -> Int -> Builder
|
||||
makeFilter prefix tag count = [b|@8
|
||||
makeFilter :: Text -> HashSet Text -> Text -> Int -> Builder
|
||||
makeFilter prefix initial tag _count = [b|@8
|
||||
<li>
|
||||
<input type=checkbox id="$id'" value="$*tag">
|
||||
<input type=checkbox id="$id'" value="$*tag"$checked>
|
||||
<label for="$id'">$*tag</label>
|
||||
|]
|
||||
where id' = [b|$*prefix$&_$tag'|]; tag' = escId tag
|
||||
where
|
||||
id' = [b|$*prefix$&_$tag'|]
|
||||
tag' = escId tag
|
||||
checked = if HashSet.member tag initial then " checked" else ""
|
||||
|
||||
makeYearItems :: Bool -- ^ nsfw
|
||||
-> Integer -- ^ year
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue