add index page
This commit is contained in:
parent
375c6e833a
commit
3f025721c8
6 changed files with 63 additions and 8 deletions
4
Makefile
4
Makefile
|
@ -13,10 +13,10 @@ YAMLS != find $(DATADIR) -iname "*.yaml"
|
||||||
|
|
||||||
all: make-pages $(BUILDDIR)/index.html
|
all: make-pages $(BUILDDIR)/index.html
|
||||||
|
|
||||||
$(BUILDDIR)/index.html:
|
$(BUILDDIR)/index.html: $(DATADIR)/galleries.yaml $(MAKEPAGES)
|
||||||
echo "[index]"
|
echo "[index]"
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
touch $@ # FIXME
|
$(MAKEPAGES) index $< -o $@
|
||||||
|
|
||||||
$(MAKEPAGES): make-pages
|
$(MAKEPAGES): make-pages
|
||||||
echo "[make-pages]"
|
echo "[make-pages]"
|
||||||
|
|
|
@ -17,7 +17,7 @@ make :: Text -> [(FilePath, Info)] -> Lazy.Text
|
||||||
make title infos = toLazyText $ make' title infos
|
make title infos = toLazyText $ make' title infos
|
||||||
|
|
||||||
make' :: Text -> [(FilePath, Info)] -> Builder
|
make' :: Text -> [(FilePath, Info)] -> Builder
|
||||||
make' title infos = [b|
|
make' title infos = [b|@0
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang=en>
|
<html lang=en>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
|
|
39
make-pages/IndexPage.hs
Normal file
39
make-pages/IndexPage.hs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
module IndexPage (make) where
|
||||||
|
|
||||||
|
import qualified Data.Text.Lazy as Lazy
|
||||||
|
import Data.Text.Lazy.Builder (Builder, toLazyText)
|
||||||
|
|
||||||
|
import BuilderQQ
|
||||||
|
import Info
|
||||||
|
|
||||||
|
make :: [GalleryInfo] -> Lazy.Text
|
||||||
|
make ginfos = toLazyText $ make' ginfos
|
||||||
|
|
||||||
|
make' :: [GalleryInfo] -> Builder
|
||||||
|
make' ginfos = [b|@0
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang=en>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
|
||||||
|
<title>gallery list</title>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<h1>gallery list</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<ul class=gallery-list>
|
||||||
|
$4.items
|
||||||
|
</ul>
|
||||||
|
</main>
|
||||||
|
|]
|
||||||
|
where
|
||||||
|
items = map makeItem ginfos
|
||||||
|
|
||||||
|
makeItem :: GalleryInfo -> Builder
|
||||||
|
makeItem (GalleryInfo {title, prefix}) = [b|@4
|
||||||
|
<li>
|
||||||
|
<a href="$@prefix">
|
||||||
|
$*title
|
||||||
|
</a>
|
||||||
|
|]
|
|
@ -18,6 +18,7 @@ import Info (Info)
|
||||||
import Options
|
import Options
|
||||||
import qualified SinglePage
|
import qualified SinglePage
|
||||||
import qualified GalleryPage
|
import qualified GalleryPage
|
||||||
|
import qualified IndexPage
|
||||||
|
|
||||||
#ifdef PRETTY_VERBOSE
|
#ifdef PRETTY_VERBOSE
|
||||||
import qualified Text.PrettyPrint as PP
|
import qualified Text.PrettyPrint as PP
|
||||||
|
@ -54,6 +55,12 @@ main2 (GalleryPage {title, files, output, dataDir}) = do
|
||||||
let page = GalleryPage.make title infos
|
let page = GalleryPage.make title infos
|
||||||
writeOutput output page
|
writeOutput output page
|
||||||
|
|
||||||
|
main2 (IndexPage {file, output}) = do
|
||||||
|
ginfos <- readYAML file
|
||||||
|
printV $ "galleries" := ginfos
|
||||||
|
let page = IndexPage.make ginfos
|
||||||
|
writeOutput output page
|
||||||
|
|
||||||
main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
||||||
info <- readYAML file
|
info <- readYAML file
|
||||||
printV $ "contents" := info
|
printV $ "contents" := info
|
||||||
|
|
|
@ -22,6 +22,10 @@ data ModeOptions =
|
||||||
output :: Maybe FilePath,
|
output :: Maybe FilePath,
|
||||||
dataDir :: FilePath
|
dataDir :: FilePath
|
||||||
}
|
}
|
||||||
|
| IndexPage {
|
||||||
|
file :: FilePath,
|
||||||
|
output :: Maybe FilePath
|
||||||
|
}
|
||||||
| DependSingle {
|
| DependSingle {
|
||||||
file :: FilePath,
|
file :: FilePath,
|
||||||
nsfw :: Bool,
|
nsfw :: Bool,
|
||||||
|
@ -48,7 +52,7 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
short 'v' <> long "verbose" <>
|
short 'v' <> long "verbose" <>
|
||||||
help "print extra stuff to stderr"
|
help "print extra stuff to stderr"
|
||||||
subcommands = hsubparser $
|
subcommands = hsubparser $
|
||||||
single <> gallery <> dependSingle <> dependGallery
|
single <> gallery <> index <> dependSingle <> dependGallery
|
||||||
|
|
||||||
single = command "single" $ singleOpts `info` singleInfo
|
single = command "single" $ singleOpts `info` singleInfo
|
||||||
singleOpts = SinglePage <$> file <*> nsfwS <*> output
|
singleOpts = SinglePage <$> file <*> nsfwS <*> output
|
||||||
|
@ -63,6 +67,10 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
help "output file (default: stdout)"
|
help "output file (default: stdout)"
|
||||||
singleInfo = progDesc "generate a page for a single work"
|
singleInfo = progDesc "generate a page for a single work"
|
||||||
|
|
||||||
|
index = command "index" $ indexOpts `info` indexInfo
|
||||||
|
indexOpts = IndexPage <$> file <*> output
|
||||||
|
indexInfo = progDesc "generate an index page for all galleries"
|
||||||
|
|
||||||
gallery = command "gallery" $ galleryOpts `info` galleryInfo
|
gallery = command "gallery" $ galleryOpts `info` galleryInfo
|
||||||
galleryOpts = GalleryPage <$> files <*> title <*> output <*> dataDir
|
galleryOpts = GalleryPage <$> files <*> title <*> output <*> dataDir
|
||||||
files = many $ strArgument $
|
files = many $ strArgument $
|
||||||
|
|
|
@ -14,13 +14,14 @@ executable make-pages
|
||||||
hs-source-dirs: .
|
hs-source-dirs: .
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules:
|
other-modules:
|
||||||
Records,
|
|
||||||
BuilderQQ,
|
BuilderQQ,
|
||||||
Info,
|
|
||||||
SinglePage,
|
|
||||||
GalleryPage,
|
|
||||||
Depend,
|
Depend,
|
||||||
|
GalleryPage,
|
||||||
|
Info,
|
||||||
|
IndexPage,
|
||||||
Options
|
Options
|
||||||
|
Records,
|
||||||
|
SinglePage
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
default-extensions:
|
default-extensions:
|
||||||
BlockArguments,
|
BlockArguments,
|
||||||
|
|
Loading…
Reference in a new issue