diff --git a/src/main/java/digital/slovensko/autogram/server/AssetsEndpoint.java b/src/main/java/digital/slovensko/autogram/server/AssetsEndpoint.java index 6fb400d6..aaa5b1fb 100644 --- a/src/main/java/digital/slovensko/autogram/server/AssetsEndpoint.java +++ b/src/main/java/digital/slovensko/autogram/server/AssetsEndpoint.java @@ -6,17 +6,13 @@ import digital.slovensko.autogram.server.errors.InvalidUrlParamException; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.List; import static java.util.Objects.requireNonNull; public class AssetsEndpoint implements HttpHandler { private static final List assets; - private static final Path assetsPath; static { - assetsPath = Path.of(requireNonNull(AssetsEndpoint.class.getResource("index.html")).getPath()).getParent().resolve("assets"); assets = List.of( "swagger-ui-bundle-v5.11.0.js", "swagger-ui-v5.11.0.css" @@ -39,7 +35,7 @@ public void handle(HttpExchange exchange) throws IOException { throw new InvalidUrlParamException("Asset with this name does not exist"); try (exchange) { - exchange.getResponseHeaders().set("Content-Type", Files.probeContentType(assetsPath.resolve(fileName))); + exchange.getResponseHeaders().set("Content-Type", getAssetMimeType(fileName)); exchange.sendResponseHeaders(200, 0); requireNonNull(stream).transferTo(exchange.getResponseBody()); } @@ -49,4 +45,14 @@ public void handle(HttpExchange exchange) throws IOException { EndpointUtils.respondWithError(ErrorResponse.buildFromException(e), exchange); } } + + private String getAssetMimeType(String fileName) { + if (fileName.endsWith(".js")) + return "application/javascript"; + + if (fileName.endsWith(".css")) + return "text/css"; + + return "applicaiton/octet-stream"; + } } diff --git a/src/main/resources/digital/slovensko/autogram/build.properties b/src/main/resources/digital/slovensko/autogram/build.properties index d3c330ad..4ef54f90 100644 --- a/src/main/resources/digital/slovensko/autogram/build.properties +++ b/src/main/resources/digital/slovensko/autogram/build.properties @@ -24,7 +24,7 @@ win.menuGroup= win.perUserInstall= # Create a desktop shortcut for the application (1/0). # Defaults to 0. -win.shortcut= +win.shortcut=1 ### Linux specific ### diff --git a/src/main/scripts/package.sh b/src/main/scripts/package.sh index f319ee8f..9b09deae 100644 --- a/src/main/scripts/package.sh +++ b/src/main/scripts/package.sh @@ -57,10 +57,10 @@ if [[ "${platform}" == "win" ]]; then arguments+=( "--name" "${properties_name}" + "--description" "${properties_name}" "--type" "msi" "--icon" "./Autogram.ico" "--java-options" "${jvmOptions} --add-opens jdk.crypto.mscapi/sun.security.mscapi=ALL-UNNAMED" - "--win-shortcut-prompt" "--win-menu" "--add-launcher" "autogram-cli=$resourcesDir/windows-cli-build.properties" )