all repos — honk @ d8aabac0766e3060770b5e34fc9c3c7707982061

my fork of honk

add search. opening the gates to hell here.
Ted Unangst tedu@tedunangst.com
Fri, 30 Aug 2019 11:46:25 -0400
commit

d8aabac0766e3060770b5e34fc9c3c7707982061

parent

47cd70806cb551c6e73b12d68932be65ed56f6ca

2 files changed, 17 insertions(+), 1 deletions(-)

jump to
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

-- next +++ Search. I hate it already. + + Unbonking. ++ Hashtags that work?
M honk.gohonk.go

@@ -637,6 +637,12 @@ u := login.GetUserInfo(r)

honks := gethonksbyconvoy(u.UserID, c) honkpage(w, r, u, nil, honks, template.HTML(html.EscapeString("honks in convoy: "+c))) } +func showsearch(w http.ResponseWriter, r *http.Request) { + q := r.FormValue("q") + u := login.GetUserInfo(r) + honks := gethonksbysearch(u.UserID, q) + honkpage(w, r, u, nil, honks, template.HTML(html.EscapeString("honks for search: "+q))) +} func showontology(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] u := login.GetUserInfo(r)

@@ -917,6 +923,12 @@ honks := getsomehonks(rows, err)

for i, j := 0, len(honks)-1; i < j; i, j = i+1, j-1 { honks[i], honks[j] = honks[j], honks[i] } + return honks +} +func gethonksbysearch(userid int64, q string) []*Honk { + q = "%" + q + "%" + rows, err := stmtHonksBySearch.Query(userid, q) + honks := getsomehonks(rows, err) return honks } func gethonksbyontology(userid int64, name string) []*Honk {

@@ -1748,6 +1760,7 @@ loggedin.HandleFunc("/h", showhonker)

loggedin.HandleFunc("/c/{name:[[:alnum:]]+}", showcombo) loggedin.HandleFunc("/c", showcombos) loggedin.HandleFunc("/t", showconvoy) + loggedin.HandleFunc("/q", showsearch) loggedin.Handle("/savehonker", login.CSRFWrap("savehonker", http.HandlerFunc(savehonker))) err = http.Serve(listener, mux)

@@ -1778,7 +1791,7 @@

var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt -var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *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 stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt

@@ -1813,6 +1826,7 @@ stmtHonksForMe = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit)

stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.userid = ? and honkers.name = ?"+butnotthose+limit) stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit) stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.combos like ?"+butnotthose+limit) + stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.userid = ? and noise like ?"+limit) stmtHonksByConvoy = preparetodie(db, selecthonks+"where (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit) stmtHonksByOntology = preparetodie(db, selecthonks+"join onts on honks.honkid = onts.honkid where onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit)