поправлен предосмотр

This commit is contained in:
2025-11-21 13:02:44 +08:00
parent 0fdfb09fa0
commit 32bd29efd5
3 changed files with 170 additions and 136 deletions

View File

@@ -12,10 +12,7 @@ cd /home/romkazvo/www/cgi-bin
``` ```
### Компиляция CGI ### Компиляция CGI
```bash ```bash
gcc -o index.cgi index.c sudo sh build.sh
gcc -o style.cgi style.c
gcc -o status.cgi status.c
chmod +x *.cgi
``` ```
### Конфигурация Nginx ### Конфигурация Nginx
Файл конфигурации `/etc/nginx/sites-available/trashbox`:<br> Файл конфигурации `/etc/nginx/sites-available/trashbox`:<br>

136
style.css
View File

@@ -351,6 +351,7 @@ li:hover {
height: 100%; height: 100%;
background-color: rgba(0,0,0,0.8); background-color: rgba(0,0,0,0.8);
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
overflow: auto;
} }
.preview-content { .preview-content {
@@ -358,9 +359,6 @@ li:hover {
margin: 2% auto; margin: 2% auto;
padding: 0; padding: 0;
border-radius: 8px; border-radius: 8px;
width: 90%;
height: 90%;
max-width: 1200px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3); box-shadow: 0 10px 30px rgba(0,0,0,0.3);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -368,39 +366,6 @@ li:hover {
transition: all 0.3s ease; transition: all 0.3s ease;
} }
/* Размеры для разных типов контента */
.preview-content.image-type {
max-width: 90%;
max-height: 90%;
width: auto;
height: auto;
}
.preview-content.text-type {
max-width: 800px;
max-height: 80%;
}
.preview-content.audio-type {
max-width: 500px;
max-height: 300px;
}
.preview-content.video-type {
max-width: 90%;
max-height: 90%;
}
.preview-content.pdf-type {
max-width: 90%;
max-height: 90%;
}
.preview-content.default-type {
max-width: 90%;
max-height: 90%;
}
.preview-header { .preview-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@@ -453,39 +418,54 @@ li:hover {
background: var(--bg-primary); background: var(--bg-primary);
} }
/* Стили для контейнера изображения */
.preview-image-container {
display: flex;
align-items: center;
justify-content: center;
flex-grow: 1;
padding: 10px;
background: var(--bg-primary);
overflow: hidden;
width: 100%;
height: 100%;
}
.preview-image {
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
object-fit: contain;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
display: block;
}
/* Улучшаем скроллинг для очень больших изображений */
.preview-modal::-webkit-scrollbar {
width: 8px;
}
.preview-modal::-webkit-scrollbar-track {
background: rgba(255,255,255,0.1);
}
.preview-modal::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.3);
border-radius: 4px;
}
.preview-modal::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.5);
}
/* Адаптивность */ /* Адаптивность */
@media (max-width: 768px) { @media (max-width: 768px) {
.preview-content { .preview-content {
width: 95%;
height: 95%;
margin: 2.5% auto; margin: 2.5% auto;
} }
.preview-content.image-type {
max-width: 95%;
max-height: 95%;
}
.preview-content.text-type {
max-width: 95%;
max-height: 80%;
}
.preview-content.audio-type {
max-width: 95%;
max-height: 300px;
}
.preview-content.video-type {
max-width: 95%;
max-height: 95%;
}
.preview-content.pdf-type {
max-width: 95%;
max-height: 95%;
}
.preview-header { .preview-header {
padding: 0.75rem; padding: 0.75rem;
} }
@@ -493,6 +473,10 @@ li:hover {
.preview-title { .preview-title {
font-size: 0.9rem; font-size: 0.9rem;
} }
.preview-image-container {
padding: 5px;
}
} }
@media (max-width: 480px) { @media (max-width: 480px) {
@@ -560,27 +544,15 @@ li:hover {
font-size: 0.8rem; font-size: 0.8rem;
} }
.preview-content { .preview-content {
width: 98%;
height: 98%;
margin: 1% auto; margin: 1% auto;
border-radius: 4px; border-radius: 4px;
} }
.preview-image-container {
.preview-content.image-type, padding: 2px;
.preview-content.video-type,
.preview-content.pdf-type {
max-width: 98%;
max-height: 98%;
} }
.preview-image {
.preview-content.text-type { border-radius: 4px;
max-width: 98%; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
max-height: 80%;
}
.preview-content.audio-type {
max-width: 98%;
max-height: 250px;
} }
} }
@@ -609,8 +581,4 @@ li:hover {
.file-link { .file-link {
width: 100%; width: 100%;
} }
.preview-content.audio-type {
max-height: 200px;
}
} }

View File

