diff --git a/make-pages/GalleryPage.hs b/make-pages/GalleryPage.hs index ac2a9de..04f75fc 100644 --- a/make-pages/GalleryPage.hs +++ b/make-pages/GalleryPage.hs @@ -2,8 +2,10 @@ module GalleryPage (make) where import Control.Exception +import Data.Foldable import Data.Function (on, (&)) -import Data.List (sortOn, groupBy) +import qualified Data.HashMap.Strict as HashMap +import Data.List (intersperse, groupBy, sortOn) import qualified Data.Text.Lazy as Lazy import System.FilePath ((>), takeDirectory, joinPath, splitPath) import GHC.Exts (Down (..), the) @@ -61,6 +63,12 @@ make' title prefix nsfw infos = [b|@0 then group by Down year using groupBy'] groupBy' f = groupBy ((==) `on` f) undir = joinPath (replicate (length (splitPath prefix)) "..") + allTags = infos + & 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 makeYearItems :: Bool -- ^ nsfw -> Integer -- ^ year @@ -77,7 +85,7 @@ makeYearItems nsfw year infos = [b|@4 makeItem :: Bool -> FilePath -> Info -> Builder makeItem nsfw file info@(Info {title}) = [b|@4 -