diff --git a/.spotless/mizule.importorder b/.spotless/mizule.importorder new file mode 100644 index 0000000..c232b17 --- /dev/null +++ b/.spotless/mizule.importorder @@ -0,0 +1,6 @@ +#Organize Import Order +#Tue Mar 30 19:56:59 PDT 2021 +0= +1=java +2=javax +3=\# diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ee62d9d..01c3ebc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,14 @@ +import com.diffplug.gradle.spotless.FormatExtension +import net.kyori.indra.licenser.spotless.HeaderFormat +import java.util.* + plugins { id("org.jetbrains.kotlin.jvm") version "1.9.20" id("com.github.johnrengelman.shadow") version "8.1.1" id("net.kyori.indra") version "3.1.3" + id("net.kyori.indra.licenser.spotless") version "3.1.3" + id("net.kyori.indra.git") version "3.1.3" + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7" `java-library` application } @@ -34,6 +41,46 @@ indra { mitLicense() } +spotless { + fun FormatExtension.applyCommon() { + trimTrailingWhitespace() + endWithNewline() + encoding("UTF-8") + toggleOffOn() + } + java { + importOrderFile(rootProject.file(".spotless/mizule.importorder")) + removeUnusedImports() + formatAnnotations() + applyCommon() + target("*/src/*/java/**/*.java") + } + kotlinGradle { + applyCommon() + ktlint("0.50.0") + } + kotlin { + applyCommon() + ktlint("0.50.0") + } +} + +indraSpotlessLicenser { + headerFormat(HeaderFormat.starSlash()) + licenseHeaderFile(rootProject.projectDir.resolve("HEADER")) + + val currentYear = Calendar.getInstance().apply { + time = Date() + }.get(Calendar.YEAR) + val createdYear = providers.gradleProperty("createdYear").map { it.toInt() }.getOrElse(currentYear) + val year = if (createdYear == currentYear) createdYear.toString() else "$createdYear-$currentYear" + + property("name", providers.gradleProperty("projectName").getOrElse("template")) + property("year", year) + property("description", project.description ?: "A template project") + property("author", providers.gradleProperty("projectAuthor").getOrElse("template")) +} + application { mainClass.set("dev.mizule.imagery.app.launcher.Launcher") } @@ -46,4 +93,11 @@ tasks { runShadow { workingDir = file("run").also(File::mkdirs) } -} \ No newline at end of file +} + +idea { + module { + isDownloadJavadoc = true + isDownloadSources = true + } +} diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/App.kt b/app/src/main/kotlin/dev/mizule/imagery/app/App.kt index 1de527b..67a23c7 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/App.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/App.kt @@ -1,3 +1,27 @@ +/* + * This file is part of Imagery, licensed under the MIT License. + * + * Copyright (c) 2023 powercas_gamer + * Copyright (c) 2023 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package dev.mizule.imagery.app import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper @@ -17,7 +41,10 @@ import org.spongepowered.configurate.jackson.JacksonConfigurationLoader import org.spongepowered.configurate.kotlin.objectMapperFactory import java.nio.file.Path import java.util.concurrent.TimeUnit -import kotlin.io.path.* +import kotlin.io.path.Path +import kotlin.io.path.createDirectories +import kotlin.io.path.inputStream +import kotlin.io.path.outputStream private val logger = KotlinLogging.logger {} @@ -76,7 +103,7 @@ class App(private val config: Config) { System.currentTimeMillis(), file.filename(), file.extension(), - MimeTypes.getDefaultMimeByExtension(file.extension()) + MimeTypes.getDefaultMimeByExtension(file.extension()), ) dataNode.node(uploadedFile.id).set(uploadedFile) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt b/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt index 68dead1..03bc228 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt @@ -1,3 +1,27 @@ +/* + * This file is part of Imagery, licensed under the MIT License. + * + * Copyright (c) 2023 powercas_gamer + * Copyright (c) 2023 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package dev.mizule.imagery.app.config import org.spongepowered.configurate.objectmapping.ConfigSerializable @@ -15,5 +39,5 @@ data class Config( val indexPath: String = "./files.json", @Comment("The path to the uploaded file storage directory.") - val storagePath: String = "./storage" + val storagePath: String = "./storage", ) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt b/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt index f899af8..6d4fccd 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt @@ -1,3 +1,27 @@ +/* + * This file is part of Imagery, licensed under the MIT License. + * + * Copyright (c) 2023 powercas_gamer + * Copyright (c) 2023 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ @file:JvmName("Launcher") package dev.mizule.imagery.app.launcher diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/model/ImageLookupResult.kt b/app/src/main/kotlin/dev/mizule/imagery/app/model/ImageLookupResult.kt index d08a7fb..61df8de 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/model/ImageLookupResult.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/model/ImageLookupResult.kt @@ -2,5 +2,5 @@ package dev.mizule.imagery.app.model data class ImageLookupResult( val url: String, - val delete: String = "$url/del" + val delete: String = "$url/del", ) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/model/UploadedFile.kt b/app/src/main/kotlin/dev/mizule/imagery/app/model/UploadedFile.kt index 9b5dc50..fb9e1ed 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/model/UploadedFile.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/model/UploadedFile.kt @@ -1,3 +1,27 @@ +/* + * This file is part of Imagery, licensed under the MIT License. + * + * Copyright (c) 2023 powercas_gamer + * Copyright (c) 2023 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package dev.mizule.imagery.app.model import org.spongepowered.configurate.objectmapping.ConfigSerializable