From d6ade574f03608daf9fb4c469f815a6c365b8351 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 25 Sep 2020 19:09:01 -0400 Subject: [PATCH] support hashtags in bios --- activity.go | 13 +++++++++++++ database.go | 1 + honk.go | 1 + 3 files changed, 15 insertions(+) diff --git a/activity.go b/activity.go index eda5ab2..b0f61c1 100644 --- a/activity.go +++ b/activity.go @@ -1418,6 +1418,19 @@ func junkuser(user *WhatAbout) junk.Junk { j["name"] = user.Display j["preferredUsername"] = user.Name j["summary"] = user.HTAbout + var tags []junk.Junk + for _, o := range user.Onts { + t := junk.New() + t["type"] = "Hashtag" + o = strings.ToLower(o) + t["href"] = fmt.Sprintf("https://%s/o/%s", serverName, o[1:]) + t["name"] = o + tags = append(tags, t) + } + if len(tags) > 0 { + j["tag"] = tags + } + if user.ID > 0 { j["type"] = "Person" j["url"] = user.URL diff --git a/database.go b/database.go index 14f00f2..790481b 100644 --- a/database.go +++ b/database.go @@ -59,6 +59,7 @@ func userfromrow(row *sql.Row) (*WhatAbout, error) { marker.HashLinker = ontoreplacer marker.AtLinker = attoreplacer user.HTAbout = template.HTML(marker.Mark(user.About)) + user.Onts = marker.HashTags return user, nil } diff --git a/honk.go b/honk.go index 9ff7b04..e741e18 100644 --- a/honk.go +++ b/honk.go @@ -41,6 +41,7 @@ type WhatAbout struct { Display string About string HTAbout template.HTML + Onts []string Key string URL string Options UserOptions