From f6995ce94e682b52beff731bc0d8a4646ce2c244 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 25 Sep 2020 19:02:26 -0400 Subject: [PATCH] handle markdown in bios better --- activity.go | 4 +--- database.go | 7 +++++++ docs/changelog.txt | 2 ++ honk.go | 1 + web.go | 4 +--- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/activity.go b/activity.go index 46c817b..eda5ab2 100644 --- a/activity.go +++ b/activity.go @@ -1410,8 +1410,6 @@ func collectiveaction(honk *Honk) { } func junkuser(user *WhatAbout) junk.Junk { - about := markitzero(user.About) - j := junk.New() j["@context"] = itiswhatitis j["id"] = user.URL @@ -1419,7 +1417,7 @@ func junkuser(user *WhatAbout) junk.Junk { j["outbox"] = user.URL + "/outbox" j["name"] = user.Display j["preferredUsername"] = user.Name - j["summary"] = about + j["summary"] = user.HTAbout if user.ID > 0 { j["type"] = "Person" j["url"] = user.URL diff --git a/database.go b/database.go index 8570213..14f00f2 100644 --- a/database.go +++ b/database.go @@ -20,6 +20,7 @@ import ( "database/sql" "encoding/json" "fmt" + "html/template" "log" "sort" "strconv" @@ -29,6 +30,7 @@ import ( "humungus.tedunangst.com/r/webs/cache" "humungus.tedunangst.com/r/webs/httpsig" "humungus.tedunangst.com/r/webs/login" + "humungus.tedunangst.com/r/webs/mz" ) func userfromrow(row *sql.Row) (*WhatAbout, error) { @@ -53,6 +55,11 @@ func userfromrow(row *sql.Row) (*WhatAbout, error) { if user.Options.Reaction == "" { user.Options.Reaction = "none" } + var marker mz.Marker + marker.HashLinker = ontoreplacer + marker.AtLinker = attoreplacer + user.HTAbout = template.HTML(marker.Mark(user.About)) + return user, nil } diff --git a/docs/changelog.txt b/docs/changelog.txt index 0136b73..78df37b 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ Better support for rich text bios. + + Follow and unfollow should work a little better. ++ backup command. diff --git a/honk.go b/honk.go index 0bc29cd..9ff7b04 100644 --- a/honk.go +++ b/honk.go @@ -40,6 +40,7 @@ type WhatAbout struct { Name string Display string About string + HTAbout template.HTML Key string URL string Options UserOptions diff --git a/web.go b/web.go index 953aaba..fe5216e 100644 --- a/web.go +++ b/web.go @@ -701,9 +701,7 @@ func showuser(w http.ResponseWriter, r *http.Request) { honks := gethonksbyuser(name, u != nil && u.Username == name, 0) templinfo := getInfo(r) templinfo["Name"] = user.Name - whatabout := user.About - whatabout = markitzero(user.About) - templinfo["WhatAbout"] = template.HTML(whatabout) + templinfo["WhatAbout"] = user.HTAbout templinfo["ServerMessage"] = "" templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) honkpage(w, u, honks, templinfo)