diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt b/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt index a5ff4d9..8dbe24d 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt @@ -42,10 +42,10 @@ class SecurityConfig( }.authorizeHttpRequests { auth -> auth .requestMatchers( - "/", "/home", + "/", "/home.bs", "/bums/where.bs" , "/user/login.bs", "/user/signup.bs","/user/login.bjx", - "/blog/viewer/**" , + "/blog/viewer/**" , "/blog/posts" , "/blog/rankOfViews.bjx","/blog/recentOfPost.bjx", "/css/**", "/js/**", "/images/**", "/webjars/**", "/assets/**").permitAll() .anyRequest().authenticated() }.formLogin { form -> 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 43a0110..d0e0c8b 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BlogController.kt @@ -32,6 +32,7 @@ import org.springframework.security.core.userdetails.UserDetails import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile import org.springframework.web.reactive.function.client.WebClient +import reactor.core.publisher.Mono import java.io.* import java.net.URLDecoder import java.text.SimpleDateFormat @@ -51,7 +52,7 @@ class BlogController() { private lateinit var locationLogService: LocationLogService @Autowired - private lateinit var postManageg: PostManageg + private lateinit var postManager: PostManager @Autowired lateinit var logService: LogService @@ -99,12 +100,12 @@ class BlogController() { } else { logService.log("target.writeTime >>> ${target.writeTime}") target.modifyTime = System.currentTimeMillis() - postManageg.save(target) + postManager.save(target) target = Gson().fromJson(fullData.joinToString(""), Post::class.java) ?: Post() target.originId = target.id target.id = null } - var postMono = postManageg.save(target) + var postMono = postManager.save(target) if (postMono != null) { lResultMsg = "save post" lResultCode = 0 @@ -128,10 +129,51 @@ class BlogController() { return responce } + + @GetMapping("rankOfViews.bjx") + fun rankOfViews(httpServletRequest: HttpServletRequest): Mono> { + logService.log(httpServletRequest.requestURI) + val resultCode = 0 + val resultMsg = "Success" + + return postManager.getTop10Posts() + .collectList() // Flux -> Mono> + .map { postsList -> + val postsResult = PostsResult().apply { + this.resultCode = resultCode + this.resultMsg = resultMsg + this.posts = postsList // List 할당 가능 + } + ResponseEntity.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(postsResult) + } + } + + @GetMapping("recentOfPost.bjx") + fun recentOfPost(httpServletRequest: HttpServletRequest): Mono> { + logService.log(httpServletRequest.requestURI) + val resultCode = 0 + val resultMsg = "Success" + + return postManager.getRecent10Posts() + .collectList() // Flux -> Mono> + .map { postsList -> + val postsResult = PostsResult().apply { + this.resultCode = resultCode + this.resultMsg = resultMsg + this.posts = postsList // List 할당 가능 + } + ResponseEntity.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(postsResult) + } + } + @GetMapping("viewer/{postId}") fun viewer(@PathVariable postId : String) : ResultMV{ val vm = ResultMV("content/blog/viewer") - postManageg.getPost(postId).block().apply { + postManager.getPost(postId).block().apply { this?.title = URLDecoder.decode(this?.title) this?.content = URLDecoder.decode(this?.content) @@ -142,14 +184,14 @@ class BlogController() { try { var addrs = GeocodingApi.reverseGeocode(GeoApiContext.Builder().apiKey(it).build(), LatLng(this?.firstPostLat!!,this?.firstPostLon!!)).await() this.firstAddress = addrs.first().formattedAddress - postManageg.save(this) + postManager.save(this) } catch (e: Exception) {} } if (this?.modifyAddress?.length ?: 0 < 4){ try { var addrs = GeocodingApi.reverseGeocode(GeoApiContext.Builder().apiKey(it).build(), LatLng(this?.modifyLat!!,this?.modifyLon!!)).await() this.modifyAddress = addrs.first().formattedAddress - postManageg.save(this) + postManager.save(this) } catch (e: Exception) {} } } @@ -168,7 +210,7 @@ class BlogController() { if (principal is UserDetails) { val username = principal.username // 추가 정보 사용 가능 - postManageg.find20()?.apply { + postManager.find20()?.apply { forEach { it.title = URLDecoder.decode(it.title) val content = URLDecoder.decode(it.content) @@ -187,7 +229,7 @@ class BlogController() { @GetMapping("editor/{postId}") fun editor(@PathVariable postId : String) : ResultMV{ val vm = ResultMV("content/blog/editor") - postManageg.getPost(postId).block().apply { + postManager.getPost(postId).block().apply { this?.title = URLDecoder.decode(this?.title) this?.content = URLDecoder.decode(this?.content) vm.modelMap.put("srcPost",this) @@ -200,7 +242,7 @@ class BlogController() { fun posts() : ResultMV{ val vm = ResultMV("content/blog/posts") try { - vm.modelMap.put("Posts", postManageg.find20().apply { + vm.modelMap.put("Posts", postManager.find20().apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BumsPrivate.kt b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BumsPrivate.kt index 7da3ade..25518b5 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BumsPrivate.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/BumsPrivate.kt @@ -35,7 +35,7 @@ class BumsPrivate { val m = ResultMV("content/private/where") locationService.find10().apply { - m.modelMap.put("locations",this.reversed()) + m.modelMap.put("locations",this) } m.setTitle("돼지 여기있다요~!!") return m 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 e0ca3cd..746dbbc 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/Home.kt @@ -2,7 +2,7 @@ package kr.lunaticbum.back.lun.controllers import com.google.gson.Gson import jakarta.servlet.http.HttpServletResponse -import kr.lunaticbum.back.lun.model.PostManageg +import kr.lunaticbum.back.lun.model.PostManager import kr.lunaticbum.back.lun.model.ResultMV import kr.lunaticbum.back.lun.utils.LogService import net.coobird.thumbnailator.Thumbnails @@ -29,13 +29,13 @@ class Home { lateinit var logService: LogService @Autowired - private lateinit var postManageg: PostManageg + private lateinit var postManager: PostManager - @GetMapping("/","/home") + @GetMapping("/","/home.bs") fun home() : ResultMV { val vm = ResultMV("content/home") try { - vm.modelMap.put("Posts", postManageg.find4().apply { + vm.modelMap.put("Posts", postManager.find4().apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) @@ -105,7 +105,7 @@ class Home { @GetMapping("/h2") fun home2() : ResultMV { val vm = ResultMV("content/index_ex") - vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { + vm.modelMap.put("Posts", postManager.find20(Pageable.ofSize(20)).apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) @@ -118,7 +118,7 @@ class Home { @GetMapping("/left-sidebar") fun lside() : ResultMV { val vm = ResultMV("content/left-sidebar") - vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { + vm.modelMap.put("Posts", postManager.find20(Pageable.ofSize(20)).apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) @@ -130,7 +130,7 @@ class Home { @GetMapping("/no-sidebar") fun nside() : ResultMV { val vm = ResultMV("content/no-sidebar") - vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { + vm.modelMap.put("Posts", postManager.find20(Pageable.ofSize(20)).apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) @@ -143,7 +143,7 @@ class Home { @GetMapping("/right-sidebar") fun rside() : ResultMV { val vm = ResultMV("content/right-sidebar") - vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { + vm.modelMap.put("Posts", postManager.find20(Pageable.ofSize(20)).apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) @@ -156,7 +156,7 @@ class Home { @GetMapping("/two-sidebar") fun bside() : ResultMV { val vm = ResultMV("content/two-sidebar") - vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply { + vm.modelMap.put("Posts", postManager.find20(Pageable.ofSize(20)).apply { this.forEach { it.title = URLDecoder.decode(it.title) it.content = URLDecoder.decode(it.content) diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/model/BumsPrivate.kt b/src/main/kotlin/kr/lunaticbum/back/lun/model/BumsPrivate.kt index 33d4c0f..dea9531 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/model/BumsPrivate.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/model/BumsPrivate.kt @@ -10,14 +10,20 @@ import org.bson.codecs.pojo.annotations.BsonIgnore import org.jsoup.Jsoup import org.springframework.beans.factory.annotation.Autowired import org.springframework.data.annotation.Id +import org.springframework.data.domain.Sort import org.springframework.data.mongodb.core.mapping.Document +import org.springframework.data.mongodb.repository.Query import org.springframework.data.mongodb.repository.ReactiveMongoRepository +import org.springframework.data.repository.query.Param import org.springframework.stereotype.Repository import org.springframework.stereotype.Service import org.springframework.web.reactive.function.client.WebClient +import reactor.core.publisher.Flux import reactor.core.publisher.Mono import java.text.SimpleDateFormat import java.time.Duration +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter import java.util.* class BumsPrivate { @@ -48,6 +54,8 @@ class LocationLog { var time : Long = 0L var userId : String? = null + var bettween : String? = null + override fun toString(): String { val buffer = StringBuffer() buffer.append(mFeatureName).append("|").append("\n") @@ -72,7 +80,13 @@ class LocationLog { @Repository interface LocationLogRepository : ReactiveMongoRepository { + @Query("{ 'time' : { \$gte: ?0 } }") + fun findRecent(since: Long, sort: Sort): Flux +// @Query("SELECT l FROM LocationLog l WHERE l.timeString >= :since ORDER BY l.timeString DESC") +// fun findRecent(@Param("since") since: String): Flux + + fun findTop30ByOrderByTimeDesc(): Flux fun findAllBy() : Mono fun findFirstByOrderByTimeDesc() : Mono fun findFirstByUserIdOrderByTimeDesc(userId: String) : Mono @@ -91,8 +105,16 @@ class LocationLogService : LocationService { private lateinit var logRepository: LocationLogRepository fun find10() : List { - return logRepository.findAll().takeLast(10).buffer(10).blockLast(Duration.ofSeconds(30)) ?: listOf() + val sinceMills = System.currentTimeMillis() - ((24 * 60 * 60 * 1000) * 7) + println("sinceMills >> $sinceMills") + val sort = Sort.by(Sort.Direction.DESC, "time") // 오름차순 정렬 +// val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") +// val since = LocalDateTime.now().minusHours(24).format(formatter) +// println("since >> $since") + val flux = filterByDistanceReactive(logRepository.findRecent(sinceMills,sort), 10.0) + return flux.collectList().block(Duration.ofSeconds(30)) ?: listOf() } + fun getLocationLog() : LocationLog? { return logRepository.findFirstByOrderByTimeDesc().block() } @@ -100,7 +122,33 @@ class LocationLogService : LocationService { fun getLocationLogBy(userId : String) : LocationLog? { return logRepository.findFirstByOrderByTimeDesc().block() } + fun filterByDistanceReactive(flux: Flux, minDistanceMeter: Double): Flux { + return flux + .buffer(2, 1) + .filter { pair -> + if (pair.size < 2) true + else haversine(pair[0].mLatitude, pair[0].mLongitude, pair[1].mLatitude, pair[1].mLongitude) >= minDistanceMeter + } + .map { pair -> + val distance = if (pair.size < 2) 0.0 else haversine(pair[0].mLatitude, pair[0].mLongitude, pair[1].mLatitude, pair[1].mLongitude) + val base = pair[0] + println("base >>> ${base.time} ${base.timeString}") + base.bettween = String.format("%.2f m", distance) // 소수점 두자리까지 거리 표시 + base + } + } + // Haversine 거리계산 함수 (단위:m) + fun haversine(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double { + val R = 6371000.0 // 지구 반지름(m) + val dLat = Math.toRadians(lat2 - lat1) + val dLon = Math.toRadians(lon2 - lon1) + val a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * + Math.sin(dLon / 2) * Math.sin(dLon / 2) + val c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) + return R * c + } fun save(log: LocationLog) { println("saved msg before ${log}") 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 5f6ac6c..59fc720 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/model/Post.kt @@ -9,13 +9,18 @@ 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.ReactiveMongoTemplate import org.springframework.data.mongodb.core.mapping.Document +import org.springframework.data.mongodb.core.query.Criteria +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.Update import org.springframework.data.mongodb.repository.ReactiveMongoRepository import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.stereotype.Repository import org.springframework.stereotype.Service import reactor.core.publisher.Flux import reactor.core.publisher.Mono +import java.net.URLDecoder import java.time.Duration @Data @@ -49,31 +54,90 @@ class Post { var modifyTime : Long = 0 var modifyLat : Double = 0.0 var modifyLon : Double = 0.0 + + var readCount : Long = 0 + var voteCount : Long = 0 + var unlikeCount : Long = 0 } +@Document(collection = "Comment") +class Comment { + @BsonId + var id: String? = null + var postId: String? = null // 댓글이 달린 포스트의 id + var parentId: String? = null // 대댓글이면 상위 댓글의 id, 최상위 댓글이면 null + var writer: String? = null + var content: String? = null + var writeTime: Long? = null + var mentions: List? = null // 언급된 유저 아이디(선택) +} +@Repository +interface CommentRepository : ReactiveMongoRepository { + fun findByPostIdAndParentIdIsNullOrderByWriteTimeAsc(postId: String): Flux // 최상위 댓글 + fun findByParentIdOrderByWriteTimeAsc(parentId: String): Flux +} + +@Service +class CommentService(private val commentRepository: CommentRepository) { + + fun addComment(comment: Comment): Mono { + // 예시: 부모 댓글 존재 여부/권한 검증 등 비즈니스 로직 처리 + return commentRepository.save(comment) + } + + fun getCommentsForPost(postId: String): Flux { + return commentRepository.findByPostIdAndParentIdIsNullOrderByWriteTimeAsc(postId) + } + + // 기타: 대댓글 불러오기, 신고/삭제, 멘션 알림 등 확장 가능 +} @Repository interface PostRepository : ReactiveMongoRepository { - fun findAllByModifyTime(time : Long? = 0): Flux + fun findAllByModifyTime(time : Long? = 0): Flux fun findAllByPostingTrue(pageable: Pageable): Flux + fun findTop10ByOrderByReadCountDesc(): Flux + fun findTop10ByOrderByModifyTimeDesc(): Flux } @Service -class PostManageg { +class PostManager( + private val postRepository: PostRepository, + private val reactiveMongoTemplate: ReactiveMongoTemplate +) { @Autowired private lateinit var logService: LogService - @Autowired - private lateinit var postRepository: PostRepository - @Autowired private lateinit var bCryptPasswordEncoder: PasswordEncoder - fun getPost(id : String) : Mono = postRepository.findById(id) + // fun getPost(id : String) : Mono = postRepository.findById(id) + fun getPost(id: String): Mono { + val query = Query.query(Criteria.where("id").`is`(id)) + val update = Update().inc("readCount", 1) + + return reactiveMongoTemplate.findAndModify(query, update, Post::class.java) + .switchIfEmpty(Mono.error(NoSuchElementException("Post not found with id $id"))) + } fun find20(pageable :Pageable) : List { return postRepository.findAllByPostingTrue(pageable).takeLast(20).buffer(20).blockLast(Duration.ofSeconds(30)) ?: listOf() } + fun getTop10Posts(): Flux { + return postRepository.findTop10ByOrderByReadCountDesc().map { p -> + p.title = URLDecoder.decode(p.title) + p + } + } + + fun getRecent10Posts(): Flux { + return postRepository.findTop10ByOrderByModifyTimeDesc().map { p -> + p.title = URLDecoder.decode(p.title) + p + } + + } + fun find4() : List { diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/model/ResponceResult.kt b/src/main/kotlin/kr/lunaticbum/back/lun/model/ResponceResult.kt index bb0980e..b9a88cf 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/model/ResponceResult.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/model/ResponceResult.kt @@ -8,6 +8,11 @@ open class ResponceResult : BaseResult() { } +@Getter +open class PostsResult : BaseResult() { + var posts: List? = null +} + @Getter open class LoginResult : ResponceResult() { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index de7f7ca..1e50057 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -91,3 +91,8 @@ resource.location=. server.forward-headers-strategy=framework #>>>>>>> ab915d0a416c69708f1df1ad76d7a14c779c1f59 +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +logging.level.org.hibernate.SQL=DEBUG +logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE + diff --git a/src/main/resources/static/assets/js/main.js b/src/main/resources/static/assets/js/main.js index cc411dd..3ddffb9 100644 --- a/src/main/resources/static/assets/js/main.js +++ b/src/main/resources/static/assets/js/main.js @@ -39,7 +39,7 @@ $( '
' + '' + - '' + $('#logo').html() + '' + + '' + $('#logo').html() + '' + '
' ) .appendTo($body); diff --git a/src/main/resources/static/css/common.css b/src/main/resources/static/css/common.css index a17557d..035635a 100644 --- a/src/main/resources/static/css/common.css +++ b/src/main/resources/static/css/common.css @@ -13,13 +13,13 @@ html { background: black; } -#where{ - table-layout: fixed; -} +/*#where{*/ +/* table-layout: fixed;*/ +/*}*/ -.where_item { - display: table-cell; -} +/*.where_item {*/ +/* display: table-cell;*/ +/*}*/ body { user-select: none; -webkit-user-select: none; diff --git a/src/main/resources/static/css/private.css b/src/main/resources/static/css/private.css index e76b235..0809fd1 100644 --- a/src/main/resources/static/css/private.css +++ b/src/main/resources/static/css/private.css @@ -1,18 +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 +/*.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 926e9ec..090f081 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -4,6 +4,68 @@ document.addEventListener('DOMContentLoaded', function() { e.preventDefault(); // 기본 폼 제출 동작 방지 submitLoginForm(); }); + if (document.querySelector(".rank_of_view")) { + fetch('blog/rankOfViews.bjx') + .then(response => response.json()) + .then(data => { + const ul = document.querySelector('.rank_of_view'); + ul.innerHTML = ''; // 기존 리스트 지움 + ul.style.listStyle = 'none'; // 불릿 제거 + ul.style.paddingLeft = '0'; // 들여쓰기 제거 (선택사항) + // data가 ['제목1', '제목2', ...] 형식이라고 가정 + data.posts.forEach(item => { + const date = new Date(item.writeTime); + + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + + const formatted = `${year}/${month}/${day}`; + const li = document.createElement('li'); + const a = document.createElement('a'); + a.id = item.id; + a.href = `${getMainPath()}/blog/viewer/${item.id}`; + a.textContent = `${item.title}[${year}/${month}/${day}]` + li.appendChild(a); + ul.appendChild(li); + }); + }) + .catch(error => { + console.error('받아오기 실패:', error); + } + ); + } + if (document.querySelector(".recent_posts")) { + fetch('blog/recentOfPost.bjx') + .then(response => response.json()) + .then(data => { + const ul = document.querySelector('.recent_posts'); + ul.innerHTML = ''; // 기존 리스트 지움 + ul.style.listStyle = 'none'; // 불릿 제거 + ul.style.paddingLeft = '0'; // 들여쓰기 제거 (선택사항) + // data가 ['제목1', '제목2', ...] 형식이라고 가정 + data.posts.forEach(item => { + const date = new Date(item.writeTime); + + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + + const formatted = `${year}/${month}/${day}`; + const li = document.createElement('li'); + const a = document.createElement('a'); + a.id = item.id; + a.href = `${getMainPath()}/blog/viewer/${item.id}`; + a.textContent = `${item.title}[${year}/${month}/${day}]` + li.appendChild(a); + ul.appendChild(li); + }); + }) + .catch(error => { + console.error('받아오기 실패:', error); + } + ); + } }); onload = function() { history.replaceState({}, null, location.pathname); @@ -213,6 +275,11 @@ function logout() { form.submit(); } +function gotoHome() { + console.log(`location.port >> ${location.port}`) + location.href = getMainPath()+"/home.bs" +} + function gotoLogin() { console.log(`location.port >> ${location.port}`) location.href = getMainPath()+"/login.bs" @@ -222,6 +289,10 @@ function gotoJoin() { document.location.replace(getMainPath() + "/user/join.bs") } +function goToViewer(item) { + location.href = getMainPath() + "/blog/viewer/" + item.id +} + function goToView(path,id) { location.href = path + id; } diff --git a/src/main/resources/templates/content/blog/posts.html b/src/main/resources/templates/content/blog/posts.html index 3c52d4a..360fefd 100644 --- a/src/main/resources/templates/content/blog/posts.html +++ b/src/main/resources/templates/content/blog/posts.html @@ -57,8 +57,8 @@
-
- +
+

diff --git a/src/main/resources/templates/content/home.html b/src/main/resources/templates/content/home.html index cbe6043..6aa5be9 100644 --- a/src/main/resources/templates/content/home.html +++ b/src/main/resources/templates/content/home.html @@ -11,11 +11,7 @@ @@ -51,7 +47,7 @@
-
+

diff --git a/src/main/resources/templates/content/left-sidebar.html b/src/main/resources/templates/content/left-sidebar.html index bebc023..bb8f232 100644 --- a/src/main/resources/templates/content/left-sidebar.html +++ b/src/main/resources/templates/content/left-sidebar.html @@ -12,10 +12,6 @@ diff --git a/src/main/resources/templates/content/no-sidebar.html b/src/main/resources/templates/content/no-sidebar.html index d65826b..5782d72 100644 --- a/src/main/resources/templates/content/no-sidebar.html +++ b/src/main/resources/templates/content/no-sidebar.html @@ -12,10 +12,7 @@ diff --git a/src/main/resources/templates/content/private/where.html b/src/main/resources/templates/content/private/where.html index 1e0ced1..978844f 100644 --- a/src/main/resources/templates/content/private/where.html +++ b/src/main/resources/templates/content/private/where.html @@ -11,12 +11,13 @@
-
-
diff --git a/src/main/resources/templates/content/right-sidebar.html b/src/main/resources/templates/content/right-sidebar.html index 45e9d43..67e27a9 100644 --- a/src/main/resources/templates/content/right-sidebar.html +++ b/src/main/resources/templates/content/right-sidebar.html @@ -11,11 +11,7 @@
--> diff --git a/src/main/resources/templates/content/two-sidebar.html b/src/main/resources/templates/content/two-sidebar.html index 7fb82be..b104620 100644 --- a/src/main/resources/templates/content/two-sidebar.html +++ b/src/main/resources/templates/content/two-sidebar.html @@ -11,11 +11,7 @@ diff --git a/src/main/resources/templates/fragments/footer.html b/src/main/resources/templates/fragments/footer.html index 290ae89..78cb362 100644 --- a/src/main/resources/templates/fragments/footer.html +++ b/src/main/resources/templates/fragments/footer.html @@ -5,8 +5,8 @@
-

Links to Stuff

-
-

More Links to Stuff

-