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 89f7850..0a7986c 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt @@ -24,6 +24,8 @@ import org.springframework.web.multipart.MultipartFile import org.springframework.web.reactive.function.client.WebClient import org.springframework.web.servlet.ModelAndView import java.io.* +import java.net.URLDecoder +import java.text.SimpleDateFormat import java.util.* @@ -51,6 +53,7 @@ class BlogController() { vm.modelMap.put(EncTypeKey, EncType11) vm.modelMap.put(ApiKeyWordKey,"WRITE") vm.modelMap.put("title","회원이 들어는 구나~!!") + vm.modelMap.put("defaultTitle","무제(無題) (Untitled, ${SimpleDateFormat("yyyy-MM-dd HH:mm").format(Date())})") } else { vm.modelMap.put(WRITE_PERMISSION_KEY,"NO") } @@ -70,7 +73,6 @@ class BlogController() { logService.log(jsonString) var lResultCode = 0 var lResultMsg = "Suscces" - var u : UserDetails? = null val decodedBytes: ByteArray = Base64.getDecoder().decode(jsonString) String(decodedBytes).let { Gson().fromJson(it, RequestModel::class.java)?.let { model -> @@ -87,6 +89,13 @@ class BlogController() { for (idx in 0..max) { if (idx % 2 == 0) { if (nb.size > 0) { fullData.add(nb.removeLast()) } } else { if (na.size > 0) { fullData.add(na.removeLast()) } } } logService.log(fullData.joinToString("")) val target = Gson().fromJson(fullData.joinToString(""), Post::class.java) ?: Post() + if (target.writeTime < 1L) { + target.writeTime = System.currentTimeMillis() + } else { + target.originId = target.id + target.id = null + target.modifyTime = System.currentTimeMillis() + } var user = postManageg.save(target) if (user != null) { lResultMsg = "save post" @@ -124,6 +133,25 @@ class BlogController() { return vm } + @GetMapping("modify") + fun modify() : ModelAndView{ + logService.log("incoming modify") + val vm = ModelAndView("content/blog/modify") + postManageg.find20()?.apply { + forEach { it.title = URLDecoder.decode(it.title)} + vm.modelMap.put("posts",this) + } + return vm + } + + @GetMapping("editor/{postId}") + fun editor(@PathVariable postId : String) : ModelAndView{ + val vm = ModelAndView("content/blog/editor") + + return vm + } + + @GetMapping("recent") fun recent() : ModelAndView{ val vm = ModelAndView("content/blog/viewer") 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 cfac475..6eeae73 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt @@ -29,14 +29,22 @@ class Post { @BsonRepresentation(BsonType.OBJECT_ID) var id: String? = null + var originId: String? = null + var title : String? = null var content : String? = null var category : String? = null var tags : String? = null + var writer : String? = null var writeTime : Long = 0 - var modifyTime : Long = 0 var posting : Boolean = false + var firstPostLat : Double = 0.0 + var firstPostLon : Double = 0.0 + + var modifyTime : Long = 0 + var modifyLat : Double = 0.0 + var modifyLon : Double = 0.0 } diff --git a/src/main/resources/static/css/blog.css b/src/main/resources/static/css/blog.css index 326e028..38e6825 100644 --- a/src/main/resources/static/css/blog.css +++ b/src/main/resources/static/css/blog.css @@ -11,13 +11,115 @@ height: var(--ButtonHeight); } .layer > * { + /*height: fit-content;*/ +} +/*input {*/ +/* width: 100%;*/ +/*}*/ +.write_controllbox { + margin: 0; + padding: 0; + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -moz-flex; + display: -webkit-flex; + display: flex; + justify-content: space-between; + list-style: none; +} +.write_option { + display: inline-block; + text-align: center; + line-height: 30px; + width: 100%; + padding: 0; + margin: 2px; + align-content: center; + top: 0; + bottom: 0; + color: white; + background: #40404564; + position: relative; + outline-width: thin; + outline-color: #ec914b8f; + border-color: #ec914b8f; + border-style: groove; + border-width: 1px; height: var(--ButtonHeight); } -input { +#title_field { +font-size: 20px; +} + +.pop_layer .pop_container { + padding: 20px 25px; +} + +.pop_layer p.ctxt { + color: #666; + line-height: 25px; +} + +.pop_layer .btn_r { width: 100%; + margin: 10px 0 20px; + padding-top: 10px; + border-top: 1px solid #DDD; + text-align: right; } -select , #hashtag{ - margin-left: 1%; - width: fit-content; - margin-right: 1%; + +.pop_layer { + display: none; + position: absolute; + top: 50%; + left: 50%; + width: 410px; + height: auto; + background-color: #fff; + border: 5px solid #3571B5; + z-index: 10; } + +.dim_layer { + display: none; + position: fixed; + _position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 100; +} + +.dim_layer .dimBg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #000; + opacity: .5; + filter: alpha(opacity=50); +} + +.dim_layer .pop_layer { + display: block; +} + +a.btn_layerClose { + display: inline-block; + height: 25px; + padding: 0 14px 0; + border: 1px solid #304a8a; + background-color: #3f5a9d; + font-size: 13px; + color: #fff; + line-height: 25px; +} + +a.btn_layerClose:hover { + border: 1px solid #091940; + background-color: #1f326a; + color: #fff; +} \ No newline at end of file diff --git a/src/main/resources/static/css/common.css b/src/main/resources/static/css/common.css index 11f0306..a6d2bb4 100644 --- a/src/main/resources/static/css/common.css +++ b/src/main/resources/static/css/common.css @@ -39,19 +39,6 @@ body > *{ /* border-radius: 10px;*/ /*}*/ -input, select ,button { - align-content: center; - top: 0; - bottom: 0; - color: white; - background: #40404564; - position: relative; - outline-width: thin; - outline-color: #ec914b8f; - border-color: #ec914b8f; - border-style: groove; - border-width: 1px; -} header { top: 0; diff --git a/src/main/resources/static/js/blog.js b/src/main/resources/static/js/blog.js index 6721462..9af9804 100644 --- a/src/main/resources/static/js/blog.js +++ b/src/main/resources/static/js/blog.js @@ -1,18 +1,44 @@ +var currentLat = 0.0 +var currentLon = 0.0 + +let baseData = { + 'title': "", + 'content': "", + 'firstPostLat': "", + 'firstPostLon': "", + 'category' : "none", + 'hashTags' : "#none", +} function onclickWrite(type, keyword, html) { let title_field = document.getElementById('title_field') var hasValues = true if (hasValues) { - let data = { - 'title': title_field.value, - 'content': encodeURIComponent(html), - } - let uploadUrl = location.protocol + "//" + location.hostname + "/blog/post.ajax"; - if(confirm(JSON.stringify(data) + "\n해당 내용으로\n유저 등록 하실??")) { - post(uploadUrl,type,JSON.stringify(data),keyword, function (resultData) { - alert(resultData) - }) - } else { - } + baseData.title = encodeURIComponent(title_field.value) + baseData.content = encodeURIComponent(html) + baseData.firstPostLat = encodeURIComponent(currentLat) + baseData.firstPostLon = encodeURIComponent(currentLon) } + let uploadUrl = getMainPath() + "/blog/post.ajax"; + if(confirm(JSON.stringify(baseData) + "\n해당 내용으로\n유저 등록 하실??")) { + post(uploadUrl,type,JSON.stringify(baseData),keyword, function (resultData) { + alert(resultData) + }) + } else { + + } +} +function getLocation() { + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(showPosition); + } else { + x.innerHTML = "Geolocation is not supported by this browser."; + } +} +function showPosition(position) { + currentLat = position.coords.latitude + currentLon = position.coords.longitude + baseData.firstPostLat = encodeURIComponent(currentLat) + baseData.firstPostLon = encodeURIComponent(currentLon) + document.getElementById('location_field').value = "Lat: " + position.coords.latitude + ", Lon: " + position.coords.longitude; } \ 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 3d1bf0a..e23b1be 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -65,3 +65,66 @@ function post(target,type, data, key,callBackResult) { 'type':type, }))); } + +function mainPath() { + console.log(`location.port >> ${location.port}`) + if ('443' === location.port) { + location = location.protocol + "//" + location.hostname + ":" + location.port + } else { + location = location.protocol + "//" + location.hostname + } +} + +function getMainPath() { + console.log(`location.port >> ${location.port}`) + if ('443' === location.port) { + return location.protocol + "//" + location.hostname + ":" + location.port + } else { + return location.protocol + "//" + location.hostname + } +} + +function openPopup(a) { + + var $href = $(a).attr('to'); + document.querySelectorAll('[id*=popLayer]').forEach(function (v,k,p) { + $(v).hide(); + }); + layer_popup($href); +} + +function layer_popup(el){ + var $el = $(el); //레이어의 id를 $el 변수에 저장 + + var isDim = true ;//$(document).hasClass('dimBg'); //dimmed 레이어를 감지하기 위한 boolean 변수 + isDim ? $('.dim_layer').fadeIn() : $el.fadeIn(); + $el.show() + var $elWidth = ~~($el.outerWidth()), + $elHeight = ~~($el.outerHeight()), + docWidth = $(document).width(), + docHeight = $(document).height(); + + // 화면의 중앙에 레이어를 띄운다. + if ($elHeight < docHeight || $elWidth < docWidth) { + $el.css({ + marginTop: -$elHeight /2, + marginLeft: -$elWidth/2 + }) + } else { + $el.css({top: 0, left: 0}); + } + + $el.find('a.btn_layerClose').click(function(){ + isDim ? $('.dim_layer').fadeOut() : $el.fadeOut(); // 닫기 버튼을 클릭하면 레이어가 닫힌다. + return false; + }); + + $('.dimBg').click(function(){ + $('.dim_layer').fadeOut(); + return false; + }); +} + +function urldecode(t){ + return decodeURI(t) +} \ 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 new file mode 100644 index 0000000..3e966a2 --- /dev/null +++ b/src/main/resources/templates/content/blog/editor.html @@ -0,0 +1,152 @@ + + + + + + + + + + + + +
+ +

권한이 없는 뎁쇼?!

+
+ +
+ +
+
+
+ +
+
+ +
+

+
+
+
+ +
+
+
+ +

Thank you.
+ Your registration was submitted successfully.
+ Selected invitees will be notified by e-mail on JANUARY 24th.

+ Hope to see you soon! +

+
+ Close +
+ +
+
+
+
+
+
+ +

+ test 002 +

+
+ Close +
+ +
+
+
+
+ + diff --git a/src/main/resources/templates/content/blog/modify.html b/src/main/resources/templates/content/blog/modify.html new file mode 100644 index 0000000..74400ff --- /dev/null +++ b/src/main/resources/templates/content/blog/modify.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + +
+
+ diff --git a/src/main/resources/templates/content/blog/write.html b/src/main/resources/templates/content/blog/write.html index 31ec449..42835de 100644 --- a/src/main/resources/templates/content/blog/write.html +++ b/src/main/resources/templates/content/blog/write.html @@ -5,7 +5,6 @@ layout:decorate="~{layout/default_layout}" > - @@ -17,6 +16,14 @@ let onChange = () => {console.log(editor.getMarkdown())} document.addEventListener("DOMContentLoaded", onLoaded); function onLoaded() { + var currentTitle = [[${defaultTitle}]] + getLocation() + var titleField = document.getElementById('title_field') + titleField.addEventListener("change", (event) => { + baseData.title = titleField.value + console.log(baseData.title) + }); + titleField.value = currentTitle var style = getComputedStyle(document.body) console.log(style.getPropertyValue('--ContentVerticalMargin')) console.log(window.c) @@ -64,8 +71,8 @@ addImageBlobHook: (blob, callback) => { const formData = new FormData(); formData.append('file', blob); - let uploadUrl = location.protocol + "//" + location.hostname + "/blog/post/imageUpload"; - let imageUrl = location.protocol + "//" + location.hostname + '/blog/post/images/'; + let uploadUrl = getMainPath() + "/blog/post/imageUpload"; + let imageUrl = getMainPath() + '/blog/post/images/'; $.ajax({ type: 'POST', enctype: 'multipart/form-data', @@ -102,15 +109,50 @@
- +
-
- - - +
+ +
+
+
+

+ +
+
+
+ +

Thank you.
+ Your registration was submitted successfully.
+ Selected invitees will be notified by e-mail on JANUARY 24th.

+ Hope to see you soon! +

+
+ Close +
+ +
+
+
+
+
+
+ +

+ test 002 +

+
+ Close +
+ +
+
+
+
+ diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 7c21dea..bd5c820 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -4,7 +4,7 @@
- +

HOME

HOME

diff --git a/src/main/resources/templates/fragments/includes.html b/src/main/resources/templates/fragments/includes.html index a635d42..15615db 100644 --- a/src/main/resources/templates/fragments/includes.html +++ b/src/main/resources/templates/fragments/includes.html @@ -6,8 +6,9 @@ + - + \ No newline at end of file diff --git a/src/main/resources/templates/layout/default_layout.html b/src/main/resources/templates/layout/default_layout.html index c82364a..cc9d8fc 100644 --- a/src/main/resources/templates/layout/default_layout.html +++ b/src/main/resources/templates/layout/default_layout.html @@ -18,6 +18,10 @@ +
+
+ +