setting avatar. if you must.
Ted Unangst tedu@tedunangst.com
Mon, 25 Nov 2019 21:34:57 -0500
4 files changed,
27 insertions(+),
1 deletions(-)
M
docs/changelog.txt
→
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.
M
docs/honk.1
→
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
M
views/account.html
→
views/account.html
@@ -7,7 +7,7 @@ <div>
<form id="aboutform" action="/saveuser" method="POST"> <input type="hidden" name="CSRF" value="{{ .UserCSRF }}"> <p>about me: -<p><textarea name="whatabout">{{ .User.About }}</textarea> +<p><textarea name="whatabout">{{ .WhatAbout }}</textarea> <p><label class="button" for="skinny">skinny layout:</label> <input tabindex=1 type="checkbox" id="skinny" name="skinny" value="skinny" {{ if .User.Options.SkinnyCSS }}checked{{ end }}><span></span> <p><label class="button" for="maps">apple map links:</label>
M
web.go
→
web.go
@@ -1069,6 +1069,8 @@ log.Print(err)
} } +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 @@ options.MapLink = "apple"
} 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 @@ templinfo := getInfo(r)
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)