all repos — honk @ 3d11175057b11df3034e660ba2974b5b198ce408

my fork of honk

tune up quotes. save the fetched post.
Ted Unangst tedu@tedunangst.com
Sun, 02 Jul 2023 14:44:52 -0400
commit

3d11175057b11df3034e660ba2974b5b198ce408

parent

332213347afb163a6f299e30aec463739e06c8af

1 files changed, 39 insertions(+), 24 deletions(-)

jump to
M activity.goactivity.go

@@ -511,42 +511,57 @@ return ""

} var re_mast0link = regexp.MustCompile(`https://[[:alnum:].]+/users/[[:alnum:]]+/statuses/[[:digit:]]+`) -var re_masto1ink = regexp.MustCompile(`https://[[:alnum:].]+/@[[:alnum:]]+/[[:digit:]]+`) +var re_masto1ink = regexp.MustCompile(`https://([[:alnum:].]+)/@([[:alnum:]]+)/([[:digit:]]+)`) var re_misslink = regexp.MustCompile(`https://[[:alnum:].]+/notes/[[:alnum:]]+`) var re_honklink = regexp.MustCompile(`https://[[:alnum:].]+/u/[[:alnum:]]+/h/[[:alnum:]]+`) var re_r0malink = regexp.MustCompile(`https://[[:alnum:].]+/objects/[[:alnum:]-]+`) var re_roma1ink = regexp.MustCompile(`https://[[:alnum:].]+/notice/[[:alnum:]]+`) var re_qtlinks = regexp.MustCompile(`>https://[^\s<]+<`) -func qutify(user *WhatAbout, content string) string { - // well this is gross - malcontent := strings.ReplaceAll(content, `</span><span class="ellipsis">`, "") - malcontent = strings.ReplaceAll(malcontent, `</span><span class="invisible">`, "") - mlinks := re_qtlinks.FindAllString(malcontent, -1) - for _, m := range mlinks { - m = m[1 : len(m)-1] - if re_mast0link.MatchString(m) || re_masto1ink.MatchString(m) || - re_misslink.MatchString(m) || - re_honklink.MatchString(m) || - re_r0malink.MatchString(m) || re_roma1ink.MatchString(m) { - j, err := GetJunk(user.ID, m) - if err == nil { - q, ok := j.GetString("content") - if ok { - content = fmt.Sprintf("%s<blockquote>%s</blockquote>", content, q) - } - } - } - } - return content -} - func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { depth := 0 maxdepth := 10 currenttid := "" goingup := 0 var xonkxonkfn func(item junk.Junk, origin string, isUpdate bool) *Honk + + qutify := func(user *WhatAbout, content string) string { + if depth >= maxdepth { + ilog.Printf("in too deep") + return content + } + // well this is gross + malcontent := strings.ReplaceAll(content, `</span><span class="ellipsis">`, "") + malcontent = strings.ReplaceAll(malcontent, `</span><span class="invisible">`, "") + mlinks := re_qtlinks.FindAllString(malcontent, -1) + for _, m := range mlinks { + tryit := false + m = m[1 : len(m)-1] + if re_mast0link.MatchString(m) || re_misslink.MatchString(m) || + re_honklink.MatchString(m) || re_r0malink.MatchString(m) || + re_roma1ink.MatchString(m) { + tryit = true + } else if re_masto1ink.MatchString(m) { + m = re_masto1ink.ReplaceAllString(m, "https://$1/users/$2/statuses/$3") + tryit = true + } + if tryit { + if x := getxonk(user.ID, m); x != nil { + content = fmt.Sprintf("%s<blockquote>%s</blockquote>", content, x.Noise) + } else if j, err := GetJunk(user.ID, m); err == nil { + q, ok := j.GetString("content") + if ok { + content = fmt.Sprintf("%s<blockquote>%s</blockquote>", content, q) + } + prevdepth := depth + depth = maxdepth + xonkxonkfn(j, originate(m), false) + depth = prevdepth + } + } + } + return content + } saveonemore := func(xid string) { dlog.Printf("getting onemore: %s", xid)