diff --git a/docs/changelog.txt b/docs/changelog.txt index 619045c..f329dcd 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Support for some user selectable styling. Currently, skinny column mode. + + webp image transcoding. -- 0.7.3 diff --git a/honk.go b/honk.go index bb2d055..ce53333 100644 --- a/honk.go +++ b/honk.go @@ -42,12 +42,13 @@ import ( ) type WhatAbout struct { - ID int64 - Name string - Display string - About string - Key string - URL string + ID int64 + Name string + Display string + About string + Key string + URL string + SkinnyCSS bool } type Honk struct { @@ -97,13 +98,26 @@ var serverMsg = "Things happen." var readviews *templates.Template +func getuserstyle(u *login.UserInfo) template.CSS { + if u == nil { + return "" + } + user, _ := butwhatabout(u.Username) + if user.SkinnyCSS { + return "main { max-width: 700px; }" + } + return "" +} + func getInfo(r *http.Request) map[string]interface{} { + u := login.GetUserInfo(r) templinfo := make(map[string]interface{}) templinfo["StyleParam"] = getstyleparam("views/style.css") templinfo["LocalStyleParam"] = getstyleparam("views/local.css") + templinfo["UserStyle"] = getuserstyle(u) templinfo["ServerName"] = serverName templinfo["IconName"] = iconName - templinfo["UserInfo"] = login.GetUserInfo(r) + templinfo["UserInfo"] = u return templinfo } @@ -238,6 +252,7 @@ func butwhatabout(name string) (*WhatAbout, error) { var options string err := row.Scan(&user.ID, &user.Name, &user.Display, &user.About, &user.Key, &options) user.URL = fmt.Sprintf("https://%s/u/%s", serverName, user.Name) + user.SkinnyCSS = strings.Contains(options, " skinny ") return &user, err } @@ -617,7 +632,11 @@ func saveuser(w http.ResponseWriter, r *http.Request) { whatabout := r.FormValue("whatabout") u := login.GetUserInfo(r) db := opendatabase() - _, err := db.Exec("update users set about = ? where username = ?", whatabout, u.Username) + options := "" + if r.FormValue("skinny") == "skinny" { + options += " skinny " + } + _, err := db.Exec("update users set about = ?, options = ? where username = ?", whatabout, options, u.Username) if err != nil { log.Printf("error bouting what: %s", err) } @@ -1248,7 +1267,7 @@ func accountpage(w http.ResponseWriter, r *http.Request) { templinfo := getInfo(r) templinfo["UserCSRF"] = login.GetCSRF("saveuser", r) templinfo["LogoutCSRF"] = login.GetCSRF("logout", r) - templinfo["WhatAbout"] = user.About + templinfo["User"] = user err := readviews.Execute(w, "account.html", templinfo) if err != nil { log.Print(err) diff --git a/views/account.html b/views/account.html index def5668..9683fdd 100644 --- a/views/account.html +++ b/views/account.html @@ -7,7 +7,9 @@
diff --git a/views/header.html b/views/header.html index 67b69e5..5db0d60 100644 --- a/views/header.html +++ b/views/header.html @@ -6,6 +6,9 @@ {{ if .LocalStyleParam }} {{ end }} +