Add cli arg for domain

This commit is contained in:
Jason Streifling 2024-04-07 11:32:38 +02:00
parent b88fb1643c
commit 5615210be5
2 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
type CliArgs struct { type CliArgs struct {
DBName string DBName string
Domain string
KeyFile string KeyFile string
LogFile string LogFile string
Port string Port string
@ -21,6 +22,7 @@ func HandleCliArgs() (*CliArgs, error) {
cliArgs := new(CliArgs) cliArgs := new(CliArgs)
flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name") 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") keyFile := flag.String("key", "/var/www/cpolis/cpolis.key", "key file")
logFile := flag.String("log", "/var/log/cpolis.log", "log file") logFile := flag.String("log", "/var/log/cpolis.log", "log file")
flag.StringVar(&cliArgs.PicsDir, "pics", "pics", "pictures directory") flag.StringVar(&cliArgs.PicsDir, "pics", "pics", "pictures directory")

View File

@ -436,7 +436,7 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc {
return 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") tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
template.Must(tmpl, err).ExecuteTemplate(w, "editor-images", imgMD) template.Must(tmpl, err).ExecuteTemplate(w, "editor-images", imgMD)
} }