{% extends 'editor/editor.html' %}

{% block main %}

    <div class="padding">
        
        {# The form used for submitting changes #}
        <form id="form_upload" method="post" enctype="multipart/form-data" action=""></form>
        
        <h3>Upload a file</h3>
        
        {% if errors and errors|length > 0 %}
            <div class="alert bg-danger">
                <ul>
                    {% if 'name' in errors %}
                        <li>File name is not valid</li>
                    {% endif %}
                    {% if 'no_extension' in errors %}
                        <li>Unknown file extension</li>
                    {% endif %}
                    {% if 'extension_mismatch' in errors %}
                        <li>File name extension does not match that of original file</li>
                    {% endif %}
                    {% if 'license' in errors %}
                        <li>License is not valid</li>
                    {% endif %}
                    {% if 'path' in errors %}
                        <li>A file with this name already exists</li>
                    {% endif %}
                </ul>
            </div>
        {% endif %}
        
        <p class="large-margin-top">
            Choose a file from your computer. Maximum file size is 100MB.
            <br />
            <input form="form_upload"
                   type="file"
                   name="blob"
                   multiple="false"
                   required="true"
                   class="form-control margin-top">
        </p>
        
        <p class="larger-margin-top">
            Provide a unique name for this file.
            <br /><strong>Files cannot be renamed later</strong>, so please
            choose a name that is clear, informative, and easy to recognize.
            Long names are not a problem.
            <br />
            <strong class="dark-green">Good:</strong> "Colosseum, view from Arch of Constantine (August 2019).png"
            <br />
            <strong class="red">Bad:</strong> "IMG_0001.jpg"
            <br />
            <input form="form_upload"
                   type="text"
                   name="name"
                   value="{{ file['name'] if file and file['name'] }}"
                   placeholder="Name"
                   maxlength="2048"
                   required="true"
                   class="form-control margin-top">
        </p>
        
        <p class="larger-margin-top">
            Specify the license of this file.
            <br />
            <strong>Important:</strong> we only accept files that are in the
            public domain or that have been released with a free culture license.
            All other files, or files whose license is not clear, will be removed.
            You cannot specify an arbitrary license of your choice. Only the
            authors can decide the license of their work.
            <br />
            <input form="form_upload"
                   type="text"
                   name="license"
                   value="{{ file['license'] if file and file['license'] }}"
                   placeholder="License"
                   maxlength="256"
                   required="true"
                   class="form-control margin-top">
        </p>
        
        <p class="larger-margin-top">
            Provide a link to a primary source for this work. This field is
            optional but it's important to know where a file came from, and it's
            useful to know where to find more information about a particular file.
            <br />
            If it's your work but you cannot provide a link, use "Own work".
            <br />
            <input form="form_upload"
                   type="text"
                   name="source"
                   value="{{ file['source'] if file and file['source'] }}"
                   placeholder="Source"
                   maxlength="2048"
                   class="form-control margin-top">
        </p>
        
        <p class="larger-margin-top">
            Provide a brief description for this file.
            <br />
            <textarea form="form_upload"
                      name="description"
                      placeholder="Description"
                      class="form-control margin-top"
                      rows="5"
                      maxlength="10240">{{ file['description'] if file and file['description'] }}</textarea>
        </p>
        
        <p class="larger-margin-top larger-margin-bottom">
            <input form="form_upload" type="submit" value="Upload" class="button button_default" />
            <a href="{{ url('editor') }}" class="margin-left">Cancel</a>
        </p>
    
    </div>

{% endblock %}
