Artberry-web/templates/content.html
2025-02-16 16:38:57 +02:00

240 lines
10 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}🫐artberry🫐{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<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">
{% if extra_css %}
<link rel="stylesheet" href="{{ url_for('static', filename=extra_css) }}">
{% endif %}
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@300&display=swap" rel="stylesheet">
</head>
<body>
<nav class="nav">
<div class="nav-buttons">
{% if content_type == 'art' %}
{% if current_user.is_authenticated %}
<a href="{{ url_for('upload') }}" class="button">Upload</a>
{% endif %}
<a href="{{ url_for('videos') }}" class="button">Videos</a>
<a href="{{ url_for('comics') }}" class="button">Comics</a>
{% elif content_type == 'video' %}
{% if current_user.is_authenticated %}
<a href="{{ url_for('upload_video') }}" class="button">Upload</a>
{% endif %}
<a href="{{ url_for('index') }}" class="button">Arts</a>
<a href="{{ url_for('comics') }}" class="button">Comics</a>
{% elif content_type == 'comic' %}
{% if current_user.is_authenticated %}
<a href="{{ url_for('comic_upload') }}" class="button">Upload</a>
{% endif %}
<a href="{{ url_for('index') }}" class="button">Arts</a>
<a href="{{ url_for('videos') }}" class="button">Videos</a>
{% endif %}
{% if current_user.is_authenticated %}
<a href="{{ url_for('logout') }}" class="button">Logout</a>
<a href="{{ url_for('shop') }}" class="button">{{ user_cookies }} 🍪</a>
{% else %}
<a href="{{ url_for('register') }}" class="button">Register</a>
<a href="{{ url_for('login') }}" class="button">Login</a>
{% endif %}
</div>
</nav>
<header class="header">
<h1 class="title"><a href="{{url_for('index')}}" style="color:white;">🫐artberry🫐</a></h1>
<form method="GET"
action="{{ search_url if search_url else url_for(request.endpoint, pub_type=pub_type, username=username) }}"
class="search-form">
<input type="text" name="search" id="search-input" placeholder="Search by tags"
class="input-field search-field" autocomplete="off">
<button type="submit" class="button search-button">Search</button>
</form>
<div id="autocomplete-suggestions" class="autocomplete-suggestions"></div>
</form>
</header>
<section class="content" id="content">
{% block content %}
{% if content_type == 'art' or content_type == 'video' or content_type == 'comic' %}
<div class="{{ content_type }}-details">
<h2>{{ content.title }}</h2>
{% if content_type == 'art' %}
<img src="{{ url_for('static', filename='uploads/' + content.filename) }}" alt="{{ content.title }}"
class="art-image" loading="lazy" width="800" height="600">
{% elif content_type == 'video' %}
<video controls class="video-player">
<source src="{{ url_for('static', filename='uploads/videos/' + content.filename) }}" type="video/mp4">
Your browser does not support the video tag.
</video>
{% elif content_type == 'comic' %}
<div class="comic-pages">
{% for page in content.pages %}
<img src="{{ url_for('static', filename='uploads/comics/' + content.name + '/' + page) }}"
alt="Comic Page {{ loop.index }}" class="comic-page">
{% endfor %}
</div>
{% endif %}
<p>Uploaded by: <a href="{{ url_for('profile', username=content.username) }}">{{ content.username }}</a></p>
<p>Description: {{ content.description }}</p>
</div>
<div class="vote-section">
<p>Votes: {{ content.cookie_votes }} 🍪</p>
{% if current_user.is_authenticated %}
<form action="{{ url_for('vote_content', content_type=content_type, content_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>
{% else %}
<p>Unknown content type.</p>
{% endif %}
<div class="comments-section">
<h3>Comments</h3>
{% if comments %}
<ul class="comments-list">
{% for comment in comments %}
<li>
<img src="{{ url_for('static', filename='avatars/' + avatars[comment.username]) }}" alt="Avatar"
class="comment-avatar">
<strong>{{ comment.username }}</strong>: {{ comment.comment_text }}
</li>
{% endfor %}
</ul>
{% else %}
<p>No comments yet. Be the first to comment!</p>
{% endif %}
{% if current_user.is_authenticated %}
<form method="POST" class="comment-form">
<textarea name="comment" placeholder="Write your comment..." maxlength="44" required
class="input-textarea"></textarea>
<button type="submit" class="button">Post Comment</button>
</form>
{% else %}
<p>You need to <a href="{{ url_for('login') }}">log in</a> to comment.</p>
{% endif %}
</div>
{% endblock %}
</section>
{% if pagination %}
<div class="pagination">
{% if pagination.has_prev %}
<a href="{{ url_for(request.endpoint, page=pagination.prev_num, search=request.args.get('search')) }}"
class="button">«</a>
{% endif %}
{% for page in pagination.iter_pages() %}
{% if page %}
<a href="{{ url_for(request.endpoint, page=page, search=request.args.get('search')) }}" class="button"
style="{% if page == pagination.page %}color: yellow;{% endif %}">
{{ page }}
</a>
{% endif %}
{% endfor %}
{% if pagination.has_next %}
<a href="{{ url_for(request.endpoint, page=pagination.next_num, search=request.args.get('search')) }}"
class="button">»</a>
{% endif %}
</div>
{% endif %}
<footer class="footer">
<p>
<a href="{{ url_for('privacy_policy') }}" class="button">Privacy</a>
<a href="{{ url_for('terms_of_use') }}" class="button">TOS</a>
<a href="{{ url_for('publication_rules') }}" class="button">Pub Rules</a>
<a href="https://discord.gg/yRFyPjceWj" target="_blank" class="button" rel="noopener noreferrer">Discord</a>
</p>
</footer>
<div class="modal-overlay" id="ageVerificationModal">
<div class="modal-content">
<p>By clicking "Yes", you agree that you are of legal age according to your state/city/province/country.</p>
<div class="modal-buttons">
<button class="modal-button" id="yesButton">Yes</button>
<button class="modal-button cancel" id="noButton">No</button>
</div>
</div>
</div>
<script>
window.onload = function () {
var modal = document.getElementById('ageVerificationModal');
var body = document.body;
var content = document.getElementById('content');
if (document.cookie.indexOf('ageVerified=true') !== -1) {
return;
}
modal.style.display = 'flex';
content.classList.add('blur');
document.getElementById('yesButton').addEventListener('click', function () {
modal.style.display = 'none';
content.classList.remove('blur');
document.cookie = "ageVerified=true; path=/; max-age=31536000";
});
document.getElementById('noButton').addEventListener('click', function () {
window.location.href = 'https://www.google.com/search?q=cats';
});
};
document.getElementById('search-input').addEventListener('input', function () {
var query = this.value;
if (query.length < 2) {
document.getElementById('autocomplete-suggestions').innerHTML = '';
return;
}
fetch(`/autocomplete?search=${encodeURIComponent(query)}`)
.then(response => response.json())
.then(data => {
var suggestionsContainer = document.getElementById('autocomplete-suggestions');
suggestionsContainer.innerHTML = '';
if (data.length > 0) {
data.forEach(function (suggestion) {
var suggestionElement = document.createElement('div');
suggestionElement.classList.add('suggestion-item');
suggestionElement.textContent = suggestion;
suggestionElement.addEventListener('click', function () {
var searchInput = document.getElementById('search-input');
var currentValue = searchInput.value;
var tags = currentValue.split(',').map(tag => tag.trim());
tags[tags.length - 1] = suggestion;
searchInput.value = tags.join(', ');
suggestionsContainer.innerHTML = '';
});
suggestionsContainer.appendChild(suggestionElement);
});
}
})
.catch(error => console.error('Error fetching autocomplete data:', error));
});
</script>
</body>
</html>