Skip to content

Commit

Permalink
#6 - Feat: PostController 추가, 글 작성 페이지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ahah525 committed Oct 18, 2022
1 parent 2ad824b commit 4449b3c
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
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";
}
}
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>

0 comments on commit 4449b3c

Please sign in to comment.