From 2fdff493cfd979f05b33f7eb68faf0604025db63 Mon Sep 17 00:00:00 2001 From: Lanius Trolling Date: Sun, 28 Jul 2024 18:04:15 -0400 Subject: [PATCH] Add more elements to RSS --- .../kotlin/info/mechyrdia/lore/ViewsRss.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRss.kt b/src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRss.kt index 30268a3..b16fae7 100644 --- a/src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRss.kt +++ b/src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRss.kt @@ -58,6 +58,10 @@ suspend fun generateRecentPageEdits(): RssChannel { val mostRecentChange = pages.firstOrNull()?.stat?.updated + val mechyrdiaCategories = listOf( + RssCategory(domain = "https://nationstates.net", category = "Mechyrdia") + ) + return RssChannel( title = "Recently Edited Factbooks | The Hour of Decision", link = MainDomainName, @@ -65,9 +69,7 @@ suspend fun generateRecentPageEdits(): RssChannel { pubDate = mostRecentChange, lastBuildDate = mostRecentChange, ttl = 30, - categories = listOf( - RssCategory(domain = "https://nationstates.net", category = "Mechyrdia") - ), + categories = mechyrdiaCategories, items = pages.mapSuspend { page -> val pageLink = page.path.elements.drop(1) val pageMarkup = FactbookLoader.loadFactbook(pageLink) ?: return@mapSuspend null @@ -93,7 +95,8 @@ suspend fun generateRecentPageEdits(): RssChannel { author = null, comments = "$MainDomainName/lore${pageLink.joinToString(separator = "") { "/$it" }}#comments", enclosure = imageEnclosure, - pubDate = page.stat.updated + pubDate = page.stat.updated, + categories = mechyrdiaCategories, ) }.filterNotNull() ) @@ -104,6 +107,10 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(limit: Int): RssChann val validLimits = 1..100 + val mechyrdiaCategories = listOf( + RssCategory(domain = "https://nationstates.net", category = "Mechyrdia") + ) + if (limit !in validLimits) { response.status(HttpStatusCode.BadRequest) @@ -114,6 +121,7 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(limit: Int): RssChann pubDate = null, lastBuildDate = Instant.now(), ttl = 120, + categories = mechyrdiaCategories, ) } @@ -141,9 +149,7 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(limit: Int): RssChann pubDate = mostRecentComment, lastBuildDate = mostRecentComment, ttl = 60, - categories = listOf( - RssCategory(domain = "https://nationstates.net", category = "Mechyrdia") - ), + categories = mechyrdiaCategories, items = comments.map { comment -> RssItem( title = "Comment by ${comment.submittedBy.name} on $MainDomainName/${comment.submittedIn}", @@ -152,9 +158,7 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(limit: Int): RssChann author = null, comments = "$MainDomainName/lore/${comment.submittedIn}#comment-${comment.id}", pubDate = comment.lastEdit ?: comment.submittedAt, - categories = listOf( - RssCategory(domain = "https://nationstates.net", category = comment.submittedBy.name) - ) + categories = mechyrdiaCategories + RssCategory(domain = "https://nationstates.net", category = comment.submittedBy.name) ) } ) -- 2.25.1