This commit is contained in:
2025-09-15 17:18:44 +09:00
parent cc43ea8e0a
commit 1ab12cb6d9
29 changed files with 4951 additions and 2912 deletions
File diff suppressed because it is too large Load Diff
@@ -23,13 +23,12 @@
</a>
<div class="inner">
<h3 style="display: flex; justify-content: space-between; align-items: center;">
<span>
<span th:if="${!post.posting}" style="background-color: #888; color: white; font-size: 0.7em; padding: 2px 6px; border-radius: 4px; margin-right: 8px; vertical-align: middle;">
비공개
</span>
<span th:text="${post.title != null and not #strings.isEmpty(post.title)} ? ${post.title} : 'untitled[' + ${#temporals.format(T(java.time.Instant).ofEpochMilli(post.writeTime).atZone(T(java.time.ZoneId).systemDefault()).toLocalDateTime(), 'yyyy-MM-dd HH:mm')} + ']'"></span>
</span>
<span>
<span th:if="${!post.posting}" style="background-color: #888; color: white; font-size: 0.7em; padding: 2px 6px; border-radius: 4px; margin-right: 8px; vertical-align: middle;">
비공개
</span>
<span th:text="${post.title != null and not #strings.isEmpty(post.title)} ? ${post.title} : 'untitled[' + ${#temporals.format(T(java.time.Instant).ofEpochMilli(post.writeTime).atZone(T(java.time.ZoneId).systemDefault()).toLocalDateTime(), 'yyyy-MM-dd HH:mm')} + ']'"></span>
</span>
<span style="font-size: 0.75em; color: #888; font-weight: normal; white-space: nowrap; margin-left: 1em;">
(읽음: <span th:text="${post.readCount}">0</span>)
</span>
@@ -40,7 +39,9 @@
</div>
<footer sec:authorize="isAuthenticated()" style="text-align: right; margin-top: 1em;">
<footer sec:authorize="isAuthenticated()"
th:if="${#authentication.name == post.writer or #authorization.expression('hasRole(''ADMIN'')')}"
style="text-align: right; margin-top: 1em;">
<a th:href="@{/blog/edit/{postId}(postId=${post.id})}" class="button small alt">수정</a>
</footer>
</div>
@@ -5,7 +5,6 @@
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
layout:decorate="~{layout/default_layout}">
<th:block layout:fragment="head">
<link th:href="@{/css/private.css}" rel="stylesheet" />
</th:block>
<th:block layout:fragment="content" id="content">
<div id="main_layer">
@@ -0,0 +1,232 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
layout:decorate="~{layout/default_layout}">
<th:block layout:fragment="head">
<style>
.tabs { display: flex; border-bottom: 2px solid #ddd; margin-bottom: 1.5em; flex-wrap: wrap; }
.tab-link { padding: 10px 20px; cursor: pointer; border: 1px solid transparent; border-bottom: 0; color: #777; }
.tab-link.active { border-color: #ddd; border-bottom-color: white; background: white; margin-bottom: -2px; font-weight: bold; color: #333; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.user-list, .post-list { list-style: none; padding-left: 0; }
.user-list li, .post-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; }
.user-list li:last-child, .post-list li:last-child { border-bottom: none; }
.button.small { margin-left: 0.5em; }
</style>
</th:block>
<th:block layout:fragment="content">
<section class="wrapper style1">
<div class="container">
<header class="major">
<h2 th:text="${isAdmin} ? '관리자 대시보드' : (${user.user_id} + '님의 정보')"></h2>
<p>가입일: <span th:text="${joinDate}"></span></p>
</header>
<div class="tabs">
<div class="tab-link active" onclick="openTab(event, 'myInfo')">내 정보</div>
<div class="tab-link" onclick="openTab(event, 'myPosts')">내가 쓴 글</div>
<div class="tab-link" onclick="openTab(event, 'myComments')">내가 쓴 댓글</div>
<th:block sec:authorize="hasRole('ADMIN')">
<div class="tab-link" onclick="openTab(event, 'userManagement')">회원 관리</div>
<div class="tab-link" onclick="openTab(event, 'contentManagement')">콘텐츠 관리</div>
</th:block>
</div>
<div id="myInfo" class="tab-content active">
<div class="box">
<h3>기본 정보</h3>
<ul>
<li><strong>아이디:</strong> <span th:text="${user.user_id}"></span></li>
<li><strong>이메일:</strong> <span th:text="${user.user_email}"></span></li>
<li>
<strong>현재 권한:</strong> <span th:id="'user-role-status-' + ${user.user_id}" th:text="${user.getRole().name()}"></span>
<th:block th:if="${user.getRole().name() == 'READ' and !user.writePermissionRequested}">
<a href="javascript:requestWritePermission()" id="request-perm-btn" class="button small alt" style="margin-left: 1em;">글쓰기 권한 요청</a>
</th:block>
<span th:if="${user.writePermissionRequested}" id="request-perm-status" style="margin-left: 1em; color: #007bff;">(권한 요청 처리 중)</span>
</li>
</ul>
</div>
</div>
<div id="myPosts" class="tab-content">
<div class="box">
<ul class="post-list">
<li th:each="post : ${myPosts}">
<a th:href="@{'/blog/viewer/' + ${post.id}}" th:text="${post.title}">게시물 제목</a>
<span th:text="${#dates.format(post.modifyTime, 'yyyy-MM-dd HH:mm')}"></span>
</li>
<li th:if="${#lists.isEmpty(myPosts)}">작성한 글이 없습니다.</li>
</ul>
</div>
</div>
<div id="myComments" class="tab-content">
<div class="box">
<ul class="post-list">
<li th:each="comment : ${myComments}">
<span th:text="${comment.content}">댓글 내용</span>
<a th:href="@{'/blog/viewer/' + ${comment.postId} + '#comment-' + ${comment.id}}">원문보기</a>
</li>
<li th:if="${#lists.isEmpty(myComments)}">작성한 댓글이 없습니다.</li>
</ul>
</div>
</div>
<div id="userManagement" class="tab-content" sec:authorize="hasRole('ADMIN')">
<div class="box">
<h4>권한 요청</h4>
<ul id="permission-requests-list" class="user-list">
<li th:each="reqUser : ${permissionRequests}" th:id="'request-row-' + ${reqUser.user_id}">
<span>
<strong th:text="${reqUser.user_id}"></strong> (<span th:text="${reqUser.user_email}"></span>)
</span>
<div>
<button class="button small primary" th:onclick="handlePermission('[[${reqUser.user_id}]]', 'approve')">승인</button>
<button class="button small alt" th:onclick="handlePermission('[[${reqUser.user_id}]]', 'reject')">거절</button>
</div>
</li>
<li th:if="${#lists.isEmpty(permissionRequests)}">새로운 권한 요청이 없습니다.</li>
</ul>
</div>
<div class="box" style="margin-top: 2em;">
<h4>전체 회원</h4>
<ul id="all-users-list" class="user-list">
<li th:each="u : ${allUsers}">
<span>
<strong th:text="${u.user_id}"></strong> - 현재 권한: <span th:id="'user-role-' + ${u.user_id}" th:text="${u.getRole().name()}"></span>
</span>
</li>
</ul>
</div>
</div>
<div id="contentManagement" class="tab-content" sec:authorize="hasRole('ADMIN')">
<div class="box">
<h4>최신 글 관리</h4>
<ul class="post-list">
<li th:each="post : ${allRecentPosts}" th:id="'post-row-' + ${post.id}">
<a th:href="@{'/blog/viewer/' + ${post.id}}" th:text="${post.title}">게시물 제목</a>
<div>
<span th:if="${post.isBlocked}" style="color: red; margin-right: 1em;">(차단됨)</span>
<button th:if="${!post.isBlocked}" class="button small alt" th:onclick="handleContent('[[${post.id}]]', 'block')">차단</button>
<button th:if="${post.isBlocked}" class="button small" th:onclick="handleContent('[[${post.id}]]', 'unblock')">차단 해제</button>
</div>
</li>
</ul>
</div>
</div>
</div>
</section>
<script th:inline="javascript">
// CSRF 토큰을 meta 태그에서 읽어옴 (POST 요청 시 필요)
const csrfToken = document.querySelector('meta[name="_csrf"]')?.getAttribute('content');
const csrfHeader = document.querySelector('meta[name="_csrf_header"]')?.getAttribute('content');
/**
* 탭 클릭 시 해당 탭 콘텐츠를 보여주는 함수
*/
function openTab(evt, tabName) {
// 모든 탭 콘텐츠 숨기기
document.querySelectorAll('.tab-content').forEach(tab => tab.style.display = 'none');
// 모든 탭 링크에서 'active' 클래스 제거
document.querySelectorAll('.tab-link').forEach(link => link.classList.remove('active'));
// 클릭된 탭 콘텐츠 보이기
document.getElementById(tabName).style.display = 'block';
// 클릭된 탭 링크에 'active' 클래스 추가
evt.currentTarget.classList.add('active');
}
/**
* '글쓰기 권한 요청'을 서버에 전송하는 함수
*/
function requestWritePermission() {
if (!confirm('글쓰기 권한을 요청하시겠습니까? 관리자 승인 후 적용됩니다.')) return;
fetch('/user/request-write', {
method: 'POST',
headers: { [csrfHeader]: csrfToken }
})
.then(response => {
if (response.ok) {
alert('요청이 성공적으로 접수되었습니다.');
// 버튼을 '처리 중' 텍스트로 변경
document.getElementById('request-perm-btn').style.display = 'none';
const statusSpan = document.getElementById('request-perm-status');
if(statusSpan) {
statusSpan.innerText = '(권한 요청 처리 중)';
} else {
// span이 없는 경우 새로 만들어 추가
const newStatusSpan = document.createElement('span');
newStatusSpan.id = 'request-perm-status';
newStatusSpan.innerText = '(권한 요청 처리 중)';
newStatusSpan.style = 'margin-left: 1em; color: #007bff;';
document.getElementById('request-perm-btn').parentElement.appendChild(newStatusSpan);
}
} else {
alert('요청에 실패했습니다. 잠시 후 다시 시도해주세요.');
}
})
.catch(error => console.error('Error:', error));
}
/**
* (관리자) 사용자 권한 요청을 처리하는 함수
* @param {string} userId - 대상 사용자 ID
* @param {'approve' | 'reject'} action - 수행할 작업
*/
function handlePermission(userId, action) {
const url = `/user/${action}-writer/${userId}`;
fetch(url, {
method: 'POST',
headers: { [csrfHeader]: csrfToken }
})
.then(response => response.json())
.then(data => {
if (data && data.user_id) {
alert(`'${userId}'님의 권한 요청을 ${action === 'approve' ? '승인' : '거절'}했습니다.`);
// UI에서 해당 항목 제거
document.getElementById(`request-row-${userId}`).remove();
// 전체 사용자 목록의 권한 정보 업데이트
const userRoleSpan = document.getElementById(`user-role-${userId}`);
if (userRoleSpan) {
userRoleSpan.innerText = data.role.name;
}
} else {
alert('작업에 실패했습니다.');
}
})
.catch(error => console.error('Error:', error));
}
/**
* (관리자) 콘텐츠(게시물)를 차단하거나 해제하는 함수
* @param {string} postId - 대상 게시물 ID
* @param {'block' | 'unblock'} action - 수행할 작업
*/
function handleContent(postId, action) {
const url = `/blog/post/${postId}/${action}`;
fetch(url, {
method: 'POST',
headers: { [csrfHeader]: csrfToken }
})
.then(response => response.json())
.then(data => {
if (data && data.id) {
alert(`게시물을 ${action === 'block' ? '차단' : '차단 해제'}했습니다.`);
location.reload(); // 페이지를 새로고침하여 상태 업데이트
} else {
alert('작업에 실패했습니다.');
}
})
.catch(error => console.error('Error:', error));
}
</script>
</th:block>
</html>
@@ -17,7 +17,14 @@
<th:block layout:fragment="content" id="content">
<section class="wrapper style2">
<div class="container" sec:authorize="isAuthenticated()" onclick="loadEditor()" style="cursor: pointer;" title="클릭하여 수정하기">
<div class="container"
th:with="isAdmin=${#authorization.expression('hasRole(''ADMIN'')')}, isWriter=${#authentication.name == srcPost.writer}"
th:attr="
onclick=${(isAdmin or isWriter) ? 'loadEditor()' : ''},
style=${(isAdmin or isWriter) ? 'cursor: pointer;' : ''},
title=${(isAdmin or isWriter) ? '클릭하여 수정하기' : ''}
"
sec:authorize="isAuthenticated()">
<header class="major">
<h2 id="title_layer">
<span th:text="${srcPost.title}">게시물 제목이 여기에 표시됩니다</span>
@@ -15,29 +15,17 @@
<section class="col-3 col-6-narrower col-12-mobilep">
<h3>Rank of Views</h3>
<ul class="rank_of_view" >
<li><a href="#">Mattis et quis rutrum</a></li>
<li><a href="#">Suspendisse amet varius</a></li>
<li><a href="#">Sed et dapibus quis</a></li>
<li><a href="#">Rutrum accumsan dolor</a></li>
<li><a href="#">Mattis rutrum accumsan</a></li>
<li><a href="#">Suspendisse varius nibh</a></li>
<li><a href="#">Sed et dapibus mattis</a></li>
</ul>
</section>
<section class="col-3 col-6-narrower col-12-mobilep">
<h3>Recent of Posts</h3>
<ul class="recent_posts">
<li><a href="#">Duis neque nisi dapibus</a></li>
<li><a href="#">Sed et dapibus quis</a></li>
<li><a href="#">Rutrum accumsan sed</a></li>
<li><a href="#">Mattis et sed accumsan</a></li>
<li><a href="#">Duis neque nisi sed</a></li>
<li><a href="#">Sed et dapibus quis</a></li>
<li><a href="#">Rutrum amet varius</a></li>
</ul>
</section>
<section class="col-6 col-12-narrower">
<h3>Get In Touch</h3>
<h3>SEND TO ME(TELEGRAM BOT)</h3>
<div id="tlg_form" >
<div class="row gtr-50">
<div class="col-6 col-12-mobilep">
@@ -43,19 +43,23 @@
<!-- <li><a href="#">Veroeros feugiat</a></li>-->
</ul>
</li>
<li><a th:href="@{/licenses}">Licenses</a></li>
</ul>
</li>
<th:block sec:authorize="isAuthenticated()">
<li><a th:href="@{/user/info}">내 정보</a></li>
</th:block>
<th:block sec:authorize="!isAuthenticated()">
<li id="menu_login">
<a class="open-login-popup" to="#loginPopup">LOGIN</a>
<a class="open-login-popup" to="#loginPopup">Login</a>
</li>
</th:block>
<th:block sec:authorize="isAuthenticated()">
<li>
<a href="javascript:logout()" style="margin-left:10px;">로그아웃</a>
<a href="javascript:logout()" style="margin-left:10px;">Logout</a>
<li>
</th:block>
<li><a th:href="@{/licenses}">Licenses</a></li>
</ul>
</nav>
@@ -12,34 +12,33 @@
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<script async th:src="@{https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9504446465764716}" crossorigin="anonymous"></script>
<link th:href="@{/css/common.css}" rel="stylesheet" />
<link th:href="@{/css/main.css}" rel="stylesheet" />
<meta name="_csrf" th:content="${_csrf.token}"/>
<meta name="_csrf_parameter" th:content="${_csrf.parameterName}"/>
<script th:inline="javascript">
/*
* [수정됨] 이 객체는 Post.kt 모델의 모든 필드를 포함해야 합니다.
* 여기서 누락된 필드는 편집 후 저장 시 서버에서 null 또는 0으로 초기화됩니다.
* (이 블록은 <head>에 남아있어도 괜찮습니다. 전역 변수를 정의하는 역할입니다.)
* [Modified] This object must include all fields from the Post.kt model.
* Any fields missing here will be initialized as null or 0 on the server upon saving after an edit.
* (This block can remain in the <head>; it defines a global variable.)
*/
var serverData = {
// --- Key IDs ---
id: [[${srcPost?.id}]], // (Thymeleaf 3.x의 안전 탐색 연산자 '?' 사용)
id: [[${srcPost?.id}]], // (Using Thymeleaf 3.x's safe navigation operator '?')
originId: [[${srcPost?.originId}]],
// --- Core Content (컨트롤러에서 이미 디코딩됨) ---
// --- Core Content (already decoded in the controller) ---
title: /*[[${srcPost?.title ?: ''}]]*/,
content: /*[[${srcPost?.content ?: ''}]]*/,
// === (수정) 치명적으로 누락되었던 필드들 ===
// === (Modified) Critically missing fields ===
category: /*[[${srcPost?.category ?: 'none'}]]*/,
tags: /*[[${srcPost?.tags ?: ''}]]*/,
// --- Timestamps (데이터 보존을 위해 필수) ---
// --- Timestamps (required for data preservation) ---
writeTime: [[${srcPost?.writeTime ?: 0}]],
modifyTime: [[${srcPost?.modifyTime ?: 0}]],
// --- Location Data (데이터 보존을 위해 필수) ---
// --- Location Data (required for data preservation) ---
firstPostLat: [[${srcPost?.firstPostLat ?: 0.0}]],
firstPostLon: [[${srcPost?.firstPostLon ?: 0.0}]],
firstAddress: /*[[${srcPost?.firstAddress ?: ''}]]*/,
@@ -47,13 +46,13 @@
modifyLon: [[${srcPost?.modifyLon ?: 0.0}]],
modifyAddress: /*[[${srcPost?.modifyAddress ?: ''}]]*/,
// --- Metadata (데이터 보존을 위해 필수) ---
// --- Metadata (required for data preservation) ---
writer: /*[[${srcPost?.writer ?: ''}]]*/,
posting: [[${srcPost?.posting ?: false}]],
readCount: [[${srcPost?.readCount ?: 0}]],
voteCount: [[${srcPost?.voteCount ?: 0}]],
unlikeCount: [[${srcPost?.unlikeCount ?: 0}]],
// --- Page-specific (모델 데이터 아님) ---
// --- Page-specific (not model data) ---
enc: /*[[${enc ?: ''}]]*/,
keyword: /*[[${keyword ?: ''}]]*/
};
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="title">
<title th:text="${title}">Bum's</title>
</th:block>
</html>
<!--<!DOCTYPE html>-->
<!--<html xmlns:th="http://www.thymeleaf.org">-->
<!--<th:block th:fragment="title">-->
<!-- <title th:text="${title}">Bum's</title>-->
<!--</th:block>-->
<!--</html>-->
@@ -6,8 +6,9 @@
xmlns="http://www.w3.org/1999/html">
<head>
<base th:href="@{/}" />
<title th:text="${pageTitle ?: 'Bum''s'}">Bum's</title>
<th:block th:replace="~{fragments/includes :: includes}"></th:block>
<th:block th:replace="~{fragments/title :: title}"></th:block>
<th:block layout:fragment="head"></th:block>
</head>
<body class="is-preload">
<div id="page-wrapper">
@@ -17,7 +18,6 @@
<div class="dimBg"></div>
<th:block layout:fragment="popup_layer"></th:block>
<!-- 로그인 팝업 -->
<div id="loginPopup" class="pop_layer">
<div class="pop_container">
<div class="pop_conts">
@@ -28,7 +28,10 @@
<input type="checkbox" id="rememberMe" class="custom-checkbox"/>
<label for="rememberMe" class="custom-label"></label>
<span>자동로그인</span>
<button type="submit" class="button">로그인</button>
<div>
<button type="submit" class="button">로그인</button>
<button type="button" class="button alt" id="openSignupBtnFromLogin" >회원가입</button>
</div>
</form>
<div class="btn_r">
<a href="#" class="btn_layerClose" onclick="closePopup()">닫기</a>
@@ -37,7 +40,6 @@
</div>
</div>
<!-- 회원가입 팝업 -->
<div id="signupPopup" class="pop_layer">
<div class="pop_container">
<div class="pop_conts">
@@ -62,7 +64,5 @@
<script th:src="@{/js/jquery.dropotron.min.js}"></script>
<script th:src="@{/js/browser.min.js}"></script>
<script th:src="@{/js/breakpoints.min.js}"></script>
<script th:src="@{/js/util.js}"></script>
<script th:src="@{/js/main.js}"></script>
</body>
<script th:src="@{/js/template.js}"></script> </body>
</html>