From 5615210be5c6c6bc525e1a650cc20244ec50c5bc Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 7 Apr 2024 11:32:38 +0200 Subject: [PATCH] Add cli arg for domain --- cmd/control/cli.go | 2 ++ cmd/view/articles.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/control/cli.go b/cmd/control/cli.go index 1715d66..0b870b3 100644 --- a/cmd/control/cli.go +++ b/cmd/control/cli.go @@ -8,6 +8,7 @@ import ( type CliArgs struct { DBName string + Domain string KeyFile string LogFile string Port string @@ -21,6 +22,7 @@ func HandleCliArgs() (*CliArgs, error) { cliArgs := new(CliArgs) flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name") + flag.StringVar(&cliArgs.Domain, "domain", "", "domain name") keyFile := flag.String("key", "/var/www/cpolis/cpolis.key", "key file") logFile := flag.String("log", "/var/log/cpolis.log", "log file") flag.StringVar(&cliArgs.PicsDir, "pics", "pics", "pictures directory") diff --git a/cmd/view/articles.go b/cmd/view/articles.go index 14b18e7..490390c 100644 --- a/cmd/view/articles.go +++ b/cmd/view/articles.go @@ -436,7 +436,7 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc { return } - imgMD := fmt.Sprint("![", header.Filename, "](/pics/", filename, ")") + imgMD := fmt.Sprint("![", header.Filename, "](", c.Domain, "/pics/", filename, ")") tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html") template.Must(tmpl, err).ExecuteTemplate(w, "editor-images", imgMD) }