aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/templates/dashboard
diff options
context:
space:
mode:
authorgrm <grm@eyesin.space>2026-09-12 12:26:17 +0300
committergrm <grm@eyesin.space>2026-09-12 12:26:17 +0300
commit2b450b66fee4906e746f6e04a6d07a72ff2faf64 (patch)
treeba2dbb3d9b3580113510dbf24d4ffe660cf95b26 /internal/web/templates/dashboard
parent336199c65d910bbd45a9c5dcbc3beae214d75b98 (diff)
downloadblogspace-2b450b66fee4906e746f6e04a6d07a72ff2faf64.tar.gz
blogspace-2b450b66fee4906e746f6e04a6d07a72ff2faf64.tar.bz2
blogspace-2b450b66fee4906e746f6e04a6d07a72ff2faf64.zip
Insert images straight from the Markdown editor
A shared editor partial adds an "Insert image" file picker plus paste and drag-and-drop on the textarea; a few lines of inline JS upload the file to the existing images endpoint (which now answers JSON when asked) and put the Markdown at the caret. Without JS the same file rides along with the form and is appended to the text on save, so nothing depends on scripting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/templates/dashboard')
-rw-r--r--internal/web/templates/dashboard/page_form.html7
-rw-r--r--internal/web/templates/dashboard/post_form.html7
2 files changed, 6 insertions, 8 deletions
diff --git a/internal/web/templates/dashboard/page_form.html b/internal/web/templates/dashboard/page_form.html
index 38aac71..2692449 100644
--- a/internal/web/templates/dashboard/page_form.html
+++ b/internal/web/templates/dashboard/page_form.html
@@ -2,13 +2,13 @@
{{define "content"}}
<div class="card">
<h1>{{if .Data.page.ID}}Edit page{{else}}New page{{end}}</h1>
- <form method="post">
+ <form method="post" enctype="multipart/form-data">
<input type="hidden" name="_csrf" value="{{.CSRF}}">
<label>Title<br><input name="title" value="{{.Data.page.Title}}" required maxlength="120"></label>
<label>Address <span class="muted">(leave empty to make one from the title; e.g. <code>about</code> → {{.BlogURL}}/about)</span><br>
<input name="slug" value="{{.Data.page.Slug}}" pattern="[a-z0-9]([a-z0-9-]*[a-z0-9])?" maxlength="80"></label>
- <label>Intro text <span class="muted">(Markdown, shown above the posts; optional)</span><br>
- <textarea name="intro" rows="8">{{.Data.page.IntroMD}}</textarea></label>
+ <label for="ed-intro">Intro text <span class="muted">(Markdown, shown above the posts; optional)</span></label>
+ {{template "editor" (dict "name" "intro" "value" .Data.page.IntroMD "rows" 8 "tall" false "upload" (print "/b/" .Blog.Subdomain "/images/upload") "csrf" .CSRF)}}
<label class="check"><input type="checkbox" name="show_in_nav"{{if .Data.page.ShowInNav}} checked{{end}}> Show in menu</label>
<p class="actionrow">
<button type="submit">Save</button>
@@ -17,5 +17,4 @@
</p>
</form>
</div>
-{{template "mdhelp"}}
{{end}}
diff --git a/internal/web/templates/dashboard/post_form.html b/internal/web/templates/dashboard/post_form.html
index 7e6f00f..8b4a593 100644
--- a/internal/web/templates/dashboard/post_form.html
+++ b/internal/web/templates/dashboard/post_form.html
@@ -2,7 +2,7 @@
{{define "content"}}
<div class="card">
<h1>{{if .Data.post.ID}}Edit post{{else}}New post{{end}}</h1>
- <form method="post">
+ <form method="post" enctype="multipart/form-data">
<input type="hidden" name="_csrf" value="{{.CSRF}}">
<label>Title<br><input name="title" value="{{.Data.post.Title}}" required maxlength="200" autofocus></label>
<div class="row">
@@ -12,8 +12,8 @@
<label>Address <span class="muted">(optional, made from the title)</span><br>
<input name="slug" value="{{.Data.post.Slug}}" pattern="[a-z0-9]([a-z0-9-]*[a-z0-9])?" maxlength="80"></label>
</div>
- <label>Content <span class="muted">(Markdown)</span><br>
- <textarea name="body" rows="24" class="editor">{{.Data.post.BodyMD}}</textarea></label>
+ <label for="ed-body">Content <span class="muted">(Markdown)</span></label>
+ {{template "editor" (dict "name" "body" "value" .Data.post.BodyMD "rows" 24 "tall" true "upload" (print "/b/" .Blog.Subdomain "/images/upload") "csrf" .CSRF)}}
<label class="check"><input type="checkbox" name="published"{{if .Data.post.Published}} checked{{end}}> Visible on the blog</label>
<p class="actionrow">
<button type="submit">Save</button>
@@ -22,5 +22,4 @@
</p>
</form>
</div>
-{{template "mdhelp"}}
{{end}}