a lot of stylin and a little scriptin
This commit is contained in:
parent
3635f04e8f
commit
64e00f83f1
16 changed files with 555 additions and 82 deletions
|
@ -64,7 +64,8 @@ dependGallery' (GalleryInfo {title, prefix, filters}) infos' build data_ tmp =
|
|||
$@path: $@files'
|
||||
echo "[gallery] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) gallery -t "$*title" -o "$$@" $$<
|
||||
$$(MAKEPAGES) $$(MPFLAGS) gallery -t "$*title" -o "$$@" \
|
||||
$$(filter $$(DATADIR)/%/$$(INFONAME),$$^)
|
||||
|
||||
$rules
|
||||
|
||||
|
@ -79,29 +80,29 @@ makeRules :: FilePath -- ^ prefix
|
|||
-> Builder
|
||||
makeRules prefix filters build data_ tmp = [b|@0
|
||||
$@buildPrefix/%/index.html: $@data_/%/info.yaml
|
||||
echo "[single] "$$@
|
||||
echo "[single] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) single "$$<" -o "$$@" $flags
|
||||
$$(MAKEPAGES) $$(MPFLAGS) single "$$<" -o "$$@" $flags
|
||||
|
||||
$@tmpPrefix/%.d: $@data_/%/info.yaml
|
||||
echo "[deps] "$$@
|
||||
echo "[deps] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) depend-single $flags \
|
||||
$$(MAKEPAGES) $$(MPFLAGS) depend-single $flags \
|
||||
-o "$$@" -p "$@prefix" -B "$@build" -D "$@data_" $$<
|
||||
|
||||
$@buildPrefix/%: $@data_/%
|
||||
echo "[copy] "$$@
|
||||
echo "[copy] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
cp "$$<" "$$@"
|
||||
|
||||
$@buildPrefix/%_small.png: $@data_/%.png
|
||||
echo "[resize] "$$@
|
||||
echo "[resize] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
convert -resize '$$(SMALL)x$$(SMALL)^' \
|
||||
-gravity center -crop 1:1+0 "$$<" "$$@"
|
||||
|
||||
$@buildPrefix/%_med.png: $@data_/%.png
|
||||
echo "[resize] "$$@
|
||||
echo "[resize] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
convert -resize '$$(MED)x$$(MED)>' "$$<" "$$@"
|
||||
|]
|
||||
|
|
|
@ -21,6 +21,7 @@ make' title infos = [b|@0
|
|||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
<link rel=stylesheet href=/style/gallery.css>
|
||||
|
||||
<title>$*title</title>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ make' ginfos = [b|@0
|
|||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
<link rel=stylesheet href=/style/index.css>
|
||||
|
||||
<title>gallery list</title>
|
||||
|
||||
|
@ -31,9 +32,11 @@ make' ginfos = [b|@0
|
|||
items = map makeItem ginfos
|
||||
|
||||
makeItem :: GalleryInfo -> Builder
|
||||
makeItem (GalleryInfo {title, prefix}) = [b|@4
|
||||
<li>
|
||||
<a href="$@prefix">
|
||||
$*title
|
||||
</a>
|
||||
makeItem (GalleryInfo {title, prefix, filters}) = [b|@4
|
||||
<li$nsfw><a href=$@prefix>$*title</a>
|
||||
|]
|
||||
where
|
||||
nsfw = if hasNsfw filters then " class=nsfw" else ""
|
||||
|
||||
hasNsfw :: GalleryFilters -> Bool
|
||||
hasNsfw (GalleryFilters {nsfw}) = nsfw /= Just False
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{-# OPTIONS_GHC -fdefer-typed-holes #-}
|
||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||
module Info
|
||||
(Info (..), Artist (..), Image (..), Link (..),
|
||||
|
@ -27,11 +28,11 @@ data Info =
|
|||
date :: !Day,
|
||||
title :: !(Maybe Text),
|
||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||
warning :: !(Maybe Text),
|
||||
tags :: ![Text],
|
||||
nsfwTags :: ![Text],
|
||||
description :: !(Maybe Text),
|
||||
images :: ![Image],
|
||||
background :: !(Maybe Text),
|
||||
thumb' :: !(Maybe FilePath),
|
||||
links :: ![Link]
|
||||
}
|
||||
|
@ -46,9 +47,10 @@ data Artist =
|
|||
|
||||
data Image =
|
||||
Image {
|
||||
label :: !Text,
|
||||
path :: !FilePath,
|
||||
nsfw :: !Bool
|
||||
label :: !Text,
|
||||
path :: !FilePath,
|
||||
nsfw :: !Bool,
|
||||
warning :: !(Maybe Text)
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
|
@ -80,11 +82,11 @@ instance FromYAML Info where
|
|||
Info <$> m .: "date"
|
||||
<*> m .:? "title"
|
||||
<*> m .:? "artist"
|
||||
<*> m .:? "warning"
|
||||
<*> m .:? "tags" .!= []
|
||||
<*> m .:? "nsfw-tags" .!= []
|
||||
<*> m .:? "description"
|
||||
<*> m .: "images"
|
||||
<*> m .:? "background"
|
||||
<*> m .:? "thumb"
|
||||
<*> m .:? "links" .!= []
|
||||
|
||||
|
@ -95,10 +97,29 @@ instance FromYAML Artist where
|
|||
Artist <$> m .: "name" <*> m .:? "url"
|
||||
|
||||
instance FromYAML Image where
|
||||
parseYAML = labelledOptNsfw Image "path" "path"
|
||||
parseYAML y = do
|
||||
Pair label rest <- parseYAML y
|
||||
asStr label rest <|> asObj label rest
|
||||
where
|
||||
asStr label = YAML.withStr "path" \(Text.unpack -> path) ->
|
||||
pure $ Image {label, path, nsfw = False, warning = Nothing}
|
||||
asObj label = YAML.withMap "image info" \m -> do
|
||||
path <- m .: "path"
|
||||
nsfw <- m .:? "nsfw" .!= False
|
||||
warning <- m .:? "warning"
|
||||
pure $ Image {label, path, nsfw, warning}
|
||||
|
||||
instance FromYAML Link where
|
||||
parseYAML = labelledOptNsfw Link "url" "url"
|
||||
parseYAML y = do
|
||||
Pair title rest <- parseYAML y
|
||||
asStr title rest <|> asObj title rest
|
||||
where
|
||||
asStr title = YAML.withStr "url" \url ->
|
||||
pure $ Link {title, url, nsfw = False}
|
||||
asObj title = YAML.withMap "link info" \m -> do
|
||||
url <- m .: "url"
|
||||
nsfw <- m .:? "nsfw" .!= False
|
||||
pure $ Link {title, url, nsfw}
|
||||
|
||||
|
||||
data GalleryInfo =
|
||||
|
@ -166,33 +187,6 @@ instance (FromYAML a, FromYAML b) => FromYAML (Pair a b) where
|
|||
_ -> fail "expected exactly one pair"
|
||||
|
||||
|
||||
data OptNsfw a = NoNsfw !a | WithNsfw !a !Bool
|
||||
|
||||
appOptNsfw :: (a -> Bool -> b) -> OptNsfw a -> b
|
||||
appOptNsfw f (NoNsfw x) = f x False
|
||||
appOptNsfw f (WithNsfw x n) = f x n
|
||||
|
||||
labelledOptNsfw :: FromYAML a
|
||||
=> (Text -> a -> Bool -> b)
|
||||
-> String -- ^ name in \"expected\" message
|
||||
-> Text -- ^ field name
|
||||
-> YAML.Node YAML.Pos -> YAML.Parser b
|
||||
labelledOptNsfw f name field y = do
|
||||
Pair l n' <- parseYAML y
|
||||
n <- parseOptNsfw name field n'
|
||||
pure $ appOptNsfw (f l) n
|
||||
|
||||
parseOptNsfw :: FromYAML a
|
||||
=> String -- ^ name in \"expected\" message
|
||||
-> Text -- ^ field name
|
||||
-> YAML.Node YAML.Pos -> YAML.Parser (OptNsfw a)
|
||||
parseOptNsfw name field y = yes y <|> no y where
|
||||
yes = YAML.withMap (name <> " & nsfw") \m ->
|
||||
WithNsfw <$> m .: field
|
||||
<*> m .:? "nsfw" .!= False
|
||||
no = fmap NoNsfw . parseYAML
|
||||
|
||||
|
||||
instance FromYAML Day where
|
||||
parseYAML = YAML.withStr "date" \str ->
|
||||
case readMaybe $ Text.unpack str of
|
||||
|
|
|
@ -30,29 +30,38 @@ make nsfw = toLazyText . make' nsfw
|
|||
|
||||
make' :: Bool -> Info -> Builder
|
||||
make' nsfw (Info {date, title, artist, tags, nsfwTags,
|
||||
description, images, links}) = [b|@0
|
||||
description, images, background, links}) = [b|@0
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
<link rel=stylesheet href=/style/single.css>
|
||||
|
||||
$titleTag
|
||||
|
||||
<header>
|
||||
$titleHeader
|
||||
$artistTag
|
||||
<h2 class=date>$formattedDate</date>
|
||||
<h2 class=date>$formattedDate</h2>
|
||||
$buttonBar
|
||||
</header>
|
||||
|
||||
<script async src=/script/single.js></script>
|
||||
|
||||
<main>
|
||||
<a href="$@path0">
|
||||
<img id=it src="$@path0'">
|
||||
</a>
|
||||
<figure id=mainfig$dataBg>
|
||||
$warning'
|
||||
<a id=mainlink href="$@path0">
|
||||
<img id=mainimg src="$@path0'">
|
||||
</a>
|
||||
</figure>
|
||||
|
||||
$descSection
|
||||
<section class=info>
|
||||
$descSection
|
||||
|
||||
$tagsList
|
||||
$tagsList
|
||||
|
||||
$linksList
|
||||
$linksList
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
|
@ -70,13 +79,21 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
|
|||
formattedDate = formatDate date
|
||||
|
||||
buttonBar = makeButtonBar (fromMaybe (Strict.pack path0) title) nsfw images
|
||||
path0 = #path $ head images
|
||||
image0 = head images
|
||||
path0 = #path image0
|
||||
path0' = pageFile path0
|
||||
|
||||
descSection = ifJust description makeDesc
|
||||
tagsList = makeTags nsfw tags nsfwTags
|
||||
linksList = extLinks nsfw links
|
||||
|
||||
dataBg = ifJust background \bg -> [b| data-bg="$*bg"|]
|
||||
warning' = ifJust (#warning image0) \w -> [b|@4
|
||||
<figcaption id=cw>
|
||||
$*w
|
||||
</figcaption>
|
||||
|]
|
||||
|
||||
makeArtist :: Artist -> Builder
|
||||
makeArtist (Artist {name, url}) =
|
||||
[b|<h2 class=artist>by $artistLink</h2>|]
|
||||
|
@ -86,11 +103,13 @@ makeArtist (Artist {name, url}) =
|
|||
Nothing -> [b|$*name|]
|
||||
|
||||
makeDesc :: Strict.Text -> Builder
|
||||
makeDesc desc = [b|@2
|
||||
<div class=desc>
|
||||
<h2>description</h2>
|
||||
$4*desc
|
||||
</div>
|
||||
makeDesc desc = [b|@4
|
||||
<section class=desc>
|
||||
<h2>about</h2>
|
||||
<div>
|
||||
$8*desc
|
||||
</div>
|
||||
</section>
|
||||
|]
|
||||
|
||||
ifJust :: Monoid b => Maybe a -> (a -> b) -> b
|
||||
|
@ -106,9 +125,8 @@ makeButtonBar title nsfw allImages =
|
|||
0 -> throw $ NoEligibleImages title
|
||||
1 -> ""
|
||||
_ -> [b|@2
|
||||
<nav id=variants class=buttonbar>
|
||||
<h2>alts</h2>
|
||||
<ul id=variantlist>
|
||||
<nav class=alts>
|
||||
<ul id=altlist>
|
||||
$6.alts
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -119,10 +137,11 @@ makeButtonBar title nsfw allImages =
|
|||
alts = map (uncurry altButton) $ zip [0..] images
|
||||
|
||||
altButton :: Int -> Image -> Builder
|
||||
altButton i (Image {label, path, nsfw}) = [b|@6
|
||||
altButton i (Image {label, path, nsfw, warning}) = [b|@6
|
||||
<li$nsfwClass>
|
||||
<input type=radio$checked id="$idLabel" name=variant
|
||||
autocomplete=off value="$@path'">
|
||||
autocomplete=off value="$@path'"
|
||||
data-link="$@path"$warning'>
|
||||
<label for="$idLabel">$*label</label>
|
||||
|]
|
||||
where
|
||||
|
@ -130,6 +149,7 @@ altButton i (Image {label, path, nsfw}) = [b|@6
|
|||
checked = if i == 0 then " checked" else ""
|
||||
idLabel = escId label
|
||||
path' = pageFile path
|
||||
warning' = ifJust warning \w -> [b| data-warning="$*w"|]
|
||||
|
||||
escId :: Strict.Text -> Builder
|
||||
escId = foldMap esc1 . Strict.unpack where
|
||||
|
@ -140,13 +160,13 @@ escId = foldMap esc1 . Strict.unpack where
|
|||
|
||||
makeTags :: Bool -> [Strict.Text] -> [Strict.Text] -> Builder
|
||||
makeTags nsfw sfwTags nsfwTags =
|
||||
if null tags then "" else [b|@2
|
||||
<div class=tags>
|
||||
if null tags then "" else [b|@4
|
||||
<section class=tags>
|
||||
<h2>tags</h2>
|
||||
<ul>
|
||||
$6.tagList
|
||||
$8.tagList
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|]
|
||||
where
|
||||
tagList = map makeTag tags
|
||||
|
@ -155,13 +175,13 @@ makeTags nsfw sfwTags nsfwTags =
|
|||
|
||||
extLinks :: Bool -> [Link] -> Builder
|
||||
extLinks nsfw allLinks =
|
||||
if null links then "" else [b|@2
|
||||
<div class=links>
|
||||
if null links then "" else [b|@4
|
||||
<section class=links>
|
||||
<h2>links</h2>
|
||||
<ul>
|
||||
$6.linkList
|
||||
$8.linkList
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|]
|
||||
where
|
||||
links = if nsfw then allLinks else filter #sfw allLinks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue