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
|
||||
|
||||
makeItem :: Bool -> FilePath -> Info -> Builder
|
||||
makeItem nsfw file info = [b|@4
|
||||
makeItem nsfw file info@(Info {title}) = [b|@4
|
||||
<li $cls>
|
||||
<figure>
|
||||
<a href="$@dir">
|
||||
<img src="$@thumb">
|
||||
</a>
|
||||
$title
|
||||
<figcaption>$*title</figcaption>
|
||||
</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>
|
||||
|]
|
||||
cls | nsfw && #anyNsfw info = [b|class="item nsfw"|]
|
||||
| otherwise = [b|class=item|]
|
||||
|
|
|
@ -28,7 +28,7 @@ import Text.Read (readMaybe)
|
|||
data Info =
|
||||
Info {
|
||||
date :: !Day,
|
||||
title :: !(Maybe Text),
|
||||
title :: !Text,
|
||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||
tags :: ![Text],
|
||||
nsfwTags :: ![Text],
|
||||
|
@ -95,7 +95,7 @@ instance Ord Info where
|
|||
instance FromYAML Info where
|
||||
parseYAML = YAML.withMap "info" \m ->
|
||||
Info <$> m .: "date"
|
||||
<*> m .:? "title"
|
||||
<*> m .: "title"
|
||||
<*> m .:? "artist"
|
||||
<*> m .:? "tags" .!= []
|
||||
<*> m .:? "nsfw-tags" .!= []
|
||||
|
|
|
@ -9,7 +9,6 @@ import Control.Exception
|
|||
import qualified Data.Text as Strict
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import Data.Time (formatTime, defaultTimeLocale)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Char as Char
|
||||
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'>
|
||||
<link rel=stylesheet href=/style/single.css>
|
||||
|
||||
$titleTag
|
||||
<title>$*title</title>
|
||||
|
||||
<header>
|
||||
$titleHeader
|
||||
<h1>$*title</h1>
|
||||
$artistTag
|
||||
<h2 class=date>$formattedDate</h2>
|
||||
$buttonBar
|
||||
|
@ -71,14 +70,11 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags,
|
|||
</footer>
|
||||
|]
|
||||
where
|
||||
titleTag = ifJust title \t -> [b|<title>$*t</title>|]
|
||||
titleHeader = ifJust title \t -> [b|<h1>$*t</h1>|]
|
||||
|
||||
artistTag = ifJust artist makeArtist
|
||||
|
||||
formattedDate = formatDate date
|
||||
|
||||
buttonBar = makeButtonBar (fromMaybe (Strict.pack path0) title) nsfw images
|
||||
buttonBar = makeButtonBar title nsfw images
|
||||
image0 = head images
|
||||
path0 = #path image0
|
||||
path0' = pageFile path0
|
||||
|
|
Loading…
Reference in a new issue