2019-08-16 21:27:24 +00:00
|
|
|
{{define "import"}}
|
|
|
|
{{template "header" .}}
|
2020-01-09 16:16:26 +00: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 21:27:24 +00:00
|
|
|
|
|
|
|
<div class="snug content-container">
|
2020-01-09 16:16:26 +00:00
|
|
|
<h1 id="import-header">Import posts</h1>
|
2019-08-17 23:18:40 +00:00
|
|
|
{{if .Message}}
|
|
|
|
<div class="alert {{if .InfoMsg}}info{{else}}success{{end}}">
|
|
|
|
<p>{{.Message}}</p>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-01-09 16:16:26 +00: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 21:27:24 +00:00
|
|
|
<div class="formContainer">
|
2020-01-09 16:16:26 +00:00
|
|
|
<form id="importPosts" class="prominent" enctype="multipart/form-data" action="/api/me/import" method="POST">
|
|
|
|
<label>Select some files to import:
|
2020-01-14 16:59:30 +00:00
|
|
|
<input id="fileInput" class="fileInput" name="files" type="file" multiple accept="text/markdown, text/plain"/>
|
2020-01-09 16:16:26 +00:00
|
|
|
</label>
|
2020-01-14 16:59:30 +00:00
|
|
|
<input id="fileDates" name="fileDates" hidden/>
|
2020-01-09 16:16:26 +00: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 16:59:30 +00:00
|
|
|
<script>
|
2020-01-15 17:04:38 +00:00
|
|
|
// timezone offset in seconds
|
|
|
|
const tzOffsetSec = new Date().getTimezoneOffset() * 60;
|
2020-01-14 16:59:30 +00: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 17:04:38 +00:00
|
|
|
// convert from milliseconds to seconds and adjust for tz
|
|
|
|
dateMap[file.name] = Math.round(file.lastModified / 1000) + tzOffsetSec;
|
2020-01-14 16:59:30 +00:00
|
|
|
}
|
|
|
|
fileDates.value = JSON.stringify(dateMap);
|
|
|
|
})
|
|
|
|
</script>
|
2019-08-16 21:27:24 +00:00
|
|
|
<input type="submit" value="Import" />
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{template "footer" .}}
|
2019-08-26 22:04:00 +00:00
|
|
|
{{end}}
|