Skip to content

Commit

Permalink
Hotfix/v1.2.2 release1 (#211)
Browse files Browse the repository at this point in the history
* fix: 미리보기 api 화이트리스트 추가 (#211)

* fix: logback 제거 (#211)

* fix: og html 코드 수정 (#211)

* fix: baseUrl model에 추가 (#211)
  • Loading branch information
violet-mj authored Aug 24, 2024
1 parent b10671c commit 6524e93
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
Expand All @@ -21,6 +22,9 @@ public class PreviewController {

private final PreviewService previewService;

@Value("${domain.url}")
private String baseUrl;

@Tag(name = "Drawing Lottery")
@Operation(summary = "미리 보기용 html 반환", description = """
# open graph html 반환
Expand All @@ -46,6 +50,8 @@ public String preview(
model.addAttribute("resultImgUrl", eventUser.getResultImgUrl());
model.addAttribute("name", eventUser.getUser().getName());
model.addAttribute("score", eventUser.getGameScore());
model.addAttribute("apiUrl", baseUrl);
model.addAttribute("ogUrl", baseUrl + "/api/v1/preview/" + previewRequest.getSharedUrl());

return "preview";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class JwtAuthorizationFilter implements Filter {
"/api/v1/firstcome/quiz/land",
"/api/v1/lottery/drawing/land",
"/api/v1/lottery/drawing/rank",
"/api/v1/lottery/drawing/preview",
"/api/v1/land"
};

Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/logback-spring.xml

This file was deleted.

38 changes: 33 additions & 5 deletions src/main/resources/templates/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,45 @@
<title>웹페이지 제목</title>

<!-- Open Graph 메타 태그 -->
<meta property="og:title" content="드로잉 이벤트~!!">
<meta property="og:description" th:content="${name} + '님은 ' + ${score} + '를 얻으셨어요~~ 한번 도전 해보실래요?'">
<meta property="og:title" content="일상과 낭만 사이, 디 올 뉴 싼타페와 함께">
<meta property="og:description" th:content="'[' + ${name} + ']' + '님의 점수는 ' + ${score} + '입니다.'">
<meta property="og:image" th:content="${resultImgUrl}">
<meta property="og:url">
<meta property="og:url" th:content="${ogUrl}">
<meta property="og:type" content="website">

<!-- 추가적인 Open Graph 태그 -->
<meta property="og:locale" content="ko_KR">
</head>
<body>
<h1>웹페이지 내용</h1>
<p>이곳에 실제 웹페이지 내용을 작성합니다.</p>
<script th:inline="javascript">
/*<![CDATA[*/
window.addEventListener('load', function() {
const pathParts = window.location.pathname.split('/');
const sharedCode = pathParts[pathParts.length - 1];
const baseUrl = /*[[${apiUrl}]]*/ '';
const url = `${baseUrl}/url/${sharedCode}`;

// fetch를 사용하여 GET 요청 보내기
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
return response.json();
})
.then(data => {
console.log('Success:', data);
if (data.data && data.data.redirectUrl) {
window.location.href = data.data.redirectUrl;
} else {
console.error('Redirect URL not found in response');
}
})
.catch(error => {
console.error('Error:', error);
});
});
/*]]>*/
</script>
</body>
</html>

0 comments on commit 6524e93

Please sign in to comment.