diff --git a/make-pages/Depend.hs b/make-pages/Depend.hs index 3cec45d..dfbe87d 100644 --- a/make-pages/Depend.hs +++ b/make-pages/Depend.hs @@ -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] "$$@ diff --git a/make-pages/Main.hs b/make-pages/Main.hs index 24b1e38..77b64c5 100644 --- a/make-pages/Main.hs +++ b/make-pages/Main.hs @@ -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 diff --git a/make-pages/Options.hs b/make-pages/Options.hs index 795881c..22d5d66 100644 --- a/make-pages/Options.hs +++ b/make-pages/Options.hs @@ -12,9 +12,10 @@ data Options = data ModeOptions = SinglePage { - file :: FilePath, - nsfw :: Bool, - output :: Maybe FilePath + file :: FilePath, + dataDir :: FilePath, + nsfw :: Bool, + output :: Maybe FilePath } | GalleryPage { files :: [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 $ diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index 368ff30..3194174 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -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,12 +24,12 @@ 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, - description, images, links}) = [b|@0 +make' :: Bool -> FilePath -> Info -> Builder +make' nsfw dir (Info {date, title, artist, tags, nsfwTags, + description, images, links}) = [b|@0 @@ -66,7 +67,7 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags, |] @@ -89,6 +90,7 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags, cw: $*w |] + undir = joinPath (replicate (length (splitPath dir)) "..") makeArtist :: Artist -> Builder makeArtist (Artist {name, url}) =