From b88fb1643c282e2567075b889b0ef79f5f9d3e27 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 7 Apr 2024 11:12:07 +0200 Subject: [PATCH] Fixed bug --- cmd/view/articles.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/view/articles.go b/cmd/view/articles.go index 5bd0ac2..14b18e7 100644 --- a/cmd/view/articles.go +++ b/cmd/view/articles.go @@ -413,8 +413,9 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc { } defer file.Close() - filename := fmt.Sprint(c.PicsDir, "/", time.Now().Format("2006-01-02_15:04:05"), "-", header.Filename) - absFilepath, err := filepath.Abs(filename) + filename := fmt.Sprint(time.Now().Format("2006-01-02_15:04:05"), "-", + header.Filename) + absFilepath, err := filepath.Abs(fmt.Sprint(c.PicsDir, "/", filename)) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) @@ -435,8 +436,8 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc { return } + imgMD := fmt.Sprint("![", header.Filename, "](/pics/", filename, ")") tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html") - tmpl = template.Must(tmpl, err) - tmpl.ExecuteTemplate(w, "editor-images", fmt.Sprint("![", header.Filename, "](", filename, ")")) + template.Must(tmpl, err).ExecuteTemplate(w, "editor-images", imgMD) } }