setting avatar. if you must.

This commit is contained in:
Ted Unangst 2019-11-25 21:34:57 -05:00
parent 83c89df14b
commit 04a82a0098
4 changed files with 27 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -7,7 +7,7 @@
<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>

18
web.go
View File

@ -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)