From d07366f6feeaf8cf03dd0fa28e00f40b651d6643 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 25 Oct 2019 17:59:30 -0400 Subject: [PATCH] expose ontology as ap collection --- web.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/web.go b/web.go index def1386..51e5c4f 100644 --- a/web.go +++ b/web.go @@ -535,6 +535,7 @@ var oldoutbox = cache.New(cache.Options{Filler: func(name string) ([]byte, bool) j := junk.New() j["@context"] = itiswhatitis j["id"] = user.URL + "/outbox" + j["attributedTo"] = user.URL j["type"] = "OrderedCollection" j["totalItems"] = len(jonks) j["orderedItems"] = jonks @@ -581,6 +582,7 @@ func emptiness(w http.ResponseWriter, r *http.Request) { j := junk.New() j["@context"] = itiswhatitis j["id"] = user.URL + colname + j["attributedTo"] = user.URL j["type"] = "OrderedCollection" j["totalItems"] = 0 j["orderedItems"] = []junk.Junk{} @@ -688,6 +690,31 @@ func showontology(w http.ResponseWriter, r *http.Request) { userid = u.UserID } honks := gethonksbyontology(userid, "#"+name, 0) + if friendorfoe(r.Header.Get("Accept")) { + if len(honks) > 20 { + honks = honks[0:20] + } + + var xids []string + for _, h := range honks { + xids = append(xids, h.XID) + } + + user := getserveruser() + + j := junk.New() + j["@context"] = itiswhatitis + j["id"] = fmt.Sprintf("https://%s/o/%s", serverName, name) + j["attributedTo"] = user.URL + j["type"] = "OrderedCollection" + j["totalItems"] = len(xids) + j["orderedItems"] = xids + + w.Header().Set("Cache-Control", "max-age=300") + j.Write(w) + return + } + templinfo := getInfo(r) templinfo["ServerMessage"] = "honks by ontology: " + name templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)