From 04a82a00987b44f2c4dc7e7a6d41f32aca39afaf Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 25 Nov 2019 21:34:57 -0500 Subject: [PATCH] setting avatar. if you must. --- docs/changelog.txt | 2 ++ docs/honk.1 | 6 ++++++ views/account.html | 2 +- web.go | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1f15a67..f1a96a4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Set an avatar. If you must. + + Try a little harder to recover from httpsig failures. + Add cite tag for block quote attributions. diff --git a/docs/honk.1 b/docs/honk.1 index 299802d..d9e679d 100644 --- a/docs/honk.1 +++ b/docs/honk.1 @@ -164,6 +164,12 @@ It also allows the import of external objects via URL, either individual posts or actor URLs, in which case their recent outbox is imported. .Ss Account It's all about you. +An avatar may be selected from the +.Pa funzone +by adding +.Dq avatar: filename.png +to one's profile info. +If truly necessary. .Pp Some options to customize the site appearance: .Bl -tag -width skinny diff --git a/views/account.html b/views/account.html index c6425eb..dc2f957 100644 --- a/views/account.html +++ b/views/account.html @@ -7,7 +7,7 @@

about me: -

+

diff --git a/web.go b/web.go index 62c07b1..8d1c6d0 100644 --- a/web.go +++ b/web.go @@ -1069,6 +1069,8 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo } } +var re_avatar = regexp.MustCompile("avatar: ?([[:alnum:]_.-]+)") + func saveuser(w http.ResponseWriter, r *http.Request) { whatabout := r.FormValue("whatabout") u := login.GetUserInfo(r) @@ -1085,6 +1087,17 @@ func saveuser(w http.ResponseWriter, r *http.Request) { } else { options.MapLink = "" } + if ava := re_avatar.FindString(whatabout); ava != "" { + whatabout = re_avatar.ReplaceAllString(whatabout, "") + ava = ava[7:] + if ava[0] == ' ' { + ava = ava[1:] + } + options.Avatar = fmt.Sprintf("https://%s/meme/%s", serverName, ava) + } else { + options.Avatar = "" + } + whatabout = strings.TrimSpace(whatabout) j, err := jsonify(options) if err == nil { _, err = db.Exec("update users set about = ?, options = ? where username = ?", whatabout, j, u.Username) @@ -1861,6 +1874,11 @@ func accountpage(w http.ResponseWriter, r *http.Request) { templinfo["UserCSRF"] = login.GetCSRF("saveuser", r) templinfo["LogoutCSRF"] = login.GetCSRF("logout", r) templinfo["User"] = user + about := user.About + if ava := user.Options.Avatar; ava != "" { + about += "\n\navatar: " + ava[strings.LastIndexByte(ava, '/')+1:] + } + templinfo["WhatAbout"] = about err := readviews.Execute(w, "account.html", templinfo) if err != nil { log.Print(err)