<!--
 SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
 SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
    {{( pgettext "Upload Media" "title" )}}
{{- end }}

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/media.uploadForm*/ -}}
    <form id="mediaUpload" enctype="multipart/form-data" action="/admin/media" method="post" data-hx-boost="true">
        <h2>{{( pgettext "Upload Media" "title" )}}</h2>
        {{ CSRFInput }}
        <fieldset>
            {{ with .File -}}
                <label>
                    {{( pgettext "File" "input" )}}
                    <input type="file" name="{{ .Name }}"
                           required {{ template "error-attrs" . }}><br>
                </label>
                <p>{{ printf (gettext "Maximum upload file size: %s") (.MaxSize | humanizeBytes) }}</p>
                {{ template "error-message" . }}
            {{- end }}
        </fieldset>
        <footer>
            <button type="submit">{{( pgettext "Upload" "action" )}}</button>
            <progress value="0" max="100"></progress>
        </footer>
    </form>
    <script type="module">
        import {camperUploadForm} from "/static/camper.js";
        camperUploadForm(document.getElementById('mediaUpload'));
    </script>
{{- end }}