Compare commits
3 Commits
v0.2.4
...
822ca2b8ab
Author | SHA1 | Date | |
---|---|---|---|
822ca2b8ab | |||
af65180893 | |||
5615210be5 |
@ -4,7 +4,7 @@ tmp_dir = "tmp"
|
|||||||
|
|
||||||
[build]
|
[build]
|
||||||
args_bin = []
|
args_bin = []
|
||||||
bin = "./tmp/main -key tmp/key.gob -log tmp/cpolis.log -pics tmp/pics -rss tmp/orientexpress_alle.rss -web web"
|
bin = "./tmp/main -domain localhost:8080 -key tmp/key.gob -log tmp/cpolis.log -pics tmp/pics -rss tmp/orientexpress_alle.rss -web web"
|
||||||
cmd = "go build -o ./tmp/main ./cmd/main.go"
|
cmd = "go build -o ./tmp/main ./cmd/main.go"
|
||||||
delay = 0
|
delay = 0
|
||||||
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||||
|
@ -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")
|
||||||
|
@ -9,8 +9,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"streifling.com/jason/cpolis/cmd/control"
|
"streifling.com/jason/cpolis/cmd/control"
|
||||||
"streifling.com/jason/cpolis/cmd/model"
|
"streifling.com/jason/cpolis/cmd/model"
|
||||||
)
|
)
|
||||||
@ -413,8 +415,9 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
filename := fmt.Sprint(time.Now().Format("2006-01-02_15:04:05"), "-",
|
nameStrings := strings.Split(header.Filename, ".")
|
||||||
header.Filename)
|
extension := "." + nameStrings[len(nameStrings)-1]
|
||||||
|
filename := fmt.Sprint(uuid.New(), extension)
|
||||||
absFilepath, err := filepath.Abs(fmt.Sprint(c.PicsDir, "/", filename))
|
absFilepath, err := filepath.Abs(fmt.Sprint(c.PicsDir, "/", filename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -436,7 +439,8 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
imgMD := fmt.Sprint("")
|
alt := strings.Join(nameStrings[0:len(nameStrings)-1], " ")
|
||||||
|
imgMD := fmt.Sprint("")
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.22.0
|
|||||||
require (
|
require (
|
||||||
git.streifling.com/jason/rss v0.1.2
|
git.streifling.com/jason/rss v0.1.2
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/go-sql-driver/mysql v1.7.1
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/sessions v1.2.2
|
github.com/gorilla/sessions v1.2.2
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26
|
github.com/microcosm-cc/bluemonday v1.0.26
|
||||||
github.com/yuin/goldmark v1.7.0
|
github.com/yuin/goldmark v1.7.0
|
||||||
|
2
go.sum
2
go.sum
@ -6,6 +6,8 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt
|
|||||||
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
||||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
||||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
|
Reference in New Issue
Block a user