From 3548aad87333e7b9e394edef5fe9610857154db0 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 27 Aug 2019 21:43:38 -0400 Subject: [PATCH] public tag index --- honk.go | 29 ++++++++++++++++++++++++++++- views/onts.html | 10 ++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 views/onts.html diff --git a/honk.go b/honk.go index 82aa66a..31c3288 100644 --- a/honk.go +++ b/honk.go @@ -648,6 +648,30 @@ func showontology(w http.ResponseWriter, r *http.Request) { 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 @@ func serve() { "views/login.html", "views/xzone.html", "views/header.html", + "views/onts.html", ) if !debug { s := "views/style.css" @@ -1662,6 +1687,7 @@ func serve() { 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, stmtSav 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 @@ func prepareStatements(db *sql.DB) { 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() { diff --git a/views/onts.html b/views/onts.html new file mode 100644 index 0000000..6d07803 --- /dev/null +++ b/views/onts.html @@ -0,0 +1,10 @@ +{{ template "header.html" . }} +
+
+

ontologies of interest +

+{{ range .Onts }} +{{ index . 0 }} +{{ end }} +

+