few refinements to tags

This commit is contained in:
Ted Unangst 2019-08-28 12:07:46 -04:00
parent 108973ef7b
commit 194c9a1223
3 changed files with 9 additions and 6 deletions

View File

@ -678,6 +678,7 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
xonk.Onts = append(xonk.Onts, name) xonk.Onts = append(xonk.Onts, name)
} }
} }
xonk.Onts = oneofakind(xonk.Onts)
} }
if originate(xid) != origin { if originate(xid) != origin {
log.Printf("original sin: %s <> %s", xid, origin) log.Printf("original sin: %s <> %s", xid, origin)
@ -853,8 +854,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
t["href"] = m.where t["href"] = m.where
tags = append(tags, t) tags = append(tags, t)
} }
ooo := ontologies(h.Noise) for _, o := range h.Onts {
for _, o := range ooo {
t := junk.New() t := junk.New()
t["type"] = "Hashtag" t["type"] = "Hashtag"
o = strings.ToLower(o) o = strings.ToLower(o)

View File

@ -669,6 +669,9 @@ func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) {
} }
onts = append(onts, []string{o, o[1:]}) onts = append(onts, []string{o, o[1:]})
} }
if u == nil {
w.Header().Set("Cache-Control", "max-age=300")
}
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["Onts"] = onts templinfo["Onts"] = onts
err = readviews.Execute(w, "onts.html", templinfo) err = readviews.Execute(w, "onts.html", templinfo)
@ -1309,10 +1312,10 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
} }
return return
} }
onts := ontologies(honk.Noise) honk.Onts = oneofakind(ontologies(honk.Noise))
res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid, res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid,
dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html", dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html",
honk.Precis, honk.Oonker, 0, strings.Join(onts, " ")) honk.Precis, honk.Oonker, 0, strings.Join(honk.Onts, " "))
if err != nil { if err != nil {
log.Printf("error saving honk: %s", err) log.Printf("error saving honk: %s", err)
http.Error(w, "something bad happened while saving", http.StatusInternalServerError) http.Error(w, "something bad happened while saving", http.StatusInternalServerError)
@ -1327,7 +1330,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
for _, o := range onts { for _, o := range honk.Onts {
_, err = stmtSaveOnts.Exec(strings.ToLower(o), honk.ID) _, err = stmtSaveOnts.Exec(strings.ToLower(o), honk.ID)
if err != nil { if err != nil {
log.Printf("error saving ont: %s", err) log.Printf("error saving ont: %s", err)

View File

@ -146,7 +146,7 @@ func upgradedb() {
onts := ontologies(noise) onts := ontologies(noise)
mo := re_more.FindAllString(noise, -1) mo := re_more.FindAllString(noise, -1)
for _, o := range mo { for _, o := range mo {
onts = append(onts, "#" + o[7:]) onts = append(onts, "#"+o[7:])
} }
if len(onts) > 0 { if len(onts) > 0 {
ontmap[honkid] = oneofakind(onts) ontmap[honkid] = oneofakind(onts)