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">
|
2024-12-27 10:30:15 +01:00
|
|
|
<h3>Titel</h3>
|
2024-10-27 07:21:36 +01:00
|
|
|
<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-12-27 10:30:15 +01:00
|
|
|
<h3>Beschreibung</h3>
|
2024-10-27 07:20:23 +01:00
|
|
|
<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-12-27 10:30:15 +01:00
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<h3>Artikel</h3>
|
2025-03-01 08:59:52 +01:00
|
|
|
<div id="editor"></div>
|
2024-12-27 10:30:15 +01:00
|
|
|
<input id="article-content" name="article-content" type="hidden" value="{{.Content}}" />
|
|
|
|
</div>
|
|
|
|
|
2024-04-03 18:08:56 +02:00
|
|
|
<div>
|
2024-12-27 10:30:15 +01:00
|
|
|
<h3>Tags</h3>
|
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-12-27 10:30:15 +01:00
|
|
|
<div>
|
|
|
|
<h3>Beteiligte</h3>
|
|
|
|
{{range .ArticleUsers}}
|
|
|
|
<div class="border border-slate-200 dark:border-slate-800 flex gap-4 px-2 py-1 rounded-md">
|
|
|
|
<span>{{.FirstName}} {{.LastName}}: </span>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<input id="{{.ID}}-author" name="user-{{.ID}}" type="radio" value="author" {{if eq .ArticleRole
|
|
|
|
1}}checked{{end}} />
|
|
|
|
<label for="{{.ID}}-author">Autor</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<input id="{{.ID}}-contributor" name="user-{{.ID}}" type="radio" value="contributor" {{if eq
|
|
|
|
.ArticleRole 2}}checked{{end}} />
|
|
|
|
<label for="{{.ID}}-contributor">Mitwirkender</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<input id="{{.ID}}-none" name="user-{{.ID}}" type="radio" {{if eq .ArticleRole 0}}checked{{end}} />
|
|
|
|
<label for="{{.ID}}-none">Unbeteiligt</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
2025-01-12 14:22:11 +01:00
|
|
|
<input id="creator" name="creator" type="checkbox" value="author" {{if eq .Creator.ArticleRole
|
|
|
|
1}}checked{{end}} />
|
|
|
|
<label for="creator">Ich bin Autor.</label>
|
2024-11-01 16:31:47 +01:00
|
|
|
</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>
|
2025-03-01 08:59:52 +01:00
|
|
|
var editor = new toastui.Editor({
|
|
|
|
el: document.querySelector('#editor'),
|
|
|
|
height: '500px',
|
|
|
|
hooks: {
|
|
|
|
addImageBlobHook: (blob, callback) => {
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('article-image', blob);
|
|
|
|
|
|
|
|
fetch('/article/upload-image', {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
2024-08-08 21:09:38 +02:00
|
|
|
})
|
2025-03-01 08:59:52 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
callback(data, 'Alternativtext');
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
htmx.trigger(htmx.find('#notification'), 'htmx:responseError', {xhr: {responseText: error.message}});
|
|
|
|
console.error('Upload fehlgeschlagen:', error);
|
|
|
|
});
|
|
|
|
}
|
2024-08-08 21:09:38 +02:00
|
|
|
},
|
2025-03-01 08:59:52 +01:00
|
|
|
initialEditType: 'wysiwyg',
|
|
|
|
initialValue: '{{.Content}}',
|
|
|
|
language: 'de',
|
|
|
|
theme: localStorage.theme,
|
|
|
|
usageStatistics: 'false'
|
2024-08-08 21:09:38 +02:00
|
|
|
});
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2025-03-01 08:59:52 +01:00
|
|
|
editor.on('change', () => {
|
|
|
|
document.getElementById('article-content').value = editor.getMarkdown();
|
2024-08-08 21:09:38 +02:00
|
|
|
});
|
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}}
|