Eluza133 commited on
Commit
4a08a1a
·
verified ·
1 Parent(s): c55da9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -171
app.py CHANGED
@@ -359,6 +359,7 @@ NAV_HTML = '''
359
  </aside>
360
  '''
361
 
 
362
  BASE_HTML = '''
363
  <!DOCTYPE html>
364
  <html lang="en">
@@ -367,7 +368,7 @@ BASE_HTML = '''
367
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
368
  <meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
369
  <meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
370
- <title>{% block title %}{% endblock %} - Content Hub</title>
371
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
372
  <style>{{ CRITICAL_CSS }}</style>
373
  <link rel="stylesheet" href="data:text/css;base64,{{ FULL_CSS_BASE64 }}" media="print" onload="this.media='all'">
@@ -434,7 +435,7 @@ def register():
434
  is_online = is_user_online(data, username) if is_authenticated else False
435
 
436
  html = BASE_HTML + '''
437
- {% block title %}Register{% endblock %}
438
  {% block content %}
439
  <style>
440
  .auth-container {
@@ -513,7 +514,7 @@ def login():
513
  is_online = is_user_online(data, username) if is_authenticated else False
514
 
515
  html = BASE_HTML + '''
516
- {% block title %}Login{% endblock %}
517
  {% block content %}
518
  <style>
519
  .auth-container {
@@ -672,170 +673,47 @@ 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
- @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):
@@ -869,7 +747,7 @@ def post_page(post_id):
869
  save_data(data)
870
 
871
  html = BASE_HTML + '''
872
- {% block title %}{{ post['title'] }}{% endblock %}
873
  {% block content %}
874
  <style>
875
  .post-container {
@@ -997,7 +875,7 @@ def profile():
997
  return redirect(url_for('profile'))
998
 
999
  html = BASE_HTML + '''
1000
- {% block title %}Profile - {{ username }}{% endblock %}
1001
  {% block content %}
1002
  <style>
