Files
MediaCollectorLibary/resources/views/games/show.twig
Lars Behrends 218d0c28c0 impoort stuff!
2025-10-24 16:04:34 +02:00

418 lines
23 KiB
Twig

{% extends "layouts/app.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-0">
<!-- Game Header -->
<div class="bg-white shadow rounded-lg mb-6">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<div class="flex items-center">
{% if main_game.image_url %}
<img class="h-16 w-16 rounded-lg object-cover mr-4" src="{{ main_game.image_url }}" alt="{{ main_game.title }}">
{% else %}
<div class="h-16 w-16 rounded-lg bg-gray-200 flex items-center justify-center mr-4">
<svg class="h-8 w-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-7 8h12a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</div>
{% endif %}
<div>
<h1 class="text-2xl font-bold text-gray-900">{{ main_game.title }}</h1>
<div class="flex items-center space-x-4 mt-1">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ platform_versions|length }} platform{{ platform_versions|length > 1 ? 's' : '' }}
</span>
{% if main_game.genre %}
<span class="text-sm text-gray-500">{{ main_game.genre }}</span>
{% endif %}
</div>
</div>
</div>
<a href="{{ path_for('games.index') }}" class="text-indigo-600 hover:text-indigo-900 text-sm font-medium">
← Back to Games
</a>
</div>
</div>
</div>
<!-- Platform Tabs -->
<div class="bg-white shadow rounded-lg">
<div class="border-b border-gray-200">
<nav class="-mb-px flex space-x-8 px-6" aria-label="Tabs">
{% for version in platform_versions %}
<button
class="platform-tab whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm {{ loop.first ? 'border-indigo-500 text-indigo-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
data-platform="{{ version.platform }}"
data-source="{{ version.source_id }}"
>
{{ version.platform }}
{% if version.source_name %}
<span class="ml-1 text-xs text-gray-400">({{ version.source_name }})</span>
{% endif %}
</button>
{% endfor %}
</nav>
</div>
<!-- Platform Content -->
{% for version in platform_versions %}
<div class="platform-content {{ loop.first ? '' : 'hidden' }}" data-platform="{{ version.platform }}" data-source="{{ version.source_id }}">
<div class="px-6 py-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Game Info -->
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">Game Information</h3>
<dl class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
{% if version.developer %}
<div>
<dt class="text-sm font-medium text-gray-500">Developer</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.developer }}</dd>
</div>
{% endif %}
{% if version.publisher %}
<div>
<dt class="text-sm font-medium text-gray-500">Publisher</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.publisher }}</dd>
</div>
{% endif %}
{% if version.release_date %}
<div>
<dt class="text-sm font-medium text-gray-500">Release Date</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.release_date|date('M j, Y') }}</dd>
</div>
{% endif %}
<div>
<dt class="text-sm font-medium text-gray-500">Playtime</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.playtime_minutes|format_duration }}</dd>
</div>
{% if version.rating %}
<div>
<dt class="text-sm font-medium text-gray-500">Rating</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.rating }}/10</dd>
</div>
{% endif %}
{% if version.completion_percentage > 0 %}
<div>
<dt class="text-sm font-medium text-gray-500">Completion</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.completion_percentage }}%</dd>
</div>
{% endif %}
</dl>
</div>
<!-- Platform Stats -->
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">Platform Statistics</h3>
<dl class="grid grid-cols-1 gap-x-4 gap-y-4">
<div>
<dt class="text-sm font-medium text-gray-500">Source</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.source_name }}</dd>
</div>
{% if version.last_played_at %}
<div>
<dt class="text-sm font-medium text-gray-500">Last Played</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.last_played_at|date('M j, Y') }}</dd>
</div>
{% endif %}
{% if version.is_installed %}
<div>
<dt class="text-sm font-medium text-gray-500">Status</dt>
<dd class="mt-1">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Installed
</span>
</dd>
</div>
{% endif %}
{% if version.is_favorite %}
<div>
<dt class="text-sm font-medium text-gray-500">Favorite</dt>
<dd class="mt-1">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
Yes
</span>
</dd>
</div>
{% endif %}
</dl>
<!-- Platform-specific metadata -->
{% set metadata = version.metadata|json_decode %}
{% if metadata %}
<div class="mt-6">
<h4 class="text-sm font-medium text-gray-900 mb-2">Platform Details</h4>
<div class="bg-gray-50 rounded-md p-3">
<dl class="grid grid-cols-1 gap-x-4 gap-y-2 text-sm">
{% if metadata.appid %}
<div>
<dt class="font-medium text-gray-500">App ID</dt>
<dd class="text-gray-900">{{ metadata.appid }}</dd>
</div>
{% endif %}
{% if metadata.playtime_windows or metadata.playtime_mac or metadata.playtime_linux %}
<div>
<dt class="font-medium text-gray-500">Platform Playtime</dt>
<dd class="text-gray-900">
{% if metadata.playtime_windows %}<span>Windows: {{ metadata.playtime_windows|format_duration }}</span>{% endif %}
{% if metadata.playtime_mac %}<span class="ml-2">Mac: {{ metadata.playtime_mac|format_duration }}</span>{% endif %}
{% if metadata.playtime_linux %}<span class="ml-2">Linux: {{ metadata.playtime_linux|format_duration }}</span>{% endif %}
</dd>
</div>
{% endif %}
</dl>
</div>
</div>
{% endif %}
</div>
</div>
{% if version.description %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-2">Description</h3>
<p class="text-sm text-gray-600">{{ version.description }}</p>
</div>
{% endif %}
<!-- Playnite Rich Metadata -->
{% set playniteGenres = version.genres_json|json_decode %}
{% if playniteGenres %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Genres</h3>
<div class="flex flex-wrap gap-2">
{% for genre in playniteGenres %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800">
{{ genre.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteTags = version.tags_json|json_decode %}
{% if playniteTags %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Tags</h3>
<div class="flex flex-wrap gap-2">
{% for tag in playniteTags|slice(0, 20) %}
<span class="inline-flex items-center px-2 py-1 rounded text-sm font-medium bg-gray-100 text-gray-800">
{{ tag.Name }}
</span>
{% endfor %}
{% if playniteTags|length > 20 %}
<span class="text-sm text-gray-500">+{{ playniteTags|length - 20 }} more</span>
{% endif %}
</div>
</div>
{% endif %}
{% set playniteFeatures = version.features_json|json_decode %}
{% if playniteFeatures %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Features</h3>
<div class="flex flex-wrap gap-2">
{% for feature in playniteFeatures %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">
{{ feature.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteLinks = version.links_json|json_decode %}
{% if playniteLinks %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Links</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
{% for link in playniteLinks %}
<a href="{{ link.Url }}" target="_blank" rel="noopener noreferrer"
class="inline-flex items-center px-3 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 transition-colors duration-200">
<svg class="w-4 h-4 mr-2 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"/>
<path d="M5 5a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"/>
</svg>
{{ link.Name }}
</a>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteSeries = version.series_json|json_decode %}
{% if playniteSeries %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Series</h3>
<div class="flex flex-wrap gap-2">
{% for series in playniteSeries %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-purple-100 text-purple-800">
{{ series.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteAgeRatings = version.age_ratings_json|json_decode %}
{% if playniteAgeRatings %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Age Ratings</h3>
<div class="flex flex-wrap gap-2">
{% for ageRating in playniteAgeRatings %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800">
{{ ageRating.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Enhanced Ratings Display -->
{% if version.critic_score or version.community_score or version.user_score %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Ratings</h3>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
{% if version.critic_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Critic Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.critic_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.community_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Community Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.community_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-blue-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3z"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.user_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">User Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.user_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Playnite-specific Statistics -->
{% if version.play_count or version.install_size or version.completion_status %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Playnite Statistics</h3>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
{% if version.play_count %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Play Count</p>
<p class="text-2xl font-bold text-gray-900">{{ version.play_count }}</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-indigo-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.install_size %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Install Size</p>
<p class="text-lg font-bold text-gray-900">{{ (version.install_size / 1024 / 1024 / 1024)|round(1) }} GB</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.completion_status %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Completion Status</p>
<p class="text-lg font-bold text-gray-900">{{ version.completion_status }}</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<script>
// Platform tab switching functionality
document.addEventListener('DOMContentLoaded', function() {
const tabs = document.querySelectorAll('.platform-tab');
const contents = document.querySelectorAll('.platform-content');
tabs.forEach(tab => {
tab.addEventListener('click', function() {
const platform = this.dataset.platform;
const source = this.dataset.source;
// Update tab styles
tabs.forEach(t => {
t.classList.remove('border-indigo-500', 'text-indigo-600');
t.classList.add('border-transparent', 'text-gray-500');
});
this.classList.remove('border-transparent', 'text-gray-500');
this.classList.add('border-indigo-500', 'text-indigo-600');
// Update content visibility
contents.forEach(content => {
if (content.dataset.platform === platform && content.dataset.source === source) {
content.classList.remove('hidden');
} else {
content.classList.add('hidden');
}
});
});
});
});
</script>
{% endblock %}