a lot of stuff sorry
This commit is contained in:
parent
adfc8b9a82
commit
375c6e833a
9 changed files with 297 additions and 151 deletions
58
make-pages/GalleryPage.hs
Normal file
58
make-pages/GalleryPage.hs
Normal file
|
@ -0,0 +1,58 @@
|
|||
module GalleryPage (make) where
|
||||
|
||||
import Control.Exception
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import Data.Text.Lazy.Builder (Builder, toLazyText)
|
||||
import System.FilePath ((</>), takeDirectory)
|
||||
|
||||
import BuilderQQ
|
||||
import Depend (thumbFile)
|
||||
import Info
|
||||
|
||||
newtype NoThumb = NoThumb FilePath
|
||||
deriving stock Eq deriving anyclass Exception
|
||||
instance Show NoThumb where show (NoThumb dir) = "no thumbnail for " ++ dir
|
||||
|
||||
make :: Text -> [(FilePath, Info)] -> Lazy.Text
|
||||
make title infos = toLazyText $ make' title infos
|
||||
|
||||
make' :: Text -> [(FilePath, Info)] -> Builder
|
||||
make' title infos = [b|
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
|
||||
<title>$*title</title>
|
||||
|
||||
<header>
|
||||
<h1>$*title</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<ul class=grid>
|
||||
$4.items
|
||||
</ul>
|
||||
</main>
|
||||
|]
|
||||
where
|
||||
items = map (uncurry makeItem) infos
|
||||
|
||||
makeItem :: FilePath -> Info -> Builder
|
||||
makeItem file info = [b|@4
|
||||
<li class=item>
|
||||
<figure>
|
||||
<a href="$@dir">
|
||||
<img src="$@thumb">
|
||||
</a>
|
||||
$title
|
||||
</figure>
|
||||
|]
|
||||
where
|
||||
dir = takeDirectory file
|
||||
thumb = maybe (throw $ NoThumb dir) (\t -> dir </> thumbFile t) $ #thumb info
|
||||
title = maybe mempty mkTitle $ #title info
|
||||
mkTitle t = [b|@8
|
||||
<figcaption>
|
||||
$*t
|
||||
</figcaption>
|
||||
|]
|
Loading…
Add table
Add a link
Reference in a new issue