allow multiple updates on one day

[the reason for this, rather than just one update listing everything, is
that i can have sfw and nsfw updates and only display the appropriate
one]
This commit is contained in:
Rhiannon Morris 2022-08-17 03:11:56 +02:00
parent 71915ed1ff
commit 2833487f62
2 changed files with 29 additions and 27 deletions

View file

@ -8,7 +8,7 @@ import qualified NsfwWarning
import Control.Exception
import Control.Monad
import Data.List (sort)
import Data.List (sort, intersperse)
import Data.Maybe (fromMaybe)
import qualified Data.Text as Strict
import qualified Data.Text.Lazy as Lazy
@ -86,7 +86,7 @@ make' root prefix nsfw _dataDir dir info@(Info {date, title, artist, bg}) = do
Nothing -> "by niss"
let thumb = getThumb "" info
let updateDate = ifJust (last' updates) \(Update {date = d}) ->
let updateDate = ifJust (last' updates) \(d, _) ->
let updated = formatLong d in
[b|<br> <span class=updated>updated $updated</span>|]
@ -286,7 +286,7 @@ extLink (Link {title, url}) = [b|@8
</a>
|]
makeUpdates :: [Update] -> Builder
makeUpdates :: [(Date, [Update])] -> Builder
makeUpdates ups =
if null ups then "" else [b|@4
<section id=updates class=info-section>
@ -296,11 +296,12 @@ makeUpdates ups =
</dl>
</section>
|]
where updateList = map makeUpdate ups
where updateList = map (uncurry makeUpdate) ups
makeUpdate :: Update -> Builder
makeUpdate (Update {date, desc}) = [b|@8
makeUpdate :: Date -> [Update] -> Builder
makeUpdate date ups = [b|@8
<dt>$date'
<dd>$desc
|]
where date' = formatSlash date
|] where
date' = formatSlash date
desc = mconcat $ map fromText $ intersperse "; " $ map #desc ups