{% extends "base.html" %}

{% block title %}{{ file.filename }}{% endblock %}

{% block content %}
<h1>{{ file.filename }}</h1>

{% set action_links = file_actions() %}
{% if action_links %}
<div class="page-action-menu">
<details class="actions-menu-links details-menu">
    <summary>
        <div class="icon-text">
            <svg class="icon" aria-labelledby="actions-menu-links-title" role="img" style="color: #fff" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <title id="actions-menu-links-title">File actions</title>
                <circle cx="12" cy="12" r="3"></circle>
                <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
            </svg>
            <span>File actions</span>
        </div>
    </summary>
    <div class="dropdown-menu">
        <div class="hook"></div>
        <ul>
            {% for link in action_links %}
            <li><a href="{{ link.href }}">{{ link.label }}
            {% if link.description %}
                <p class="dropdown-description">{{ link.description }}</p>
            {% endif %}</a>
            </li>
            {% endfor %}
        </ul>
    </div>
</details>
</div>
{% endif %}

<table>
    <tr><th>File ID</th><td>{{ file.id }}</td></tr>
    <tr><th>Filename</th><td>{{ file.filename }}</td></tr>
    <tr><th>Content Type</th><td>{{ file.content_type or "unknown" }}</td></tr>
    <tr><th>Size</th><td>{{ file.size }} bytes</td></tr>
    {% if file.content_hash %}
    <tr><th>Content Hash</th><td>{{ file.content_hash }}</td></tr>
    {% endif %}
    {% if file.uploaded_by %}
    <tr><th>Uploaded By</th><td>{{ file.uploaded_by }}</td></tr>
    {% endif %}
    <tr><th>Created</th><td>{{ file.created_at }}</td></tr>
</table>

{% if file.content_type and file.content_type.startswith("image/") %}
<p><img src="{{ urls.path('/-/files/' ~ file.id ~ '/download') }}" alt="{{ file.filename }}" style="max-width: 600px;"></p>
{% endif %}

<p><a href="{{ urls.path('/-/files/' ~ file.id ~ '/download') }}">Download {{ file.filename }}</a></p>

<h2>Search text</h2>

{% if file.search_text %}
<p>{{ file.search_text }}</p>
{% else %}
<p><em>No search text set.</em></p>
{% endif %}
{% endblock %}
