1
0

Add categories

This commit is contained in:
Hubert Van De Walle 2020-09-10 16:34:03 +02:00
parent cf46ec26c4
commit 7f2256bcbb
8 changed files with 52 additions and 13 deletions

View File

@ -22,11 +22,13 @@ display = "Kotlin Version"
groupId = "org.http4k" groupId = "org.http4k"
artifactId = "http4k-core" artifactId = "http4k-core"
version = "3.260.0" version = "3.260.0"
category = "server"
[dependencies.javalin] [dependencies.javalin]
groupId = "io.javalin" groupId = "io.javalin"
artifactId = "javalin" artifactId = "javalin"
version = "3.10.1" version = "3.10.1"
category = "server"
[dependencies.pebble] [dependencies.pebble]
groupId = "io.pebbletemplates" groupId = "io.pebbletemplates"
@ -43,28 +45,34 @@ default = true
groupId = "org.mariadb.jdbc" groupId = "org.mariadb.jdbc"
artifactId = "mariadb-java-client" artifactId = "mariadb-java-client"
version = "2.6.2" version = "2.6.2"
category = "database"
[dependencies.h2] [dependencies.h2]
groupId = "com.h2database" groupId = "com.h2database"
artifactId = "h2" artifactId = "h2"
version = "1.4.200" version = "1.4.200"
category = "database"
[dependencies.flyway] [dependencies.flyway]
groupId = "org.flywaydb" groupId = "org.flywaydb"
artifactId = "flyway-core" artifactId = "flyway-core"
version = "6.5.4" version = "6.5.4"
category = "database"
[dependencies.HikariCP] [dependencies.HikariCP]
groupId = "com.zaxxer" groupId = "com.zaxxer"
artifactId = "HikariCP" artifactId = "HikariCP"
version = "3.4.5" version = "3.4.5"
category = "database"
[dependencies.Ktorm] [dependencies.Ktorm]
groupId = "me.liuwj.ktorm" groupId = "me.liuwj.ktorm"
artifactId = "ktorm-core" artifactId = "ktorm-core"
version = "3.0.0" version = "3.0.0"
category = "database"
[dependencies.Ktorm-Mysql] [dependencies.Ktorm-Mysql]
groupId = "me.liuwj.ktorm" groupId = "me.liuwj.ktorm"
artifactId = "ktorm-support-mysql" artifactId = "ktorm-support-mysql"
version = "3.0.0" version = "3.0.0"
category = "database"

View File

@ -0,0 +1,3 @@
.category{
@apply text-lg inline-block text-center font-semibold text-gray-800 bg-green-300 rounded-full px-3 py-1 my-2;
}

View File

@ -5,6 +5,7 @@
@import "tailwindcss/components"; @import "tailwindcss/components";
@import "button.pcss"; @import "button.pcss";
@import "category.pcss";
@import "inputs.pcss"; @import "inputs.pcss";
/*noinspection CssUnknownTarget*/ /*noinspection CssUnknownTarget*/

View File

@ -12,7 +12,14 @@ class Config {
val dependenciesNode: NightConfig = cfg["dependencies"] val dependenciesNode: NightConfig = cfg["dependencies"]
@Suppress("UNCHECKED_CAST") val dependenciesMap = dependenciesNode.valueMap() as Map<String, NightConfig> @Suppress("UNCHECKED_CAST") val dependenciesMap = dependenciesNode.valueMap() as Map<String, NightConfig>
val dependencies = dependenciesMap.map { (name, values) -> val dependencies = dependenciesMap.map { (name, values) ->
Dependency(name, values["groupId"], values["artifactId"], values["version"], values.getOrElse("default", false)) Dependency(
name,
values["groupId"],
values["artifactId"],
values["version"],
values.getOrElse("default", false),
values.getEnumOrElse("category", Category.Other)
)
} }
val inputsNode: NightConfig = cfg["inputs"] val inputsNode: NightConfig = cfg["inputs"]

View File

@ -1,4 +1,15 @@
package starter package starter
data class Dependency(val name: String, val groupId: String, val artifactId: String, val version: String, val default: Boolean) enum class Category {
Server, Database, Other
}
data class Dependency(
val name: String,
val groupId: String,
val artifactId: String,
val version: String,
val default: Boolean,
val category: Category,
)
data class Input(val name: String, val display: String, val value: String? = null) data class Input(val name: String, val display: String, val value: String? = null)

View File

@ -14,11 +14,15 @@ private fun PebbleEngine.render(name: String, args: Map<String, Any?> = mapOf())
class Views(private val engine: PebbleEngine) { class Views(private val engine: PebbleEngine) {
private val logger = LoggerFactory.getLogger(javaClass) private val logger = LoggerFactory.getLogger(javaClass)
fun index(dependencies: List<Dependency>, inputs: List<Input>) = engine.render("views/index", fun index(dependencies: List<Dependency>, inputs: List<Input>): String {
mapOf("dependencies" to dependencies, "inputs" to inputs) val dependenciesByCategory = dependencies.groupBy { it.category }.toSortedMap()
return engine.render("views/index",
mapOf("dependencies" to dependenciesByCategory, "inputs" to inputs)
) )
}
fun pom(dependencies: List<Dependency>, inputs: List<Input>): String { fun pom(dependencies: List<Dependency>, inputs: List<Input>): String {
val args: MutableMap<String, Any?> = mutableMapOf( val args: MutableMap<String, Any?> = mutableMapOf(
"dependencies" to dependencies, "dependencies" to dependencies,
) )
@ -27,8 +31,6 @@ class Views(private val engine: PebbleEngine) {
args[it.name] = it.value args[it.name] = it.value
} }
logger.debug(args.toString())
return engine.render("starter/pom", return engine.render("starter/pom",
args args
) )

File diff suppressed because one or more lines are too long

View File

@ -8,10 +8,17 @@
{% for input in inputs %} {% for input in inputs %}
{{ input(input) }} {{ input(input) }}
{% endfor %} {% endfor %}
<hr>
<div class="flex flex-wrap"> <div class="mt-4">
{% for dependency in dependencies %} {% for category in dependencies %}
{{ dependency(dependency) }} <section>
<h2 class="category">{{ category.key }}</h2>
<ul>
{% for dependency in category.value %}
<li>{{ dependency(dependency) }}</li>
{% endfor %}
</ul>
</section>
{% endfor %} {% endfor %}
</div> </div>
<button type="submit" class="w-full btn btn-purple">Submit</button> <button type="submit" class="w-full btn btn-purple">Submit</button>