mirror of https://github.com/velour/catbase.git
meme: fix default config and save path
This commit is contained in:
parent
c09dfd46e2
commit
067d3064a6
|
@ -370,8 +370,8 @@ func (p *MemePlugin) defaultFormatConfig() []memeText {
|
||||||
}
|
}
|
||||||
ret:
|
ret:
|
||||||
return []memeText{
|
return []memeText{
|
||||||
{XPerc: 0.5, YPerc: 0.1, Caps: true},
|
{XPerc: 0.5, YPerc: 0.05, Caps: true},
|
||||||
{XPerc: 0.5, YPerc: 0.9, Caps: true},
|
{XPerc: 0.5, YPerc: 0.95, Caps: true},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package meme
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ggicci/httpin"
|
"github.com/ggicci/httpin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -89,7 +90,7 @@ func (p *MemePlugin) rmMeme(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SaveReq struct {
|
type SaveReq struct {
|
||||||
Name string `in:"path=name"`
|
Name string `in:"path=name;form=name"`
|
||||||
Config string `in:"form=config"`
|
Config string `in:"form=config"`
|
||||||
URL string `in:"form=url"`
|
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)
|
input := r.Context().Value(httpin.Input).(*SaveReq)
|
||||||
checkError := mkCheckError(w)
|
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 := p.c.GetMap("meme.memes", defaultFormats)
|
||||||
formats[input.Name] = input.URL
|
formats[input.Name] = input.URL
|
||||||
err := p.c.SetMap("meme.memes", formats)
|
err := p.c.SetMap("meme.memes", formats)
|
||||||
|
|
Loading…
Reference in New Issue