diff --git a/common/conversations.go b/common/conversations.go index f8feb359..d6201695 100644 --- a/common/conversations.go +++ b/common/conversations.go @@ -238,7 +238,7 @@ func (s *DefaultConversationStore) GetUserExtra(uid, offset int) (cos []*Convers users[i] = user i++ } - return []*ConversationExtra{&ConversationExtra{raw[0], users}}, nil + return []*ConversationExtra{{raw[0], users}}, nil } //log.Println("1") diff --git a/common/counters/performance.go b/common/counters/performance.go index e1417c3d..8585fc3d 100644 --- a/common/counters/performance.go +++ b/common/counters/performance.go @@ -28,7 +28,7 @@ type DefaultPerfCounter struct { func NewDefaultPerfCounter(acc *qgen.Accumulator) (*DefaultPerfCounter, error) { co := &DefaultPerfCounter{ buckets: []*PerfCounterBucket{ - &PerfCounterBucket{ + { low: &MutexCounter64Bucket{counter: math.MaxInt64}, high: &MutexCounter64Bucket{counter: 0}, avg: &MutexCounter64Bucket{counter: 0}, diff --git a/common/parser.go b/common/parser.go index 47e36116..edbfd0e4 100644 --- a/common/parser.go +++ b/common/parser.go @@ -163,15 +163,15 @@ func PreparseMessage(msg string) string { // TODO: We can maybe reduce the size of this by using an offset? // TODO: Move some of these closures out of this function to make things a little more efficient allowedTags := [][]string{ - 'e': []string{"m"}, - 's': []string{"", "trong", "poiler", "pan"}, - 'd': []string{"el"}, - 'u': []string{""}, - 'b': []string{"", "lockquote"}, - 'i': []string{""}, - 'h': []string{"1", "2", "3"}, - //'p': []string{""}, - 'g': []string{""}, // Quick and dirty fix for Grammarly + 'e': {"m"}, + 's': {"", "trong", "poiler", "pan"}, + 'd': {"el"}, + 'u': {""}, + 'b': {"", "lockquote"}, + 'i': {""}, + 'h': {"1", "2", "3"}, + //'p': {""}, + 'g': {""}, // Quick and dirty fix for Grammarly } buildLitMatch := func(tag string) func(*TagToAction, bool, int, []rune) (int, string) { return func(action *TagToAction, open bool, _ int, _ []rune) (int, string) { @@ -187,13 +187,13 @@ func PreparseMessage(msg string) string { } } tagToAction := [][]*TagToAction{ - 'e': []*TagToAction{&TagToAction{"m", buildLitMatch("em"), 0, false}}, - 's': []*TagToAction{ - &TagToAction{"", buildLitMatch("del"), 0, false}, - &TagToAction{"trong", buildLitMatch("strong"), 0, false}, - &TagToAction{"poiler", buildLitMatch("spoiler"), 0, false}, + 'e': {{"m", buildLitMatch("em"), 0, false}}, + 's': { + {"", buildLitMatch("del"), 0, false}, + {"trong", buildLitMatch("strong"), 0, false}, + {"poiler", buildLitMatch("spoiler"), 0, false}, // Hides the span tags Trumbowyg loves blasting out randomly - &TagToAction{"pan", func(act *TagToAction, open bool, i int, runes []rune) (int, string) { + {"pan", func(act *TagToAction, open bool, i int, runes []rune) (int, string) { if open { act.Depth++ //fmt.Println("skipping attributes") @@ -212,21 +212,21 @@ func PreparseMessage(msg string) string { return -1, " " }, 0, true}, }, - 'd': []*TagToAction{&TagToAction{"el", buildLitMatch("del"), 0, false}}, - 'u': []*TagToAction{&TagToAction{"", buildLitMatch("u"), 0, false}}, - 'b': []*TagToAction{ - &TagToAction{"", buildLitMatch("strong"), 0, false}, - &TagToAction{"lockquote", buildLitMatch("blockquote"), 0, false}, + 'd': {{"el", buildLitMatch("del"), 0, false}}, + 'u': {{"", buildLitMatch("u"), 0, false}}, + 'b': { + {"", buildLitMatch("strong"), 0, false}, + {"lockquote", buildLitMatch("blockquote"), 0, false}, }, - 'i': []*TagToAction{&TagToAction{"", buildLitMatch("em"), 0, false}}, - 'h': []*TagToAction{ - &TagToAction{"1", buildLitMatch("h2"), 0, false}, - &TagToAction{"2", buildLitMatch("h3"), 0, false}, - &TagToAction{"3", buildLitMatch("h4"), 0, false}, + 'i': {{"", buildLitMatch("em"), 0, false}}, + 'h': { + {"1", buildLitMatch("h2"), 0, false}, + {"2", buildLitMatch("h3"), 0, false}, + {"3", buildLitMatch("h4"), 0, false}, }, - //'p': []*TagToAction{&TagToAction{"", buildLitMatch2("\n\n", ""), 0, false}}, - 'g': []*TagToAction{ - &TagToAction{"", func(act *TagToAction, open bool, i int, runes []rune) (int, string) { + //'p': {{"", buildLitMatch2("\n\n", ""), 0, false}}, + 'g': { + {"", func(act *TagToAction, open bool, i int, runes []rune) (int, string) { if open { act.Depth++ //fmt.Println("skipping attributes") @@ -482,9 +482,11 @@ func ParseMessage(msg string, sectionID int, sectionType string, settings *Parse msg, _ = ParseMessage2(msg, sectionID, sectionType, settings, user) return msg } -var litRepPrefix = []byte{':',';'} -//var litRep = [][]byte{':':[]byte{')','(','D','O','o','P','p'},';':[]byte{')'}} -var litRep = [][]string{':':[]string{')':"😀",'(':"😞",'D':"😃",'O':"😲",'o':"😲",'P':"😛",'p':"😛"},';':[]string{')':"😉"}} + +var litRepPrefix = []byte{':', ';'} + +//var litRep = [][]byte{':':{')','(','D','O','o','P','p'},';':{')'}} +var litRep = [][]string{':': {')': "😀", '(': "😞", 'D': "😃", 'O': "😲", 'o': "😲", 'P': "😛", 'p': "😛"}, ';': {')': "😉"}} // TODO: Write a test for this // TODO: We need a lot more hooks here. E.g. To add custom media types and handlers. diff --git a/common/ratelimit.go b/common/ratelimit.go index 0c7d3226..33fc5a96 100644 --- a/common/ratelimit.go +++ b/common/ratelimit.go @@ -79,7 +79,7 @@ type DefaultRateLimiter struct { func NewDefaultRateLimiter() *DefaultRateLimiter { return &DefaultRateLimiter{map[string]*RateLimit{ - "register": NewRateLimit([]RateFence{RateFence{int(time.Hour / 2), 1}}), + "register": NewRateLimit([]RateFence{{int(time.Hour / 2), 1}}), }} } diff --git a/common/template_init.go b/common/template_init.go index 48c308b9..fc051c5f 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -114,10 +114,10 @@ func tmplInitHeaders(u, u2, u3 *User) (*Header, *Header, *Header) { Theme: Themes[DefaultThemeBox.Load().(string)], CurrentUser: u, NoticeList: []string{"test"}, - Stylesheets: []HScript{HScript{"panel.css", ""}}, - Scripts: []HScript{HScript{"whatever.js", ""}}, - PreScriptsAsync: []HScript{HScript{"whatever.js", ""}}, - ScriptsAsync: []HScript{HScript{"whatever.js", ""}}, + Stylesheets: []HScript{{"panel.css", ""}}, + Scripts: []HScript{{"whatever.js", ""}}, + PreScriptsAsync: []HScript{{"whatever.js", ""}}, + ScriptsAsync: []HScript{{"whatever.js", ""}}, Widgets: PageWidgets{ LeftSidebar: template.HTML("lalala"), }, @@ -239,11 +239,11 @@ func compileCommons(c *tmpl.CTemplateSet, head, head2 *Header, forumList []Forum o.Add("forums", "c.ForumsPage", ForumsPage{htitle("Forum List"), forumList}) poll := Poll{ID: 1, Type: 0, Options: map[int]string{0: "Nothing", 1: "Something"}, Results: map[int]int{0: 5, 1: 2}, QuickOptions: []PollOption{ - PollOption{0, "Nothing"}, - PollOption{1, "Something"}, + {0, "Nothing"}, + {1, "Something"}, }, VoteCount: 7} avatar, microAvatar := BuildAvatar(62, "") - miniAttach := []*MiniAttachment{&MiniAttachment{Path: "/"}} + miniAttach := []*MiniAttachment{{Path: "/"}} tu := TopicUser{1, "blah", "Blah", "Hey there!", 0, false, false, now, now, 1, 1, 0, "", "127.0.0.1", 1, 0, 1, 0, "classname", poll.ID, "weird-data", BuildProfileURL("fake-user", 62), "Fake User", Config.DefaultGroup, avatar, microAvatar, 0, "", "", "", 58, false, miniAttach, nil, false} var replyList []*ReplyUser @@ -272,7 +272,7 @@ func compileTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName string PollOption{1, "Something"}, }, VoteCount: 7}*/ //avatar, microAvatar := BuildAvatar(62, "") - miniAttach := []*MiniAttachment{&MiniAttachment{Path: "/"}} + miniAttach := []*MiniAttachment{{Path: "/"}} var replyList []*ReplyUser //topic := TopicUser{1, "blah", "Blah", "Hey there!", 0, false, false, now, now, 1, 1, 0, "", "127.0.0.1", 1, 0, 1, 0, "classname", poll.ID, "weird-data", BuildProfileURL("fake-user", 62), "Fake User", Config.DefaultGroup, avatar, microAvatar, 0, "", "", "", "", "", 58, false, miniAttach, nil} // TODO: Do we want the UID on this to be 0? @@ -351,7 +351,7 @@ func compileTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName string } t.AddStd("login", "c.Page", Page{htitle("Login Page"), tList, nil}) - t.AddStd("register", "c.RegisterPage", RegisterPage{htitle("Registration Page"), false, "", []RegisterVerify{RegisterVerify{true, &RegisterVerifyImageGrid{"What?", []RegisterVerifyImageGridImage{RegisterVerifyImageGridImage{"something.png"}}}}}}) + t.AddStd("register", "c.RegisterPage", RegisterPage{htitle("Registration Page"), false, "", []RegisterVerify{{true, &RegisterVerifyImageGrid{"What?", []RegisterVerifyImageGridImage{{"something.png"}}}}}}) t.AddStd("error", "c.ErrorPage", ErrorPage{htitle("Error"), "A problem has occurred in the system."}) ipSearchPage := IPSearchPage{htitle("IP Search"), map[int]*User{1: user2}, "::1"} @@ -363,11 +363,11 @@ func compileTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName string parti := []*User{user} convo := &Conversation{1, BuildConvoURL(1), user.ID, time.Now(), 0, time.Now()} - convoItems := []ConvoViewRow{ConvoViewRow{&ConversationPost{1, 1, "hey", "", user.ID}, user, "", 4, true}} + convoItems := []ConvoViewRow{{&ConversationPost{1, 1, "hey", "", user.ID}, user, "", 4, true}} convoPage := ConvoViewPage{header, convo, convoItems, parti, true, Paginator{[]int{1}, 1, 1}} t.AddStd("convo", "c.ConvoViewPage", convoPage) - convos := []*ConversationExtra{&ConversationExtra{&Conversation{}, []*User{user}}} + convos := []*ConversationExtra{{&Conversation{}, []*User{user}}} var cRows []ConvoListRow for _, convo := range convos { cRows = append(cRows, ConvoListRow{convo, convo.Users, false}) @@ -377,7 +377,7 @@ func compileTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName string basePage := &BasePanelPage{header, PanelStats{}, "dashboard", ReportForumID, true} t.AddStd("panel", "c.Panel", Panel{basePage, "panel_dashboard_right", "", "panel_dashboard", inter}) - ges := []GridElement{GridElement{"", "", "", 1, "grid_istat", "", "", ""}} + ges := []GridElement{{"", "", "", 1, "grid_istat", "", "", ""}} t.AddStd("panel_dashboard", "c.DashGrids", DashGrids{ges, ges}) goVersion := runtime.Version() @@ -545,11 +545,11 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri t.AddStd("topics_topic", "c.TopicsRowMut", topicsRow) poll := Poll{ID: 1, Type: 0, Options: map[int]string{0: "Nothing", 1: "Something"}, Results: map[int]int{0: 5, 1: 2}, QuickOptions: []PollOption{ - PollOption{0, "Nothing"}, - PollOption{1, "Something"}, + {0, "Nothing"}, + {1, "Something"}, }, VoteCount: 7} avatar, microAvatar := BuildAvatar(62, "") - miniAttach := []*MiniAttachment{&MiniAttachment{Path: "/"}} + miniAttach := []*MiniAttachment{{Path: "/"}} tu := TopicUser{1, "blah", "Blah", "Hey there!", 62, false, false, now, now, 1, 1, 0, "", "::1", 1, 0, 1, 0, "classname", poll.ID, "weird-data", BuildProfileURL("fake-user", 62), "Fake User", Config.DefaultGroup, avatar, microAvatar, 0, "", "", "", 58, false, miniAttach, nil, false} var replyList []*ReplyUser // TODO: Do we really want the UID here to be zero? @@ -577,7 +577,7 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri parti := []*User{user} convo := &Conversation{1, BuildConvoURL(1), user.ID, time.Now(), 0, time.Now()} - convoItems := []ConvoViewRow{ConvoViewRow{&ConversationPost{1, 1, "hey", "", user.ID}, user, "", 4, true}} + convoItems := []ConvoViewRow{{&ConversationPost{1, 1, "hey", "", user.ID}, user, "", 4, true}} convoPage := ConvoViewPage{header, convo, convoItems, parti, true, Paginator{[]int{1}, 1, 1}} t.AddStd("convo", "c.ConvoViewPage", convoPage) diff --git a/common/thumbnailer.go b/common/thumbnailer.go index ef0cd25d..813fc062 100644 --- a/common/thumbnailer.go +++ b/common/thumbnailer.go @@ -49,7 +49,11 @@ func ThumbTask(thumbChan chan bool) { /*if user.RawAvatar == ".gif" { return nil }*/ - if u.RawAvatar != ".png" && u.RawAvatar != ".jpg" && u.RawAvatar != ".jpe" && u.RawAvatar != ".jpeg" && u.RawAvatar != ".jif" && u.RawAvatar != ".jfi" && u.RawAvatar != ".jfif" && u.RawAvatar != ".gif" && u.RawAvatar != "tiff" && u.RawAvatar != "tif" { + canResize := func(ext string) bool { + // TODO: Fix tif and tiff extensions? + return ext == ".png" && ext == ".jpg" && ext == ".jpe" && ext == ".jpeg" && ext == ".jif" && ext == ".jfi" && ext == ".jfif" && ext == ".gif" && ext == ".tiff" && ext == ".tif" + } + if !canResize(u.RawAvatar) { return nil } diff --git a/common/topic_list.go b/common/topic_list.go index fc1d5c23..39f1ef04 100644 --- a/common/topic_list.go +++ b/common/topic_list.go @@ -138,8 +138,8 @@ func (tList *DefaultTopicList) Tick() error { return err } canSeeHolders[name] = [2]*TopicListHolder{ - &TopicListHolder{topicList, forumList, pagi}, - &TopicListHolder{topicList2, forumList2, pagi2}, + {topicList, forumList, pagi}, + {topicList2, forumList2, pagi2}, } if len(canSee) > 1 { forumCounts[len(canSee)] += 1 diff --git a/common/ws_hub.go b/common/ws_hub.go index 07236ae4..6f47b65a 100644 --- a/common/ws_hub.go +++ b/common/ws_hub.go @@ -441,7 +441,7 @@ func (h *WsHubImpl) AddConn(user *User, conn *websocket.Conn) (*WSUser, error) { if !ok { wsUser = new(WSUser) wsUser.User = userptr - wsUser.Sockets = []*WSUserSocket{&WSUserSocket{conn, ""}} + wsUser.Sockets = []*WSUserSocket{{conn, ""}} theMap[user.ID] = wsUser mutex.Unlock() return wsUser, nil diff --git a/patcher/patches.go b/patcher/patches.go index 493fb641..456d5cd5 100644 --- a/patcher/patches.go +++ b/patcher/patches.go @@ -68,10 +68,10 @@ func ccol(col string, size int, sdefault string) qgen.DBTableColumn { func patch0(scanner *bufio.Scanner) (err error) { err = createTable("menus", "", "", []tC{ - tC{"mid", "int", 0, false, true, ""}, + {"mid", "int", 0, false, true, ""}, }, []tK{ - tK{"mid", "primary", "", false}, + {"mid", "primary", "", false}, }, ) if err != nil { @@ -80,8 +80,8 @@ func patch0(scanner *bufio.Scanner) (err error) { err = createTable("menu_items", "", "", []tC{ - tC{"miid", "int", 0, false, true, ""}, - tC{"mid", "int", 0, false, false, ""}, + {"miid", "int", 0, false, true, ""}, + {"mid", "int", 0, false, false, ""}, ccol("name", 200, ""), ccol("htmlID", 200, "''"), ccol("cssClass", 200, "''"), @@ -90,7 +90,7 @@ func patch0(scanner *bufio.Scanner) (err error) { ccol("aria", 200, "''"), ccol("tooltip", 200, "''"), ccol("tmplName", 200, "''"), - tC{"order", "int", 0, false, false, "0"}, + {"order", "int", 0, false, false, "0"}, bcol("guestOnly", false), bcol("memberOnly", false), @@ -98,7 +98,7 @@ func patch0(scanner *bufio.Scanner) (err error) { bcol("adminOnly", false), }, []tK{ - tK{"miid", "primary", "", false}, + {"miid", "primary", "", false}, }, ) if err != nil { @@ -196,16 +196,16 @@ func patch2(scanner *bufio.Scanner) error { func patch3(scanner *bufio.Scanner) error { return createTable("registration_logs", "", "", []tC{ - tC{"rlid", "int", 0, false, true, ""}, + {"rlid", "int", 0, false, true, ""}, ccol("username", 100, ""), ccol("email", 100, ""), ccol("failureReason", 100, ""), bcol("success", false), // Did this attempt succeed? ccol("ipaddress", 200, ""), - tC{"doneAt", "createdAt", 0, false, false, ""}, + {"doneAt", "createdAt", 0, false, false, ""}, }, []tK{ - tK{"rlid", "primary", "", false}, + {"rlid", "primary", "", false}, }, ) } @@ -258,24 +258,19 @@ func patch4(scanner *bufio.Scanner) error { return err } - err = createTable("pages", "utf8mb4", "utf8mb4_general_ci", + return createTable("pages", "utf8mb4", "utf8mb4_general_ci", []tC{ - tC{"pid", "int", 0, false, true, ""}, + {"pid", "int", 0, false, true, ""}, ccol("name", 200, ""), ccol("title", 200, ""), - tC{"body", "text", 0, false, false, ""}, - tC{"allowedGroups", "text", 0, false, false, ""}, - tC{"menuID", "int", 0, false, false, "-1"}, + {"body", "text", 0, false, false, ""}, + {"allowedGroups", "text", 0, false, false, ""}, + {"menuID", "int", 0, false, false, "-1"}, }, []tK{ - tK{"pid", "primary", "", false}, + {"pid", "primary", "", false}, }, ) - if err != nil { - return err - } - - return nil } func patch5(scanner *bufio.Scanner) error { @@ -298,7 +293,7 @@ func patch5(scanner *bufio.Scanner) error { return createTable("users_2fa_keys", "utf8mb4", "utf8mb4_general_ci", []tC{ - tC{"uid", "int", 0, false, false, ""}, + {"uid", "int", 0, false, false, ""}, ccol("secret", 100, ""), ccol("scratch1", 50, ""), ccol("scratch2", 50, ""), @@ -308,10 +303,10 @@ func patch5(scanner *bufio.Scanner) error { ccol("scratch6", 50, ""), ccol("scratch7", 50, ""), ccol("scratch8", 50, ""), - tC{"createdAt", "createdAt", 0, false, false, ""}, + {"createdAt", "createdAt", 0, false, false, ""}, }, []tK{ - tK{"uid", "primary", "", false}, + {"uid", "primary", "", false}, }, ) } @@ -323,10 +318,10 @@ func patch6(scanner *bufio.Scanner) error { func patch7(scanner *bufio.Scanner) error { return createTable("users_avatar_queue", "", "", []tC{ - tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key }, []tK{ - tK{"uid", "primary", "", false}, + {"uid", "primary", "", false}, }, ) } @@ -382,7 +377,7 @@ func patch8(scanner *bufio.Scanner) error { return createTable("updates", "", "", []tC{ - tC{"dbVersion", "int", 0, false, false, "0"}, + {"dbVersion", "int", 0, false, false, "0"}, }, nil, ) } @@ -396,14 +391,14 @@ func patch9(scanner *bufio.Scanner) error { return createTable("login_logs", "", "", []tC{ - tC{"lid", "int", 0, false, true, ""}, - tC{"uid", "int", 0, false, false, ""}, + {"lid", "int", 0, false, true, ""}, + {"uid", "int", 0, false, false, ""}, bcol("success", false), // Did this attempt succeed? ccol("ipaddress", 200, ""), - tC{"doneAt", "createdAt", 0, false, false, ""}, + {"doneAt", "createdAt", 0, false, false, ""}, }, []tK{ - tK{"lid", "primary", "", false}, + {"lid", "primary", "", false}, }, ) } @@ -536,10 +531,10 @@ func patch16(scanner *bufio.Scanner) error { return createTable("password_resets", "", "", []tC{ ccol("email", 200, ""), - tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token ccol("token", 200, ""), - tC{"createdAt", "createdAt", 0, false, false, ""}, + {"createdAt", "createdAt", 0, false, false, ""}, }, nil, ) } @@ -585,8 +580,8 @@ func patch18(scanner *bufio.Scanner) error { func patch19(scanner *bufio.Scanner) error { return createTable("memchunks", "", "", []tC{ - tC{"count", "int", 0, false, false, "0"}, - tC{"createdAt", "datetime", 0, false, false, ""}, + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, }, nil, ) } @@ -642,14 +637,14 @@ func patch22(scanner *bufio.Scanner) error { func patch23(scanner *bufio.Scanner) error { err := createTable("conversations", "", "", []tC{ - tC{"cid", "int", 0, false, true, ""}, - tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - tC{"createdAt", "createdAt", 0, false, false, ""}, - tC{"lastReplyAt", "datetime", 0, false, false, ""}, - tC{"lastReplyBy", "int", 0, false, false, ""}, + {"cid", "int", 0, false, true, ""}, + {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"createdAt", "createdAt", 0, false, false, ""}, + {"lastReplyAt", "datetime", 0, false, false, ""}, + {"lastReplyBy", "int", 0, false, false, ""}, }, []tK{ - tK{"cid", "primary", "", false}, + {"cid", "primary", "", false}, }, ) if err != nil { @@ -658,14 +653,14 @@ func patch23(scanner *bufio.Scanner) error { err = createTable("conversations_posts", "", "", []tC{ - tC{"pid", "int", 0, false, true, ""}, - tC{"cid", "int", 0, false, false, ""}, - tC{"createdBy", "int", 0, false, false, ""}, + {"pid", "int", 0, false, true, ""}, + {"cid", "int", 0, false, false, ""}, + {"createdBy", "int", 0, false, false, ""}, ccol("body", 50, ""), ccol("post", 50, "''"), }, []tK{ - tK{"pid", "primary", "", false}, + {"pid", "primary", "", false}, }, ) if err != nil { @@ -674,8 +669,8 @@ func patch23(scanner *bufio.Scanner) error { return createTable("conversations_participants", "", "", []tC{ - tC{"uid", "int", 0, false, false, ""}, - tC{"cid", "int", 0, false, false, ""}, + {"uid", "int", 0, false, false, ""}, + {"cid", "int", 0, false, false, ""}, }, nil, ) } @@ -683,17 +678,17 @@ func patch23(scanner *bufio.Scanner) error { func patch24(scanner *bufio.Scanner) error { return createTable("users_groups_promotions", "", "", []tC{ - tC{"pid", "int", 0, false, true, ""}, - tC{"from_gid", "int", 0, false, false, ""}, - tC{"to_gid", "int", 0, false, false, ""}, + {"pid", "int", 0, false, true, ""}, + {"from_gid", "int", 0, false, false, ""}, + {"to_gid", "int", 0, false, false, ""}, bcol("two_way", false), // If a user no longer meets the requirements for this promotion then they will be demoted if this flag is set // Requirements - tC{"level", "int", 0, false, false, ""}, - tC{"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted + {"level", "int", 0, false, false, ""}, + {"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted }, []tK{ - tK{"pid", "primary", "", false}, + {"pid", "primary", "", false}, }, ) } @@ -705,8 +700,8 @@ func patch25(scanner *bufio.Scanner) error { func patch26(scanner *bufio.Scanner) error { return createTable("users_blocks", "", "", []tC{ - tC{"blocker", "int", 0, false, false, ""}, - tC{"blockedUser", "int", 0, false, false, ""}, + {"blocker", "int", 0, false, false, ""}, + {"blockedUser", "int", 0, false, false, ""}, }, nil, ) } @@ -854,10 +849,10 @@ func createTable(tbl, charset, collation string, cols []tC, keys []tK) error { func patch32(scanner *bufio.Scanner) error { return createTable("perfchunks", "", "", []tC{ - tC{"low", "int", 0, false, false, "0"}, - tC{"high", "int", 0, false, false, "0"}, - tC{"avg", "int", 0, false, false, "0"}, - tC{"createdAt", "datetime", 0, false, false, ""}, + {"low", "int", 0, false, false, "0"}, + {"high", "int", 0, false, false, "0"}, + {"avg", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, }, nil, ) } @@ -869,12 +864,12 @@ func patch33(scanner *bufio.Scanner) error { func patch34(scanner *bufio.Scanner) error { /*err := createTable("tables", "", "", []tC{ - tC{"id", "int", 0, false, true, ""}, + {"id", "int", 0, false, true, ""}, ccol("name", 200, ""), }, []tK{ - tK{"id", "primary", "", false}, - tK{"name", "unique", "", false}, + {"id", "primary", "", false}, + {"name", "unique", "", false}, }, ) if err != nil { diff --git a/public/analytics.js b/public/analytics.js index a3c0e12c..e254de00 100644 --- a/public/analytics.js +++ b/public/analytics.js @@ -1,8 +1,8 @@ -function memStuff(window, document, Chartist) { +function memStuff(window,document,Chartist) { 'use strict'; Chartist.plugins = Chartist.plugins || {}; Chartist.plugins.byteUnits = function(options) { - options = Chartist.extend({}, {}, options); + options = Chartist.extend({},{},options); return function byteUnits(chart) { if(!chart instanceof Chartist.Line) return; @@ -13,7 +13,7 @@ function memStuff(window, document, Chartist) { if(vbits==null) return; let tbits = []; - for(let i = 0; i < vbits.length; i++) { + for(let i=0; i