put data in subdirs by artist

This commit is contained in:
Rhiannon Morris 2020-07-22 00:13:02 +02:00
parent 488a4cdd08
commit 9e9d2d83b7
4 changed files with 17 additions and 13 deletions

View file

@ -93,7 +93,7 @@ makeRules prefix filters build data_ tmp = [b|@0
$@buildPrefix/%/index.html: $@data_/%/info.yaml $$(MAKEPAGES)
echo "[single] "$$@
mkdir -p $$(dir $$@)
$$(MAKEPAGES) $$(MPFLAGS) single "$$<" -o "$$@" $flags
$$(MAKEPAGES) $$(MPFLAGS) single -D "$@data_" "$$<" -o "$$@" $flags
$@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES)
echo "[deps] "$$@

View file

@ -44,10 +44,11 @@ main = do
main2 mode
main2 :: HasVerbose => ModeOptions -> IO ()
main2 (SinglePage {file, nsfw, output}) = do
main2 (SinglePage {file, dataDir, nsfw, output}) = do
info <- readYAML file
printV $ "contents" := info
let page = SinglePage.make nsfw info
let dir = takeDirectory $ makeRelative dataDir file
let page = SinglePage.make nsfw dir info
writeOutput output page
main2 (GalleryPage {title, files, nsfw, output, dataDir}) = do

View file

@ -13,6 +13,7 @@ data Options =
data ModeOptions =
SinglePage {
file :: FilePath,
dataDir :: FilePath,
nsfw :: Bool,
output :: Maybe FilePath
}
@ -65,7 +66,7 @@ optionsParser = globalOpts `info` mainInfo where
single <> gallery <> index <> rss <> dependSingle <> dependGallery
single = command "single" $ singleOpts `info` singleInfo
singleOpts = SinglePage <$> file <*> nsfwS <*> output
singleOpts = SinglePage <$> file <*> dataDir <*> nsfwS <*> output
file = strArgument $
metavar "FILE" <> help "yaml file to read"
nsfwS = switch $

View file

@ -11,6 +11,7 @@ import qualified Data.Text.Lazy as Lazy
import Data.Time (formatTime, defaultTimeLocale)
import qualified Data.Char as Char
import qualified Data.List as List
import System.FilePath (joinPath, splitPath)
-- | e.g. only nsfw images are present for a non-nsfw page
@ -23,11 +24,11 @@ instance Show NoEligibleImages where
" (probably a nsfw-only work without --nsfw set)"
make :: Bool -> Info -> Lazy.Text
make nsfw = toLazyText . make' nsfw
make :: Bool -> FilePath -> Info -> Lazy.Text
make nsfw dir = toLazyText . make' nsfw dir
make' :: Bool -> Info -> Builder
make' nsfw (Info {date, title, artist, tags, nsfwTags,
make' :: Bool -> FilePath -> Info -> Builder
make' nsfw dir (Info {date, title, artist, tags, nsfwTags,
description, images, links}) = [b|@0
<!DOCTYPE html>
<html lang=en>
@ -66,7 +67,7 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
<footer>
<nav class=back>
<a href=../>back to gallery</a>
<a href=$@undir>back to gallery</a>
</nav>
</footer>
|]
@ -89,6 +90,7 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
<span id=cw-text>cw: <b>$*w</b></span>
</figcaption>
|]
undir = joinPath (replicate (length (splitPath dir)) "..")
makeArtist :: Artist -> Builder
makeArtist (Artist {name, url}) =