Update app.py
Browse files
app.py
CHANGED
|
@@ -1784,7 +1784,303 @@ def chat():
|
|
| 1784 |
<html lang="en">
|
| 1785 |
<head>
|
| 1786 |
<meta charset="UTF-8">
|
| 1787 |
-
<meta name="viewport" content="width=device-width, initial-scale=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1788 |
<meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
|
| 1789 |
<title>Users - Content Hub</title>
|
| 1790 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|
|
|
|
| 1784 |
<html lang="en">
|
| 1785 |
<head>
|
| 1786 |
<meta charset="UTF-8">
|
| 1787 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 1788 |
+
<meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
|
| 1789 |
+
<title>General Chat - Content Hub</title>
|
| 1790 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|
| 1791 |
+
<style>
|
| 1792 |
+
''' + BASE_STYLE + '''
|
| 1793 |
+
.container {
|
| 1794 |
+
max-width: 800px;
|
| 1795 |
+
background: var(--card-bg);
|
| 1796 |
+
padding: 25px;
|
| 1797 |
+
border-radius: 16px;
|
| 1798 |
+
box-shadow: var(--shadow);
|
| 1799 |
+
}
|
| 1800 |
+
body.dark .container {
|
| 1801 |
+
background: var(--card-bg-dark);
|
| 1802 |
+
}
|
| 1803 |
+
h1 {
|
| 1804 |
+
font-size: 2em;
|
| 1805 |
+
font-weight: 800;
|
| 1806 |
+
margin-bottom: 20px;
|
| 1807 |
+
background: linear-gradient(135deg, var(--primary), var(--accent));
|
| 1808 |
+
-webkit-background-clip: text;
|
| 1809 |
+
color: transparent;
|
| 1810 |
+
}
|
| 1811 |
+
.messages {
|
| 1812 |
+
max-height: 450px;
|
| 1813 |
+
overflow-y: auto;
|
| 1814 |
+
padding: 12px;
|
| 1815 |
+
background: var(--glass-bg);
|
| 1816 |
+
border-radius: 12px;
|
| 1817 |
+
margin-bottom: 15px;
|
| 1818 |
+
scroll-behavior: smooth;
|
| 1819 |
+
}
|
| 1820 |
+
.message {
|
| 1821 |
+
margin-bottom: 12px;
|
| 1822 |
+
display: flex;
|
| 1823 |
+
align-items: flex-start;
|
| 1824 |
+
gap: 10px;
|
| 1825 |
+
max-width: 70%;
|
| 1826 |
+
}
|
| 1827 |
+
.message.sent {
|
| 1828 |
+
margin-left: auto;
|
| 1829 |
+
flex-direction: row-reverse;
|
| 1830 |
+
}
|
| 1831 |
+
.message.received {
|
| 1832 |
+
margin-right: auto;
|
| 1833 |
+
}
|
| 1834 |
+
.message-avatar {
|
| 1835 |
+
width: 35px;
|
| 1836 |
+
height: 35px;
|
| 1837 |
+
border-radius: 50%;
|
| 1838 |
+
object-fit: cover;
|
| 1839 |
+
box-shadow: var(--shadow);
|
| 1840 |
+
loading: lazy;
|
| 1841 |
+
}
|
| 1842 |
+
.message-content {
|
| 1843 |
+
padding: 10px 15px;
|
| 1844 |
+
background: var(--card-bg);
|
| 1845 |
+
border-radius: 10px;
|
| 1846 |
+
font-size: 0.9em;
|
| 1847 |
+
transition: var(--transition);
|
| 1848 |
+
box-shadow: var(--shadow);
|
| 1849 |
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
| 1850 |
+
word-wrap: break-word;
|
| 1851 |
+
}
|
| 1852 |
+
body.dark .message-content {
|
| 1853 |
+
background: var(--card-bg-dark);
|
| 1854 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
| 1855 |
+
}
|
| 1856 |
+
.message.sent .message-content {
|
| 1857 |
+
border-color: var(--primary);
|
| 1858 |
+
}
|
| 1859 |
+
.message.received .message-content {
|
| 1860 |
+
border-color: var(--secondary);
|
| 1861 |
+
}
|
| 1862 |
+
.message:hover .message-content {
|
| 1863 |
+
transform: translateY(-2px);
|
| 1864 |
+
}
|
| 1865 |
+
.message .sender {
|
| 1866 |
+
color: var(--primary);
|
| 1867 |
+
font-weight: 600;
|
| 1868 |
+
text-decoration: none;
|
| 1869 |
+
}
|
| 1870 |
+
.message .sender:hover {
|
| 1871 |
+
color: var(--accent);
|
| 1872 |
+
}
|
| 1873 |
+
.message .time {
|
| 1874 |
+
font-size: 0.8em;
|
| 1875 |
+
color: rgba(0, 0, 0, 0.5);
|
| 1876 |
+
margin-top: 5px;
|
| 1877 |
+
display: block;
|
| 1878 |
+
}
|
| 1879 |
+
body.dark .message .time {
|
| 1880 |
+
color: rgba(255, 255, 255, 0.5);
|
| 1881 |
+
}
|
| 1882 |
+
.message img, .message video {
|
| 1883 |
+
max-width: 250px;
|
| 1884 |
+
max-height: 250px;
|
| 1885 |
+
width: 100%;
|
| 1886 |
+
border-radius: 8px;
|
| 1887 |
+
margin-top: 8px;
|
| 1888 |
+
display: block;
|
| 1889 |
+
loading: lazy;
|
| 1890 |
+
}
|
| 1891 |
+
.message a {
|
| 1892 |
+
color: var(--primary);
|
| 1893 |
+
text-decoration: none;
|
| 1894 |
+
}
|
| 1895 |
+
.message a:hover {
|
| 1896 |
+
color: var(--accent);
|
| 1897 |
+
}
|
| 1898 |
+
.message-form {
|
| 1899 |
+
margin-top: 15px;
|
| 1900 |
+
display: flex;
|
| 1901 |
+
flex-direction: column;
|
| 1902 |
+
gap: 10px;
|
| 1903 |
+
}
|
| 1904 |
+
.post-select {
|
| 1905 |
+
padding: 10px;
|
| 1906 |
+
border-radius: 10px;
|
| 1907 |
+
background: var(--glass-bg);
|
| 1908 |
+
color: var(--text-light);
|
| 1909 |
+
}
|
| 1910 |
+
body.dark .post-select {
|
| 1911 |
+
color: var(--text-dark);
|
| 1912 |
+
}
|
| 1913 |
+
@media (max-width: 900px) {
|
| 1914 |
+
.message-avatar {
|
| 1915 |
+
width: 30px;
|
| 1916 |
+
height: 30px;
|
| 1917 |
+
}
|
| 1918 |
+
.message {
|
| 1919 |
+
max-width: 80%;
|
| 1920 |
+
}
|
| 1921 |
+
}
|
| 1922 |
+
@media (max-width: 480px) {
|
| 1923 |
+
.container {
|
| 1924 |
+
padding: 15px;
|
| 1925 |
+
}
|
| 1926 |
+
.messages {
|
| 1927 |
+
max-height: 350px;
|
| 1928 |
+
}
|
| 1929 |
+
.message-avatar {
|
| 1930 |
+
width: 25px;
|
| 1931 |
+
height: 25px;
|
| 1932 |
+
}
|
| 1933 |
+
.message {
|
| 1934 |
+
max-width: 85%;
|
| 1935 |
+
}
|
| 1936 |
+
.message-content {
|
| 1937 |
+
padding: 8px 12px;
|
| 1938 |
+
font-size: 0.85em;
|
| 1939 |
+
}
|
| 1940 |
+
.message img, .message video {
|
| 1941 |
+
max-width: 180px;
|
| 1942 |
+
max-height: 180px;
|
| 1943 |
+
}
|
| 1944 |
+
}
|
| 1945 |
+
</style>
|
| 1946 |
+
</head>
|
| 1947 |
+
<body>
|
| 1948 |
+
<button class="menu-btn" onclick="toggleSidebar()">☰</button>
|
| 1949 |
+
''' + NAV_HTML + '''
|
| 1950 |
+
<button class="theme-toggle" onclick="toggleTheme()">🌙</button>
|
| 1951 |
+
<div class="container">
|
| 1952 |
+
<h1>General Chat</h1>
|
| 1953 |
+
<div class="messages" id="messages">
|
| 1954 |
+
{% for message in chat_messages %}
|
| 1955 |
+
<div class="message {{ 'sent' if message['sender'] == username else 'received' }}">
|
| 1956 |
+
{% if message['sender'] == username %}
|
| 1957 |
+
{% if avatar %}
|
| 1958 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ avatar }}" alt="Your Avatar" class="message-avatar" loading="lazy">
|
| 1959 |
+
{% else %}
|
| 1960 |
+
<div class="message-avatar" style="background: var(--primary);"></div>
|
| 1961 |
+
{% endif %}
|
| 1962 |
+
{% else %}
|
| 1963 |
+
{% if data['users'][message['sender']].get('avatar') %}
|
| 1964 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ data['users'][message['sender']]['avatar'] }}" alt="{{ message['sender'] }} Avatar" class="message-avatar" loading="lazy">
|
| 1965 |
+
{% else %}
|
| 1966 |
+
<div class="message-avatar" style="background: var(--secondary);"></div>
|
| 1967 |
+
{% endif %}
|
| 1968 |
+
{% endif %}
|
| 1969 |
+
<div class="message-content">
|
| 1970 |
+
<a href="{{ url_for('user_profile', username=message['sender']) }}" class="sender">{{ message['sender'] }}</a>
|
| 1971 |
+
<span class="status-dot {{ 'online' if is_user_online(message['sender']) else 'offline' }}"></span>
|
| 1972 |
+
{% if 'text' in message %}
|
| 1973 |
+
<p>{{ message['text'] }}</p>
|
| 1974 |
+
{% endif %}
|
| 1975 |
+
{% if 'file' in message %}
|
| 1976 |
+
{% if message['file_type'] == 'video' %}
|
| 1977 |
+
<video controls loading="lazy">
|
| 1978 |
+
<source src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ message['file'] }}" type="video/mp4">
|
| 1979 |
+
</video>
|
| 1980 |
+
{% else %}
|
| 1981 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/{{ message['file'] }}" alt="Chat file" loading="lazy" onclick="openModal(this.src)">
|
| 1982 |
+
{% endif %}
|
| 1983 |
+
{% endif %}
|
| 1984 |
+
{% if 'post_id' in message %}
|
| 1985 |
+
{% with post = posts|selectattr('id', 'equalto', message['post_id'])|first %}
|
| 1986 |
+
{% if post %}
|
| 1987 |
+
<p>Shared: <a href="{{ url_for('post_page', post_id=message['post_id']) }}">{{ post['title'] }}</a></p>
|
| 1988 |
+
{% endif %}
|
| 1989 |
+
{% endwith %}
|
| 1990 |
+
{% endif %}
|
| 1991 |
+
<span class="time">{{ message['time'] }}</span>
|
| 1992 |
+
</div>
|
| 1993 |
+
</div>
|
| 1994 |
+
{% endfor %}
|
| 1995 |
+
</div>
|
| 1996 |
+
{% if is_authenticated %}
|
| 1997 |
+
<form method="POST" enctype="multipart/form-data" class="message-form">
|
| 1998 |
+
<textarea name="message" placeholder="Type a message" rows="2"></textarea>
|
| 1999 |
+
<input type="file" name="file" accept="video/*,image/*">
|
| 2000 |
+
<select name="post_id" class="post-select">
|
| 2001 |
+
<option value="">Share a post (optional)</option>
|
| 2002 |
+
{% for post in user_posts %}
|
| 2003 |
+
<option value="{{ post['id'] }}">{{ post['title'] }}</option>
|
| 2004 |
+
{% endfor %}
|
| 2005 |
+
</select>
|
| 2006 |
+
<button type="submit" class="btn">Send</button>
|
| 2007 |
+
</form>
|
| 2008 |
+
{% else %}
|
| 2009 |
+
<p style="font-size: 1em;"><a href="{{ url_for('login') }}">Login</a> to send messages.</p>
|
| 2010 |
+
{% endif %}
|
| 2011 |
+
</div>
|
| 2012 |
+
<div class="modal" id="imageModal" onclick="closeModal(event)">
|
| 2013 |
+
<img id="modalImage" src="">
|
| 2014 |
+
</div>
|
| 2015 |
+
<script>
|
| 2016 |
+
function toggleSidebar() {
|
| 2017 |
+
document.getElementById('sidebar').classList.toggle('active');
|
| 2018 |
+
}
|
| 2019 |
+
function toggleTheme() {
|
| 2020 |
+
document.body.classList.toggle('dark');
|
| 2021 |
+
localStorage.setItem('theme', document.body.classList.contains('dark') ? 'dark' : 'light');
|
| 2022 |
+
}
|
| 2023 |
+
function openModal(src) {
|
| 2024 |
+
const modal = document.getElementById('imageModal');
|
| 2025 |
+
const modalImg = document.getElementById('modalImage');
|
| 2026 |
+
modal.style.display = 'flex';
|
| 2027 |
+
modalImg.src = src;
|
| 2028 |
+
}
|
| 2029 |
+
function closeModal(event) {
|
| 2030 |
+
if (event.target.tagName !== 'IMG') {
|
| 2031 |
+
document.getElementById('imageModal').style.display = 'none';
|
| 2032 |
+
}
|
| 2033 |
+
}
|
| 2034 |
+
window.onload = () => {
|
| 2035 |
+
if (localStorage.getItem('theme') === 'dark') document.body.classList.add('dark');
|
| 2036 |
+
const messagesDiv = document.getElementById('messages');
|
| 2037 |
+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
| 2038 |
+
};
|
| 2039 |
+
</script>
|
| 2040 |
+
</body>
|
| 2041 |
+
</html>
|
| 2042 |
+
'''
|
| 2043 |
+
user_posts = [p for p in data['posts'] if p['uploader'] == username] if is_authenticated else []
|
| 2044 |
+
avatar = data['users'][username].get('avatar') if is_authenticated else None
|
| 2045 |
+
return render_template_string(html,
|
| 2046 |
+
chat_messages=chat_messages,
|
| 2047 |
+
username=username,
|
| 2048 |
+
is_authenticated=is_authenticated,
|
| 2049 |
+
repo_id=REPO_ID,
|
| 2050 |
+
posts=data['posts'],
|
| 2051 |
+
user_posts=user_posts,
|
| 2052 |
+
unread_count=unread_count,
|
| 2053 |
+
user_count=user_count,
|
| 2054 |
+
private_unread_count=private_unread_count,
|
| 2055 |
+
is_online=is_online,
|
| 2056 |
+
is_user_online=lambda u: is_user_online(data, u),
|
| 2057 |
+
data=data,
|
| 2058 |
+
avatar=avatar)
|
| 2059 |
+
|
| 2060 |
+
# Список пользователей
|
| 2061 |
+
@app.route('/users', methods=['GET', 'POST'])
|
| 2062 |
+
def users():
|
| 2063 |
+
data = load_data()
|
| 2064 |
+
username = session.get('username', None)
|
| 2065 |
+
if username:
|
| 2066 |
+
update_last_seen(data, username)
|
| 2067 |
+
|
| 2068 |
+
is_authenticated = 'username' in session
|
| 2069 |
+
unread_count = get_unread_count(data, username) if is_authenticated else 0
|
| 2070 |
+
private_unread_count = get_private_unread_count(data, username) if is_authenticated else 0
|
| 2071 |
+
user_count = len(data['users'])
|
| 2072 |
+
is_online = is_user_online(data, username) if is_authenticated else False
|
| 2073 |
+
|
| 2074 |
+
search_query = request.form.get('search', '').strip().lower() if request.method == 'POST' else ''
|
| 2075 |
+
user_list = [(user, data['users'][user].get('avatar'), is_user_online(data, user))
|
| 2076 |
+
for user in data['users'] if not search_query or search_query in user.lower()]
|
| 2077 |
+
|
| 2078 |
+
html = '''
|
| 2079 |
+
<!DOCTYPE html>
|
| 2080 |
+
<html lang="en">
|
| 2081 |
+
<head>
|
| 2082 |
+
<meta charset="UTF-8">
|
| 2083 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 2084 |
<meta name="keywords" content="interracial porn, bbc porn, qos, queen of spades, big black cock">
|
| 2085 |
<title>Users - Content Hub</title>
|
| 2086 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|