From: David ‘Bombe’ Roden Date: Thu, 11 Apr 2024 09:41:53 +0000 (+0200) Subject: 🚧 Add HTML output to game state X-Git-Tag: v2^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=cce17237a408a44339d4301ea7664ab87edbdf26;p=rhynodge.git 🚧 Add HTML output to game state --- diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/FreeGamesState.kt b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/FreeGamesState.kt index 580f0b4..47a78fd 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/FreeGamesState.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/FreeGamesState.kt @@ -1,12 +1,66 @@ package net.pterodactylus.rhynodge.filters.webpages.epicgames +import kotlinx.html.body +import kotlinx.html.div +import kotlinx.html.dom.createHTMLDocument +import kotlinx.html.dom.serialize +import kotlinx.html.head +import kotlinx.html.html +import kotlinx.html.img +import kotlinx.html.style +import kotlinx.html.unsafe import net.pterodactylus.rhynodge.states.AbstractState +import java.time.ZoneId +import java.util.Comparator.comparing -class FreeGamesState(val games: Set, private val triggered: Boolean = false) : AbstractState(true) { +class FreeGamesState(val games: Set, private val triggered: Boolean = false, private val timezone: ZoneId = ZoneId.systemDefault()) : AbstractState(true) { - override fun plainText(): String { - TODO("Not yet implemented") - } + override fun plainText() = games + .sortedWith(comparing(FreeGame::startDate).thenBy(FreeGame::title)) + .joinToString("\n") { game -> + "${game.title}: ${"%tF % + div("game") { + div("game-image") { + img(src = game.imageUrl) + } + div("game-title") { + +game.title + } + div("game-start") { + +"%tF %