add footer to index page
This commit is contained in:
parent
185f8d5ca4
commit
a29fff1094
3 changed files with 30 additions and 12 deletions
|
@ -6,11 +6,11 @@ import Data.Text.Lazy.Builder (Builder, toLazyText)
|
||||||
import BuilderQQ
|
import BuilderQQ
|
||||||
import Info
|
import Info
|
||||||
|
|
||||||
make :: [GalleryInfo] -> Lazy.Text
|
make :: IndexInfo -> Lazy.Text
|
||||||
make ginfos = toLazyText $ make' ginfos
|
make iinfo = toLazyText $ make' iinfo
|
||||||
|
|
||||||
make' :: [GalleryInfo] -> Builder
|
make' :: IndexInfo -> Builder
|
||||||
make' ginfos = [b|@0
|
make' (IndexInfo {galleries, footer}) = [b|@0
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang=en>
|
<html lang=en>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
|
@ -27,9 +27,13 @@ make' ginfos = [b|@0
|
||||||
$4.items
|
$4.items
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
$4*footer
|
||||||
|
</footer>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
items = map makeItem ginfos
|
items = map makeItem galleries
|
||||||
|
|
||||||
makeItem :: GalleryInfo -> Builder
|
makeItem :: GalleryInfo -> Builder
|
||||||
makeItem (GalleryInfo {title, prefix, filters}) = [b|@4
|
makeItem (GalleryInfo {title, prefix, filters}) = [b|@4
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
module Info
|
module Info
|
||||||
(Info (..), Artist (..), Image (..), Link (..),
|
(Info (..), Artist (..), Image (..), Link (..),
|
||||||
GalleryInfo (..), GalleryFilters (..), Whose (..),
|
GalleryInfo (..), GalleryFilters (..), Whose (..),
|
||||||
|
IndexInfo (..),
|
||||||
readWhose, matchWhose, matchNsfw, matchFilters,
|
readWhose, matchWhose, matchNsfw, matchFilters,
|
||||||
-- ** Reexports
|
-- ** Reexports
|
||||||
Day (..), Text)
|
Day (..), Text)
|
||||||
|
@ -195,6 +196,19 @@ instance FromYAML GalleryFilters where
|
||||||
instance FromYAML Whose where parseYAML = YAML.withStr "whose" readWhose
|
instance FromYAML Whose where parseYAML = YAML.withStr "whose" readWhose
|
||||||
|
|
||||||
|
|
||||||
|
data IndexInfo =
|
||||||
|
IndexInfo {
|
||||||
|
galleries :: ![GalleryInfo],
|
||||||
|
footer :: !Text
|
||||||
|
}
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
instance FromYAML IndexInfo where
|
||||||
|
parseYAML = YAML.withMap "index info" \m ->
|
||||||
|
IndexInfo <$> m .:? "galleries" .!= []
|
||||||
|
<*> m .:? "footer" .!= ""
|
||||||
|
|
||||||
|
|
||||||
data Pair a b = Pair !a !b
|
data Pair a b = Pair !a !b
|
||||||
|
|
||||||
instance (FromYAML a, FromYAML b) => FromYAML (Pair a b) where
|
instance (FromYAML a, FromYAML b) => FromYAML (Pair a b) where
|
||||||
|
|
|
@ -14,7 +14,7 @@ import System.FilePath.Find (find, always, fileName, (==?))
|
||||||
import System.IO (hPrint, stderr)
|
import System.IO (hPrint, stderr)
|
||||||
|
|
||||||
import Depend
|
import Depend
|
||||||
import Info (Info)
|
import Info (IndexInfo (..), Info)
|
||||||
import Options
|
import Options
|
||||||
import qualified SinglePage
|
import qualified SinglePage
|
||||||
import qualified GalleryPage
|
import qualified GalleryPage
|
||||||
|
@ -56,9 +56,9 @@ main2 (GalleryPage {title, files, nsfw, output, dataDir}) = do
|
||||||
writeOutput output page
|
writeOutput output page
|
||||||
|
|
||||||
main2 (IndexPage {file, output}) = do
|
main2 (IndexPage {file, output}) = do
|
||||||
ginfos <- readYAML file
|
info <- readYAML file
|
||||||
printV $ "galleries" := ginfos
|
printV $ "info" := info
|
||||||
let page = IndexPage.make ginfos
|
let page = IndexPage.make info
|
||||||
writeOutput output page
|
writeOutput output page
|
||||||
|
|
||||||
main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
||||||
|
@ -70,14 +70,14 @@ main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
||||||
writeOutput output deps
|
writeOutput output deps
|
||||||
|
|
||||||
main2 (DependGallery {file, output, buildDir, dataDir, tmpDir, infoName}) = do
|
main2 (DependGallery {file, output, buildDir, dataDir, tmpDir, infoName}) = do
|
||||||
ginfos <- readYAML @[_] file
|
IndexInfo {galleries} <- readYAML file
|
||||||
printV $ "galleries" := ginfos
|
printV $ "galleries" := galleries
|
||||||
infos <- mapM (infoYAML dataDir) =<<
|
infos <- mapM (infoYAML dataDir) =<<
|
||||||
find always (fileName ==? infoName) dataDir
|
find always (fileName ==? infoName) dataDir
|
||||||
printV $ "info files" := infos
|
printV $ "info files" := infos
|
||||||
let dependGallery0 g = dependGallery' g infos buildDir dataDir tmpDir
|
let dependGallery0 g = dependGallery' g infos buildDir dataDir tmpDir
|
||||||
let deps = toLazyText $ mconcat $ intersperse "\n\n\n" $
|
let deps = toLazyText $ mconcat $ intersperse "\n\n\n" $
|
||||||
map dependGallery0 ginfos
|
map dependGallery0 galleries
|
||||||
writeOutput output deps
|
writeOutput output deps
|
||||||
|
|
||||||
infoYAML :: FilePath -- ^ data dir
|
infoYAML :: FilePath -- ^ data dir
|
||||||
|
|
Loading…
Reference in a new issue