aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_posts.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/handlers_posts.go')
-rw-r--r--internal/web/handlers_posts.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/web/handlers_posts.go b/internal/web/handlers_posts.go
index 02a3fd7..88d5c20 100644
--- a/internal/web/handlers_posts.go
+++ b/internal/web/handlers_posts.go
@@ -86,7 +86,7 @@ func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) {
}
img, err := s.readUpload(r, "inline_image")
if err != nil {
- fail(http.StatusBadRequest, "Image not added: "+err.Error())
+ fail(http.StatusBadRequest, s.tr(r, "Image not added:")+" "+err.Error())
return
}
p.BodyMD = appendImageMD(p.BodyMD, img)
@@ -98,16 +98,16 @@ func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) {
}
switch {
case p.Title == "" || len(p.Title) > 200:
- fail(http.StatusBadRequest, "Title is required (max 200 characters).")
+ fail(http.StatusBadRequest, s.tr(r, "Title is required (max 200 characters)."))
return
case !slug.Valid(p.Slug):
- fail(http.StatusBadRequest, "Slug may only contain lowercase letters, digits and dashes.")
+ fail(http.StatusBadRequest, s.tr(r, "Slug may only contain lowercase letters, digits and dashes."))
return
case !pageOK:
- fail(http.StatusBadRequest, "Pick a page for this post.")
+ fail(http.StatusBadRequest, s.tr(r, "Pick a page for this post."))
return
case len(p.BodyMD) > 200_000:
- fail(http.StatusBadRequest, "Post is too long (200 KB max).")
+ fail(http.StatusBadRequest, s.tr(r, "Post is too long (200 KB max)."))
return
}
p.BodyHTML = markdown.Render(p.BodyMD)
@@ -128,13 +128,13 @@ func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
if errors.Is(err, store.ErrConflict) {
- fail(http.StatusConflict, "A post with that slug already exists on this page; choose another slug.")
+ fail(http.StatusConflict, s.tr(r, "A post with that slug already exists on this page; choose another slug."))
return
}
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+blog.Subdomain+"/posts/"+strconv.FormatInt(p.ID, 10)+"/edit", "Saved. Refresh your blog to see it.")
+ redirectOK(w, r, "/b/"+blog.Subdomain+"/posts/"+strconv.FormatInt(p.ID, 10)+"/edit", s.tr(r, "Saved. Refresh your blog to see it."))
}
func (s *Server) handlePostDeleteConfirm(w http.ResponseWriter, r *http.Request) {
@@ -143,7 +143,7 @@ func (s *Server) handlePostDeleteConfirm(w http.ResponseWriter, r *http.Request)
return
}
s.render(w, r, "dashboard/confirm.html", map[string]any{
- "what": "the post \"" + p.Title + "\"",
+ "what": s.trf(r, "the post ā€œ%sā€", p.Title),
"action": r.URL.Path,
"back": "/b/" + currentBlog(r).Subdomain + "/posts",
})
@@ -158,5 +158,5 @@ func (s *Server) handlePostDelete(w http.ResponseWriter, r *http.Request) {
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/posts", "Post deleted.")
+ redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/posts", s.tr(r, "Post deleted."))
}