diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt index 6298272..53bcb5d 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt @@ -125,16 +125,14 @@ class BlogController() { return responce } - @GetMapping("viewer/{blogId}") - fun viewer(@PathVariable blogId : String) : ModelAndView{ + @GetMapping("viewer/{postId}") + fun viewer(@PathVariable postId : String) : ModelAndView{ val vm = ModelAndView("content/blog/viewer") -// when(System.currentTimeMillis() % 5L) { -// 0L -> vm.modelMap.put(EncTypeKey,"T4") -// 1L -> vm.modelMap.put(EncTypeKey,"T3") -// 2L -> vm.modelMap.put(EncTypeKey,"T2") -// else -> vm.modelMap.put(EncTypeKey,"T0") -// } - + postManageg.getPost(postId).block().apply { + this?.title = URLDecoder.decode(this?.title) + this?.content = URLDecoder.decode(this?.content) + vm.modelMap.put("srcPost",this) + } return vm } @@ -163,7 +161,11 @@ class BlogController() { @GetMapping("editor/{postId}") fun editor(@PathVariable postId : String, @RequestParam("token") token : String?) : ModelAndView{ val vm = ModelAndView("content/blog/editor") - vm.modelMap.put("srcPost",postManageg.getPost(postId).block().apply { }) + postManageg.getPost(postId).block().apply { + this?.title = URLDecoder.decode(this?.title) + this?.content = URLDecoder.decode(this?.content) + vm.modelMap.put("srcPost",this) + } if (TEMPTOKEN.equals(token)) { vm.modelMap.put(WRITE_PERMISSION_KEY,"OK") } else { diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt index afc5953..1ef65a8 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt @@ -5,10 +5,12 @@ import jakarta.servlet.http.HttpServletResponse import kr.lunaticbum.back.lun.model.PostManageg import kr.lunaticbum.back.lun.utils.LogService import org.springframework.beans.factory.annotation.Autowired +import org.springframework.data.domain.Pageable import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import org.springframework.web.servlet.ModelAndView +import java.net.URLDecoder import java.net.http.HttpClient.Redirect @RestController @@ -24,11 +26,14 @@ class Home { @GetMapping("/","/home") fun home() : ModelAndView { val vm = ModelAndView("content/home") - vm.modelMap.put("posts", postManageg.find20().apply { + vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { this.forEach { + it.title = URLDecoder.decode(it.title) + it.content = URLDecoder.decode(it.content) logService.log(Gson().toJson(it)) } }) + vm.modelMap.put("path","/blog/viewer/") return vm } @GetMapping("/login") diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt b/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt index 38f5dbc..ebb4ac0 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt @@ -9,6 +9,7 @@ import org.bson.codecs.pojo.annotations.BsonCreator import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation import org.springframework.beans.factory.annotation.Autowired +import org.springframework.data.domain.Pageable import org.springframework.data.mongodb.core.mapping.Document import org.springframework.data.mongodb.repository.Query import org.springframework.data.mongodb.repository.ReactiveMongoRepository @@ -52,6 +53,7 @@ class Post { @Repository interface PostRepository : ReactiveMongoRepository { fun findAllByModifyTime(time : Long? = 0): Flux + fun findAllByPostingTrue(pageable: Pageable): Flux } @@ -67,6 +69,10 @@ class PostManageg { private lateinit var bCryptPasswordEncoder: PasswordEncoder fun getPost(id : String) : Mono = postRepository.findById(id) + fun find20(pageable :Pageable) : List { + return postRepository.findAllByPostingTrue(pageable).takeLast(20).buffer(20).blockLast(Duration.ofSeconds(30)) ?: listOf() + } + fun find20() : List { return postRepository.findAllByModifyTime(0).takeLast(20).buffer(20).blockLast(Duration.ofSeconds(30)) ?: listOf() } diff --git a/src/main/resources/static/css/blog.css b/src/main/resources/static/css/blog.css index 8f17211..51c9bfe 100644 --- a/src/main/resources/static/css/blog.css +++ b/src/main/resources/static/css/blog.css @@ -130,7 +130,7 @@ a.btn_layerClose:hover { display: grid; gap: 10px; /*grid-auto-rows: minmax(200px, auto);*/ - grid-template-columns: repeat(auto-fill, minmax(300px, auto)); + grid-template-columns: repeat(auto-fill, minmax(200px, auto)); width: 100%; } diff --git a/src/main/resources/static/css/common.css b/src/main/resources/static/css/common.css index a6d2bb4..05b495c 100644 --- a/src/main/resources/static/css/common.css +++ b/src/main/resources/static/css/common.css @@ -3,12 +3,13 @@ --TopHeight: 160px; --FooterHeight: 160px; --ContentVerticalMargin: 5px; + --DEFAULT_LAYER_BACK : #2e2e2eBB /*background-image: url("data:image/svg+xml,")*/ } html { margin: 1vh 1vw; - background: #202025ee; + background: var(--DEFAULT_LAYER_BACK); } #where{ table-layout: fixed; @@ -42,15 +43,44 @@ body > *{ header { top: 0; - background: #F0F0F524; + background: var(--DEFAULT_LAYER_BACK); border-top: #ec914b8f; border-radius: 10px 30px; border-width: 1px; - height: 8vh; - min-height: 8vh; - display: flex; + height: 5vh; + min-height: 5vh; + display: flex;; position: relative; } +.user_info { + + padding: 2px; + position: absolute; + display: inline-flex; + flex-direction: column; + right: 0; +} +.login_input { + border-radius: 10px; + border-width: 2px; + border: #F0F0F514; + background: #F0F0F524; + color: white; + text-align: center; + margin: 2px; +} +.login_input::placeholder { + color: #ec914b; +} + +.login_input::-webkit-input-placeholder{ + color: #ec914b; +} + +.login_input:-ms-input-placeholder{ + color: #ec914b; +} + #bottom { float: right; display: inline-block; @@ -102,10 +132,10 @@ footer { display: flex; bottom: 0; border-top: #ec914b8f; - background: #F0F0F524; + background: var(--DEFAULT_LAYER_BACK); border-radius: 30px 10px; border-width: 1px; - height: 8vh; - min-height: 8vh; + height: 5vh; + min-height: 5vh; position: relative; } \ No newline at end of file diff --git a/src/main/resources/static/css/private.css b/src/main/resources/static/css/private.css new file mode 100644 index 0000000..e76b235 --- /dev/null +++ b/src/main/resources/static/css/private.css @@ -0,0 +1,18 @@ +.layer { + height: 100%; + place-content: space-between; + place-items: stretch; + display: grid; + gap: 10px; + grid-auto-rows: minmax(200px, auto); + grid-template-columns: repeat(auto-fill, minmax(200px, auto)); + width: 100%; +} +.where_item { + justify-content: space-between; + flex-wrap: wrap; + flex-direction: row; + width: 100%; + border-radius: 10px; + background: #F0F0F524; +} \ No newline at end of file diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index e23b1be..d5da10c 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -75,6 +75,29 @@ function mainPath() { } } + +function gotoLogin() { + console.log(`location.port >> ${location.port}`) + location.href = getMainPath()+"/login" +} + + +function goToView(path,id) { + location.href = path + id; +} +function onclickLogin(type, keyword) { + let user_id = document.getElementById('user_id') + let user_pw = document.getElementById('user_pw') + let data = { + 'user_id': user_id.value, + 'user_pw': user_pw.value, + } + post(getMainPath()+"/user/login.ajax",type,JSON.stringify(data),keyword, function (resultData) { + alert(resultData) + }) +} + + function getMainPath() { console.log(`location.port >> ${location.port}`) if ('443' === location.port) { diff --git a/src/main/resources/static/js/user.js b/src/main/resources/static/js/user.js index 10c9199..a207545 100644 --- a/src/main/resources/static/js/user.js +++ b/src/main/resources/static/js/user.js @@ -75,16 +75,3 @@ function onclickJoin(type, keyword) { } - - -function onclickLogin(type, keyword) { - let user_id = document.getElementById('user_id') - let user_pw = document.getElementById('user_pw') - let data = { - 'user_id': user_id.value, - 'user_pw': user_pw.value, - } - post("login.ajax",type,JSON.stringify(data),keyword, function (resultData) { - alert(resultData) - }) -} \ No newline at end of file diff --git a/src/main/resources/templates/content/blog/editor.html b/src/main/resources/templates/content/blog/editor.html index 70e3de2..0be5ff1 100644 --- a/src/main/resources/templates/content/blog/editor.html +++ b/src/main/resources/templates/content/blog/editor.html @@ -17,8 +17,8 @@ document.addEventListener("DOMContentLoaded", onLoaded); function onLoaded() { baseData.id = [[${srcPost.id}]]; - baseData.title = [[${srcPost.title}]]; - baseData.content = [[${srcPost.content}]]; + baseData.title = urldecode([[${srcPost.title}]]); + baseData.content = urldecode([[${srcPost.content}]]); baseData.firstPostLat = [[${srcPost.firstPostLat}]]; baseData.firstPostLon = [[${srcPost.firstPostLon}]]; baseData.writeTime = [[${srcPost.writeTime}]]; @@ -44,26 +44,7 @@ theme:'dark', usageStatistics : false, toolbar:null, - initialValue: - "# 제목 " +"\n" + - "평문 사이에 **볼드체** *이탤릭체*"+"\n" + - "~~어디쓰지~~"+"\n" + - "***"+"\n" + - "### 모라모라 " +"\n" + - "> 으흐흠..." +"\n" + - "* 쓸까?" +"\n" + - "1. 첫번째" +"\n" + - "* [x] 체크하자" +"\n" + - "* [ ] 체크하자" +"\n" + - " \|dd\|cc\|ff\|\n" + - " \|\-\-\-\|\-\-\-\|\-\-\-\|\n" + - " \|aa\|s\|s\|" +"\n" + - "[링크다](https://youtube.com)" +"\n" + - "`var test = 'real test'`" +"\n" + - "```\n" + - "let test= = 'real test'\n" + - "```" - , + initialValue:baseData.content, theme:"dark", initialEditType:"wysiwyg", hooks: { diff --git a/src/main/resources/templates/content/blog/modify.html b/src/main/resources/templates/content/blog/modify.html index 4b073de..4a7e42c 100644 --- a/src/main/resources/templates/content/blog/modify.html +++ b/src/main/resources/templates/content/blog/modify.html @@ -43,7 +43,7 @@
- +
diff --git a/src/main/resources/templates/content/blog/viewer.html b/src/main/resources/templates/content/blog/viewer.html index c14d62f..403dfb1 100644 --- a/src/main/resources/templates/content/blog/viewer.html +++ b/src/main/resources/templates/content/blog/viewer.html @@ -7,12 +7,15 @@ - + + + + + + -
+
+ +
+ +
+ +
+ + +
+
+
+
diff --git a/src/main/resources/templates/content/private/where.html b/src/main/resources/templates/content/private/where.html index 6f328ad..7e36ecc 100644 --- a/src/main/resources/templates/content/private/where.html +++ b/src/main/resources/templates/content/private/where.html @@ -4,17 +4,21 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/default_layout}"> - + - - - - - - - - -
+
+
+ +
+ + + + + +
+
+
+
\ No newline at end of file diff --git a/src/main/resources/templates/content/user/login.html b/src/main/resources/templates/content/user/login.html index fccc952..5aee4e2 100644 --- a/src/main/resources/templates/content/user/login.html +++ b/src/main/resources/templates/content/user/login.html @@ -6,11 +6,7 @@ Spring Boot - + > @@ -22,7 +18,7 @@ 비밀번호 - + diff --git a/src/main/resources/templates/fragments/footer.html b/src/main/resources/templates/fragments/footer.html index a48b38b..f2e21d4 100644 --- a/src/main/resources/templates/fragments/footer.html +++ b/src/main/resources/templates/fragments/footer.html @@ -4,8 +4,8 @@ diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index bd5c820..c9f67a5 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -1,12 +1,25 @@ - +
- - - - -

HOME

+
+

HOME

+
+ + + + + + + +
\ No newline at end of file