Update app.py
Browse files
app.py
CHANGED
|
@@ -672,47 +672,170 @@ def feed():
|
|
| 672 |
<div class="search-container">
|
| 673 |
<form method="POST">
|
| 674 |
<input type="text" name="search" class="search-input" placeholder="Search posts..." value="{{ search_query }}">
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
<
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
}
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 709 |
'''
|
|
|
|
| 710 |
return render_template_string(html, CRITICAL_CSS=CRITICAL_CSS, FULL_CSS_BASE64=base64.b64encode(FULL_CSS.encode()).decode(),
|
| 711 |
NAV_HTML=NAV_HTML, is_user_online=lambda u: is_user_online(data, u), posts=posts,
|
| 712 |
is_authenticated=is_authenticated, username=username, repo_id=REPO_ID,
|
| 713 |
search_query=search_query, unread_count=unread_count, user_count=user_count,
|
| 714 |
private_unread_count=private_unread_count, is_online=is_online)
|
| 715 |
-
|
| 716 |
# Страница поста
|
| 717 |
@app.route('/post/<post_id>', methods=['GET', 'POST'])
|
| 718 |
def post_page(post_id):
|
|
|
|
| 672 |
<div class="search-container">
|
| 673 |
<form method="POST">
|
| 674 |
<input type="text" name="search" class="search-input" placeholder="Search posts..." value="{{ search_query }}">
|
| 675 |
+
# Лента
|
| 676 |
+
@app.route('/', methods=['GET', 'POST'])
|
| 677 |
+
def feed():
|
| 678 |
+
data = load_data()
|
| 679 |
+
username = session.get('username', None)
|
| 680 |
+
if username:
|
| 681 |
+
update_last_seen(data, username)
|
| 682 |
+
posts = sorted(data.get('posts', []), key=lambda x: datetime.strptime(x['upload_date'], '%Y-%m-%d %H:%M:%S'), reverse=True)
|
| 683 |
+
is_authenticated = 'username' in session
|
| 684 |
+
unread_count = get_unread_count(data, username) if is_authenticated else 0
|
| 685 |
+
private_unread_count = get_private_unread_count(data, username) if is_authenticated else 0
|
| 686 |
+
user_count = len(data['users'])
|
| 687 |
+
is_online = is_user_online(data, username) if is_authenticated else False
|
| 688 |
+
|
| 689 |
+
search_query = request.form.get('search', '').strip().lower() if request.method == 'POST' else request.args.get('search', '').strip().lower()
|
| 690 |
+
if search_query:
|
| 691 |
+
posts = [post for post in posts if search_query in post['title'].lower() or search_query in post['description'].lower()]
|
| 692 |
+
|
| 693 |
+
html = '''
|
| 694 |
+
<!DOCTYPE html>
|
| 695 |
+
<html lang="en">
|
| 696 |
+
<head>
|
| 697 |
+
<meta charset="UTF-8">
|
| 698 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 699 |
+
<meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
|
| 700 |
+
<meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
|
| 701 |
+
<title>{% block title %}Adusis - QoS, BBC, BNWO HUB{% endblock %}</title>
|
| 702 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
|
| 703 |
+
<style>{{ CRITICAL_CSS }}</style>
|
| 704 |
+
<link rel="stylesheet" href="data:text/css;base64,{{ FULL_CSS_BASE64 }}" media="print" onload="this.media='all'">
|
| 705 |
+
</head>
|
| 706 |
+
<body>
|
| 707 |
+
<button class="menu-btn" onclick="toggleSidebar()">☰</button>
|
| 708 |
+
{{ NAV_HTML | safe }}
|
| 709 |
+
<button class="theme-toggle" onclick="toggleTheme()">🌙</button>
|
| 710 |
+
<div class="container">
|
| 711 |
+
{% block content %}
|
| 712 |
+
<style>
|
| 713 |
+
h1 {
|
| 714 |
+
font-size: 2.2em;
|
| 715 |
+
font-weight: 800;
|
| 716 |
+
margin-bottom: 25px;
|
| 717 |
+
background: linear-gradient(135deg, var(--primary), var(--accent));
|
| 718 |
+
-webkit-background-clip: text;
|
| 719 |
+
color: transparent;
|
| 720 |
+
animation: slideIn 0.5s ease;
|
| 721 |
+
}
|
| 722 |
+
.search-container {
|
| 723 |
+
max-width: 600px;
|
| 724 |
+
margin: 0 auto 30px;
|
| 725 |
+
position: relative;
|
| 726 |
+
}
|
| 727 |
+
.search-input {
|
| 728 |
+
padding-right: 40px;
|
| 729 |
+
background: var(--card-bg-light);
|
| 730 |
+
border-radius: 12px;
|
| 731 |
+
}
|
| 732 |
+
body.dark .search-input { background: var(--card-bg-dark); }
|
| 733 |
+
.search-btn {
|
| 734 |
+
position: absolute;
|
| 735 |
+
right: 5px;
|
| 736 |
+
top: 50%;
|
| 737 |
+
transform: translateY(-50%);
|
| 738 |
+
padding: 8px 12px;
|
| 739 |
+
}
|
| 740 |
+
.post-grid {
|
| 741 |
+
display: grid;
|
| 742 |
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
| 743 |
+
gap: 20px;
|
| 744 |
+
}
|
| 745 |
+
.post-item {
|
| 746 |
+
background: var(--card-bg-light);
|
| 747 |
+
padding: 15px;
|
| 748 |
+
border-radius: 15px;
|
| 749 |
+
box-shadow: var(--shadow);
|
| 750 |
+
transition: var(--transition);
|
| 751 |
+
text-decoration: none;
|
| 752 |
+
color: var(--text-light);
|
| 753 |
+
animation: fadeIn 0.5s ease;
|
| 754 |
+
}
|
| 755 |
+
body.dark .post-item { background: var(--card-bg-dark); color: var(--text-dark); }
|
| 756 |
+
.post-item:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); }
|
| 757 |
+
.post-preview {
|
| 758 |
+
width: 100%;
|
| 759 |
+
height: 200px;
|
| 760 |
+
object-fit: cover;
|
| 761 |
+
border-radius: 10px;
|
| 762 |
+
margin-bottom: 15px;
|
| 763 |
+
}
|
| 764 |
+
.post-item h2 { font-size: 1.3em; font-weight: 600; margin-bottom: 10px; }
|
| 765 |
+
.post-item p { font-size: 0.95em; margin-bottom: 10px; }
|
| 766 |
+
.stats { font-size: 0.85em; color: rgba(0, 0, 0, 0.6); }
|
| 767 |
+
body.dark .stats { color: rgba(255, 255, 255, 0.6); }
|
| 768 |
+
.username-link { color: var(--primary); font-weight: 600; text-decoration: none; }
|
| 769 |
+
.username-link:hover { color: var(--accent); }
|
| 770 |
+
@media (max-width: 480px) {
|
| 771 |
+
.post-grid { grid-template-columns: 1fr; }
|
| 772 |
+
.post-preview { height: 180px; }
|
| 773 |
+
}
|
| 774 |
+
</style>
|
| 775 |
+
<h1>Content Feed</h1>
|
| 776 |
+
<div class="search-container">
|
| 777 |
+
<form method="POST">
|
| 778 |
+
<input type="text" name="search" class="search-input" placeholder="Search posts..." value="{{ search_query }}">
|
| 779 |
+
<button type="submit" class="btn search-btn">🔍</button>
|
| 780 |
+
</form>
|
| 781 |
+
</div>
|
| 782 |
+
<div class="post-grid">
|
| 783 |
+
{% for post in posts %}
|
| 784 |
+
<a href="{{ url_for('post_page', post_id=post['id']) }}" class="post-item">
|
| 785 |
+
{% if post['type'] == 'video' %}
|
| 786 |
+
<video class="post-preview" preload="metadata" muted loading="lazy">
|
| 787 |
+
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" type="video/mp4">
|
| 788 |
+
</video>
|
| 789 |
+
{% else %}
|
| 790 |
+
<img class="post-preview" src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ post['type'] }}s/{{ post['filename'] }}" alt="{{ post['title'] }}" loading="lazy" onclick="openModal(this.src, event, '{{ post['id'] }}')">
|
| 791 |
+
{% endif %}
|
| 792 |
+
<h2>{{ post['title'] }}</h2>
|
| 793 |
+
<p>{{ post['description'] }}</p>
|
| 794 |
+
<p>By: <a href="{{ url_for('user_profile', username=post['uploader']) }}" class="username-link">{{ post['uploader'] }}</a> <span class="status-dot {{ 'online' if is_user_online(post['uploader']) else 'offline' }}"></span> | {{ post['upload_date'] }}</p>
|
| 795 |
+
<p class="stats">Views: {{ post['views'] }} | Likes: {{ post['likes']|length }}</p>
|
| 796 |
+
</a>
|
| 797 |
+
{% endfor %}
|
| 798 |
+
</div>
|
| 799 |
+
{% endblock %}
|
| 800 |
+
</div>
|
| 801 |
+
<div class="modal" id="modal" onclick="closeModal(event)">
|
| 802 |
+
<img id="modalImage" src="" alt="Modal content">
|
| 803 |
+
</div>
|
| 804 |
+
<script>
|
| 805 |
+
function toggleSidebar() { document.getElementById('sidebar').classList.toggle('active'); }
|
| 806 |
+
function toggleTheme() {
|
| 807 |
+
document.body.classList.toggle('dark');
|
| 808 |
+
localStorage.setItem('theme', document.body.classList.contains('dark') ? 'dark' : 'light');
|
| 809 |
+
}
|
| 810 |
+
function openModal(src, event, postId) {
|
| 811 |
+
event.preventDefault();
|
| 812 |
+
const modal = document.getElementById('modal');
|
| 813 |
+
const modalImg = document.getElementById('modalImage');
|
| 814 |
+
modal.style.display = 'flex';
|
| 815 |
+
modalImg.src = src;
|
| 816 |
+
if (postId) fetch('/increment_view/' + postId, { method: 'POST' });
|
| 817 |
+
}
|
| 818 |
+
function closeModal(event) {
|
| 819 |
+
if (event.target.tagName !== 'IMG') document.getElementById('modal').style.display = 'none';
|
| 820 |
+
}
|
| 821 |
+
window.onload = () => {
|
| 822 |
+
if (localStorage.getItem('theme') === 'dark') document.body.classList.add('dark');
|
| 823 |
+
const videos = document.querySelectorAll('video');
|
| 824 |
+
videos.forEach(v => {
|
| 825 |
+
v.addEventListener('loadedmetadata', () => { v.currentTime = Math.random() * v.duration; });
|
| 826 |
+
});
|
| 827 |
+
};
|
| 828 |
+
</script>
|
| 829 |
+
{% block scripts %}{% endblock %}
|
| 830 |
+
</body>
|
| 831 |
+
</html>
|
| 832 |
'''
|
| 833 |
+
import base64
|
| 834 |
return render_template_string(html, CRITICAL_CSS=CRITICAL_CSS, FULL_CSS_BASE64=base64.b64encode(FULL_CSS.encode()).decode(),
|
| 835 |
NAV_HTML=NAV_HTML, is_user_online=lambda u: is_user_online(data, u), posts=posts,
|
| 836 |
is_authenticated=is_authenticated, username=username, repo_id=REPO_ID,
|
| 837 |
search_query=search_query, unread_count=unread_count, user_count=user_count,
|
| 838 |
private_unread_count=private_unread_count, is_online=is_online)
|
|
|
|
| 839 |
# Страница поста
|
| 840 |
@app.route('/post/<post_id>', methods=['GET', 'POST'])
|
| 841 |
def post_page(post_id):
|