-
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.
Added admin login and post adding page
- Loading branch information
1 parent
c9696e7
commit 8d04587
Showing
8 changed files
with
212 additions
and
36 deletions.
There are no files selected for viewing
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
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,47 @@ | ||
function auto_grow(element) { | ||
element.style.height = "5px"; | ||
element.style.height = (element.scrollHeight)+"px"; | ||
} | ||
|
||
window.addEventListener('unload', function () { | ||
const form = document.querySelector('form'); | ||
form.reset(); // Очищаем все поля формы | ||
}); | ||
|
||
// JavaScript для отображения выбранных файлов | ||
function handleFileSelect(event) { | ||
const files = event.target.files; | ||
const fileList = document.getElementById('fileList'); | ||
|
||
// Обновляем список файлов | ||
for (const file of files) { | ||
const listItem = document.createElement('li'); | ||
listItem.classList.add('file-item'); | ||
|
||
const link = document.createElement('a'); | ||
link.href = URL.createObjectURL(file); | ||
link.download = file.name; | ||
|
||
const icon = document.createElement('img'); | ||
icon.src = 'resources/icons/' + getFileType(file.name) + '.png'; | ||
icon.alt = getFileType(file.name) + ' Icon'; | ||
icon.width = 128; | ||
icon.height = 128; | ||
icon.classList.add('file-icon'); | ||
|
||
const fileName = document.createTextNode(file.name); | ||
|
||
link.appendChild(icon); | ||
link.appendChild(fileName); | ||
listItem.appendChild(link); | ||
|
||
fileList.appendChild(listItem); | ||
} | ||
} | ||
|
||
// Получаем тип файла по расширению | ||
function getFileType(fileName) { | ||
const extension = fileName.split('.').pop().toLowerCase(); | ||
// Ваш код определения типа файла по расширению, например, расширения 'pdf' -> 'PDF' | ||
return extension.toUpperCase(); | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
<header> | ||
<h1>Калиновський Валентин<br>Мій Особистий Блог</h1> | ||
<h1>Калиновський Валентин</h1> | ||
<h2>Мій Особистий Блог</h2> | ||
{% if is_admin %} | ||
<p>Привіт, Вальок!</p> | ||
{% endif %} | ||
</header> |
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
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,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Новий пост</title> | ||
<link rel="stylesheet" href="../resources/style/style.css"> | ||
</head> | ||
<body> | ||
|
||
{% include 'header.html' %} | ||
|
||
{% include 'nav.html' %} | ||
|
||
<script src="resources/scripts/scripts.js"></script> | ||
|
||
<main> | ||
<form action="{{ url_for('save_post_route') }}" method="post" enctype="multipart/form-data"> | ||
<input type="text" name="title" placeholder="Заголовок" required> | ||
|
||
<input type="text" name="description" placeholder="Опис" required> | ||
|
||
<textarea name="content" placeholder="Текст" oninput="auto_grow(this)" required></textarea> | ||
|
||
<input type="file" id="fileInput" name="files" onchange="handleFileSelect(event)" multiple> | ||
|
||
<!-- Список выбранных файлов --> | ||
<ul id="fileList" class="file-list"></ul> | ||
|
||
<input type="submit" value="Зберегти пост"> | ||
</form> | ||
</main> | ||
|
||
{% include 'footer.html' %} | ||
|
||
</body> | ||
</html> |