From 2184ad717142a16e88a63ed3002c988c30b3c277 Mon Sep 17 00:00:00 2001 From: Vinejar <Хуев@мыло.чпок> Date: Sun, 30 Mar 2025 02:59:20 +0300 Subject: [PATCH] 0_0_1 --- Hentai_manga_model/models.py | 13 +++++ Hentai_manga_model/urls.py | 7 +++ Hentai_manga_model/views.py | 19 +++++++ templates/manga_view.html | 64 +++++++++++++++++++++++ templates/static/css/style.css | 94 ++++++++++++++++++++++++++++++++++ templates/static/js/script.js | 34 ++++++++++++ 6 files changed, 231 insertions(+) create mode 100644 Hentai_manga_model/models.py create mode 100644 Hentai_manga_model/urls.py create mode 100644 Hentai_manga_model/views.py create mode 100644 templates/manga_view.html create mode 100644 templates/static/css/style.css create mode 100644 templates/static/js/script.js diff --git a/Hentai_manga_model/models.py b/Hentai_manga_model/models.py new file mode 100644 index 0000000..77f6067 --- /dev/null +++ b/Hentai_manga_model/models.py @@ -0,0 +1,13 @@ +from pymongo import MongoClient + +client = MongoClient('mongodb://localhost:27017/') +db = client['Manga'] # Название базы данных +manga_collection = db['Hentai_Manga'] # Название коллекции + + + + + + + + diff --git a/Hentai_manga_model/urls.py b/Hentai_manga_model/urls.py new file mode 100644 index 0000000..a23eaa6 --- /dev/null +++ b/Hentai_manga_model/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from .views import show_manga, show_manga_page + +urlpatterns = [ + path('manga//', show_manga, name='show_manga'), + path('manga//page//', show_manga_page, name='show_manga_page'), # новый маршрут +] diff --git a/Hentai_manga_model/views.py b/Hentai_manga_model/views.py new file mode 100644 index 0000000..dbfe9b9 --- /dev/null +++ b/Hentai_manga_model/views.py @@ -0,0 +1,19 @@ +from django.shortcuts import render +from .models import manga_collection + +def show_manga(request, manga_id): + manga = manga_collection.find_one({"id": int(manga_id)}) # Ищем мангу по ID + if not manga: + return render(request, "not_found.html") # Если нет манги, показываем заглушку + return render(request, "manga_view.html", {"manga": manga}) + +def show_manga_page(request, manga_id, page_number): + manga = manga_collection.find_one({"id": int(manga_id)}) + if not manga or page_number < 1 or page_number > manga['len_manga']: + return render(request, "not_found.html") + + img_url = manga['imgs_manga'][page_number - 1] # Индекс страницы манги (начинаем с 0) + return render(request, "manga_page.html", {"manga": manga, "img_url": img_url, "page_number": page_number}) + + + diff --git a/templates/manga_view.html b/templates/manga_view.html new file mode 100644 index 0000000..769b122 --- /dev/null +++ b/templates/manga_view.html @@ -0,0 +1,64 @@ + + + + {% load static %} + + + {{ manga.original_title }} + + + + + +
+ + + + +
+ +
+ + + + +
+ Страница +
+ + + + +
+ {% for img in manga.imgs_manga %} +
+ Стр {{ forloop.counter }} +
+ {% endfor %} +
+
+
+ + +
+ +
+
+ + + diff --git a/templates/static/css/style.css b/templates/static/css/style.css new file mode 100644 index 0000000..3c4ed4c --- /dev/null +++ b/templates/static/css/style.css @@ -0,0 +1,94 @@ +.content-wrapper { + position: relative; + min-height: 500px; +} + +.image-box { + display: none; + width: 100%; + text-align: center; + margin-bottom: 20px; +} + +#mangaImage { + max-width: 100%; + max-height: 90vh; + object-fit: contain; +} + +.manga-grid-container { + width: 90%; + margin: 0 auto; +} + +.manga-grid { + display: grid; + grid-template-columns: repeat(9, 102px); + gap: 10px; + justify-content: center; + margin: 0 auto; + max-width: calc(6 * 102px + 5 * 10px); +} + +.manga-preview { + width: 102px; + height: 142px; + overflow: hidden; + border-radius: 3px; + box-shadow: 0 1px 3px rgba(0,0,0,0.2); + background: #eee; +} + +.manga-preview img { + width: 100%; + height: 100%; + object-fit: cover; + object-position: center top; + cursor: pointer; + transition: transform 0.2s; +} + +.manga-preview img:hover { + transform: scale(1.05); +} + +.breadcrumb-item { + list-style: none; + display: flex; + align-items: center; +} + +.breadcrumb-item a { + text-decoration: none; + color: green; /* Сохраняет цвет текста как у родителя */ + font-weight: bold; +} + +.breadcrumb-item .separator { + margin: 0 5px; +} + + + + + + + +/* Адаптивность */ +@media (max-width: 768px) { + .manga-grid { + grid-template-columns: repeat(4, 102px); + } +} + +@media (max-width: 480px) { + .manga-grid { + grid-template-columns: repeat(3, 102px); + } +} + +@media (max-width: 360px) { + .manga-grid { + grid-template-columns: repeat(2, 102px); + } +} \ No newline at end of file diff --git a/templates/static/js/script.js b/templates/static/js/script.js new file mode 100644 index 0000000..4dfd9d5 --- /dev/null +++ b/templates/static/js/script.js @@ -0,0 +1,34 @@ +function changePage(select) { + const selectedImg = select.value; + const previewContainer = document.getElementById("previewContainer"); + const imageBox = document.getElementById("imageBox"); + const mangaImage = document.getElementById("mangaImage"); + + if (selectedImg === "preview") { + previewContainer.style.display = "block"; + imageBox.style.display = "none"; + } else { + previewContainer.style.display = "none"; + mangaImage.src = selectedImg; + imageBox.style.display = "block"; + } +} + +function showImage(imgSrc) { + const drop = document.getElementById("drop"); + drop.value = imgSrc; + changePage(drop); + + // Прокрутка к изображению + document.getElementById("imageBox").scrollIntoView({ + behavior: 'smooth', + block: 'start' + }); +} + +// Инициализация при загрузке +document.addEventListener('DOMContentLoaded', function() { + // Убедимся, что превью отображается по умолчанию + document.getElementById("previewContainer").style.display = "block"; + document.getElementById("imageBox").style.display = "none"; +}); \ No newline at end of file