2019-08-16 23:27:24 +02:00
|
|
|
{{define "import"}}
|
|
|
|
{{template "header" .}}
|
2020-01-09 17:16:26 +01:00
|
|
|
<style>
|
|
|
|
input[type=file] {
|
|
|
|
padding: 0;
|
|
|
|
font-size: 0.86em;
|
|
|
|
display: block;
|
|
|
|
margin: 0.5rem 0;
|
|
|
|
}
|
|
|
|
label {
|
|
|
|
display: block;
|
|
|
|
margin: 1em 0;
|
|
|
|
}
|
|
|
|
</style>
|
2019-08-16 23:27:24 +02:00
|
|
|
|
|
|
|
<div class="snug content-container">
|
2020-01-09 17:16:26 +01:00
|
|
|
<h1 id="import-header">Import posts</h1>
|
2019-08-18 01:18:40 +02:00
|
|
|
{{if .Message}}
|
|
|
|
<div class="alert {{if .InfoMsg}}info{{else}}success{{end}}">
|
|
|
|
<p>{{.Message}}</p>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-01-09 17:16:26 +01:00
|
|
|
{{if .Flashes}}
|
|
|
|
<ul class="errors">
|
|
|
|
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
|
|
|
|
</ul>
|
|
|
|
{{end}}
|
|
|
|
<p>Publish plain text or Markdown files to your account by uploading them below.</p>
|
2019-08-16 23:27:24 +02:00
|
|
|
<div class="formContainer">
|
2020-01-09 17:16:26 +01:00
|
|
|
<form id="importPosts" class="prominent" enctype="multipart/form-data" action="/api/me/import" method="POST">
|
|
|
|
<label>Select some files to import:
|
2021-04-06 21:59:32 +02:00
|
|
|
<input id="fileInput" class="fileInput" name="files" type="file" multiple accept="text/*"/>
|
2020-01-09 17:16:26 +01:00
|
|
|
</label>
|
2020-01-14 17:59:30 +01:00
|
|
|
<input id="fileDates" name="fileDates" hidden/>
|
2020-01-09 17:16:26 +01:00
|
|
|
<label>
|
|
|
|
Import these posts to:
|
|
|
|
<select name="collection">
|
|
|
|
{{range $i, $el := .Collections}}
|
|
|
|
<option value="{{.Alias}}" {{if eq $i 0}}selected{{end}}>{{.DisplayTitle}}</option>
|
|
|
|
{{end}}
|
|
|
|
<option value="">Drafts</option>
|
|
|
|
</select>
|
|
|
|
</label>
|
2020-01-14 17:59:30 +01:00
|
|
|
<script>
|
2020-01-15 18:04:38 +01:00
|
|
|
// timezone offset in seconds
|
|
|
|
const tzOffsetSec = new Date().getTimezoneOffset() * 60;
|
2020-01-14 17:59:30 +01:00
|
|
|
const fileInput = document.getElementById('fileInput');
|
|
|
|
const fileDates = document.getElementById('fileDates');
|
|
|
|
fileInput.addEventListener('change', (e) => {
|
|
|
|
const files = e.target.files;
|
|
|
|
let dateMap = {};
|
|
|
|
for (let file of files) {
|
2020-01-15 18:04:38 +01:00
|
|
|
// convert from milliseconds to seconds and adjust for tz
|
|
|
|
dateMap[file.name] = Math.round(file.lastModified / 1000) + tzOffsetSec;
|
2020-01-14 17:59:30 +01:00
|
|
|
}
|
|
|
|
fileDates.value = JSON.stringify(dateMap);
|
|
|
|
})
|
|
|
|
</script>
|
2019-08-16 23:27:24 +02:00
|
|
|
<input type="submit" value="Import" />
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{template "footer" .}}
|
2019-08-27 00:04:00 +02:00
|
|
|
{{end}}
|