1003
  .profile-header {
@@ -1131,7 +1009,7 @@ def user_profile(username):
1131
  last_seen = user_data.get('last_seen', 'Never')
1132
 
1133
  html = BASE_HTML + '''
1134
- {% block title %}Profile - {{ username }}{% endblock %}
1135
  {% block content %}
1136
  <style>
1137
  .profile-header {
@@ -1286,7 +1164,7 @@ def upload():
1286
  return redirect(url_for('profile'))
1287
 
1288
  html = BASE_HTML + '''
1289
- {% block title %}Upload Content{% endblock %}
1290
  {% block content %}
1291
  <style>
1292
  .upload-container {
@@ -1403,7 +1281,7 @@ def chat():
1403
  return redirect(url_for('chat'))
1404
 
1405
  html = BASE_HTML + '''
1406
- {% block title %}General Chat{% endblock %}
1407
  {% block content %}
1408
  <style>
1409
  .chat-container {
@@ -1509,7 +1387,7 @@ def users():
1509
  user_list = [u for u in user_list if search_query in u[0].lower()]
1510
 
1511
  html = BASE_HTML + '''
1512
- {% block title %}Users{% endblock %}
1513
  {% block content %}
1514
  <style>
1515
  .users-container {
@@ -1607,7 +1485,7 @@ def messages():
1607
  }
1608
 
1609
  html = BASE_HTML + '''
1610
- {% block title %}Messages{% endblock %}
1611
  {% block content %}
1612
  <style>
1613
  .messages-container {
@@ -1621,7 +1499,7 @@ def messages():
1621
  body.dark .messages-container { background: var(--card-bg-dark); }
1622
  h1 { font-size: 2em; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; color: transparent; margin-bottom: 20px; }
1623
  .dialog-list { display: flex; flex-direction: column; gap: 10px; }
1624
- .dialog-item { background: var(--card-bg-light); padding: 15px; border-radius: 10px; box-shadow: var(--shadow); transition: var(--transition); display: flex align-items: center; gap: 10px; }
1625
  body.dark .dialog-item { background: var(--card-bg-dark); }
1626
  .dialog-item:hover { transform: translateY(-3px); }
1627
  .dialog-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
@@ -1741,7 +1619,7 @@ def private_chat(recipient):
1741
  avatar = data['users'][username].get('avatar') if is_authenticated else None
1742
 
1743
  html = BASE_HTML + '''
1744
- {% block title %}Chat with {{ recipient }}{% endblock %}
1745
  {% block content %}
1746
  <style>
1747
  .chat-container {
@@ -1881,7 +1759,7 @@ def admin_panel():
1881
  return redirect(url_for('admin_panel'))
1882
 
1883
  html = BASE_HTML + '''
1884
- {% block title %}Admin Panel{% endblock %}
1885
  {% block content %}
1886
  <style>
1887
  .admin-container {
 
359
  </aside>
360
  '''
361
 
362
+ # Исправленный базовый шаблон - убираем дублирование title
363
  BASE_HTML = '''
364
  <!DOCTYPE html>
365
  <html lang="en">
 
368
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
369
  <meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
370
  <meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
371
+ <title>{% block title %}{% endblock %}</title>
372
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
373
  <style>{{ CRITICAL_CSS }}</style>
374
  <link rel="stylesheet" href="data:text/css;base64,{{ FULL_CSS_BASE64 }}" media="print" onload="this.media='all'">
 
435
  is_online = is_user_online(data, username) if is_authenticated else False
436
 
437
  html = BASE_HTML + '''
438
+ {% block title %}Register - Content Hub{% endblock %}
439
  {% block content %}
440
  <style>
441
  .auth-container {
 
514
  is_online = is_user_online(data, username) if is_authenticated else False
515
 
516
  html = BASE_HTML + '''
517
+ {% block title %}Login - Content Hub{% endblock %}
518
  {% block content %}
519
  <style>
520
  .auth-container {
 
673
  <div class="search-container">
674
  <form method="POST">
675
  <input type="text" name="search" class="search-input" placeholder="Search posts..." value="{{ search_query }}">
676
+ <button type="submit" class="btn search-btn">🔍</button>
677
+ </form>
678
+ </div>
679
+ <div class="post-grid">
680
+ {% for post in posts %}
681
+ <a href="{{ url_for('post_page', post_id=post['id']) }}" class="post-item">
682
+ {% if post['type'] == 'video' %}
683
+ <video class="post-preview" preload="metadata" muted loading="lazy">
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'] }}" loading="lazy" onclick="openModal(this.src, event, '{{ post['id'] }}')">
688
+ {% endif %}
689
+ <h2>{{ post['title'] }}</h2>
690
+ <p>{{ post['description'] }}</p>
691
+ <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>
692
+ <p class="stats">Views: {{ post['views'] }} | Likes: {{ post['likes']|length }}</p>
693
+ </a>
694
+ {% endfor %}
695
+ </div>
696
+ {% block scripts %}
697
+ <script>
698
+ function openModal(src, event, postId) {
699
+ event.preventDefault();
700
+ openModal(src);
701
+ fetch('/increment_view/' + postId, { method: 'POST' });
702
+ }
703
+ const videos = document.querySelectorAll('video');
704
+ videos.forEach(v => {
705
+ v.addEventListener('loadedmetadata', () => { v.currentTime = Math.random() * v.duration; });
706
+ });
707
+ </script>
708
+ {% endblock %}
709
+ {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  '''
 
711
  return render_template_string(html, CRITICAL_CSS=CRITICAL_CSS, FULL_CSS_BASE64=base64.b64encode(FULL_CSS.encode()).decode(),
712
  NAV_HTML=NAV_HTML, is_user_online=lambda u: is_user_online(data, u), posts=posts,
713
  is_authenticated=is_authenticated, username=username, repo_id=REPO_ID,
714
  search_query=search_query, unread_count=unread_count, user_count=user_count,
715
  private_unread_count=private_unread_count, is_online=is_online)
716
+
717
  # Страница поста
718
  @app.route('/post/<post_id>', methods=['GET', 'POST'])
719
  def post_page(post_id):
 
747
  save_data(data)
748
 
749
  html = BASE_HTML + '''
750
+ {% block title %}{{ post['title'] }} - Content Hub{% endblock %}
751
  {% block content %}
752
  <style>
753
  .post-container {
 
875
  return redirect(url_for('profile'))
876
 
877
  html = BASE_HTML + '''
878
+ {% block title %}Profile - {{ username }} - Content Hub{% endblock %}
879
  {% block content %}
880
  <style>
881
  .profile-header {
 
1009
  last_seen = user_data.get('last_seen', 'Never')
1010
 
1011
  html = BASE_HTML + '''
1012
+ {% block title %}Profile - {{ username }} - Content Hub{% endblock %}
1013
  {% block content %}
1014
  <style>
1015
  .profile-header {
 
1164
  return redirect(url_for('profile'))
1165
 
1166
  html = BASE_HTML + '''
1167
+ {% block title %}Upload Content - Content Hub{% endblock %}
1168
  {% block content %}
1169
  <style>
1170
  .upload-container {
 
1281
  return redirect(url_for('chat'))
1282
 
1283
  html = BASE_HTML + '''
1284
+ {% block title %}General Chat - Content Hub{% endblock %}
1285
  {% block content %}
1286
  <style>
1287
  .chat-container {
 
1387
  user_list = [u for u in user_list if search_query in u[0].lower()]
1388
 
1389
  html = BASE_HTML + '''
1390
+ {% block title %}Users - Content Hub{% endblock %}
1391
  {% block content %}
1392
  <style>
1393
  .users-container {
 
1485
  }
1486
 
1487
  html = BASE_HTML + '''
1488
+ {% block title %}Messages - Content Hub{% endblock %}
1489
  {% block content %}
1490
  <style>
1491
  .messages-container {
 
1499
  body.dark .messages-container { background: var(--card-bg-dark); }
1500
  h1 { font-size: 2em; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; color: transparent; margin-bottom: 20px; }
1501
  .dialog-list { display: flex; flex-direction: column; gap: 10px; }
1502
+ .dialog-item { background: var(--card-bg-light); padding: 15px; border-radius: 10px; box-shadow: var(--shadow); transition: var(--transition); display: flex; align-items: center; gap: 10px; }
1503
  body.dark .dialog-item { background: var(--card-bg-dark); }
1504
  .dialog-item:hover { transform: translateY(-3px); }
1505
  .dialog-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
 
1619
  avatar = data['users'][username].get('avatar') if is_authenticated else None
1620
 
1621
  html = BASE_HTML + '''
1622
+ {% block title %}Chat with {{ recipient }} - Content Hub{% endblock %}
1623
  {% block content %}
1624
  <style>
1625
  .chat-container {
 
1759
  return redirect(url_for('admin_panel'))
1760
 
1761
  html = BASE_HTML + '''
1762
+ {% block title %}Admin Panel - Content Hub{% endblock %}
1763
  {% block content %}
1764
  <style>
1765
  .admin-container {