블로그 기능 구현
> 글쓰기, 수정, 삭제 구현 > 목록 페이지 벽돌 레이아웃 구성 > 로그인 기능 추가 > 컨텐츠 공개/숨김 기능 추가
This commit is contained in:
73
templates/edit_post.html
Normal file
73
templates/edit_post.html
Normal file
@@ -0,0 +1,73 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="uk-container uk-margin-top">
|
||||
<h1 class="uk-text-center"><span>포스트 수정</span></h1>
|
||||
<form action="/edit_post/{{ post.id }}" method="post" class="uk-form-stacked">
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="title">제목</label>
|
||||
<div class="uk-form-controls">
|
||||
<input class="uk-input" id="title" type="text" name="title" value="{{ post.title }}"
|
||||
placeholder="제목을 입력하세요..." required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="category">카테고리</label>
|
||||
<div class="uk-form-controls">
|
||||
<select class="uk-select" id="category" name="category" required>
|
||||
<option value="">카테고리를 선택하세요...</option>
|
||||
<option value="IT" {% if post.category == 'IT' %} selected {% endif %}>IT</option>
|
||||
<option value="NEWS" {% if post.category == 'NEWS' %} selected {% endif %}>NEWS</option>
|
||||
<option value="ETC" {% if post.category == 'ETC' %} selected {% endif %}>ETC</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="public">공개 여부</label>
|
||||
<div class="uk-form-controls">
|
||||
<label><input class="uk-checkbox" id="public" type="checkbox" name="public" {% if post.is_public %}
|
||||
checked {% endif %}> 이 글을 외부 공개합니다</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="contents">내용</label>
|
||||
<div class="uk-form-controls">
|
||||
<textarea class="summernote" id="contents" name="contents" required>{{ post.contents }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-margin">
|
||||
<a style="float: left;" href="{{ url_for('post', post_id=post.id) }}" class="uk-button uk-button-default">뒤로가기</a>
|
||||
<button style="float: right;" type="submit" class="uk-button uk-button-primary">글 수정</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.summernote').summernote({
|
||||
height: 300,
|
||||
callbacks: {
|
||||
onImageUpload: function (files) {
|
||||
var $editor = $(this);
|
||||
var data = new FormData();
|
||||
data.append("file", files[0]);
|
||||
$.ajax({
|
||||
url: "/upload_image",
|
||||
method: "POST",
|
||||
data: data,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
var imageUrl = response.fileUrl;
|
||||
$editor.summernote("insertImage", imageUrl);
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user