rename includeNsfw to just nsfw
This commit is contained in:
parent
aff6f513e9
commit
120e258f7f
2 changed files with 22 additions and 22 deletions
|
@ -21,12 +21,12 @@ data Options =
|
||||||
data ModeOptions =
|
data ModeOptions =
|
||||||
SinglePage {
|
SinglePage {
|
||||||
file :: FilePath,
|
file :: FilePath,
|
||||||
includeNsfw :: Bool,
|
nsfw :: Bool,
|
||||||
output :: Maybe FilePath
|
output :: Maybe FilePath
|
||||||
}
|
}
|
||||||
| GalleryPage {
|
| GalleryPage {
|
||||||
files :: [FilePath],
|
files :: [FilePath],
|
||||||
includeNsfw :: Bool,
|
nsfw :: Bool,
|
||||||
output :: Maybe FilePath
|
output :: Maybe FilePath
|
||||||
}
|
}
|
||||||
deriving Show
|
deriving Show
|
||||||
|
@ -71,10 +71,10 @@ main = do
|
||||||
main2 opts
|
main2 opts
|
||||||
|
|
||||||
main2 :: Options -> IO ()
|
main2 :: Options -> IO ()
|
||||||
main2 opts@(Options {mode = SinglePage {file, includeNsfw, output}}) = do
|
main2 opts@(Options {mode = SinglePage {file, nsfw, output}}) = do
|
||||||
info <- readYAML file
|
info <- readYAML file
|
||||||
printVerbose opts info
|
printVerbose opts info
|
||||||
let page = make includeNsfw info
|
let page = make nsfw info
|
||||||
case output of
|
case output of
|
||||||
Nothing -> Text.putStr page
|
Nothing -> Text.putStr page
|
||||||
Just out -> Text.writeFile out page
|
Just out -> Text.writeFile out page
|
||||||
|
|
|
@ -24,10 +24,10 @@ instance Show NoEligibleImages where
|
||||||
|
|
||||||
|
|
||||||
make :: Bool -> Info -> Lazy.Text
|
make :: Bool -> Info -> Lazy.Text
|
||||||
make includeNsfw = toLazyText . make' includeNsfw
|
make nsfw = toLazyText . make' nsfw
|
||||||
|
|
||||||
make' :: Bool -> Info -> Builder
|
make' :: Bool -> Info -> Builder
|
||||||
make' includeNsfw (Info {date, title, tags, nsfwTags,
|
make' nsfw (Info {date, title, tags, nsfwTags,
|
||||||
description, images, links}) = [b|@0
|
description, images, links}) = [b|@0
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang=en>
|
<html lang=en>
|
||||||
|
@ -60,12 +60,12 @@ make' includeNsfw (Info {date, title, tags, nsfwTags,
|
||||||
titleTag = ifJust title \t -> [b|<title>$*t</title>|]
|
titleTag = ifJust title \t -> [b|<title>$*t</title>|]
|
||||||
titleHeader = ifJust title \t -> [b|<h1>$*t</h1>|]
|
titleHeader = ifJust title \t -> [b|<h1>$*t</h1>|]
|
||||||
formattedDate = formatDate date
|
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
|
path0 = let Image {path} = head images in path
|
||||||
|
|
||||||
descSection = ifJust description makeDesc
|
descSection = ifJust description makeDesc
|
||||||
tagsList = makeTags includeNsfw tags nsfwTags
|
tagsList = makeTags nsfw tags nsfwTags
|
||||||
linksList = extLinks includeNsfw links
|
linksList = extLinks nsfw links
|
||||||
|
|
||||||
makeDesc :: Strict.Text -> Builder
|
makeDesc :: Strict.Text -> Builder
|
||||||
makeDesc desc = [b|@2
|
makeDesc desc = [b|@2
|
||||||
|
@ -82,7 +82,7 @@ formatDate :: Day -> Builder
|
||||||
formatDate = fromString . formatTime defaultTimeLocale "%e %#B %Y"
|
formatDate = fromString . formatTime defaultTimeLocale "%e %#B %Y"
|
||||||
|
|
||||||
makeButtonBar :: Strict.Text -> Bool -> [Image] -> Builder
|
makeButtonBar :: Strict.Text -> Bool -> [Image] -> Builder
|
||||||
makeButtonBar title includeNsfw allImages =
|
makeButtonBar title nsfw allImages =
|
||||||
case length images of
|
case length images of
|
||||||
0 -> throw $ NoEligibleImages title
|
0 -> throw $ NoEligibleImages title
|
||||||
1 -> ""
|
1 -> ""
|
||||||
|
@ -95,7 +95,7 @@ makeButtonBar title includeNsfw allImages =
|
||||||
</nav>
|
</nav>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
images | includeNsfw = allImages
|
images | nsfw = allImages
|
||||||
| otherwise = filter (\Image {nsfw} -> not nsfw) allImages
|
| otherwise = filter (\Image {nsfw} -> not nsfw) allImages
|
||||||
iimages = zip [0..] images
|
iimages = zip [0..] images
|
||||||
alts = map (uncurry altButton) iimages
|
alts = map (uncurry altButton) iimages
|
||||||
|
@ -120,7 +120,7 @@ escId = foldMap esc1 . Strict.unpack where
|
||||||
| otherwise = singleton c
|
| otherwise = singleton c
|
||||||
|
|
||||||
makeTags :: Bool -> [Strict.Text] -> [Strict.Text] -> Builder
|
makeTags :: Bool -> [Strict.Text] -> [Strict.Text] -> Builder
|
||||||
makeTags includeNsfw sfwTags nsfwTags =
|
makeTags nsfw sfwTags nsfwTags =
|
||||||
if null tags then "" else [b|@2
|
if null tags then "" else [b|@2
|
||||||
<div class=tags>
|
<div class=tags>
|
||||||
<h2>tags</h2>
|
<h2>tags</h2>
|
||||||
|
@ -132,10 +132,10 @@ makeTags includeNsfw sfwTags nsfwTags =
|
||||||
where
|
where
|
||||||
tagList = map makeTag tags
|
tagList = map makeTag tags
|
||||||
makeTag t = [b|<li>$*t|]
|
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 :: Bool -> [Link] -> Builder
|
||||||
extLinks includeNsfw allLinks =
|
extLinks nsfw allLinks =
|
||||||
if null links then "" else [b|@2
|
if null links then "" else [b|@2
|
||||||
<div class=links>
|
<div class=links>
|
||||||
<h2>links</h2>
|
<h2>links</h2>
|
||||||
|
@ -145,7 +145,7 @@ extLinks includeNsfw allLinks =
|
||||||
</div>
|
</div>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
links | includeNsfw = allLinks
|
links | nsfw = allLinks
|
||||||
| otherwise = filter (\Link {nsfw} -> not nsfw) allLinks
|
| otherwise = filter (\Link {nsfw} -> not nsfw) allLinks
|
||||||
linkList = map extLink links
|
linkList = map extLink links
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue