nirvash/templates/file_move.html

55 lines
1.5 KiB
HTML

{{ $slug := ((.Context).Value "params").Slug }}
{{ $dest := .FormValue "dest" }}
{{ $fileList := ((.Context).Value "file-manager").ListSubTree $dest }}
{{ $fileData := ((.Context).Value "file-manager").GetFileData $slug }}
{{ $csrfToken := (.Context).Value "csrfToken" }}
{{ template "header" .}}
{{ if ($fileList).Error}}
<h2>File Listing Error</h2>
<span class="adapter-error">{{($fileList).Error}}</span>
{{ else if ($fileData).Error }}
<h2>File Listing Error</h2>
<span class="adapter-error">{{($fileData).Error}}</span>
{{ else }}
<h2>Moving {{($fileData).Name}}: {{($fileList).Root}}</h2>
<form class="move-rename-file" method="POST" action="/file-move-process/{{($fileData).Path}}">
<input hidden type="text" name="csrfToken" value="{{$csrfToken}}"/>
<input hidden type="text" name="dest" value="{{($fileList).Root}}"/>
<div class="new-page-button-wrapper">
<input type="submit" class="new-page-button" value="Move here"/>
</div>
<div class="page-list">
<label>New file name
<input type="text" name="filename" value="{{($fileData).Name}}"/>
</label>
<ul class="file-list">
{{ if ($fileList).Up }}
<li><a href="/file-move/{{($fileData).Path}}?dest={{($fileList).Up}}">..</a></li>
{{ end }}
{{ range $dir := ($fileList).SubDirs }}
<li>
<a href="/file-move/{{($fileData).Path}}?dest={{($fileList).Root}}{{$dir}}">{{$dir}}/</a>
</li>
{{ end }}
{{ range $file := ($fileList).Files }}
<li>
<span class="file-nolink">{{$file}}</span>
</li>
{{ end }}
</ul>
</div>
</form>
{{ end }}
{{ template "footer" .}}