make title mandatory
This commit is contained in:
parent
b6203a2d4a
commit
c10a3ab340
3 changed files with 7 additions and 17 deletions
|
@ -63,23 +63,17 @@ makeYearItems nsfw year infos = [b|@4
|
||||||
where items = map (uncurry $ makeItem nsfw) infos
|
where items = map (uncurry $ makeItem nsfw) infos
|
||||||
|
|
||||||
makeItem :: Bool -> FilePath -> Info -> Builder
|
makeItem :: Bool -> FilePath -> Info -> Builder
|
||||||
makeItem nsfw file info = [b|@4
|
makeItem nsfw file info@(Info {title}) = [b|@4
|
||||||
<li $cls>
|
<li $cls>
|
||||||
<figure>
|
<figure>
|
||||||
<a href="$@dir">
|
<a href="$@dir">
|
||||||
<img src="$@thumb">
|
<img src="$@thumb">
|
||||||
</a>
|
</a>
|
||||||
$title
|
<figcaption>$*title</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
dir = takeDirectory file
|
dir = takeDirectory file
|
||||||
thumb = maybe (throw $ NoThumb dir) (\t -> dir </> thumbFile t) $ #thumb info
|
thumb = maybe (throw $ NoThumb dir) (\t -> dir </> thumbFile t) $ #thumb info
|
||||||
title = maybe mempty mkTitle $ #title info
|
|
||||||
mkTitle t = [b|@8
|
|
||||||
<figcaption>
|
|
||||||
$*t
|
|
||||||
</figcaption>
|
|
||||||
|]
|
|
||||||
cls | nsfw && #anyNsfw info = [b|class="item nsfw"|]
|
cls | nsfw && #anyNsfw info = [b|class="item nsfw"|]
|
||||||
| otherwise = [b|class=item|]
|
| otherwise = [b|class=item|]
|
||||||
|
|
|
@ -28,7 +28,7 @@ import Text.Read (readMaybe)
|
||||||
data Info =
|
data Info =
|
||||||
Info {
|
Info {
|
||||||
date :: !Day,
|
date :: !Day,
|
||||||
title :: !(Maybe Text),
|
title :: !Text,
|
||||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||||
tags :: ![Text],
|
tags :: ![Text],
|
||||||
nsfwTags :: ![Text],
|
nsfwTags :: ![Text],
|
||||||
|
@ -95,7 +95,7 @@ instance Ord Info where
|
||||||
instance FromYAML Info where
|
instance FromYAML Info where
|
||||||
parseYAML = YAML.withMap "info" \m ->
|
parseYAML = YAML.withMap "info" \m ->
|
||||||
Info <$> m .: "date"
|
Info <$> m .: "date"
|
||||||
<*> m .:? "title"
|
<*> m .: "title"
|
||||||
<*> m .:? "artist"
|
<*> m .:? "artist"
|
||||||
<*> m .:? "tags" .!= []
|
<*> m .:? "tags" .!= []
|
||||||
<*> m .:? "nsfw-tags" .!= []
|
<*> m .:? "nsfw-tags" .!= []
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Control.Exception
|
||||||
import qualified Data.Text as Strict
|
import qualified Data.Text as Strict
|
||||||
import qualified Data.Text.Lazy as Lazy
|
import qualified Data.Text.Lazy as Lazy
|
||||||
import Data.Time (formatTime, defaultTimeLocale)
|
import Data.Time (formatTime, defaultTimeLocale)
|
||||||
import Data.Maybe (fromMaybe)
|
|
||||||
import qualified Data.Char as Char
|
import qualified Data.Char as Char
|
||||||
import qualified Data.List as List
|
import qualified Data.List as List
|
||||||
|
|
||||||
|
@ -36,10 +35,10 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
|
||||||
<meta name=viewport content='width=1200,viewport-fit=cover'>
|
<meta name=viewport content='width=1200,viewport-fit=cover'>
|
||||||
<link rel=stylesheet href=/style/single.css>
|
<link rel=stylesheet href=/style/single.css>
|
||||||
|
|
||||||
$titleTag
|
<title>$*title</title>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
$titleHeader
|
<h1>$*title</h1>
|
||||||
$artistTag
|
$artistTag
|
||||||
<h2 class=date>$formattedDate</h2>
|
<h2 class=date>$formattedDate</h2>
|
||||||
$buttonBar
|
$buttonBar
|
||||||
|
@ -71,14 +70,11 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
|
||||||
</footer>
|
</footer>
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
titleTag = ifJust title \t -> [b|<title>$*t</title>|]
|
|
||||||
titleHeader = ifJust title \t -> [b|<h1>$*t</h1>|]
|
|
||||||
|
|
||||||
artistTag = ifJust artist makeArtist
|
artistTag = ifJust artist makeArtist
|
||||||
|
|
||||||
formattedDate = formatDate date
|
formattedDate = formatDate date
|
||||||
|
|
||||||
buttonBar = makeButtonBar (fromMaybe (Strict.pack path0) title) nsfw images
|
buttonBar = makeButtonBar title nsfw images
|
||||||
image0 = head images
|
image0 = head images
|
||||||
path0 = #path image0
|
path0 = #path image0
|
||||||
path0' = pageFile path0
|
path0' = pageFile path0
|
||||||
|
|
Loading…
Reference in a new issue