diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -11,7 +11,7 @@ import random app = Flask(__name__) app.secret_key = 'supersecretkey' # Замените на безопасный ключ в продакшене -DATA_FILE = 'data_ostenhost.json' +DATA_FILE = 'datatest.json' REPO_ID = "Eluza133/w1f9" HF_TOKEN_WRITE = os.getenv("HF_TOKEN") # Токен с правами записи HF_TOKEN_READ = os.getenv("HF_TOKEN_READ") or HF_TOKEN_WRITE @@ -92,14 +92,14 @@ NAV_HTML = ''' OstenHost @@ -132,144 +132,104 @@ def register(): OstenHost - Регистрация - + @@ -739,53 +619,46 @@ def feed():

Лента публикаций

-
+
{% for post in posts %} - - {% if post['type'] == 'video' %} - - {% else %} - {{ post['title'] }} - {% endif %} -

{{ post['title'] }}

+
+ + {% if post['type'] == 'video' %} + + {% else %} + {{ post['title'] }} + {% endif %} +

{{ post['title'] }}

+

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

- +

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+
+ Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} + {% if is_authenticated %} +
+ + +
+ {% endif %} +
+
{% endfor %}
- @@ -878,194 +712,133 @@ def post_page(post_id): OstenHost - {{ post['title'] }} - + @@ -1079,17 +852,21 @@ def post_page(post_id): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %}

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

+

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+
+ Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} + {% if is_authenticated %} +
+ +
+ {% endif %} +
{% if is_authenticated %} -
- -
@@ -1098,77 +875,18 @@ def post_page(post_id):

Комментарии

{% for comment in post.get('comments', []) %}
-

{{ comment['user'] }} ({{ comment['date'] }}): {{ comment['text'] }}

+

{{ comment['user'] }} ({{ comment['date'] }}): {{ comment['text'] }}

{% endfor %} Назад к ленте {% if not is_authenticated %} -

Войдите, чтобы ставить лайки и комментировать.

+

Войдите, чтобы ставить лайки и комментировать.

{% endif %} - @@ -1232,6 +950,15 @@ def profile(): save_data(data) logging.info(f"Профиль {username} обновлен") return redirect(url_for('profile')) + elif 'like' in request.form: + post_id = request.form.get('post_id') + post = next((p for p in user_posts if p['id'] == post_id), None) + if post: + if username not in post.get('likes', []): + post['likes'] = post.get('likes', []) + [username] + else: + post['likes'] = [user for user in post.get('likes', []) if user != username] + save_data(data) html = ''' @@ -1240,209 +967,154 @@ def profile(): OstenHost - Профиль {{ username }} - + @@ -1458,7 +1130,7 @@ def profile(): {% endif %}

{{ bio }}

{% if link %} -

{{ link }}

+

{{ link }}

{% endif %}

Всего просмотров: {{ total_views }} | Всего лайков: {{ total_likes }}

@@ -1482,17 +1154,25 @@ def profile(): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %} -

{{ post['title'] }}

+

{{ post['title'] }}

{{ post['description'] }}

{{ post['upload_date'] }}

-

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

- - - -
+
+ Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} +
+ + +
+
+ + +
+
{% endfor %} {% else %} @@ -1500,30 +1180,11 @@ def profile(): {% endif %} - @@ -1616,201 +1238,141 @@ def user_profile(username): OstenHost - Профиль {{ username }} - + @@ -1826,7 +1388,7 @@ def user_profile(username): {% endif %}

{{ bio }}

{% if link %} -

{{ link }}

+

{{ link }}

{% endif %}

Всего просмотров: {{ total_views }} | Всего лайков: {{ total_likes }}

@@ -1842,13 +1404,15 @@ def user_profile(username): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %} -

{{ post['title'] }}

+

{{ post['title'] }}

{{ post['description'] }}

{{ post['upload_date'] }}

-

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

+
+ Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} +
{% endfor %} {% else %} @@ -1856,30 +1420,11 @@ def user_profile(username): {% endif %} - @@ -2013,155 +1519,109 @@ def upload(): OstenHost - Загрузка контента - + @@ -2248,199 +1708,147 @@ def admin_panel(): OstenHost - Админ-панель - + @@ -2450,7 +1858,7 @@ def admin_panel():

Админ-панель: Все посты

-
+
@@ -2470,8 +1878,10 @@ def admin_panel():

{{ post['title'] }}

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

+

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+
+ Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} +
@@ -2509,5 +1919,4 @@ def admin_panel(): if __name__ == '__main__': backup_thread = threading.Thread(target=periodic_backup, daemon=True) backup_thread.start() - app.run(debug=True, host='0.0.0.0', port=7860) - \ No newline at end of file + app.run(debug=True, host='0.0.0.0', port=7860) \ No newline at end of file