#!/usr/bin/env runhaskell import Control.Arrow import Data.Char import Data.Foldable import Data.Function import Data.List import Data.Maybe import Data.Monoid import System.Directory import System.FilePath.Posix import System.Environment icons :: FilePath -> IO [FilePath] icons httpdSource = listDirectory $ httpdSource > "docs/icons" ext :: String -> FilePath -> Bool ext e = (== e) . takeExtension . map toLower excl :: String -> FilePath -> Bool excl p = not . isPrefixOf p filterIcons :: [FilePath] -> [FilePath] filterIcons = filter (getAny . foldMap (Any .) [ext ".png", ext ".gif"]) >>> filter (getAll . foldMap (All .) [excl "apache", excl "icon.sheet"]) prefer :: [FilePath] -> Maybe FilePath prefer xs = getAlt $ foldMap (Alt . flip find xs) [ext ".png", ext ".gif", const True] uniq :: [FilePath] -> [FilePath] uniq = mapMaybe prefer . groupBy ((==) `on` dropExtension) html :: FilePath -> String html f = "