diff --git a/common/site.go b/common/site.go index ecb6361d..264e1fcd 100644 --- a/common/site.go +++ b/common/site.go @@ -266,11 +266,11 @@ func ProcessConfig() (err error) { if Config.AvatarResBase == "" { Config.AvatarResBase = "/uploads/" } - + if !Config.DisableDefaultNoavatar { - noavatarCache200 = make([]string, 5) - noavatarCache48 = make([]string, 5) - for i := 0; i < 5; i++ { + noavatarCache200 = make([]string, 10) + noavatarCache48 = make([]string, 10) + for i := 0; i < 11; i++ { noavatarCache200[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".png?i=0" noavatarCache48[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".png?i=0" } diff --git a/common/user.go b/common/user.go index 9e115a78..4faf554f 100644 --- a/common/user.go +++ b/common/user.go @@ -235,8 +235,8 @@ func (u *User) CacheRemove() { TopicListThaw.Thaw() } -func (u *User) Ban(duration time.Duration, issuedBy int) error { - return u.ScheduleGroupUpdate(BanGroup, issuedBy, duration) +func (u *User) Ban(dur time.Duration, issuedBy int) error { + return u.ScheduleGroupUpdate(BanGroup, issuedBy, dur) } func (u *User) Unban() error { @@ -244,30 +244,30 @@ func (u *User) Unban() error { } func (u *User) deleteScheduleGroupTx(tx *sql.Tx) error { - deleteScheduleGroupStmt, err := qgen.Builder.SimpleDeleteTx(tx, "users_groups_scheduler", "uid=?") - if err != nil { - return err + deleteScheduleGroupStmt, e := qgen.Builder.SimpleDeleteTx(tx, "users_groups_scheduler", "uid=?") + if e != nil { + return e } - _, err = deleteScheduleGroupStmt.Exec(u.ID) - return err + _, e = deleteScheduleGroupStmt.Exec(u.ID) + return e } func (u *User) setTempGroupTx(tx *sql.Tx, tempGroup int) error { - setTempGroupStmt, err := qgen.Builder.SimpleUpdateTx(tx, "users", "temp_group=?", "uid=?") - if err != nil { - return err + setTempGroupStmt, e := qgen.Builder.SimpleUpdateTx(tx, "users", "temp_group=?", "uid=?") + if e != nil { + return e } - _, err = setTempGroupStmt.Exec(tempGroup, u.ID) - return err + _, e = setTempGroupStmt.Exec(tempGroup, u.ID) + return e } // Make this more stateless? -func (u *User) ScheduleGroupUpdate(gid, issuedBy int, duration time.Duration) error { +func (u *User) ScheduleGroupUpdate(gid, issuedBy int, dur time.Duration) error { var temp bool - if duration.Nanoseconds() != 0 { + if dur.Nanoseconds() != 0 { temp = true } - revertAt := time.Now().Add(duration) + revertAt := time.Now().Add(dur) tx, err := qgen.Builder.Begin() if err != nil { @@ -300,46 +300,46 @@ func (u *User) ScheduleGroupUpdate(gid, issuedBy int, duration time.Duration) er } func (u *User) RevertGroupUpdate() error { - tx, err := qgen.Builder.Begin() - if err != nil { - return err + tx, e := qgen.Builder.Begin() + if e != nil { + return e } defer tx.Rollback() - err = u.deleteScheduleGroupTx(tx) - if err != nil { - return err + e = u.deleteScheduleGroupTx(tx) + if e != nil { + return e } - err = u.setTempGroupTx(tx, 0) - if err != nil { - return err + e = u.setTempGroupTx(tx, 0) + if e != nil { + return e } - err = tx.Commit() + e = tx.Commit() u.CacheRemove() - return err + return e } // TODO: Use a transaction here // ? - Add a Deactivate method? Not really needed, if someone's been bad you could do a ban, I guess it might be useful, if someone says that email x isn't actually owned by the user in question? -func (u *User) Activate() (err error) { - _, err = userStmts.activate.Exec(u.ID) - if err != nil { - return err +func (u *User) Activate() (e error) { + _, e = userStmts.activate.Exec(u.ID) + if e != nil { + return e } - _, err = userStmts.changeGroup.Exec(Config.DefaultGroup, u.ID) + _, e = userStmts.changeGroup.Exec(Config.DefaultGroup, u.ID) u.CacheRemove() - return err + return e } // TODO: Write tests for this // TODO: Delete this user's content too? // TODO: Expose this to the admin? func (u *User) Delete() error { - _, err := userStmts.delete.Exec(u.ID) - if err != nil { - return err + _, e := userStmts.delete.Exec(u.ID) + if e != nil { + return e } u.CacheRemove() return nil @@ -514,18 +514,18 @@ func (u *User) DeletePosts() error { return rows.Err() } -func (u *User) bindStmt(stmt *sql.Stmt, params ...interface{}) (err error) { +func (u *User) bindStmt(stmt *sql.Stmt, params ...interface{}) (e error) { params = append(params, u.ID) - _, err = stmt.Exec(params...) + _, e = stmt.Exec(params...) u.CacheRemove() - return err + return e } -func (u *User) ChangeName(name string) (err error) { +func (u *User) ChangeName(name string) error { return u.bindStmt(userStmts.setName, name) } -func (u *User) ChangeAvatar(avatar string) (err error) { +func (u *User) ChangeAvatar(avatar string) error { return u.bindStmt(userStmts.setAvatar, avatar) } @@ -546,7 +546,7 @@ func (u *User) ScheduleAvatarResize() (err error) { return nil } -func (u *User) ChangeGroup(group int) (err error) { +func (u *User) ChangeGroup(group int) error { return u.bindStmt(userStmts.changeGroup, group) } @@ -623,9 +623,9 @@ func (u *User) IncreasePostStats(wcount int, topic bool) (err error) { } func (u *User) countf(stmt *sql.Stmt) (count int) { - err := stmt.QueryRow().Scan(&count) - if err != nil { - LogError(err) + e := stmt.QueryRow().Scan(&count) + if e != nil { + LogError(e) } return count } @@ -684,8 +684,8 @@ func (u *User) DecreasePostStats(wcount int, topic bool) (err error) { return err } -func (u *User) ResetPostStats() (err error) { - _, err = userStmts.resetStats.Exec(u.ID) +func (u *User) ResetPostStats() error { + _, err := userStmts.resetStats.Exec(u.ID) u.CacheRemove() return err } @@ -805,10 +805,10 @@ func BuildAvatar(uid int, avatar string) (normalAvatar, microAvatar string) { } if avatar[0] == '.' { if avatar[1] == '.' { - normalAvatar = Config.AvatarResBase+"avatar_" + strconv.Itoa(uid) + "_tmp" + avatar[1:] + normalAvatar = Config.AvatarResBase + "avatar_" + strconv.Itoa(uid) + "_tmp" + avatar[1:] return normalAvatar, normalAvatar } - normalAvatar = Config.AvatarResBase+"avatar_" + strconv.Itoa(uid) + avatar + normalAvatar = Config.AvatarResBase + "avatar_" + strconv.Itoa(uid) + avatar return normalAvatar, normalAvatar } return avatar, avatar diff --git a/public/n10-200.png b/public/n10-200.png new file mode 100644 index 00000000..a8a92a48 Binary files /dev/null and b/public/n10-200.png differ diff --git a/public/n10-48.png b/public/n10-48.png new file mode 100644 index 00000000..214f52f7 Binary files /dev/null and b/public/n10-48.png differ diff --git a/public/n5-200.png b/public/n5-200.png new file mode 100644 index 00000000..09479503 Binary files /dev/null and b/public/n5-200.png differ diff --git a/public/n5-48.png b/public/n5-48.png new file mode 100644 index 00000000..8bbc97c7 Binary files /dev/null and b/public/n5-48.png differ diff --git a/public/n6-200.png b/public/n6-200.png new file mode 100644 index 00000000..9fff9762 Binary files /dev/null and b/public/n6-200.png differ diff --git a/public/n6-48.png b/public/n6-48.png new file mode 100644 index 00000000..983242ec Binary files /dev/null and b/public/n6-48.png differ diff --git a/public/n7-200.png b/public/n7-200.png new file mode 100644 index 00000000..5e64f8bb Binary files /dev/null and b/public/n7-200.png differ diff --git a/public/n7-48.png b/public/n7-48.png new file mode 100644 index 00000000..3e13a427 Binary files /dev/null and b/public/n7-48.png differ diff --git a/public/n8-200.png b/public/n8-200.png new file mode 100644 index 00000000..7b6c8bd9 Binary files /dev/null and b/public/n8-200.png differ diff --git a/public/n8-48.png b/public/n8-48.png new file mode 100644 index 00000000..d2ab7873 Binary files /dev/null and b/public/n8-48.png differ diff --git a/public/n9-200.png b/public/n9-200.png new file mode 100644 index 00000000..b6cd1e58 Binary files /dev/null and b/public/n9-200.png differ diff --git a/public/n9-48.png b/public/n9-48.png new file mode 100644 index 00000000..254e8f72 Binary files /dev/null and b/public/n9-48.png differ diff --git a/updater/main.go b/updater/main.go index 06b3cc10..0d4dbe50 100644 --- a/updater/main.go +++ b/updater/main.go @@ -16,8 +16,7 @@ func main() { // Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows defer func() { - r := recover() - if r != nil { + if r := recover(); r != nil { fmt.Println(r) debug.PrintStack() pressAnyKey(scanner)