From 067d3064a6047583fc2b969db09722161e400186 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:37:11 -0400 Subject: [PATCH] meme: fix default config and save path --- plugins/meme/meme.go | 4 ++-- plugins/meme/webHandlers.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/meme/meme.go b/plugins/meme/meme.go index 319eabf..b819a1c 100644 --- a/plugins/meme/meme.go +++ b/plugins/meme/meme.go @@ -370,8 +370,8 @@ func (p *MemePlugin) defaultFormatConfig() []memeText { } ret: return []memeText{ - {XPerc: 0.5, YPerc: 0.1, Caps: true}, - {XPerc: 0.5, YPerc: 0.9, Caps: true}, + {XPerc: 0.5, YPerc: 0.05, Caps: true}, + {XPerc: 0.5, YPerc: 0.95, Caps: true}, } } diff --git a/plugins/meme/webHandlers.go b/plugins/meme/webHandlers.go index f671b02..1734e17 100644 --- a/plugins/meme/webHandlers.go +++ b/plugins/meme/webHandlers.go @@ -2,6 +2,7 @@ package meme import ( "encoding/json" + "errors" "fmt" "github.com/ggicci/httpin" "net/http" @@ -89,7 +90,7 @@ func (p *MemePlugin) rmMeme(w http.ResponseWriter, r *http.Request) { } type SaveReq struct { - Name string `in:"path=name"` + Name string `in:"path=name;form=name"` Config string `in:"form=config"` URL string `in:"form=url"` } @@ -98,6 +99,14 @@ func (p *MemePlugin) saveMeme(w http.ResponseWriter, r *http.Request) { input := r.Context().Value(httpin.Input).(*SaveReq) checkError := mkCheckError(w) + log.Debug().Interface("save input", input).Send() + if input.Name == "" { + checkError(errors.New("no name")) + } + if input.URL == "" { + checkError(errors.New("no URL")) + } + formats := p.c.GetMap("meme.memes", defaultFormats) formats[input.Name] = input.URL err := p.c.SetMap("meme.memes", formats)