quick mention @alias
Ted Unangst tedu@tedunangst.com
Tue, 10 Sep 2019 14:30:52 -0400
3 files changed,
31 insertions(+),
1 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ Quick mention @alias. + + Image descriptions. ++ Search. I hate it already.
M
fun.go
→
fun.go
@@ -346,6 +346,32 @@ s = strings.Replace(s, "\n", "<br>", -1)
return s } +var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+ ") + +func quickrename(s string, userid int64) string { + return re_quickmention.ReplaceAllStringFunc(s, func(m string) string { + prefix := "" + if m[0] == ' ' { + prefix = " " + m = m[1:] + } + prefix += "@" + m = m[1:] + m = m[:len(m)-1] + + row := stmtOneHonker.QueryRow(m, userid) + var xid string + err := row.Scan(&xid) + if err == nil { + _, name := handles(xid) + if name != "" { + m = name + } + } + return prefix + m + " " + }) +} + func mentionize(s string) string { s = re_mentions.ReplaceAllStringFunc(s, func(m string) string { where := gofish(m)
M
honk.go
→
honk.go
@@ -1186,6 +1186,7 @@ honk.Precis = noise[:idx]
noise = noise[idx+1:] } } + noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) noise = strings.TrimSpace(noise) honk.Precis = strings.TrimSpace(honk.Precis)@@ -1801,7 +1802,7 @@ var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt
var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt var stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt -var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt +var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt var stmtSelectOnts, stmtSaveOnts, stmtUpdateFlags, stmtClearFlags *sql.Stmt@@ -1820,6 +1821,7 @@ stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos) values (?, ?, ?, ?, ?)")
stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and flavor = ?") stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?") stmtHasHonker = preparetodie(db, "select honkerid from honkers where xid = ? and userid = ?") + stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid "