2024-02-18 10:07:49 +01:00
|
|
|
{{define "page-content"}}
|
2024-02-24 09:54:25 +01:00
|
|
|
<h2>Editor</h2>
|
2024-04-07 18:57:03 +02:00
|
|
|
|
2024-11-01 16:31:47 +01:00
|
|
|
<form class="flex flex-col gap-4" id="edit-area" hx-encoding="multipart/form-data">
|
2024-04-01 14:22:59 +02:00
|
|
|
<div class="flex flex-col gap-y-1">
|
2024-10-29 16:36:40 +01:00
|
|
|
{{template "article-banner-template" .}}
|
2024-10-27 07:21:36 +01:00
|
|
|
|
2024-10-20 16:10:25 +02:00
|
|
|
<div class="grid grid-cols-2 gap-4 items-center">
|
2024-10-27 07:21:36 +01:00
|
|
|
<div class="flex flex-col">
|
|
|
|
<label for="article-title">Titel</label>
|
|
|
|
<input name="article-title" type="text" value="{{.Article.Title}}" />
|
|
|
|
</div>
|
|
|
|
|
2024-11-01 16:31:47 +01:00
|
|
|
<div class="flex">
|
2024-10-27 13:58:03 +01:00
|
|
|
<label class="btn text-center" for="article-banner">Titelbild</label>
|
2024-10-27 07:21:36 +01:00
|
|
|
<input class="hidden" id="article-banner" name="article-banner" type="file" required
|
2024-10-29 16:36:40 +01:00
|
|
|
hx-post="/article/upload-banner" hx-swap="outerHTML" hx-target="#article-banner-container" />
|
2024-10-27 07:21:36 +01:00
|
|
|
</div>
|
2024-10-20 16:10:25 +02:00
|
|
|
</div>
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
2024-08-30 21:20:29 +02:00
|
|
|
|
2024-11-01 16:31:47 +01:00
|
|
|
<div class="flex flex-col gap-1">
|
2024-10-27 07:20:23 +01:00
|
|
|
<label for="article-summary">Beschreibung</label>
|
|
|
|
<textarea name="article-summary">{{.Article.Summary}}</textarea>
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
2024-08-30 21:20:29 +02:00
|
|
|
|
2024-04-03 18:08:56 +02:00
|
|
|
<div>
|
|
|
|
<span>Tags</span>
|
2024-11-01 16:31:47 +01:00
|
|
|
<div class="flex flex-wrap gap-4">
|
2024-09-01 18:18:07 +02:00
|
|
|
<div>
|
2024-09-28 12:17:03 +02:00
|
|
|
<input id="issue" name="issue" type="checkbox" {{if .Article.IsInIssue}}checked{{end}} />
|
2024-09-01 18:18:07 +02:00
|
|
|
<label for="issue">Orient Express</label>
|
|
|
|
</div>
|
|
|
|
|
2024-07-17 23:25:57 +02:00
|
|
|
{{range .Tags}}
|
2024-04-03 18:08:56 +02:00
|
|
|
<div>
|
2024-09-28 12:17:03 +02:00
|
|
|
<input id="tag-{{.Name}}" name="tags" type="checkbox" value="{{.ID}}" {{if index $.Selected
|
|
|
|
.ID}}checked{{end}} />
|
|
|
|
<label for="tag-{{.Name}}">{{.Name}}</label>
|
2024-04-03 18:08:56 +02:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2024-03-28 08:41:38 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-11-01 16:31:47 +01:00
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<label for="easyMDE">Artikel</label>
|
|
|
|
<textarea id="easyMDE">{{.Content}}</textarea>
|
|
|
|
<input id="article-content" name="article-content" type="hidden" value="{{.Content}}" />
|
|
|
|
</div>
|
|
|
|
|
2024-04-01 14:22:59 +02:00
|
|
|
<div class="btn-area">
|
2024-09-28 12:17:03 +02:00
|
|
|
<input class="action-btn" type="submit" value="Senden" hx-post="/article/{{.Action}}"
|
|
|
|
hx-target="#page-content" />
|
2024-04-03 20:24:54 +02:00
|
|
|
<button class="btn" hx-get="/hub" hx-target="#page-content">Abbrechen</button>
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
2024-02-18 10:07:49 +01:00
|
|
|
</form>
|
2024-03-28 08:41:38 +01:00
|
|
|
|
2024-03-29 09:07:17 +01:00
|
|
|
<script>
|
2024-08-08 21:09:38 +02:00
|
|
|
var easyMDE = new EasyMDE({
|
|
|
|
element: document.getElementById('easyMDE'),
|
|
|
|
hideIcons: ['image'],
|
|
|
|
imageTexts: {sbInit: ''},
|
|
|
|
showIcons: ["code", "table", "upload-image"],
|
|
|
|
uploadImage: true,
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-08 21:09:38 +02:00
|
|
|
imageUploadFunction: function (file, onSuccess, onError) {
|
|
|
|
var formData = new FormData();
|
|
|
|
formData.append('article-image', file);
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-30 21:20:29 +02:00
|
|
|
fetch('/article/upload-image', {
|
2024-08-08 21:09:38 +02:00
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
onSuccess(data);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2024-10-04 16:06:33 +02:00
|
|
|
htmx.trigger(htmx.find('#notification'), 'htmx:responseError', {xhr: {responseText: error.message}});
|
2024-08-08 21:09:38 +02:00
|
|
|
onError(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-08 21:09:38 +02:00
|
|
|
easyMDE.codemirror.on("change", () => {
|
|
|
|
document.getElementById('article-content').value = easyMDE.value();
|
|
|
|
});
|
2024-03-29 09:07:17 +01:00
|
|
|
</script>
|
|
|
|
{{end}}
|
2024-10-27 07:21:36 +01:00
|
|
|
|
|
|
|
{{define "article-banner-template"}}
|
2024-10-29 16:36:40 +01:00
|
|
|
<div id="article-banner-container">
|
2024-11-01 16:31:47 +01:00
|
|
|
<img src="/image/serve/{{.Image}}" alt="" />
|
|
|
|
<input id="article-banner-url" name="article-banner-url" type="hidden" value="{{.Image}}" />
|
2024-10-27 07:21:36 +01:00
|
|
|
</div>
|
|
|
|
{{end}}
|