From 2128c6579cd13847f69032338f2cecd0b1ef8d1c Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 31 May 2022 01:31:11 -0400 Subject: [PATCH] specify banner: in profile --- activity.go | 7 +++++++ docs/changelog.txt | 2 ++ docs/honk.1 | 2 ++ fun.go | 1 + honk.go | 1 + web.go | 16 ++++++++++++++++ 6 files changed, 29 insertions(+) diff --git a/activity.go b/activity.go index d84dba8..2489aab 100644 --- a/activity.go +++ b/activity.go @@ -1539,6 +1539,13 @@ func junkuser(user *WhatAbout) junk.Junk { a["url"] = u } j["icon"] = a + if ban := user.Options.Banner; ban != "" { + a := junk.New() + a["type"] = "Image" + a["mediaType"] = "image/jpg" + a["url"] = ban + j["image"] = a + } } else { j["type"] = "Service" } diff --git a/docs/changelog.txt b/docs/changelog.txt index 84fb865..2f2b81c 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ Specify banner: image in profile. + + Update activity compatibility with mastodon. - Signed fetch. diff --git a/docs/honk.1 b/docs/honk.1 index 8443445..e1aef57 100644 --- a/docs/honk.1 +++ b/docs/honk.1 @@ -178,6 +178,8 @@ meme collection by adding .Dq avatar: filename.png to one's profile info. If truly necessary. +A banner may be set by specifying +.Dq banner: image.jpg . See .Xr honk 8 for more about the funzone. diff --git a/fun.go b/fun.go index 3a341e3..bf4c677 100644 --- a/fun.go +++ b/fun.go @@ -419,6 +419,7 @@ func herdofemus(noise string) []Emu { var re_memes = regexp.MustCompile("meme: ?([^\n]+)") var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)") +var re_banner = regexp.MustCompile("banner: ?([^\n]+)") func memetize(honk *Honk) { repl := func(x string) string { diff --git a/honk.go b/honk.go index 83b9d40..dae5072 100644 --- a/honk.go +++ b/honk.go @@ -56,6 +56,7 @@ type UserOptions struct { Avahex bool `json:",omitempty"` MentionAll bool `json:",omitempty"` Avatar string `json:",omitempty"` + Banner string `json:",omitempty"` MapLink string `json:",omitempty"` Reaction string `json:",omitempty"` MeCount int64 diff --git a/web.go b/web.go index 74f13ca..b3b5008 100644 --- a/web.go +++ b/web.go @@ -1147,6 +1147,19 @@ func saveuser(w http.ResponseWriter, r *http.Request) { options.Avatar = ava sendupdate = true } + ban := re_banner.FindString(whatabout) + if ban != "" { + whatabout = re_banner.ReplaceAllString(whatabout, "") + ban = ban[7:] + if ban[0] == ' ' { + ban = ban[1:] + } + ban = fmt.Sprintf("https://%s/meme/%s", serverName, ban) + } + if ban != options.Banner { + options.Banner = ban + sendupdate = true + } whatabout = strings.TrimSpace(whatabout) if whatabout != user.About { sendupdate = true @@ -2017,6 +2030,9 @@ func accountpage(w http.ResponseWriter, r *http.Request) { if ava := user.Options.Avatar; ava != "" { about += "\n\navatar: " + ava[strings.LastIndexByte(ava, '/')+1:] } + if ban := user.Options.Banner; ban != "" { + about += "\n\nbanner: " + ban[strings.LastIndexByte(ban, '/')+1:] + } templinfo["WhatAbout"] = about err := readviews.Execute(w, "account.html", templinfo) if err != nil {