public tag index
Ted Unangst tedu@tedunangst.com
Tue, 27 Aug 2019 21:43:38 -0400
2 files changed,
38 insertions(+),
1 deletions(-)
M
honk.go
→
honk.go
@@ -648,6 +648,30 @@ honks := gethonksbyontology(userid, "#"+name)
honkpage(w, r, u, nil, honks, template.HTML(html.EscapeString("honks by ontology: "+name))) } +func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) { + rows, err := stmtSelectOnts.Query() + if err != nil { + log.Printf("selection error: %s", err) + return + } + var onts [][]string + for rows.Next() { + var o string + err := rows.Scan(&o) + if err != nil { + log.Printf("error scanning ont: %s", err) + continue + } + onts = append(onts, []string{o, o[1:]}) + } + templinfo := getInfo(r) + templinfo["Onts"] = onts + err = readviews.Execute(w, "onts.html", templinfo) + if err != nil { + log.Print(err) + } +} + func showhonk(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] user, err := butwhatabout(name)@@ -1634,6 +1658,7 @@ "views/funzone.html",
"views/login.html", "views/xzone.html", "views/header.html", + "views/onts.html", ) if !debug { s := "views/style.css"@@ -1662,6 +1687,7 @@ getters.HandleFunc("/"+userSep+"/{name:[[:alnum:]]+}/outbox", outbox)
getters.HandleFunc("/"+userSep+"/{name:[[:alnum:]]+}/followers", emptiness) getters.HandleFunc("/"+userSep+"/{name:[[:alnum:]]+}/following", emptiness) getters.HandleFunc("/a", avatate) + getters.HandleFunc("/o", thelistingoftheontologies) getters.HandleFunc("/o/{name:[a-z0-9-]+}", showontology) getters.HandleFunc("/d/{xid:[[:alnum:].]+}", servefile) getters.HandleFunc("/emu/{xid:[[:alnum:]_.-]+}", serveemu)@@ -1730,7 +1756,7 @@ var stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt -var stmtSaveOnts, stmtUpdateFlags, stmtClearFlags *sql.Stmt +var stmtSelectOnts, stmtSaveOnts, stmtUpdateFlags, stmtClearFlags *sql.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s)@@ -1788,6 +1814,7 @@ stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ?")
stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100") stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?") stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?") + stmtSelectOnts = preparetodie(db, "select distinct(ontology) from onts join honks on onts.honkid = honks.honkid where honks.whofore = 2") } func ElaborateUnitTests() {
A
views/onts.html
@@ -0,0 +1,10 @@
+{{ template "header.html" . }} +<main> +<div class="info"> +<p>ontologies of interest +<p> +{{ range .Onts }} +<a href="/o/{{ index . 1 }}">{{ index . 0 }}</a> +{{ end }} +</div> +</main>