List sources on each artifact page

Signed-off-by: Graham <gpe@openrs2.org>
Graham 1 year ago
parent 3932debd92
commit 67762dd226
  1. 30
      archive/src/main/kotlin/org/openrs2/archive/client/ClientExporter.kt
  2. 23
      archive/src/main/resources/org/openrs2/archive/templates/clients/show.html

@ -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 data class ArtifactLinkExport(
public val id: Long?, public val id: Long?,
public val build: CacheExporter.Build?, public val build: CacheExporter.Build?,
@ -90,6 +96,7 @@ public class ClientExporter @Inject constructor(
public val summary: ArtifactSummary, public val summary: ArtifactSummary,
public val crc32: Int, public val crc32: Int,
public val sha1: ByteArray, public val sha1: ByteArray,
public val sources: List<ArtifactSource>,
public val links: List<ArtifactLinkExport> public val links: List<ArtifactLinkExport>
) { ) {
public val sha1Hex: String public val sha1Hex: String
@ -180,8 +187,29 @@ public class ClientExporter @Inject constructor(
public suspend fun get(id: Long): Artifact? { public suspend fun get(id: Long): Artifact? {
return database.execute { connection -> return database.execute { connection ->
val sources = mutableListOf<ArtifactSource>()
val links = mutableListOf<ArtifactLinkExport>() val links = mutableListOf<ArtifactLinkExport>()
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( connection.prepareStatement(
""" """
SELECT SELECT
@ -339,7 +367,7 @@ public class ClientExporter @Inject constructor(
arch, arch,
jvm, jvm,
size size
), crc32, sha1, links ), crc32, sha1, sources, links
) )
} }
} }

@ -73,6 +73,29 @@
</tr> </tr>
</table> </table>
<h2>Sources</h2>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead class="table-dark">
<tr>
<th>Name</th>
<th>Description</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr th:each="source : ${artifact.sources}">
<td th:text="${source.name}">Moparisthebest</td>
<td th:text="${source.description}"></td>
<td>
<a th:href="${source.url}" th:text="${source.url}" th:if="${source.url}">https://www.example.com/</a>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="${artifact.links}" th:tag="remove"> <div th:if="${artifact.links}" th:tag="remove">
<h2>Links</h2> <h2>Links</h2>

Loading…
Cancel
Save