remove inline meme text from post
This commit is contained in:
parent
2a440560d9
commit
227a6a38c4
16
fun.go
16
fun.go
|
@ -192,10 +192,8 @@ func herdofemus(noise string) []Emu {
|
|||
|
||||
var re_memes = regexp.MustCompile("meme: ?([[:alnum:]_.-]+)")
|
||||
|
||||
func memetics(noise string) []*Donk {
|
||||
var donks []*Donk
|
||||
m := re_memes.FindAllString(noise, -1)
|
||||
for _, x := range m {
|
||||
func memetize(honk *Honk) {
|
||||
repl := func(x string) string {
|
||||
name := x[5:]
|
||||
if name[0] == ' ' {
|
||||
name = name[1:]
|
||||
|
@ -203,7 +201,7 @@ func memetics(noise string) []*Donk {
|
|||
fd, err := os.Open("memes/" + name)
|
||||
if err != nil {
|
||||
log.Printf("no meme for %s", name)
|
||||
continue
|
||||
return x
|
||||
}
|
||||
var peek [512]byte
|
||||
n, _ := fd.Read(peek[:])
|
||||
|
@ -214,7 +212,7 @@ func memetics(noise string) []*Donk {
|
|||
res, err := stmtSaveFile.Exec("", name, url, ct, 0, "")
|
||||
if err != nil {
|
||||
log.Printf("error saving meme: %s", err)
|
||||
continue
|
||||
return x
|
||||
}
|
||||
var d Donk
|
||||
d.FileID, _ = res.LastInsertId()
|
||||
|
@ -223,9 +221,11 @@ func memetics(noise string) []*Donk {
|
|||
d.Media = ct
|
||||
d.URL = url
|
||||
d.Local = false
|
||||
donks = append(donks, &d)
|
||||
honk.Donks = append(honk.Donks, &d)
|
||||
log.Printf("replace with -")
|
||||
return ""
|
||||
}
|
||||
return donks
|
||||
honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl)
|
||||
}
|
||||
|
||||
var re_bolder = regexp.MustCompile(`(^|\W)\*\*([\w\s,.!?'-]+)\*\*($|\W)`)
|
||||
|
|
4
honk.go
4
honk.go
|
@ -1047,7 +1047,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
honk.Donks = append(honk.Donks, donk)
|
||||
}
|
||||
}
|
||||
honk.Donks = append(honk.Donks, memetics(honk.Noise)...)
|
||||
memetize(&honk)
|
||||
|
||||
aud := strings.Join(honk.Audience, " ")
|
||||
whofore := 2
|
||||
|
@ -1069,7 +1069,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid,
|
||||
dt.Format(dbtimeformat), "", aud, noise, convoy, whofore, "html", honk.Precis, honk.Oonker)
|
||||
dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html", honk.Precis, honk.Oonker)
|
||||
if err != nil {
|
||||
log.Printf("error saving honk: %s", err)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue