<h1 class="my-3">Sideload WARC</h1>

<div class="my-3 p-3 border bg-light">
This will load HTML from a directory structure containing WARC files, one per domain.
A warc export can be created using e.g. wget: <p>
<code>$ wget -r --warc-file=www.marginalia.nu www.marginalia.nu</code>
</div>
<form method="post" action="actions/sideload-warc" onsubmit="return confirm('Confirm sideloading')">
    <div class="my-3 py-3">

        <table class="table">
            <th></th><th>Filename</th><th>Size</th><th>Last Modified</th>
            {{#each uploadDirContents.items}}
                <tr>
                    <td><input {{#unless isWarc}}disabled{{/unless}} class="form-check-input" type="radio" name="source" id="{{name}}" value="{{name}}"></td>
                    <td>
                        <label {{#unless isWarc}}class="text-muted"{{/unless}} class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
                    </td>
                    <td>{{#unless directory}}{{size}}{{/unless}}</td>
                    <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
                </tr>
            {{/each}}
            {{#unless uploadDirContents.items}}
                <tr>
                    <td colspan="3">Nothing found in upload directory</td>
                </tr>
            {{/unless}}
        </table>

        <p>
            <small class="text-muted">
                The upload directory is typically mounted to /uploads on the server.  The external
                directory is typically something like index-{{node.id}}/uploads.
            </small>
        </p>

        <button type="submit" {{#unless uploadDirContents.items}}disabled{{/unless}} class="btn btn-primary">Sideload WARCs</button>
    </div>
</form>