Compare commits

...

2 Commits

Author SHA1 Message Date
Chris Sexton ba47710b46 meme: add confirm to deletion button 2021-01-11 17:30:09 -05:00
Chris Sexton 33372ed770 meme: add default to all new memes 2021-01-11 16:30:18 -05:00
3 changed files with 18 additions and 7 deletions

View File

@ -41,7 +41,7 @@ type cachedImage struct {
type memeText struct {
XPerc float64 `json:"x"`
YPerc float64 `json:"y"`
Text string `json:"t"`
Text string `json:"t",omitempty`
Caps bool `json:"c"`
}
@ -335,6 +335,11 @@ func defaultFormatConfig() []memeText {
}
}
func defaultFormatConfigJSON() string {
c, _ := json.Marshal(defaultFormatConfig())
return string(c)
}
func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText) (string, int, int, error) {
fontSizes := []float64{48, 36, 24, 16, 12}
formats := p.c.GetMap("meme.memes", defaultFormats)

View File

@ -200,12 +200,14 @@ var memeIndex = `
evt.preventDefault();
evt.stopPropagation();
}
axios.delete('/meme/rm', { data: this.editConfig })
.then(resp => {
this.editConfig = null;
this.refresh();
})
.catch(err => this.err = err);
if (confirm("Are you sure you want to delete this meme?")) {
axios.delete('/meme/rm', { data: this.editConfig })
.then(resp => {
this.editConfig = null;
this.refresh();
})
.catch(err => this.err = err);
}
}
}
})

View File

@ -122,6 +122,10 @@ func (p *MemePlugin) addMeme(w http.ResponseWriter, r *http.Request) {
formats[values.Name] = values.URL
err = p.c.SetMap("meme.memes", formats)
checkError(err)
if values.Config == "" {
values.Config = defaultFormatConfigJSON()
}
configs := p.c.GetMap("meme.memeconfigs", map[string]string{})
configs[values.Name] = values.Config
err = p.c.SetMap("meme.memeconfigs", configs)