start dependency stuff for single pages
This commit is contained in:
parent
3586a5b447
commit
070e2110c0
3 changed files with 91 additions and 13 deletions
43
make-pages/Depend.hs
Normal file
43
make-pages/Depend.hs
Normal file
|
@ -0,0 +1,43 @@
|
|||
module Depend where
|
||||
|
||||
import Info hiding (Text)
|
||||
import Data.Foldable
|
||||
import System.FilePath
|
||||
import Data.Text.Lazy (Text)
|
||||
import Data.Text.Lazy.Builder (toLazyText)
|
||||
import BuildVar
|
||||
|
||||
|
||||
dependSingle' :: FilePath -- ^ yaml file name (relative to data dir!)
|
||||
-> Info
|
||||
-> FilePath -- ^ build dir
|
||||
-> Bool -- ^ include nsfw?
|
||||
-> Text
|
||||
dependSingle' yaml info build nsfw =
|
||||
let dir = build </> takeDirectory yaml
|
||||
images = if nsfw then #images info else filter #sfw $ #images info
|
||||
paths = map #path images
|
||||
index = dir </> "index.html"
|
||||
deps = map (dir </>) $
|
||||
thumbFile (thumbnail info) : map pageFile paths ++ paths
|
||||
deps' = unwords deps
|
||||
in
|
||||
toLazyText [b|$@index: $@deps'|]
|
||||
|
||||
|
||||
thumbnail :: Info -> FilePath
|
||||
thumbnail (Info {thumb = Just t}) = t
|
||||
thumbnail (Info {images})
|
||||
| Just i <- find #sfw images = #path i
|
||||
| otherwise = error "no thumbnail or sfw images"
|
||||
|
||||
addSuffix :: String -> FilePath -> FilePath
|
||||
addSuffix suf path =
|
||||
let (pre, ext) = splitExtension path in
|
||||
pre ++ suf ++ ext
|
||||
|
||||
thumbFile :: FilePath -> FilePath
|
||||
thumbFile = addSuffix "_small"
|
||||
|
||||
pageFile :: FilePath -> FilePath
|
||||
pageFile = addSuffix "_med"
|
Loading…
Add table
Add a link
Reference in a new issue