Skip to content

Commit

Permalink
Shuffle around LocalEnvConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorbg committed Jan 6, 2024
1 parent 4f4dbd5 commit 28d0cb6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory
import org.worldcubeassociation.tnoodle.server.ApplicationHandler
import org.worldcubeassociation.tnoodle.server.TNoodleServer
import org.worldcubeassociation.tnoodle.server.ServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.deployable.jar.config.LocalServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.server.config.LocalServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.deployable.jar.routing.HomepageHandler
import org.worldcubeassociation.tnoodle.deployable.jar.routing.IconHandler
import org.worldcubeassociation.tnoodle.deployable.jar.routing.ReadmeHandler
Expand Down Expand Up @@ -58,7 +58,7 @@ class WebscramblesServer(environmentConfig: ServerEnvironmentConfig) : Applicati
val onlineConfig by parser.flagging("-o", "--online", help = "Change configuration for online mode. This will override port bindings and sun.awt.fontconfig")

val port = System.getenv("PORT")?.takeIf { onlineConfig }?.toIntOrNull() ?: cliPort
val offlineHandler = OfflineJarUtils(port)
val offlineHandler = OfflineJarUtils(port, LocalServerEnvironmentConfig)

val isWrapped = if (!noReexec) {
MainLauncher.wrapMain(args, MIN_HEAP_SIZE_MEGS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.worldcubeassociation.tnoodle.deployable.jar.server

import org.slf4j.LoggerFactory
import org.worldcubeassociation.tnoodle.server.config.WebServerUtils
import java.io.File
import java.io.IOException
import kotlin.math.max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package org.worldcubeassociation.tnoodle.deployable.jar.server
import dorkbox.systemTray.SystemTray
import dorkbox.systemTray.MenuItem
import org.slf4j.LoggerFactory
import org.worldcubeassociation.tnoodle.deployable.jar.config.LocalServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.server.ServerEnvironmentConfig
import java.awt.*
import java.io.IOException
import java.net.URI
import java.net.URISyntaxException
import kotlin.system.exitProcess

data class OfflineJarUtils(val port: Int) {
data class OfflineJarUtils(val port: Int, val envConfig: ServerEnvironmentConfig) {
val url = "http://localhost:$port"

fun openTabInBrowser() {
Expand Down Expand Up @@ -60,7 +60,7 @@ data class OfflineJarUtils(val port: Int) {

trayAdapter.menu.add(exitItem)

val tooltip = "${LocalServerEnvironmentConfig.projectName} v${LocalServerEnvironmentConfig.projectVersion}"
val tooltip = "${envConfig.projectName} v${envConfig.projectVersion}"
trayAdapter.setTooltip(tooltip)
trayAdapter.status = tooltip

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.ktor.server.plugins.statuspages.*
import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import kotlinx.serialization.SerializationException
import org.worldcubeassociation.tnoodle.server.config.LocalServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.server.exceptions.BadWcifParameterException
import org.worldcubeassociation.tnoodle.server.exceptions.ScheduleMatchingException
import org.worldcubeassociation.tnoodle.server.exceptions.ScrambleMatchingException
Expand All @@ -30,7 +31,7 @@ import org.worldcubeassociation.tnoodle.server.routing.frontend.WcifDataHandler
import java.io.DataInputStream
import java.io.DataOutputStream

class TNoodleServer(val environmentConfig: ServerEnvironmentConfig) : ApplicationHandler {
class TNoodleServer(val environmentConfig: ServerEnvironmentConfig = LocalServerEnvironmentConfig) : ApplicationHandler {
override fun spinUp(app: Application) {
initPruning()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.worldcubeassociation.tnoodle.deployable.jar.config
package org.worldcubeassociation.tnoodle.server.config

import org.worldcubeassociation.tnoodle.server.ServerEnvironmentConfig
import org.worldcubeassociation.tnoodle.deployable.jar.server.WebServerUtils.DEVEL_VERSION
import org.worldcubeassociation.tnoodle.deployable.jar.server.WebServerUtils.PRUNING_FOLDER
import org.worldcubeassociation.tnoodle.deployable.jar.server.WebServerUtils
import org.worldcubeassociation.tnoodle.deployable.jar.server.WebServerUtils.jarFile
import org.worldcubeassociation.tnoodle.server.config.WebServerUtils.DEVEL_VERSION
import org.worldcubeassociation.tnoodle.server.config.WebServerUtils.PRUNING_FOLDER
import org.worldcubeassociation.tnoodle.server.config.WebServerUtils.jarFile
import java.io.File
import java.io.FileNotFoundException

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.worldcubeassociation.tnoodle.deployable.jar.server
package org.worldcubeassociation.tnoodle.server.config

import java.io.*
import java.net.URISyntaxException
Expand Down

0 comments on commit 28d0cb6

Please sign in to comment.