diff --git a/make-pages/Main.hs b/make-pages/Main.hs
index 2511907..3680508 100644
--- a/make-pages/Main.hs
+++ b/make-pages/Main.hs
@@ -51,7 +51,7 @@ main2 (SinglePage {file, dataDir, nsfw, output}) = do
info <- readYAML file
printV $ "contents" := info
let dir = takeDirectory $ makeRelative dataDir file
- let page = SinglePage.make nsfw dir info
+ page <- SinglePage.make nsfw dataDir dir info
writeOutput output page
main2 (GalleryPage {files, prefix, index, output, dataDir}) = do
diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs
index b1dbda4..9b52772 100644
--- a/make-pages/SinglePage.hs
+++ b/make-pages/SinglePage.hs
@@ -10,7 +10,9 @@ import Data.Maybe (fromMaybe)
import qualified Data.Text as Strict
import qualified Data.Text.Lazy as Lazy
import qualified Data.Time.Calendar as Time
-import System.FilePath (joinPath, splitPath)
+import System.FilePath (joinPath, splitPath, (>))
+import qualified System.Process as Proc
+import Text.Read (readMaybe)
-- | e.g. only nsfw images are present for a non-nsfw page
@@ -23,11 +25,43 @@ instance Show NoEligibleImages where
" (probably a nsfw-only work without --nsfw set)"
-make :: Bool -> FilePath -> Info -> Lazy.Text
-make nsfw dir = toLazyText . make' nsfw dir
+make :: Bool -- ^ nsfw?
+ -> FilePath -- ^ data dir
+ -> FilePath -- ^ subdir of datadir containing this @info.yaml@
+ -> Info -> IO Lazy.Text
+make nsfw dataDir dir info = toLazyText <$> make' nsfw dataDir dir info
-make' :: Bool -> FilePath -> Info -> Builder
-make' nsfw dir info@(Info {date, title, artist}) = [b|@0
+make' :: Bool -> FilePath -> FilePath -> Info -> IO Builder
+make' nsfw dataDir dir info@(Info {date, title, artist}) = do
+ images <- withSizes (dataDir > dir) $ imagesFor nsfw info
+
+ let undir = joinPath (replicate (length (splitPath dir)) "..")
+
+ let artistTag = ifJust artist makeArtist
+
+ let formattedDate = formatDate date
+
+ let buttonBar = makeButtonBar title images
+ let (image0@(Image {path = path0, download = download0'}),
+ Size {width = width0, height = height0})
+ = head images
+ let download0 = fromMaybe path0 download0'
+ let path0' = pageFile path0
+
+ let descSection = makeDesc $ descFor nsfw info
+ let tagsList = makeTags undir $ tagsFor nsfw info
+ let linksList = extLinks $ linksFor nsfw info
+
+ let makePrefetch (Image {path}) = [b||]
+ let prefetches = map (makePrefetch . #first) $ tail images
+
+ let warning' = ifJust (#warning image0) \w -> [b|@4
+
+ cw: $*w
+
+ |]
+
+ pure [b|@0
@@ -50,7 +84,8 @@ make' nsfw dir info@(Info {date, title, artist}) = [b|@0
$buttonBar
-