From 67762dd22670b38b61c449304968c4102324c5cb Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 8 Oct 2023 17:02:51 +0100 Subject: [PATCH] List sources on each artifact page Signed-off-by: Graham --- .../openrs2/archive/client/ClientExporter.kt | 30 ++++++++++++++++++- .../archive/templates/clients/show.html | 23 ++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/client/ClientExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/client/ClientExporter.kt index 35baf911a5..133ee0b842 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/client/ClientExporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/client/ClientExporter.kt @@ -79,6 +79,12 @@ public class ClientExporter @Inject constructor( } } + public data class ArtifactSource( + public val name: String?, + public val description: String?, + public val url: String? + ) + public data class ArtifactLinkExport( public val id: Long?, public val build: CacheExporter.Build?, @@ -90,6 +96,7 @@ public class ClientExporter @Inject constructor( public val summary: ArtifactSummary, public val crc32: Int, public val sha1: ByteArray, + public val sources: List, public val links: List ) { public val sha1Hex: String @@ -180,8 +187,29 @@ public class ClientExporter @Inject constructor( public suspend fun get(id: Long): Artifact? { return database.execute { connection -> + val sources = mutableListOf() val links = mutableListOf() + connection.prepareStatement( + """ + SELECT name, description, url + FROM artifact_sources + WHERE blob_id = ? + """.trimIndent() + ).use { stmt -> + stmt.setLong(1, id) + + stmt.executeQuery().use { rows -> + while (rows.next()) { + val name = rows.getString(1) + val description = rows.getString(2) + val url = rows.getString(3) + + sources += ArtifactSource(name, description, url) + } + } + } + connection.prepareStatement( """ SELECT @@ -339,7 +367,7 @@ public class ClientExporter @Inject constructor( arch, jvm, size - ), crc32, sha1, links + ), crc32, sha1, sources, links ) } } diff --git a/archive/src/main/resources/org/openrs2/archive/templates/clients/show.html b/archive/src/main/resources/org/openrs2/archive/templates/clients/show.html index b49efa4744..23c9fa7ec1 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/clients/show.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/clients/show.html @@ -73,6 +73,29 @@ +

Sources

+ +
+ + + + + + + + + + + + + + + +
NameDescriptionURL
Moparisthebest + https://www.example.com/ +
+
+

Links