- Artwork entity (name, stored filename, original name, mime, size, date)
- /art gallery grid; /art/upload (name + image file, PNG/JPEG/GIF/WebP,
20M cap); /art/{id}/file streams the image behind auth; /art/{id}/delete
(CSRF) removes row + file
- files stored under var/uploads/art/ (git-ignored, on the php_var volume
in Docker), served through a controller so they stay login-gated
- "Art" nav item
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
46 lines
2.3 KiB
Twig
46 lines
2.3 KiB
Twig
{% extends 'base.html.twig' %}
|
|
|
|
{% block title %}Art · dmtools{% endblock %}
|
|
|
|
{% block body %}
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h1 class="h3 mb-0">Art</h1>
|
|
<a href="{{ path('app_art_upload') }}" class="btn btn-primary btn-sm">Upload art</a>
|
|
</div>
|
|
|
|
{% if artworks is empty %}
|
|
<div class="card shadow-sm">
|
|
<div class="card-body text-center text-body-secondary py-5">
|
|
Nothing uploaded yet. Use <strong>Upload art</strong> to add maps, handouts or character pieces.
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-3">
|
|
{% for art in artworks %}
|
|
<div class="col">
|
|
<div class="card shadow-sm h-100">
|
|
<a href="{{ path('app_art_file', {id: art.id}) }}" target="_blank" rel="noopener">
|
|
<img src="{{ path('app_art_file', {id: art.id}) }}" alt="{{ art.name }}"
|
|
class="card-img-top object-fit-cover" style="height: 180px;"
|
|
loading="lazy">
|
|
</a>
|
|
<div class="card-body py-2 d-flex justify-content-between align-items-start gap-2">
|
|
<div class="min-w-0">
|
|
<div class="fw-semibold text-truncate" title="{{ art.name }}">{{ art.name }}</div>
|
|
<div class="text-body-secondary small">
|
|
{{ art.uploadedAt|date('Y-m-d') }} · {{ (art.size / 1024)|round }} KB
|
|
</div>
|
|
</div>
|
|
<form method="post" action="{{ path('app_art_delete', {id: art.id}) }}"
|
|
onsubmit="return confirm('Delete “{{ art.name|e('js') }}”?')">
|
|
<input type="hidden" name="_token" value="{{ csrf_token('delete-art-' ~ art.id) }}">
|
|
<button class="btn btn-sm btn-outline-danger" title="Delete">×</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|