From 120e258f7f57c231192de31cbc0eb84560da6027 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Mon, 13 Jul 2020 08:32:59 +0200 Subject: [PATCH] rename includeNsfw to just nsfw --- make-pages/Main.hs | 16 ++++++++-------- make-pages/SinglePage.hs | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/make-pages/Main.hs b/make-pages/Main.hs index 05e7b07..ede6d58 100644 --- a/make-pages/Main.hs +++ b/make-pages/Main.hs @@ -20,14 +20,14 @@ data Options = data ModeOptions = SinglePage { - file :: FilePath, - includeNsfw :: Bool, - output :: Maybe FilePath + file :: FilePath, + nsfw :: Bool, + output :: Maybe FilePath } | GalleryPage { - files :: [FilePath], - includeNsfw :: Bool, - output :: Maybe FilePath + files :: [FilePath], + nsfw :: Bool, + output :: Maybe FilePath } deriving Show @@ -71,10 +71,10 @@ main = do main2 opts main2 :: Options -> IO () -main2 opts@(Options {mode = SinglePage {file, includeNsfw, output}}) = do +main2 opts@(Options {mode = SinglePage {file, nsfw, output}}) = do info <- readYAML file printVerbose opts info - let page = make includeNsfw info + let page = make nsfw info case output of Nothing -> Text.putStr page Just out -> Text.writeFile out page diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index d386d70..56b4424 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -24,11 +24,11 @@ instance Show NoEligibleImages where make :: Bool -> Info -> Lazy.Text -make includeNsfw = toLazyText . make' includeNsfw +make nsfw = toLazyText . make' nsfw make' :: Bool -> Info -> Builder -make' includeNsfw (Info {date, title, tags, nsfwTags, - description, images, links}) = [b|@0 +make' nsfw (Info {date, title, tags, nsfwTags, + description, images, links}) = [b|@0 @@ -60,12 +60,12 @@ make' includeNsfw (Info {date, title, tags, nsfwTags, titleTag = ifJust title \t -> [b|$*t|] titleHeader = ifJust title \t -> [b|

$*t

|] formattedDate = formatDate date - buttonBar = makeButtonBar (fromMaybe path0 title) includeNsfw images + buttonBar = makeButtonBar (fromMaybe path0 title) nsfw images path0 = let Image {path} = head images in path descSection = ifJust description makeDesc - tagsList = makeTags includeNsfw tags nsfwTags - linksList = extLinks includeNsfw links + tagsList = makeTags nsfw tags nsfwTags + linksList = extLinks nsfw links makeDesc :: Strict.Text -> Builder makeDesc desc = [b|@2 @@ -82,7 +82,7 @@ formatDate :: Day -> Builder formatDate = fromString . formatTime defaultTimeLocale "%e %#B %Y" makeButtonBar :: Strict.Text -> Bool -> [Image] -> Builder -makeButtonBar title includeNsfw allImages = +makeButtonBar title nsfw allImages = case length images of 0 -> throw $ NoEligibleImages title 1 -> "" @@ -95,8 +95,8 @@ makeButtonBar title includeNsfw allImages = |] where - images | includeNsfw = allImages - | otherwise = filter (\Image {nsfw} -> not nsfw) allImages + images | nsfw = allImages + | otherwise = filter (\Image {nsfw} -> not nsfw) allImages iimages = zip [0..] images alts = map (uncurry altButton) iimages @@ -120,7 +120,7 @@ escId = foldMap esc1 . Strict.unpack where | otherwise = singleton c makeTags :: Bool -> [Strict.Text] -> [Strict.Text] -> Builder -makeTags includeNsfw sfwTags nsfwTags = +makeTags nsfw sfwTags nsfwTags = if null tags then "" else [b|@2

tags

@@ -132,10 +132,10 @@ makeTags includeNsfw sfwTags nsfwTags = where tagList = map makeTag tags makeTag t = [b|
  • $*t|] - tags = List.nub $ if includeNsfw then sfwTags else sfwTags <> nsfwTags + tags = List.nub $ if nsfw then sfwTags else sfwTags <> nsfwTags extLinks :: Bool -> [Link] -> Builder -extLinks includeNsfw allLinks = +extLinks nsfw allLinks = if null links then "" else [b|@2 |] where - links | includeNsfw = allLinks - | otherwise = filter (\Link {nsfw} -> not nsfw) allLinks + links | nsfw = allLinks + | otherwise = filter (\Link {nsfw} -> not nsfw) allLinks linkList = map extLink links extLink :: Link -> Builder