2025-02-20 20:16:06 +02:00

133 lines
6.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>🫐Content View - Artberry🫐</title>
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
<link rel="icon" href="{{ url_for('static', filename='artberry.ico') }}" type="image/x-icon">
</head>
<body>
{% include 'navbar.html' %}
{% if content_type == 'art' %}
<h1>Image</h1>
<div class="details">
<img src="{{ url_for('static', filename='arts/' + content.image_file) }}" alt="Art Image">
<p><strong>Author:</strong> <a href="{{ url_for('profile', username=content.username) }}">{{ content.username }}</a></p>
<p><strong>Publication Date:</strong> {{ content.publication_date }}</p>
<p><strong>Tags:</strong>
{% for tag in content.tags.split(',') %}
<a href="{{ url_for('index', search=tag.strip()) }}" class="tag-link">{{ tag.strip() }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
</p>
</div>
{% elif content_type == 'video' %}
<h1>Video</h1>
<div class="video-details">
<video controls>
<source src="{{ url_for('static', filename='videos/' + content.video_file) }}" type="video/mp4">
</video>
<p><strong>Author:</strong> <a href="{{ url_for('profile', username=content.username) }}">{{ content.username }}</a></p>
<p><strong>Publication Date:</strong> {{ content.publication_date }}</p>
<p>Description: {{ content.description }}</p>
<p><strong>Tags:</strong>
{% for tag in content.tags.split(',') %}
<a href="{{ url_for('videos', search=tag.strip()) }}" class="tag-link">{{ tag.strip() }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
</p>
</div>
{% elif content_type == 'comic' %}
<h1>{{ content.name }}</h1>
<div class="comic-pages">
{% if comic_pages %}
{% for page in comic_pages %}
<img src="{{ url_for('static', filename='comics/' + content.comic_folder + '/' + page) }}" alt="Page {{ loop.index }}">
{% endfor %}
{% else %}
<p>No pages available for this comic.</p>
{% endif %}
</div>
{% endif %}
{% if current_user.is_authenticated and current_user.username == content.username %}
<form method="POST" action="{{ url_for('delete', content_type=content_type, content_id=content.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="button" onclick="return confirm('Are you sure you want to delete this content?');">Delete</button>
</form>
{% endif %}
{% if content_type != 'comic' %}
<section class="comments">
<h2>Comments</h2>
<div class="comments-list">
{% for comment in comments %}
<div class="comment">
<a href="{{ url_for('profile', username=comment.username) }}">
<img src="{{ url_for('static', filename='avatars/' + (avatars[comment.username] if avatars.get(comment.username) else 'default_avatar.png')) }}"
alt="Avatar of {{ comment.username }}" class="avatar">
{% if current_user.is_authenticated and comment.username == current_user.username %}
<form class="button" action="{{ url_for('delete_comment', comment_id=comment.id) }}" method="POST" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="delete-button" onclick="return confirm('Are you sure you want to delete this comment?')">Delete</button>
</form>
{% endif %}
</a>
<div class="content">
<p>
<a href="{{ url_for('profile', username=comment.username) }}" class="username-link">
<strong>{{ comment.username }}</strong>
</a>
({{ comment.comment_date.strftime('%Y-%m-%d %H:%M') }}):
</p>
<p style="margin-top: 10px;">{{ comment.comment_text }}</p>
</div>
</div>
{% else %}
<p>No comments yet. Be the first to comment!</p>
{% endfor %}
</div>
{% if current_user.is_authenticated %}
<form method="POST" action="{{ url_for('view', content_type=content_type, id=content.id) }}" class="comment-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<textarea name="comment" class="input-field" placeholder="Add a comment..." rows="3" maxlength="44" required></textarea>
<button type="submit" class="button">Post Comment</button>
</form>
{% else %}
<p>You need to <a href="{{ url_for('login') }}">log in</a> to post a comment.</p>
{% endif %}
</section>
{% endif %}
{% if content_type != 'comic' %}
<div class="navigation">
<a href="{{ url_for('view', content_type=content_type, id=prev_content.id, page=request.args.get('page', 1)) }}" class="button">&larr; Prev</a>
<a href="{{ url_for('view', content_type=content_type, id=random_content.id, page=request.args.get('page', 1)) }}" class="button">Random</a>
<a href="{{ url_for('view', content_type=content_type, id=next_content.id, page=request.args.get('page', 1)) }}" class="button">Next &rarr;</a>
{% if current_user.is_authenticated and content.username == current_user.username %}
{% if content_type == 'art' %}
<a href="{{ url_for('image_edit', id=content.id) }}" class="button">Edit Art</a>
{% elif content_type == 'video' %}
<a href="{{ url_for('video_edit', id=content.id) }}" class="button">Edit Video</a>
{% elif content_type == 'comic' %}
<a href="{{ url_for('comic_edit', id=content.id) }}" class="button">Edit Comic</a>
{% endif %}
{% endif %}
</div>
{% endif %}
<div class="vote-section">
<p>Votes: {{ content.cookie_votes }} 🍪</p>
{% if current_user.is_authenticated %}
<form action="{{ url_for('vote_' + content_type, **({'image_id': content.id} if content_type == 'art' else {'video_id': content.id} if content_type == 'video' else {'comic_id': content.id})) }}" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="button">Vote</button>
</form>
{% else %}
<p>You need to <a href="{{ url_for('login') }}">log in</a> to vote.</p>
{% endif %}
</div>
</body>
</html>