diff --git a/build.gradle.kts b/build.gradle.kts index 14524ee..a88b126 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { group = "de.hoennig" // bump at least the patch version for every deployment, so the UI footer // (BuildProperties) and --version identify what is actually running -version = "0.9.3" +version = "0.9.4" java { toolchain { diff --git a/src/main/kotlin/de/hoennig/gittally/server/UiController.kt b/src/main/kotlin/de/hoennig/gittally/server/UiController.kt index 934f2d3..731b879 100644 --- a/src/main/kotlin/de/hoennig/gittally/server/UiController.kt +++ b/src/main/kotlin/de/hoennig/gittally/server/UiController.kt @@ -7,6 +7,7 @@ import de.hoennig.gittally.build.BuildResultRepository import de.hoennig.gittally.build.BuildStatus import de.hoennig.gittally.config.ConfigLoader import de.hoennig.gittally.metrics.SystemMetricsCollector +import jakarta.servlet.http.HttpServletRequest import org.springframework.beans.factory.ObjectProvider import org.springframework.boot.info.BuildProperties import org.springframework.http.HttpStatus @@ -15,6 +16,7 @@ import org.springframework.ui.Model import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.server.ResponseStatusException +import org.springframework.web.servlet.view.RedirectView import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -41,6 +43,16 @@ class UiController( ) { var workingDir: Path = Paths.get(".") + /** + * Permanent redirects for the legacy script's static page names, so bookmarks + * and links from before the rewrite (e.g. via the old host's redirect) keep working. + */ + @GetMapping("/index.html", "/branches.html", "/history.html", "/system.html", "/about.html", "/license.html") + fun legacyPageName(request: HttpServletRequest): RedirectView = + RedirectView(LEGACY_PAGE_TARGETS.getValue(request.requestURI)).apply { + setStatusCode(HttpStatus.MOVED_PERMANENTLY) + } + @GetMapping("/") fun latest(model: Model): String { val links = baseModel(model, view = "latest", pageTitle = "Latest Builds") @@ -256,5 +268,16 @@ class UiController( companion object { private val FAILURES_COUNTER = Regex("""id="failures">\s*