From c8a8e770216b0e27933efc7eced9e724c554cb7e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:31:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20OGP=E7=94=A8=E3=81=AE=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springframework/SPAInterceptor.kt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SPAInterceptor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SPAInterceptor.kt index 7f525144..866e1ae2 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SPAInterceptor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SPAInterceptor.kt @@ -1,11 +1,11 @@ package dev.usbharu.hideout.core.infrastructure.springframework +import dev.usbharu.hideout.core.interfaces.web.common.OGP import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse import org.springframework.stereotype.Component import org.springframework.web.servlet.HandlerInterceptor import org.springframework.web.servlet.ModelAndView -import org.springframework.web.servlet.support.ServletUriComponentsBuilder @Component class SPAInterceptor : HandlerInterceptor { @@ -29,18 +29,12 @@ class SPAInterceptor : HandlerInterceptor { if (request.session.getAttribute("s") == "f") { return } - val title = modelAndView?.modelMap?.getOrDefault("title", "") - val url = modelAndView?.modelMap?.getOrDefault( - "url", - ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString() + '?' + request.queryString - ) - val description = modelAndView?.modelMap?.getOrDefault("description", "") - val image = modelAndView?.modelMap?.get("image") + + val ogp = modelAndView?.modelMap?.get("ogp") as? OGP modelAndView?.clear() modelAndView?.addObject("nsUrl", request.requestURI + "?s=f" + request.queryString?.let { "&$it" }.orEmpty()) - modelAndView?.addAllObjects(mapOf("title" to title, "url" to url, "description" to description)) - image?.let { modelAndView?.addObject("image", it) } + modelAndView?.addObject("ogp", ogp) modelAndView?.viewName = "index" } } \ No newline at end of file