handle markdown in bios better

This commit is contained in:
Ted Unangst 2020-09-25 19:02:26 -04:00
parent 8f9c838a07
commit f6995ce94e
5 changed files with 12 additions and 6 deletions

View File

@ -1410,8 +1410,6 @@ func collectiveaction(honk *Honk) {
} }
func junkuser(user *WhatAbout) junk.Junk { func junkuser(user *WhatAbout) junk.Junk {
about := markitzero(user.About)
j := junk.New() j := junk.New()
j["@context"] = itiswhatitis j["@context"] = itiswhatitis
j["id"] = user.URL j["id"] = user.URL
@ -1419,7 +1417,7 @@ func junkuser(user *WhatAbout) junk.Junk {
j["outbox"] = user.URL + "/outbox" j["outbox"] = user.URL + "/outbox"
j["name"] = user.Display j["name"] = user.Display
j["preferredUsername"] = user.Name j["preferredUsername"] = user.Name
j["summary"] = about j["summary"] = user.HTAbout
if user.ID > 0 { if user.ID > 0 {
j["type"] = "Person" j["type"] = "Person"
j["url"] = user.URL j["url"] = user.URL

View File

@ -20,6 +20,7 @@ import (
"database/sql" "database/sql"
"encoding/json" "encoding/json"
"fmt" "fmt"
"html/template"
"log" "log"
"sort" "sort"
"strconv" "strconv"
@ -29,6 +30,7 @@ import (
"humungus.tedunangst.com/r/webs/cache" "humungus.tedunangst.com/r/webs/cache"
"humungus.tedunangst.com/r/webs/httpsig" "humungus.tedunangst.com/r/webs/httpsig"
"humungus.tedunangst.com/r/webs/login" "humungus.tedunangst.com/r/webs/login"
"humungus.tedunangst.com/r/webs/mz"
) )
func userfromrow(row *sql.Row) (*WhatAbout, error) { func userfromrow(row *sql.Row) (*WhatAbout, error) {
@ -53,6 +55,11 @@ func userfromrow(row *sql.Row) (*WhatAbout, error) {
if user.Options.Reaction == "" { if user.Options.Reaction == "" {
user.Options.Reaction = "none" 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 return user, nil
} }

View File

@ -2,6 +2,8 @@ changelog
=== next === next
+ Better support for rich text bios.
+ Follow and unfollow should work a little better. + Follow and unfollow should work a little better.
++ backup command. ++ backup command.

View File

@ -40,6 +40,7 @@ type WhatAbout struct {
Name string Name string
Display string Display string
About string About string
HTAbout template.HTML
Key string Key string
URL string URL string
Options UserOptions Options UserOptions

4
web.go
View File

@ -701,9 +701,7 @@ func showuser(w http.ResponseWriter, r *http.Request) {
honks := gethonksbyuser(name, u != nil && u.Username == name, 0) honks := gethonksbyuser(name, u != nil && u.Username == name, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["Name"] = user.Name templinfo["Name"] = user.Name
whatabout := user.About templinfo["WhatAbout"] = user.HTAbout
whatabout = markitzero(user.About)
templinfo["WhatAbout"] = template.HTML(whatabout)
templinfo["ServerMessage"] = "" templinfo["ServerMessage"] = ""
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
honkpage(w, u, honks, templinfo) honkpage(w, u, honks, templinfo)