From 498a3cd04677f2d2e290b745ad57207688c8ef0c Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 13:17:14 +0900 Subject: [PATCH 01/13] =?UTF-8?q?refactor:=20=EC=95=84=ED=8B=B0=ED=81=B4?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D=EC=8B=9C=20=EC=97=AC=EB=9F=AC=20=EA=B0=9C?= =?UTF-8?q?=EC=9D=98=20=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=ED=95=A8=EA=BB=98=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../few/api/repo/dao/problem/ProblemDao.kt | 21 ++++--- .../admin/document/dto/AddArticleUseCaseIn.kt | 2 +- .../document/usecase/AddArticleUseCase.kt | 34 +++++----- .../com/few/api/web/config/WebConfig.kt | 2 +- .../web/controller/admin/AdminController.kt | 24 +++---- .../admin/request/AddArticleRequest.kt | 2 +- .../controller/admin/AdminControllerTest.kt | 62 +++++++++++++------ 7 files changed, 90 insertions(+), 57 deletions(-) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/problem/ProblemDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/problem/ProblemDao.kt index 980cf3da6..326efda44 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/problem/ProblemDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/problem/ProblemDao.kt @@ -56,14 +56,17 @@ class ProblemDao( .let { ProblemIdsRecord(it) } } - fun insertProblems(command: InsertProblemsCommand) { - dslContext.insertInto(Problem.PROBLEM) - .set(Problem.PROBLEM.ARTICLE_ID, command.articleId) - .set(Problem.PROBLEM.CREATOR_ID, command.createrId) - .set(Problem.PROBLEM.TITLE, command.title) - .set(Problem.PROBLEM.CONTENTS, JSON.valueOf(contentsJsonMapper.toJson(command.contents))) - .set(Problem.PROBLEM.ANSWER, command.answer) - .set(Problem.PROBLEM.EXPLANATION, command.explanation) - .execute() + fun insertProblems(command: List) { + dslContext.batch( + command.map { + dslContext.insertInto(Problem.PROBLEM) + .set(Problem.PROBLEM.ARTICLE_ID, it.articleId) + .set(Problem.PROBLEM.CREATOR_ID, it.createrId) + .set(Problem.PROBLEM.TITLE, it.title) + .set(Problem.PROBLEM.CONTENTS, JSON.valueOf(contentsJsonMapper.toJson(it.contents))) + .set(Problem.PROBLEM.ANSWER, it.answer) + .set(Problem.PROBLEM.EXPLANATION, it.explanation) + } + ).execute() } } \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt index cb1163af5..c612eb591 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt @@ -10,7 +10,7 @@ data class AddArticleUseCaseIn( val category: String, /** Article IFO */ val contentSource: String, - val problemData: ProblemDetail + val problemData: List ) diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt index 2517e0a61..9943797a6 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt @@ -37,22 +37,24 @@ class AddArticleUseCase( ).let { articleDao.insertFullArticleRecord(it) } /** insert problems */ - InsertProblemsCommand( - articleId = articleMstId, - createrId = 0L, // todo fix - title = useCaseIn.title, - contents = Contents( - useCaseIn.problemData.contents.map { - Content( - it.number, - it.content - ) - } - ), - answer = useCaseIn.problemData.answer, - explanation = useCaseIn.problemData.explanation - ).let { - problemDao.insertProblems(it) + useCaseIn.problemData.stream().map { problemDatum -> + InsertProblemsCommand( + articleId = articleMstId, + createrId = 0L, // todo fix + title = problemDatum.title, + contents = Contents( + problemDatum.contents.map { detail -> + Content( + detail.number, + detail.content + ) + } + ), + answer = problemDatum.answer, + explanation = problemDatum.explanation + ) + }.toList().let { commands -> + problemDao.insertProblems(commands) } return AddArticleUseCaseOut(articleMstId) diff --git a/api/src/main/kotlin/com/few/api/web/config/WebConfig.kt b/api/src/main/kotlin/com/few/api/web/config/WebConfig.kt index cb308f31c..b084fb1ce 100644 --- a/api/src/main/kotlin/com/few/api/web/config/WebConfig.kt +++ b/api/src/main/kotlin/com/few/api/web/config/WebConfig.kt @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration -@EnableWebMvc +@EnableWebMvc // todo refactor class WebConfig : WebMvcConfigurer { override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") diff --git a/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt b/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt index 316270786..f5c71e304 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt @@ -58,17 +58,19 @@ class AdminController( title = request.title, category = request.category, contentSource = request.contentSource, - problemData = ProblemDetail( - title = request.problemData.title, - contents = request.problemData.contents.map { - ProblemContentDetail( - number = it.number, - content = it.content - ) - }, - answer = request.problemData.answer, - explanation = request.problemData.explanation - ) + problemData = request.problemData.map { datum -> + ProblemDetail( + title = datum.title, + contents = datum.contents.map { detail -> + ProblemContentDetail( + number = detail.number, + content = detail.content + ) + }, + answer = datum.answer, + explanation = datum.explanation + ) + }.toList() ).let { useCaseIn -> addArticleUseCase.execute(useCaseIn) } diff --git a/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt b/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt index 483fc12fb..37fe8acf3 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt @@ -16,7 +16,7 @@ data class AddArticleRequest( /** Article IFO */ @field:NotBlank(message = "{content.source.notblank}") val contentSource: String, - val problemData: ProblemDto + val problemData: List ) data class ProblemDto( diff --git a/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt b/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt index c4fbf3868..6337f02b3 100644 --- a/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt +++ b/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt @@ -138,16 +138,29 @@ class AdminControllerTest : ControllerTestSpec() { "title", CategoryType.fromCode(0)!!.name, "contentSource", - ProblemDto( - "title", - listOf( - ProblemContentDto(1L, "content1"), - ProblemContentDto(2L, "content2"), - ProblemContentDto(3L, "content3"), - ProblemContentDto(4L, "content4") + listOf( + ProblemDto( + "title1", + listOf( + ProblemContentDto(1L, "content1"), + ProblemContentDto(2L, "content2"), + ProblemContentDto(3L, "content3"), + ProblemContentDto(4L, "content4") + ), + "1", + "explanation" ), - "1", - "explanation" + ProblemDto( + "title2", + listOf( + ProblemContentDto(1L, "content1"), + ProblemContentDto(2L, "content2"), + ProblemContentDto(3L, "content3"), + ProblemContentDto(4L, "content4") + ), + "2", + "explanation" + ) ) ) val body = objectMapper.writeValueAsString(request) @@ -160,16 +173,29 @@ class AdminControllerTest : ControllerTestSpec() { "title", CategoryType.fromCode(0)!!.name, "contentSource", - ProblemDetail( - "title", - listOf( - ProblemContentDetail(1L, "content1"), - ProblemContentDetail(2L, "content2"), - ProblemContentDetail(3L, "content3"), - ProblemContentDetail(4L, "content4") + listOf( + ProblemDetail( + "title1", + listOf( + ProblemContentDetail(1L, "content1"), + ProblemContentDetail(2L, "content2"), + ProblemContentDetail(3L, "content3"), + ProblemContentDetail(4L, "content4") + ), + "1", + "explanation" ), - "1", - "explanation" + ProblemDetail( + "title2", + listOf( + ProblemContentDetail(1L, "content1"), + ProblemContentDetail(2L, "content2"), + ProblemContentDetail(3L, "content3"), + ProblemContentDetail(4L, "content4") + ), + "2", + "explanation" + ) ) ) ) From 2b2a30bf190f8075e69e5d97ba63c244d597c371 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 15:26:14 +0900 Subject: [PATCH 02/13] =?UTF-8?q?refactor:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=A0=95=EC=B1=85=20=EB=B3=80=EA=B2=BD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/data/common/code/CategoryType.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt b/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt index e9b029b46..62f9bb6fe 100644 --- a/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt +++ b/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt @@ -1,17 +1,11 @@ package com.few.data.common.code enum class CategoryType(val code: Byte, val displayName: String) { - POLITICS(0, "정치"), - ECONOMY(10, "경제"), - SOCIETY(20, "사회"), - CULTURE(30, "문화"), - LIFE(40, "생활"), - IT(50, "IT"), - SCIENCE(60, "과학"), - ENTERTAINMENTS(70, "엔터테인먼트"), - SPORTS(80, "스포츠"), - GLOBAL(90, "국제"), - ETC(100, "기타"); + ECONOMY(0, "경제"), + IT(10, "IT"), + MARKETING(20, "마케팅"), + CULTURE(30, "교양"), + SCIENCE(40, "과학"); companion object { fun fromCode(code: Byte): CategoryType? { From 872e1f363bbf7565dc1dd901aa574676e4a45efc Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 15:27:08 +0900 Subject: [PATCH 03/13] =?UTF-8?q?refactor:=20html=20=ED=83=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=A0=95=EC=B1=85=20=EC=88=98=EC=A0=95=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/document/service/ConvertDocumentService.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index 3eb7f01d8..0564d3b7a 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -2,7 +2,6 @@ package com.few.storage.document.service import org.commonmark.parser.Parser import org.commonmark.renderer.html.HtmlRenderer -import org.jsoup.Jsoup import org.springframework.stereotype.Service @Service @@ -11,14 +10,10 @@ class ConvertDocumentService { companion object { val parser = Parser.builder().build() val htmlRenderer = HtmlRenderer.builder().build() - val HTML_HEADER = - " " } fun mdToHtml(md: String): String { - val html = Jsoup.parse(HTML_HEADER) - val body = htmlRenderer.render(parser.parse(md)) - html.body().append(body) - return html.toString() + val article = htmlRenderer.render(parser.parse(md)) + return article.toString() } } \ No newline at end of file From 5548fd1f2f658cd3f67a83ec637c1d5ad5d93cfb Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 15:28:37 +0900 Subject: [PATCH 04/13] =?UTF-8?q?refactor:=20contentType=EC=9D=84=20?= =?UTF-8?q?=ED=86=B5=ED=95=B4=20md=EC=99=80=20html=20contentSource?= =?UTF-8?q?=EB=A5=BC=20=EC=B2=98=EB=A6=AC=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/document/dto/AddArticleUseCaseIn.kt | 1 + .../document/usecase/AddArticleUseCase.kt | 61 ++++++++++++++++++- .../web/controller/admin/AdminController.kt | 1 + .../admin/request/AddArticleRequest.kt | 2 + .../resources/ValidationMessages.properties | 2 +- .../controller/admin/AdminControllerTest.kt | 6 +- 6 files changed, 68 insertions(+), 5 deletions(-) diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt index c612eb591..466f1946d 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/dto/AddArticleUseCaseIn.kt @@ -9,6 +9,7 @@ data class AddArticleUseCaseIn( val title: String, val category: String, /** Article IFO */ + val contentType: String, val contentSource: String, val problemData: List diff --git a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt index 9943797a6..24fb4b491 100644 --- a/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/admin/document/usecase/AddArticleUseCase.kt @@ -2,8 +2,13 @@ package com.few.api.domain.admin.document.usecase import com.few.api.domain.admin.document.dto.AddArticleUseCaseIn import com.few.api.domain.admin.document.dto.AddArticleUseCaseOut +import com.few.api.domain.admin.document.service.GetUrlService +import com.few.api.domain.admin.document.service.dto.GetUrlQuery +import com.few.api.domain.admin.document.utils.ObjectPathGenerator import com.few.api.repo.dao.article.ArticleDao import com.few.api.repo.dao.article.command.InsertFullArticleRecordCommand +import com.few.api.repo.dao.document.DocumentDao +import com.few.api.repo.dao.document.command.InsertDocumentIfoCommand import com.few.api.repo.dao.member.MemberDao import com.few.api.repo.dao.member.query.SelectMemberByEmailQuery import com.few.api.repo.dao.problem.ProblemDao @@ -11,14 +16,22 @@ import com.few.api.repo.dao.problem.command.InsertProblemsCommand import com.few.api.repo.dao.problem.support.Content import com.few.api.repo.dao.problem.support.Contents import com.few.data.common.code.CategoryType +import com.few.storage.document.service.ConvertDocumentService +import com.few.storage.document.service.PutDocumentService import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional +import java.io.File +import java.util.* @Component class AddArticleUseCase( private val articleDao: ArticleDao, private val memberDao: MemberDao, - private val problemDao: ProblemDao + private val problemDao: ProblemDao, + private val documentDao: DocumentDao, + private val convertDocumentService: ConvertDocumentService, + private val putDocumentService: PutDocumentService, + private val getUrlService: GetUrlService ) { @Transactional fun execute(useCaseIn: AddArticleUseCaseIn): AddArticleUseCaseOut { @@ -27,13 +40,57 @@ class AddArticleUseCase( memberDao.selectMemberByEmail(it) } ?: throw RuntimeException("writer not found") + /** + * - content type: "md" + * put origin document to object storage + * and convert to html source + * - content type: "html" + * save html source + */ + val htmlSource = when { + useCaseIn.contentType.lowercase(Locale.getDefault()) == "md" -> { + val mdSource = useCaseIn.contentSource + val htmlSource = convertDocumentService.mdToHtml(useCaseIn.contentSource) + + val document = runCatching { + File.createTempFile("temp", ".md") + }.onSuccess { + it.writeText(mdSource) + }.getOrThrow() + val documentName = ObjectPathGenerator.documentPath("md") + + putDocumentService.execute(documentName, document)?.let { res -> + val source = res.`object` + GetUrlQuery(source).let { query -> + getUrlService.execute(query) + }.let { url -> + InsertDocumentIfoCommand( + path = documentName, + url = url + ).let { command -> + documentDao.insertDocumentIfo(command) + } + url + } + } ?: throw IllegalStateException("Failed to put document") + + htmlSource + } + useCaseIn.contentType.lowercase(Locale.getDefault()) == "html" -> { + useCaseIn.contentSource + } + else -> { + throw IllegalArgumentException("content type is not supported") + } + } + /** insert article */ val articleMstId = InsertFullArticleRecordCommand( writerId = writerId.memberId, mainImageURL = useCaseIn.articleImageUrl, title = useCaseIn.title, category = CategoryType.convertToCode(useCaseIn.category), - content = useCaseIn.contentSource + content = htmlSource ).let { articleDao.insertFullArticleRecord(it) } /** insert problems */ diff --git a/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt b/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt index f5c71e304..d9c53cf89 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/admin/AdminController.kt @@ -57,6 +57,7 @@ class AdminController( articleImageUrl = request.articleImageUrl, title = request.title, category = request.category, + contentType = request.contentType, contentSource = request.contentSource, problemData = request.problemData.map { datum -> ProblemDetail( diff --git a/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt b/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt index 37fe8acf3..eada423dd 100644 --- a/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt +++ b/api/src/main/kotlin/com/few/api/web/controller/admin/request/AddArticleRequest.kt @@ -14,6 +14,8 @@ data class AddArticleRequest( @field:NotBlank(message = "{category.notblank}") val category: String, /** Article IFO */ + @NotBlank(message = "{content.type.notblank}") + val contentType: String, @field:NotBlank(message = "{content.source.notblank}") val contentSource: String, val problemData: List diff --git a/api/src/main/resources/ValidationMessages.properties b/api/src/main/resources/ValidationMessages.properties index f15dea708..f7353f561 100644 --- a/api/src/main/resources/ValidationMessages.properties +++ b/api/src/main/resources/ValidationMessages.properties @@ -5,6 +5,7 @@ image.url.notblank=Image URL must be blank title.notblank=Title must not be blank category.notblank=Category must not be blank content.source.notblank=Content must not be blank +content.type.notblank=Content Type must not be blank problem.title.notblank=Problem Title must not be blank problem.content.notblank=Problem Content must not be blank problem.answer.notblank=Problem Answer must not be blank @@ -14,4 +15,3 @@ workbook.description.notblank=Workbook Description must not be blank min.day=The Day field must be greater than or equal to 1 min.id=The ID field must be greater than or equal to 1 min.problem.number=The Problem Number field must be greater than or equal to 1 -max.day=The Day field must be less than or equal to 7 diff --git a/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt b/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt index 6337f02b3..b563f37f6 100644 --- a/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt +++ b/api/src/test/kotlin/com/few/api/web/controller/admin/AdminControllerTest.kt @@ -137,7 +137,8 @@ class AdminControllerTest : ControllerTestSpec() { URL("http://localhost:8080"), "title", CategoryType.fromCode(0)!!.name, - "contentSource", + "md", + "content source", listOf( ProblemDto( "title1", @@ -172,7 +173,8 @@ class AdminControllerTest : ControllerTestSpec() { URL("http://localhost:8080"), "title", CategoryType.fromCode(0)!!.name, - "contentSource", + "md", + "content source", listOf( ProblemDetail( "title1", From 91e05cce9310dc3f4902259334bb8ed15eb42af8 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 15:31:46 +0900 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20api-start=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=EC=97=90=20pull=20=EB=8B=A8=EA=B3=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/docker/scripts/api-start | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/docker/scripts/api-start b/resources/docker/scripts/api-start index f7e675d91..d4981c561 100644 --- a/resources/docker/scripts/api-start +++ b/resources/docker/scripts/api-start @@ -1,6 +1,7 @@ #!/bin/sh cd .. +docker-compose -f docker-compose-api.yml pull docker-compose -f docker-compose-api.yml down docker-compose -f docker-compose-api.yml up -d -sleep 10 \ No newline at end of file +sleep 10 From 9940907520e9811245cc0e9a8cb2a3c9cf925f34 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 19:47:28 +0900 Subject: [PATCH 06/13] =?UTF-8?q?refactor:=20html=20article=20=ED=85=8C?= =?UTF-8?q?=EA=B7=B8=20=EC=B6=94=EA=B0=80=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../few/storage/document/service/ConvertDocumentService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index 0564d3b7a..fddf3582a 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -2,6 +2,7 @@ package com.few.storage.document.service import org.commonmark.parser.Parser import org.commonmark.renderer.html.HtmlRenderer +import org.jsoup.Jsoup import org.springframework.stereotype.Service @Service @@ -10,10 +11,13 @@ class ConvertDocumentService { companion object { val parser = Parser.builder().build() val htmlRenderer = HtmlRenderer.builder().build() + val ARTICLE = "
" } fun mdToHtml(md: String): String { + val html = Jsoup.parse(ARTICLE) val article = htmlRenderer.render(parser.parse(md)) - return article.toString() + html.body().append(article) + return html.toString() } } \ No newline at end of file From fa01da58f4fb99ecd4d1cbe0eda5e85ae15431cc Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 3 Jul 2024 22:32:36 +0900 Subject: [PATCH 07/13] =?UTF-8?q?refactor:=20html=20=ED=85=8C=EA=B7=B8=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=A7=80=EC=A0=95=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/service/ConvertDocumentService.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index fddf3582a..5dd8121b4 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -17,7 +17,19 @@ class ConvertDocumentService { fun mdToHtml(md: String): String { val html = Jsoup.parse(ARTICLE) val article = htmlRenderer.render(parser.parse(md)) - html.body().append(article) - return html.toString() + html.getElementsByTag("article").append(article) + html.getElementsByTag("h1").forEach { + it.addClass("sub1-semibold") + } + html.getElementsByTag("h2").forEach { + it.addClass("sub1-semibold") + } + html.getElementsByTag("h3").forEach { + it.addClass("sub1-semibold") + } + html.getElementsByTag("img").forEach { + it.addClass("!max-h-[260px] object-contain") + } + return html.body().html() } } \ No newline at end of file From e7a51792624505358dd5096ae82481575537cafd Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Thu, 4 Jul 2024 00:59:09 +0900 Subject: [PATCH 08/13] =?UTF-8?q?refactor:=20img=20=ED=83=9C=EA=B7=B8=20st?= =?UTF-8?q?yle=20=EC=86=8D=EC=84=B1=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/storage/document/service/ConvertDocumentService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index 5dd8121b4..7d3fead38 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -28,7 +28,7 @@ class ConvertDocumentService { it.addClass("sub1-semibold") } html.getElementsByTag("img").forEach { - it.addClass("!max-h-[260px] object-contain") + it.attr("style", "max-height: 260px; object-fit: contain;") } return html.body().html() } From b8b8aaba1b9ee7868d6df9d4bdf3ca0c33add402 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Fri, 5 Jul 2024 02:04:47 +0900 Subject: [PATCH 09/13] =?UTF-8?q?refactor:=20html=20=ED=85=8C=EA=B7=B8=20?= =?UTF-8?q?=EC=8A=A4=ED=83=80=EC=9D=BC=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/service/ConvertDocumentService.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt index 7d3fead38..ef58012a9 100644 --- a/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt +++ b/storage/src/main/kotlin/com/few/storage/document/service/ConvertDocumentService.kt @@ -19,16 +19,19 @@ class ConvertDocumentService { val article = htmlRenderer.render(parser.parse(md)) html.getElementsByTag("article").append(article) html.getElementsByTag("h1").forEach { - it.addClass("sub1-semibold") + it.attr("style", "font-size: 20px; line-height: 140%; font-weight: 600") } html.getElementsByTag("h2").forEach { - it.addClass("sub1-semibold") + it.attr("style", "font-size: 20px; line-height: 140%; font-weight: 600") } html.getElementsByTag("h3").forEach { - it.addClass("sub1-semibold") + it.attr("style", "font-size: 20px; line-height: 140%; font-weight: 600") } html.getElementsByTag("img").forEach { - it.attr("style", "max-height: 260px; object-fit: contain;") + it.attr("style", "max-height: 280px; object-fit: contain; max-width: 480px; margin-left: auto; margin-right: auto; width: 100%;") + } + html.getElementsByTag("article").forEach { + it.attr("style", "max-width: 480px; font-size: 15px; line-height: 170%; font-weight: 400;") } return html.body().html() } From 7f1a2fb9c80a78960d1e20c6952356b0a9d80f40 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Fri, 5 Jul 2024 02:05:06 +0900 Subject: [PATCH 10/13] =?UTF-8?q?refactor:=20article.html=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/article.html | 358 ++++++++++++------ 1 file changed, 241 insertions(+), 117 deletions(-) diff --git a/email/src/main/resources/templates/article.html b/email/src/main/resources/templates/article.html index 7d8c63623..58c8773e2 100644 --- a/email/src/main/resources/templates/article.html +++ b/email/src/main/resources/templates/article.html @@ -1,126 +1,250 @@ - - + - - - - - + + + FEW + + + + + - -
+ + + + + + + +
+ few_logo +
+

+ 웹으로 읽을래요! +
+
- - -