Update app.py
Browse files
app.py
CHANGED
|
@@ -308,7 +308,9 @@ def feed():
|
|
| 308 |
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
|
| 309 |
.post-item { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 15px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); text-decoration: none; color: #2d3748; transition: transform 0.3s ease; }
|
| 310 |
.post-item:hover { transform: scale(1.02); }
|
| 311 |
-
.post-preview { width: 100%; border-radius: 8px; height: 200px; object-fit: cover; }
|
|
|
|
|
|
|
| 312 |
.stats { font-size: 0.9em; color: #666; margin-top: 5px; }
|
| 313 |
@media (max-width: 768px) {
|
| 314 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
|
@@ -335,7 +337,7 @@ def feed():
|
|
| 335 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 336 |
</video>
|
| 337 |
{% else %}
|
| 338 |
-
<img class="post-preview" src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}">
|
| 339 |
{% endif %}
|
| 340 |
<h2>{{ post['title'] }}</h2>
|
| 341 |
<p>{{ post['description'] }}</p>
|
|
@@ -345,10 +347,30 @@ def feed():
|
|
| 345 |
{% endfor %}
|
| 346 |
</div>
|
| 347 |
</div>
|
|
|
|
|
|
|
|
|
|
| 348 |
<script>
|
| 349 |
function toggleSidebar() {
|
| 350 |
document.getElementById('sidebar').classList.toggle('active');
|
| 351 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
document.addEventListener('DOMContentLoaded', function() {
|
| 353 |
const videos = document.querySelectorAll('.post-preview');
|
| 354 |
videos.forEach(video => {
|
|
@@ -360,6 +382,45 @@ def feed():
|
|
| 360 |
});
|
| 361 |
}
|
| 362 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
});
|
| 364 |
</script>
|
| 365 |
</body>
|
|
@@ -415,13 +476,15 @@ def post_page(post_id):
|
|
| 415 |
.logout-btn:hover { background: rgba(239, 68, 68, 0.3); color: #dc2626; }
|
| 416 |
.menu-btn { display: none; font-size: 28px; background: rgba(255, 255, 255, 0.9); border: none; color: #3b82f6; cursor: pointer; position: fixed; top: 15px; left: 15px; z-index: 1001; padding: 5px 10px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
| 417 |
.container { max-width: 800px; margin: 20px auto 20px 270px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); transition: margin-left 0.3s ease; }
|
| 418 |
-
video, img { width: 100%; border-radius: 8px; max-height: 400px; object-fit: cover; }
|
| 419 |
.btn { display: inline-block; margin: 10px 0; padding: 12px 20px; background: rgba(59, 130, 246, 0.9); color: white; text-decoration: none; border-radius: 8px; border: none; cursor: pointer; transition: all 0.3s ease; }
|
| 420 |
.btn:hover { background: rgba(59, 130, 246, 1); transform: scale(1.05); }
|
| 421 |
.like-btn.liked { background: rgba(239, 68, 68, 0.9); }
|
| 422 |
.like-btn.liked:hover { background: rgba(239, 68, 68, 1); }
|
| 423 |
textarea { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #e2e8f0; border-radius: 8px; resize: vertical; background: rgba(255, 255, 255, 0.8); }
|
| 424 |
.comment { border-top: 1px solid #e2e8f0; padding: 10px 0; }
|
|
|
|
|
|
|
| 425 |
@media (max-width: 768px) {
|
| 426 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
| 427 |
.sidebar.active { transform: translateX(0); }
|
|
@@ -444,7 +507,7 @@ def post_page(post_id):
|
|
| 444 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 445 |
</video>
|
| 446 |
{% else %}
|
| 447 |
-
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}">
|
| 448 |
{% endif %}
|
| 449 |
<p>{{ post['description'] }}</p>
|
| 450 |
<p>Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}</p>
|
|
@@ -471,10 +534,69 @@ def post_page(post_id):
|
|
| 471 |
<p><a href="{{ url_for('login') }}">Войдите</a>, чтобы ставить лайки и комментировать.</p>
|
| 472 |
{% endif %}
|
| 473 |
</div>
|
|
|
|
|
|
|
|
|
|
| 474 |
<script>
|
| 475 |
function toggleSidebar() {
|
| 476 |
document.getElementById('sidebar').classList.toggle('active');
|
| 477 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
</script>
|
| 479 |
</body>
|
| 480 |
</html>
|
|
@@ -524,12 +646,14 @@ def profile():
|
|
| 524 |
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
|
| 525 |
.post-item { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 15px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); transition: transform 0.3s ease; }
|
| 526 |
.post-item:hover { transform: scale(1.02); }
|
| 527 |
-
.post-preview { width: 100%; border-radius: 8px; height: 200px; object-fit: cover; }
|
| 528 |
.btn { display: block; margin: 10px 0; padding: 12px 20px; background: rgba(59, 130, 246, 0.9); color: white; text-decoration: none; border-radius: 8px; border: none; cursor: pointer; transition: all 0.3s ease; }
|
| 529 |
.btn:hover { background: rgba(59, 130, 246, 1); transform: scale(1.05); }
|
| 530 |
.delete-btn { background: rgba(239, 68, 68, 0.9); }
|
| 531 |
.delete-btn:hover { background: rgba(239, 68, 68, 1); }
|
| 532 |
.stats { font-size: 0.9em; color: #666; margin-top: 5px; }
|
|
|
|
|
|
|
| 533 |
@media (max-width: 768px) {
|
| 534 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
| 535 |
.sidebar.active { transform: translateX(0); }
|
|
@@ -560,7 +684,7 @@ def profile():
|
|
| 560 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 561 |
</video>
|
| 562 |
{% else %}
|
| 563 |
-
<img class="post-preview" src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}">
|
| 564 |
{% endif %}
|
| 565 |
<h3>{{ post['title'] }}</h3>
|
| 566 |
</a>
|
|
@@ -578,10 +702,30 @@ def profile():
|
|
| 578 |
{% endif %}
|
| 579 |
</div>
|
| 580 |
</div>
|
|
|
|
|
|
|
|
|
|
| 581 |
<script>
|
| 582 |
function toggleSidebar() {
|
| 583 |
document.getElementById('sidebar').classList.toggle('active');
|
| 584 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
document.addEventListener('DOMContentLoaded', function() {
|
| 586 |
const videos = document.querySelectorAll('.post-preview');
|
| 587 |
videos.forEach(video => {
|
|
@@ -593,6 +737,45 @@ def profile():
|
|
| 593 |
});
|
| 594 |
}
|
| 595 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
});
|
| 597 |
</script>
|
| 598 |
</body>
|
|
|
|
| 308 |
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
|
| 309 |
.post-item { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 15px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); text-decoration: none; color: #2d3748; transition: transform 0.3s ease; }
|
| 310 |
.post-item:hover { transform: scale(1.02); }
|
| 311 |
+
.post-preview { width: 100%; border-radius: 8px; height: 200px; object-fit: cover; cursor: pointer; }
|
| 312 |
+
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; justify-content: center; align-items: center; }
|
| 313 |
+
.modal img { max-width: 90%; max-height: 90%; object-fit: contain; transform: scale(1); transition: transform 0.2s ease; }
|
| 314 |
.stats { font-size: 0.9em; color: #666; margin-top: 5px; }
|
| 315 |
@media (max-width: 768px) {
|
| 316 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
|
|
|
| 337 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 338 |
</video>
|
| 339 |
{% else %}
|
| 340 |
+
<img class="post-preview" src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}" onclick="openModal(this.src, event)">
|
| 341 |
{% endif %}
|
| 342 |
<h2>{{ post['title'] }}</h2>
|
| 343 |
<p>{{ post['description'] }}</p>
|
|
|
|
| 347 |
{% endfor %}
|
| 348 |
</div>
|
| 349 |
</div>
|
| 350 |
+
<div class="modal" id="imageModal" onclick="closeModal(event)">
|
| 351 |
+
<img id="modalImage" src="">
|
| 352 |
+
</div>
|
| 353 |
<script>
|
| 354 |
function toggleSidebar() {
|
| 355 |
document.getElementById('sidebar').classList.toggle('active');
|
| 356 |
}
|
| 357 |
+
|
| 358 |
+
function openModal(src, event) {
|
| 359 |
+
event.preventDefault();
|
| 360 |
+
const modal = document.getElementById('imageModal');
|
| 361 |
+
const modalImg = document.getElementById('modalImage');
|
| 362 |
+
modal.style.display = 'flex';
|
| 363 |
+
modalImg.src = src;
|
| 364 |
+
modalImg.style.transform = 'scale(1)';
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
function closeModal(event) {
|
| 368 |
+
if (event.target.tagName !== 'IMG') {
|
| 369 |
+
const modal = document.getElementById('imageModal');
|
| 370 |
+
modal.style.display = 'none';
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
document.addEventListener('DOMContentLoaded', function() {
|
| 375 |
const videos = document.querySelectorAll('.post-preview');
|
| 376 |
videos.forEach(video => {
|
|
|
|
| 382 |
});
|
| 383 |
}
|
| 384 |
});
|
| 385 |
+
|
| 386 |
+
const modalImg = document.getElementById('modalImage');
|
| 387 |
+
let scale = 1;
|
| 388 |
+
let startDistance = 0;
|
| 389 |
+
let lastTap = 0;
|
| 390 |
+
|
| 391 |
+
modalImg.addEventListener('dblclick', function() {
|
| 392 |
+
scale = scale === 1 ? 2 : 1;
|
| 393 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 394 |
+
});
|
| 395 |
+
|
| 396 |
+
modalImg.addEventListener('touchstart', function(e) {
|
| 397 |
+
if (e.touches.length === 2) {
|
| 398 |
+
startDistance = getDistance(e.touches[0], e.touches[1]);
|
| 399 |
+
} else if (e.touches.length === 1) {
|
| 400 |
+
const now = new Date().getTime();
|
| 401 |
+
if (now - lastTap < 300) {
|
| 402 |
+
scale = scale === 1 ? 2 : 1;
|
| 403 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 404 |
+
}
|
| 405 |
+
lastTap = now;
|
| 406 |
+
}
|
| 407 |
+
});
|
| 408 |
+
|
| 409 |
+
modalImg.addEventListener('touchmove', function(e) {
|
| 410 |
+
if (e.touches.length === 2) {
|
| 411 |
+
e.preventDefault();
|
| 412 |
+
const currentDistance = getDistance(e.touches[0], e.touches[1]);
|
| 413 |
+
scale = Math.max(1, Math.min(3, scale * (currentDistance / startDistance)));
|
| 414 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 415 |
+
startDistance = currentDistance;
|
| 416 |
+
}
|
| 417 |
+
});
|
| 418 |
+
|
| 419 |
+
function getDistance(touch1, touch2) {
|
| 420 |
+
const dx = touch1.pageX - touch2.pageX;
|
| 421 |
+
const dy = touch1.pageY - touch2.pageY;
|
| 422 |
+
return Math.sqrt(dx * dx + dy * dy);
|
| 423 |
+
}
|
| 424 |
});
|
| 425 |
</script>
|
| 426 |
</body>
|
|
|
|
| 476 |
.logout-btn:hover { background: rgba(239, 68, 68, 0.3); color: #dc2626; }
|
| 477 |
.menu-btn { display: none; font-size: 28px; background: rgba(255, 255, 255, 0.9); border: none; color: #3b82f6; cursor: pointer; position: fixed; top: 15px; left: 15px; z-index: 1001; padding: 5px 10px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
| 478 |
.container { max-width: 800px; margin: 20px auto 20px 270px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); transition: margin-left 0.3s ease; }
|
| 479 |
+
video, img { width: 100%; border-radius: 8px; max-height: 400px; object-fit: cover; cursor: pointer; }
|
| 480 |
.btn { display: inline-block; margin: 10px 0; padding: 12px 20px; background: rgba(59, 130, 246, 0.9); color: white; text-decoration: none; border-radius: 8px; border: none; cursor: pointer; transition: all 0.3s ease; }
|
| 481 |
.btn:hover { background: rgba(59, 130, 246, 1); transform: scale(1.05); }
|
| 482 |
.like-btn.liked { background: rgba(239, 68, 68, 0.9); }
|
| 483 |
.like-btn.liked:hover { background: rgba(239, 68, 68, 1); }
|
| 484 |
textarea { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #e2e8f0; border-radius: 8px; resize: vertical; background: rgba(255, 255, 255, 0.8); }
|
| 485 |
.comment { border-top: 1px solid #e2e8f0; padding: 10px 0; }
|
| 486 |
+
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; justify-content: center; align-items: center; }
|
| 487 |
+
.modal img { max-width: 90%; max-height: 90%; object-fit: contain; transform: scale(1); transition: transform 0.2s ease; }
|
| 488 |
@media (max-width: 768px) {
|
| 489 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
| 490 |
.sidebar.active { transform: translateX(0); }
|
|
|
|
| 507 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 508 |
</video>
|
| 509 |
{% else %}
|
| 510 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}" onclick="openModal(this.src)">
|
| 511 |
{% endif %}
|
| 512 |
<p>{{ post['description'] }}</p>
|
| 513 |
<p>Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}</p>
|
|
|
|
| 534 |
<p><a href="{{ url_for('login') }}">Войдите</a>, чтобы ставить лайки и комментировать.</p>
|
| 535 |
{% endif %}
|
| 536 |
</div>
|
| 537 |
+
<div class="modal" id="imageModal" onclick="closeModal(event)">
|
| 538 |
+
<img id="modalImage" src="">
|
| 539 |
+
</div>
|
| 540 |
<script>
|
| 541 |
function toggleSidebar() {
|
| 542 |
document.getElementById('sidebar').classList.toggle('active');
|
| 543 |
}
|
| 544 |
+
|
| 545 |
+
function openModal(src) {
|
| 546 |
+
const modal = document.getElementById('imageModal');
|
| 547 |
+
const modalImg = document.getElementById('modalImage');
|
| 548 |
+
modal.style.display = 'flex';
|
| 549 |
+
modalImg.src = src;
|
| 550 |
+
modalImg.style.transform = 'scale(1)';
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
function closeModal(event) {
|
| 554 |
+
if (event.target.tagName !== 'IMG') {
|
| 555 |
+
const modal = document.getElementById('imageModal');
|
| 556 |
+
modal.style.display = 'none';
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 561 |
+
const modalImg = document.getElementById('modalImage');
|
| 562 |
+
let scale = 1;
|
| 563 |
+
let startDistance = 0;
|
| 564 |
+
let lastTap = 0;
|
| 565 |
+
|
| 566 |
+
modalImg.addEventListener('dblclick', function() {
|
| 567 |
+
scale = scale === 1 ? 2 : 1;
|
| 568 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 569 |
+
});
|
| 570 |
+
|
| 571 |
+
modalImg.addEventListener('touchstart', function(e) {
|
| 572 |
+
if (e.touches.length === 2) {
|
| 573 |
+
startDistance = getDistance(e.touches[0], e.touches[1]);
|
| 574 |
+
} else if (e.touches.length === 1) {
|
| 575 |
+
const now = new Date().getTime();
|
| 576 |
+
if (now - lastTap < 300) {
|
| 577 |
+
scale = scale === 1 ? 2 : 1;
|
| 578 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 579 |
+
}
|
| 580 |
+
lastTap = now;
|
| 581 |
+
}
|
| 582 |
+
});
|
| 583 |
+
|
| 584 |
+
modalImg.addEventListener('touchmove', function(e) {
|
| 585 |
+
if (e.touches.length === 2) {
|
| 586 |
+
e.preventDefault();
|
| 587 |
+
const currentDistance = getDistance(e.touches[0], e.touches[1]);
|
| 588 |
+
scale = Math.max(1, Math.min(3, scale * (currentDistance / startDistance)));
|
| 589 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 590 |
+
startDistance = currentDistance;
|
| 591 |
+
}
|
| 592 |
+
});
|
| 593 |
+
|
| 594 |
+
function getDistance(touch1, touch2) {
|
| 595 |
+
const dx = touch1.pageX - touch2.pageX;
|
| 596 |
+
const dy = touch1.pageY - touch2.pageY;
|
| 597 |
+
return Math.sqrt(dx * dx + dy * dy);
|
| 598 |
+
}
|
| 599 |
+
});
|
| 600 |
</script>
|
| 601 |
</body>
|
| 602 |
</html>
|
|
|
|
| 646 |
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
|
| 647 |
.post-item { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); padding: 15px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); transition: transform 0.3s ease; }
|
| 648 |
.post-item:hover { transform: scale(1.02); }
|
| 649 |
+
.post-preview { width: 100%; border-radius: 8px; height: 200px; object-fit: cover; cursor: pointer; }
|
| 650 |
.btn { display: block; margin: 10px 0; padding: 12px 20px; background: rgba(59, 130, 246, 0.9); color: white; text-decoration: none; border-radius: 8px; border: none; cursor: pointer; transition: all 0.3s ease; }
|
| 651 |
.btn:hover { background: rgba(59, 130, 246, 1); transform: scale(1.05); }
|
| 652 |
.delete-btn { background: rgba(239, 68, 68, 0.9); }
|
| 653 |
.delete-btn:hover { background: rgba(239, 68, 68, 1); }
|
| 654 |
.stats { font-size: 0.9em; color: #666; margin-top: 5px; }
|
| 655 |
+
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; justify-content: center; align-items: center; }
|
| 656 |
+
.modal img { max-width: 90%; max-height: 90%; object-fit: contain; transform: scale(1); transition: transform 0.2s ease; }
|
| 657 |
@media (max-width: 768px) {
|
| 658 |
.sidebar { transform: translateX(-100%); width: 200px; }
|
| 659 |
.sidebar.active { transform: translateX(0); }
|
|
|
|
| 684 |
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 685 |
</video>
|
| 686 |
{% else %}
|
| 687 |
+
<img class="post-preview" src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}" onclick="openModal(this.src, event)">
|
| 688 |
{% endif %}
|
| 689 |
<h3>{{ post['title'] }}</h3>
|
| 690 |
</a>
|
|
|
|
| 702 |
{% endif %}
|
| 703 |
</div>
|
| 704 |
</div>
|
| 705 |
+
<div class="modal" id="imageModal" onclick="closeModal(event)">
|
| 706 |
+
<img id="modalImage" src="">
|
| 707 |
+
</div>
|
| 708 |
<script>
|
| 709 |
function toggleSidebar() {
|
| 710 |
document.getElementById('sidebar').classList.toggle('active');
|
| 711 |
}
|
| 712 |
+
|
| 713 |
+
function openModal(src, event) {
|
| 714 |
+
if (event) event.preventDefault();
|
| 715 |
+
const modal = document.getElementById('imageModal');
|
| 716 |
+
const modalImg = document.getElementById('modalImage');
|
| 717 |
+
modal.style.display = 'flex';
|
| 718 |
+
modalImg.src = src;
|
| 719 |
+
modalImg.style.transform = 'scale(1)';
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
function closeModal(event) {
|
| 723 |
+
if (event.target.tagName !== 'IMG') {
|
| 724 |
+
const modal = document.getElementById('imageModal');
|
| 725 |
+
modal.style.display = 'none';
|
| 726 |
+
}
|
| 727 |
+
}
|
| 728 |
+
|
| 729 |
document.addEventListener('DOMContentLoaded', function() {
|
| 730 |
const videos = document.querySelectorAll('.post-preview');
|
| 731 |
videos.forEach(video => {
|
|
|
|
| 737 |
});
|
| 738 |
}
|
| 739 |
});
|
| 740 |
+
|
| 741 |
+
const modalImg = document.getElementById('modalImage');
|
| 742 |
+
let scale = 1;
|
| 743 |
+
let startDistance = 0;
|
| 744 |
+
let lastTap = 0;
|
| 745 |
+
|
| 746 |
+
modalImg.addEventListener('dblclick', function() {
|
| 747 |
+
scale = scale === 1 ? 2 : 1;
|
| 748 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 749 |
+
});
|
| 750 |
+
|
| 751 |
+
modalImg.addEventListener('touchstart', function(e) {
|
| 752 |
+
if (e.touches.length === 2) {
|
| 753 |
+
startDistance = getDistance(e.touches[0], e.touches[1]);
|
| 754 |
+
} else if (e.touches.length === 1) {
|
| 755 |
+
const now = new Date().getTime();
|
| 756 |
+
if (now - lastTap < 300) {
|
| 757 |
+
scale = scale === 1 ? 2 : 1;
|
| 758 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 759 |
+
}
|
| 760 |
+
lastTap = now;
|
| 761 |
+
}
|
| 762 |
+
});
|
| 763 |
+
|
| 764 |
+
modalImg.addEventListener('touchmove', function(e) {
|
| 765 |
+
if (e.touches.length === 2) {
|
| 766 |
+
e.preventDefault();
|
| 767 |
+
const currentDistance = getDistance(e.touches[0], e.touches[1]);
|
| 768 |
+
scale = Math.max(1, Math.min(3, scale * (currentDistance / startDistance)));
|
| 769 |
+
modalImg.style.transform = `scale(${scale})`;
|
| 770 |
+
startDistance = currentDistance;
|
| 771 |
+
}
|
| 772 |
+
});
|
| 773 |
+
|
| 774 |
+
function getDistance(touch1, touch2) {
|
| 775 |
+
const dx = touch1.pageX - touch2.pageX;
|
| 776 |
+
const dy = touch1.pageY - touch2.pageY;
|
| 777 |
+
return Math.sqrt(dx * dx + dy * dy);
|
| 778 |
+
}
|
| 779 |
});
|
| 780 |
</script>
|
| 781 |
</body>
|