setting avatar. if you must.

Ted Unangst 5 years ago
parent 9028de97cf
commit 7f838884e2

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

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

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

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

Loading…
Cancel
Save