-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6 - Feat: PostController 추가, 글 작성 페이지 추가
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ssion/mutbooks/src/main/java/com/example/mutbooks/app/post/controller/PostController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.mutbooks.app.post.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
@RequestMapping("/post") | ||
public class PostController { | ||
// 글 등록폼 | ||
@PreAuthorize("isAuthenticated()") | ||
@GetMapping("/write") | ||
public String showWrite() { | ||
return "post/write"; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
1Week_Mission/mutbooks/src/main/resources/templates/post/write.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html layout:decorate="~{layout/layout.html}"> | ||
|
||
<head> | ||
<title>글 작성</title> | ||
</head> | ||
|
||
<body> | ||
<main layout:fragment="main"> | ||
<section class="section section-write container mx-auto"> | ||
|
||
<div class="px-2 pt-4"> | ||
<h1 class="font-bold text-lg">글 작성</h1> | ||
|
||
<script> | ||
let SongCreate__submitDone = false; | ||
|
||
function SongCreate__submit(form) { | ||
if (SongCreate__submitDone) { | ||
return; | ||
} | ||
|
||
form.subject.value = form.subject.value.trim(); | ||
|
||
if (form.subject.value.length == 0) { | ||
warningModal("제목을 입력해주세요."); | ||
form.subject.focus(); | ||
|
||
return; | ||
} | ||
|
||
form.content.value = form.content.value.trim(); | ||
|
||
if (form.content.value.length == 0) { | ||
warningModal("내용을 입력해주세요."); | ||
form.content.focus(); | ||
|
||
return; | ||
} | ||
|
||
form.submit(); | ||
SongCreate__submitDone = true; | ||
} | ||
</script> | ||
|
||
|
||
<form th:action method="POST" class="flex flex-col gap-3" | ||
onsubmit="SongCreate__submit(this); return false;"> | ||
<div class="form-control"> | ||
<label class="label"> | ||
<span class="label-text">제목</span> | ||
</label> | ||
<input autofocus type="text" name="subject" placeholder="제목" class="input input-bordered" | ||
maxlength="50"> | ||
</div> | ||
|
||
<div class="form-control"> | ||
<label class="label"> | ||
<span class="label-text">내용</span> | ||
</label> | ||
<textarea name="content" placeholder="#내용" class="textarea textarea-bordered min-h-[500px] h-[calc(100vh-400px)]" | ||
maxlength="10000"></textarea> | ||
</div> | ||
|
||
<div class="grid grid-cols-2 mt-2 gap-2"> | ||
<button type="button" onclick="history.back();" class="btn btn-secondary btn-outline">취소</button> | ||
<input class="btn btn-primary" type="submit" value="완료"> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
</div> | ||
</section> | ||
|
||
</main> | ||
</body> | ||
</html> |