@@ -20,7 +20,7 @@
<meta name="twitter:description" content="Моя личная помоечка" /> <meta name="twitter:description" content="Моя личная помоечка" />
<meta name="twitter:image" content="https://home.mashup.su/og.png" /> <meta name="twitter:image" content="https://home.mashup.su/og.png" />
<meta name="description" content="Моя личная помоечка" /> <meta name="description" content="Моя личная помоечка" />
<meta name="keywords" content="файлы, обмен, скачать, загрузить" /> <meta name="keywords" content="RomkaZVO, mashup, mashup su, файлы, обмен, скачать, загрузить" />
<script> <script>
function getCookie(name) { function getCookie(name) {
@@ -58,7 +58,7 @@
<div class="footer-content"> <div class="footer-content">
<span>Навайбкодил с любовью ❤️</span> <span>Навайбкодил с любовью ❤️</span>
<a href="https://romkazvo.ru" target="_blank" class="footer-link">RomkaZVO</a><br> <a href="https://romkazvo.ru" target="_blank" class="footer-link">RomkaZVO</a><br>
Сделано при помощи BusyBox httpd и nginx для SSL<br> Сделано при помощи BusyBox httpd и Nginx для SSL<br>
Боже, храни Китай партия за DeepSeek Боже, храни Китай партия за DeepSeek
</div> </div>
@@ -80,7 +80,6 @@
<button class="scroll-top" onclick="scrollToTop()"></button> <button class="scroll-top" onclick="scrollToTop()"></button>
<!-- Модальное окно предпросмотра -->
<div id="previewModal" class="preview-modal"> <div id="previewModal" class="preview-modal">
<div class="preview-content" id="previewContent"> <div class="preview-content" id="previewContent">
<div class="preview-header"> <div class="preview-header">
@@ -123,18 +122,15 @@
document.cookie = `theme=${newTheme}; expires=${date.toUTCString()}; path=/`; document.cookie = `theme=${newTheme}; expires=${date.toUTCString()}; path=/`;
} }
// Функции для предпросмотра файлов
function openPreview(fileUrl) { function openPreview(fileUrl) {
const modal = document.getElementById('previewModal'); const modal = document.getElementById('previewModal');
const frame = document.getElementById('previewFrame'); const frame = document.getElementById('previewFrame');
const content = document.getElementById('previewContent'); const content = document.getElementById('previewContent');
const title = document.getElementById('previewTitle'); const title = document.getElementById('previewTitle');
// Получаем имя файла из URL
const fileName = fileUrl.split('/').pop(); const fileName = fileUrl.split('/').pop();
title.textContent = `Предпросмотр: ${fileName}`; title.textContent = `Предпросмотр: ${fileName}`;
// Определяем тип файла для адаптивного масштабирования
const fileExt = fileName.split('.').pop().toLowerCase(); const fileExt = fileName.split('.').pop().toLowerCase();
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'ico']; const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'ico'];
const textTypes = ['txt', 'md', 'html', 'htm', 'css', 'js', 'json', 'xml', 'csv']; const textTypes = ['txt', 'md', 'html', 'htm', 'css', 'js', 'json', 'xml', 'csv'];
@@ -142,81 +138,154 @@
const videoTypes = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv']; const videoTypes = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
const isPDF = fileExt === 'pdf'; const isPDF = fileExt === 'pdf';
// Устанавливаем размеры в зависимости от типа файла frame.style.display = 'block';
frame.src = '';
let imgContainer = document.getElementById('previewImageContainer');
if (!imgContainer) {
imgContainer = document.createElement('div');
imgContainer.id = 'previewImageContainer';
imgContainer.className = 'preview-image-container';
content.appendChild(imgContainer);
}
imgContainer.style.display = 'none';
imgContainer.innerHTML = '';
if (imageTypes.includes(fileExt)) { if (imageTypes.includes(fileExt)) {
// Для изображений - автоматический размер frame.style.display = 'none';
content.style.width = 'auto'; imgContainer.style.display = 'flex';
content.style.height = 'auto';
content.style.maxWidth = '90vw'; const img = document.createElement('img');
content.style.maxHeight = '90vh'; img.src = fileUrl;
} else if (textTypes.includes(fileExt)) { img.alt = fileName;
// Для текстовых файлов - компактное окно img.className = 'preview-image';
content.style.width = '80vw';
content.style.height = '70vh'; img.onload = function() {
content.style.maxWidth = '800px'; adjustModalForImage(this);
content.style.maxHeight = '600px'; };
} else if (audioTypes.includes(fileExt)) {
// Для аудио - маленькое окно img.onerror = function() {
content.style.width = '500px'; console.error('Failed to load image:', fileUrl);
content.style.height = '300px'; frame.style.display = 'block';
content.style.maxWidth = '90vw'; imgContainer.style.display = 'none';
content.style.maxHeight = '400px'; frame.src = fileUrl;
} else if (videoTypes.includes(fileExt)) { };
// Для видео - большое окно
content.style.width = '90vw'; imgContainer.appendChild(img);
content.style.height = '80vh';
content.style.maxWidth = '1200px';
content.style.maxHeight = '800px';
} else if (isPDF) {
// Для PDF - большое окно
content.style.width = '90vw'; content.style.width = '90vw';
content.style.height = '90vh'; content.style.height = '90vh';
content.style.maxWidth = '1200px'; content.style.maxWidth = 'none';
content.style.maxHeight = '900px'; content.style.maxHeight = 'none';
frame.classList.add('pdf');
} else { } else {
// По умолчанию - средний размер frame.style.display = 'block';
content.style.width = '80vw'; imgContainer.style.display = 'none';
content.style.height = '80vh';
content.style.maxWidth = '1000px'; if (textTypes.includes(fileExt)) {
content.style.maxHeight = '800px'; content.style.width = '80vw';
content.style.height = '70vh';
content.style.maxWidth = '800px';
content.style.maxHeight = '600px';
} else if (audioTypes.includes(fileExt)) {
content.style.width = '500px';
content.style.height = '300px';
content.style.maxWidth = '90vw';
content.style.maxHeight = '400px';
} else if (videoTypes.includes(fileExt)) {
content.style.width = '90vw';
content.style.height = '80vh';
content.style.maxWidth = '1200px';
content.style.maxHeight = '800px';
} else if (isPDF) {
content.style.width = '90vw';
content.style.height = '90vh';
content.style.maxWidth = '1200px';
content.style.maxHeight = '900px';
frame.classList.add('pdf');
} else {
content.style.width = '80vw';
content.style.height = '80vh';
content.style.maxWidth = '1000px';
content.style.maxHeight = '800px';
}
frame.src = fileUrl;
} }
// Просто открываем файл напрямую в iframe
frame.src = fileUrl;
// Показываем модальное окно
modal.style.display = 'block'; modal.style.display = 'block';
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
} }
function adjustModalForImage(img) {
const content = document.getElementById('previewContent');
const maxWidth = window.innerWidth * 0.95;
const maxHeight = window.innerHeight * 0.95;
const imgWidth = img.naturalWidth;
const imgHeight = img.naturalHeight;
console.log(`Image size: ${imgWidth}x${imgHeight}, Screen limits: ${maxWidth}x${maxHeight}`);
let scale = 1;
if (imgWidth > maxWidth) {
scale = Math.min(scale, maxWidth / imgWidth);
}
if (imgHeight > maxHeight) {
scale = Math.min(scale, maxHeight / imgHeight);
}
const displayWidth = imgWidth * scale;
const displayHeight = imgHeight * scale;
console.log(`Display size: ${displayWidth}x${displayHeight}, Scale: ${scale}`);
content.style.width = (displayWidth + 20) + 'px';
content.style.height = (displayHeight + 80) + 'px';
content.style.margin = 'auto';
content.style.position = 'absolute';
content.style.left = '50%';
content.style.top = '50%';
content.style.transform = 'translate(-50%, -50%)';
}
function closePreview() { function closePreview() {
const modal = document.getElementById('previewModal'); const modal = document.getElementById('previewModal');
const frame = document.getElementById('previewFrame'); const frame = document.getElementById('previewFrame');
const content = document.getElementById('previewContent'); const content = document.getElementById('previewContent');
// Скрываем модальное окно и сбрасываем iframe
modal.style.display = 'none'; modal.style.display = 'none';
frame.src = ''; frame.src = '';
frame.classList.remove('pdf'); frame.classList.remove('pdf');
// Сбрасываем стили
content.style.width = ''; content.style.width = '';
content.style.height = ''; content.style.height = '';
content.style.maxWidth = ''; content.style.maxWidth = '';
content.style.maxHeight = ''; content.style.maxHeight = '';
content.style.margin = '';
content.style.position = '';
content.style.left = '';
content.style.top = '';
content.style.transform = '';
const imgContainer = document.getElementById('previewImageContainer');
if (imgContainer) {
imgContainer.style.display = 'none';
imgContainer.innerHTML = '';
}
document.body.style.overflow = 'auto'; document.body.style.overflow = 'auto';
} }
// Закрытие модального окна по клику вне контента
document.getElementById('previewModal').addEventListener('click', function(e) { document.getElementById('previewModal').addEventListener('click', function(e) {
if (e.target === this) { if (e.target === this) {
closePreview(); closePreview();
} }
}); });
// Закрытие по ESC
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') { if (e.key === 'Escape') {
closePreview(); closePreview();