mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Add logo support to plugins and UI
This commit is contained in:
@@ -2,9 +2,15 @@ package de.grimsi.gameyfin.pluginapi.core
|
||||
|
||||
import org.pf4j.Plugin
|
||||
import org.pf4j.PluginWrapper
|
||||
import java.io.InputStream
|
||||
|
||||
abstract class GameyfinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||
|
||||
companion object {
|
||||
const val LOGO_FILE_NAME: String = "logo"
|
||||
val SUPPORTED_LOGO_FORMATS: List<String> = listOf("png", "jpg", "jpeg", "gif", "svg", "webp")
|
||||
}
|
||||
|
||||
abstract val configMetadata: List<PluginConfigElement>
|
||||
protected open var config: Map<String, String?> = emptyMap()
|
||||
|
||||
@@ -21,4 +27,28 @@ abstract class GameyfinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||
}
|
||||
|
||||
abstract fun validateConfig(config: Map<String, String?>): Boolean
|
||||
|
||||
fun hasLogo(): Boolean {
|
||||
for (format in SUPPORTED_LOGO_FORMATS) {
|
||||
val resourcePath = "$LOGO_FILE_NAME.$format"
|
||||
val inputStream = wrapper.pluginClassLoader.getResourceAsStream(resourcePath)
|
||||
if (inputStream != null) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun getLogo(): InputStream? {
|
||||
for (format in SUPPORTED_LOGO_FORMATS) {
|
||||
val resourcePath = "$LOGO_FILE_NAME.$format"
|
||||
val inputStream = wrapper.pluginClassLoader.getResourceAsStream(resourcePath)
|
||||
if (inputStream != null) {
|
||||
return inputStream
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user