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) $@buildPrefix/%/index.html: $@data_/%/info.yaml $$(MAKEPAGES)
echo "[single] "$$@ echo "[single] "$$@
mkdir -p $$(dir $$@) mkdir -p $$(dir $$@)
$$(MAKEPAGES) $$(MPFLAGS) single "$$<" -o "$$@" $flags $$(MAKEPAGES) $$(MPFLAGS) single -D "$@data_" "$$<" -o "$$@" $flags
$@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES) $@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES)
echo "[deps] "$$@ echo "[deps] "$$@

View file

@ -44,10 +44,11 @@ main = do
main2 mode main2 mode
main2 :: HasVerbose => ModeOptions -> IO () main2 :: HasVerbose => ModeOptions -> IO ()
main2 (SinglePage {file, nsfw, output}) = do main2 (SinglePage {file, dataDir, nsfw, output}) = do
info <- readYAML file info <- readYAML file
printV $ "contents" := info 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 writeOutput output page
main2 (GalleryPage {title, files, nsfw, output, dataDir}) = do main2 (GalleryPage {title, files, nsfw, output, dataDir}) = do

View file

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

View file

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