rename includeNsfw to just nsfw

This commit is contained in:
Rhiannon Morris 2020-07-13 08:32:59 +02:00
parent aff6f513e9
commit 120e258f7f
2 changed files with 22 additions and 22 deletions

View File

@ -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

View File

@ -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
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
@ -60,12 +60,12 @@ make' includeNsfw (Info {date, title, tags, nsfwTags,
titleTag = ifJust title \t -> [b|<title>$*t</title>|]
titleHeader = ifJust title \t -> [b|<h1>$*t</h1>|]
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 =
</nav>
|]
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
<div class=tags>
<h2>tags</h2>
@ -132,10 +132,10 @@ makeTags includeNsfw sfwTags nsfwTags =
where
tagList = map makeTag tags
makeTag t = [b|<li>$*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
<div class=links>
<h2>links</h2>
@ -145,8 +145,8 @@ extLinks includeNsfw allLinks =
</div>
|]
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