From 65b4fef40e33578915cb501c7a0d83dbb44ef80d Mon Sep 17 00:00:00 2001 From: Azareal Date: Fri, 11 Oct 2019 10:57:33 +1000 Subject: [PATCH] WIP Add more language strings for panel debug. Shorten more things. Sneak draft tables in. Add the profile_block phrase. Add the panel_debug_memory_stats phrase. Add the panel_debug_memory_stats_sys phrase. Add the panel_debug_memory_stats_heapsys phrase. Add the panel_debug_memory_stats_heapalloc phrase. Add the panel_debug_memory_stats_heapidle phrase. Add the panel_debug_memory_stats_heapobjects phrase. Add the panel_debug_memory_stats_stackinuse phrase. Add the panel_debug_caches phrase. Add the panel_debug_caches_topic phrase. Add the panel_debug_caches_user phrase. Add the panel_debug_caches_reply phrase. Add the panel_debug_caches_topic_list phrase. Add the panel_debug_database phrase. Add the panel_debug_database_topics phrase. Add the panel_debug_database_users phrase. Add the panel_debug_database_replies phrase. Add the panel_debug_disk phrase. --- cmd/query_gen/tables.go | 16 ++++- common/routes_common.go | 17 ++--- extend/filler.go | 1 + extend/filler.txt | 1 - langs/english.json | 23 +++++- routes/panel/analytics.go | 36 +++++----- templates/ip_search.html | 4 +- templates/level_list.html | 4 +- templates/panel_debug.html | 99 ++++++++++++-------------- templates/panel_debug_stat.html | 1 + templates/panel_debug_stat_head.html | 1 + templates/panel_debug_stat_head_q.html | 1 + templates/panel_debug_stat_q.html | 1 + templates/panel_group_edit.html | 2 +- templates/panel_group_edit_perms.html | 2 +- templates/password_reset.html | 2 +- 16 files changed, 120 insertions(+), 91 deletions(-) create mode 100644 extend/filler.go delete mode 100644 extend/filler.txt create mode 100644 templates/panel_debug_stat.html create mode 100644 templates/panel_debug_stat_head.html create mode 100644 templates/panel_debug_stat_head_q.html create mode 100644 templates/panel_debug_stat_q.html diff --git a/cmd/query_gen/tables.go b/cmd/query_gen/tables.go index ace48b3f..047c9d31 100644 --- a/cmd/query_gen/tables.go +++ b/cmd/query_gen/tables.go @@ -10,7 +10,7 @@ type tC = tblColumn type tblKey = qgen.DBTableKey func createTables(adapter qgen.Adapter) (err error) { - createTable := func(table string, charset string, collation string, columns []qgen.DBTableColumn, keys []qgen.DBTableKey) { + createTable := func(table string, charset string, collation string, columns []tC, keys []tblKey) { if err != nil { return } @@ -419,10 +419,22 @@ func createTables(adapter qgen.Adapter) (err error) { ) /* + createTable("users_friends", "", "", + []tC{ + tC{"uid", "int", 0, false, false, ""}, + tC{"uid2", "int", 0, false, false, ""}, + }, nil, + ) + createTable("users_friends_invites", "", "", + []tC{ + tC{"requester", "int", 0, false, false, ""}, + tC{"target", "int", 0, false, false, ""}, + }, nil, + ) createTable("users_blocks", "", "", []tC{ tC{"blocker", "int", 0, false, false, ""}, - tC{"uid", "int", 0, false, false, ""}, + tC{"blockedUser", "int", 0, false, false, ""}, }, nil, ) */ diff --git a/common/routes_common.go b/common/routes_common.go index db606182..5e65dbe3 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -1,16 +1,16 @@ package common import ( + "crypto/subtle" "html" + "io" "net" "net/http" + "os" + "regexp" "strconv" "strings" "time" - "os" - "io" - "regexp" - "crypto/subtle" "github.com/Azareal/Gosora/common/phrases" ) @@ -182,8 +182,7 @@ func simpleUserCheck(w http.ResponseWriter, r *http.Request, user *User) (header } func GetThemeByReq(r *http.Request) *Theme { - var theme = &Theme{Name: ""} - + theme := &Theme{Name: ""} cookie, err := r.Cookie("current_theme") if err == nil { inTheme, ok := Themes[html.EscapeString(cookie.Value)] @@ -462,16 +461,14 @@ func NoBanned(w http.ResponseWriter, r *http.Request, user User) RouteError { } func ParseForm(w http.ResponseWriter, r *http.Request, user User) RouteError { - err := r.ParseForm() - if err != nil { + if err := r.ParseForm(); err != nil { return LocalError("Bad Form", w, r, user) } return nil } func NoSessionMismatch(w http.ResponseWriter, r *http.Request, user User) RouteError { - err := r.ParseForm() - if err != nil { + if err := r.ParseForm(); err != nil { return LocalError("Bad Form", w, r, user) } // TODO: Try to eliminate some of these allocations diff --git a/extend/filler.go b/extend/filler.go new file mode 100644 index 00000000..bc21a8e8 --- /dev/null +++ b/extend/filler.go @@ -0,0 +1 @@ +package extend \ No newline at end of file diff --git a/extend/filler.txt b/extend/filler.txt deleted file mode 100644 index 20e14b1e..00000000 --- a/extend/filler.txt +++ /dev/null @@ -1 +0,0 @@ -This file is here so that Git will include this folder in the repository. \ No newline at end of file diff --git a/langs/english.json b/langs/english.json index 0fd6eeca..385e7d86 100644 --- a/langs/english.json +++ b/langs/english.json @@ -699,6 +699,7 @@ "profile_add_friend":"Add Friend", "profile_unban":"Unban", "profile_ban":"Ban", + "profile_block":"Block", "profile_report_user_tooltip":"Report User", "profile_report_user_aria":"Report User", "profile_ban_user_head":"Ban User", @@ -1085,6 +1086,26 @@ "panel_debug_adapter_label":"Adapter", "panel_debug_goroutine_count_label":"Goroutines", - "panel_debug_cpu_count_label":"CPUs" + "panel_debug_cpu_count_label":"CPUs", + + "panel_debug_memory_stats":"Memory Statistics", + "panel_debug_memory_stats_sys":"Sys", + "panel_debug_memory_stats_heapsys":"HeapSys", + "panel_debug_memory_stats_heapalloc":"HeapAlloc", + "panel_debug_memory_stats_heapidle":"HeapIdle", + "panel_debug_memory_stats_heapobjects":"HeapObjects", + "panel_debug_memory_stats_stackinuse":"StackInuse", + + "panel_debug_caches":"Caches", + "panel_debug_caches_topic":"Topic Cache", + "panel_debug_caches_user":"User Cache", + "panel_debug_caches_reply":"Reply Cache", + "panel_debug_caches_topic_list":"Topic List", + + "panel_debug_database":"Database", + "panel_debug_database_topics":"Topics", + "panel_debug_database_users":"Users", + "panel_debug_database_replies":"Replies", + "panel_debug_disk":"Disk" } } \ No newline at end of file diff --git a/routes/panel/analytics.go b/routes/panel/analytics.go index 7fdc8d41..0480331d 100644 --- a/routes/panel/analytics.go +++ b/routes/panel/analytics.go @@ -10,7 +10,7 @@ import ( "time" c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + p "github.com/Azareal/Gosora/common/phrases" "github.com/Azareal/Gosora/query_gen" ) @@ -199,14 +199,14 @@ func analyticsRowsToAverageMap2(rows *sql.Rows, labelList []int64, avgMap map[in } func PreAnalyticsDetail(w http.ResponseWriter, r *http.Request, user *c.User) (*c.BasePanelPage, c.RouteError) { - bPage, ferr := buildBasePage(w, r, user, "analytics", "analytics") + bp, ferr := buildBasePage(w, r, user, "analytics", "analytics") if ferr != nil { return nil, ferr } - bPage.AddSheet("chartist/chartist.min.css") - bPage.AddScript("chartist/chartist.min.js") - bPage.AddScriptAsync("analytics.js") - return bPage, nil + bp.AddSheet("chartist/chartist.min.css") + bp.AddScript("chartist/chartist.min.js") + bp.AddScriptAsync("analytics.js") + return bp, nil } func AnalyticsViews(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { @@ -315,7 +315,7 @@ func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user c.User, ag graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList} c.DebugLogf("graph: %+v\n", graph) - friendlyAgent, ok := phrases.GetUserAgentPhrase(agent) + friendlyAgent, ok := p.GetUserAgentPhrase(agent) if !ok { friendlyAgent = agent } @@ -397,7 +397,7 @@ func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user c.User, s graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList} c.DebugLogf("graph: %+v\n", graph) - friendlySystem, ok := phrases.GetOSPhrase(system) + friendlySystem, ok := p.GetOSPhrase(system) if !ok { friendlySystem = system } @@ -437,7 +437,7 @@ func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user c.User, graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList} c.DebugLogf("graph: %+v\n", graph) - friendlyLang, ok := phrases.GetHumanLangPhrase(lang) + friendlyLang, ok := p.GetHumanLangPhrase(lang) if !ok { friendlyLang = lang } @@ -659,7 +659,7 @@ func analyticsRowsToDuoMap(rows *sql.Rows, labelList []int64, viewMap map[int64] } // TODO: Bulk log this - var unixCreatedAt = createdAt.Unix() + unixCreatedAt := createdAt.Unix() if c.Dev.SuperDebug { log.Print("count: ", count) log.Print("name: ", name) @@ -830,7 +830,7 @@ func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user c.User) c.Rout ovList := analyticsVMapToOVList(vMap) ex := strings.Split(r.FormValue("ex"), ",") - var inEx = func(name string) bool { + inEx := func(name string) bool { for _, e := range ex { if e == name { return true @@ -902,7 +902,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout ovList := analyticsVMapToOVList(vMap) ex := strings.Split(r.FormValue("ex"), ",") - var inEx = func(name string) bool { + inEx := func(name string) bool { for _, e := range ex { if e == name { return true @@ -918,7 +918,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout if inEx(ovitem.name) { continue } - lName, ok := phrases.GetUserAgentPhrase(ovitem.name) + lName, ok := p.GetUserAgentPhrase(ovitem.name) if !ok { lName = ovitem.name } @@ -945,7 +945,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout if inEx(agent) { continue } - aAgent, ok := phrases.GetUserAgentPhrase(agent) + aAgent, ok := p.GetUserAgentPhrase(agent) if !ok { aAgent = agent } @@ -996,7 +996,7 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user c.User) c.Rou viewList = append(viewList, ovitem.viewMap[value]) } vList = append(vList, viewList) - lName, ok := phrases.GetOSPhrase(ovitem.name) + lName, ok := p.GetOSPhrase(ovitem.name) if !ok { lName = ovitem.name } @@ -1012,7 +1012,7 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user c.User) c.Rou // TODO: Sort this slice var systemItems []c.PanelAnalyticsAgentsItem for system, count := range osMap { - sSystem, ok := phrases.GetOSPhrase(system) + sSystem, ok := p.GetOSPhrase(system) if !ok { sSystem = system } @@ -1068,7 +1068,7 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user c.User) c.R if inEx(ovitem.name) { continue } - lName, ok := phrases.GetHumanLangPhrase(ovitem.name) + lName, ok := p.GetHumanLangPhrase(ovitem.name) if !ok { lName = ovitem.name } @@ -1096,7 +1096,7 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user c.User) c.R if inEx(lang) { continue } - lLang, ok := phrases.GetHumanLangPhrase(lang) + lLang, ok := p.GetHumanLangPhrase(lang) if !ok { lLang = lang } diff --git a/templates/ip_search.html b/templates/ip_search.html index 92ded6fc..dde6c4fa 100644 --- a/templates/ip_search.html +++ b/templates/ip_search.html @@ -14,7 +14,7 @@ {{if .IP}}
- {{range .ItemList}}
+ {{range .ItemList}} @@ -22,4 +22,4 @@
{{end}} -{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/level_list.html b/templates/level_list.html index 0922da94..a2eccabd 100644 --- a/templates/level_list.html +++ b/templates/level_list.html @@ -7,11 +7,11 @@
{{level .Level}}
-
+
Score: {{.Score}}
{{end}} -{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/panel_debug.html b/templates/panel_debug.html index 1882f806..4beb2fb8 100644 --- a/templates/panel_debug.html +++ b/templates/panel_debug.html @@ -2,50 +2,45 @@

{{lang "panel_debug_head"}}

{{flush}}
-
{{lang "panel_debug_uptime_label"}}
-
{{lang "panel_debug_go_version_label"}}
-
{{lang "panel_debug_database_version_label"}}
- -
{{.Uptime}}
-
{{.GoVersion}}
-
{{.DBVersion}}
+ {{template "panel_debug_stat_head.html" "panel_debug_uptime_label"}} + {{template "panel_debug_stat_head.html" "panel_debug_go_version_label"}} + {{template "panel_debug_stat_head.html" "panel_debug_database_version_label"}} + {{template "panel_debug_stat.html" .Uptime}} + {{template "panel_debug_stat.html" .GoVersion}} + {{template "panel_debug_stat.html" .DBVersion}} - -
{{lang "panel_debug_open_database_connections_label"}}
-
{{lang "panel_debug_adapter_label"}}
+ {{template "panel_debug_stat_head.html" "panel_debug_open_database_connections_label"}} + {{template "panel_debug_stat_head.html" "panel_debug_adapter_label"}} {{/** TODO: Use this for active database connections when Go 1.11 lands **/}} -
???
+ {{template "panel_debug_stat_head_q.html"}} + {{template "panel_debug_stat.html" .OpenConns}} + {{template "panel_debug_stat.html" .DBAdapter}} + {{template "panel_debug_stat_q.html"}} -
{{.OpenConns}}
-
{{.DBAdapter}}
-
?
- - -
{{lang "panel_debug_goroutine_count_label"}}
-
{{lang "panel_debug_cpu_count_label"}}
-
???
- -
{{.Goroutines}}
-
{{.CPUs}}
-
?
+ {{template "panel_debug_stat_head.html" "panel_debug_goroutine_count_label"}} + {{template "panel_debug_stat_head.html" "panel_debug_cpu_count_label"}} + {{template "panel_debug_stat_head_q.html"}} + {{template "panel_debug_stat.html" .Goroutines}} + {{template "panel_debug_stat.html" .CPUs}} + {{template "panel_debug_stat_q.html"}}
-

Memory Statistics

+

{{lang "panel_debug_memory_stats"}}

{{flush}}
-
Sys
-
HeapSys
-
HeapAlloc
+ {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_sys"}} + {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapsys"}} + {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapalloc"}}
{{.MemStats.Sys}} ({{bunit .MemStats.Sys}})
{{.MemStats.HeapSys}} ({{bunit .MemStats.HeapSys}})
{{.MemStats.HeapAlloc}} ({{bunit .MemStats.HeapAlloc}})
-
HeapIdle
-
HeapObjects
-
StackInuse
+ {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapidle"}} + {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapobjects"}} + {{template "panel_debug_stat_head.html" "panel_debug_memory_stats_stackinuse"}}
{{.MemStats.HeapIdle}} ({{bunit .MemStats.HeapIdle}})
{{.MemStats.HeapObjects}}
@@ -70,33 +65,33 @@
{{.MemStats.OtherSys}} ({{bunit .MemStats.OtherSys}})
-

Caches

+

{{lang "panel_debug_caches"}}

-
Topic Cache
-
User Cache
-
Reply Cache
+ {{template "panel_debug_stat_head.html" "panel_debug_caches_topic"}} + {{template "panel_debug_stat_head.html" "panel_debug_caches_user"}} + {{template "panel_debug_stat_head.html" "panel_debug_caches_reply"}}
{{.Cache.Topics}} / {{.Cache.TCap}}
{{.Cache.Users}} / {{.Cache.UCap}}
{{.Cache.Replies}} / {{.Cache.RCap}}
-
Topic List
-
???
-
???
+ {{template "panel_debug_stat_head.html" "panel_debug_caches_topic_list"}} + {{template "panel_debug_stat_head_q.html"}} + {{template "panel_debug_stat_head_q.html"}}
{{if .Cache.TopicListThaw}}Thawed{{else}}Sleeping{{end}}
-
?
-
?
+ {{template "panel_debug_stat_q.html"}} + {{template "panel_debug_stat_q.html"}}
-

Database

+

{{lang "panel_debug_database"}}

{{flush}}
-
Topics
-
Users
-
Replies
+ {{template "panel_debug_stat_head.html" "panel_debug_database_topics"}} + {{template "panel_debug_stat_head.html" "panel_debug_database_users"}} + {{template "panel_debug_stat_head.html" "panel_debug_database_replies"}}
{{.Database.Topics}}
{{.Database.Users}}
@@ -114,11 +109,11 @@
Attachments
Polls
-
???
+ {{template "panel_debug_stat_head_q.html"}}
{{.Database.Attachments}}
{{.Database.Polls}}
-
?
+ {{template "panel_debug_stat_q.html"}}
Login Logs
@@ -131,12 +126,12 @@
Admin Logs
-
???
-
???
+ {{template "panel_debug_stat_head_q.html"}} + {{template "panel_debug_stat_head_q.html"}}
{{.Database.AdminLogs}}
-
?
-
?
+ {{template "panel_debug_stat_q.html"}} + {{template "panel_debug_stat_q.html"}}
Views
@@ -159,14 +154,14 @@
Post Analytics
Topic Analytics
-
???
+ {{template "panel_debug_stat_head_q.html"}}
{{.Database.PostChunks}}
{{.Database.TopicChunks}}
-
?
+ {{template "panel_debug_stat_q.html"}}
-

Disk

+

{{lang "panel_debug_disk"}}

{{flush}}
Static Files
diff --git a/templates/panel_debug_stat.html b/templates/panel_debug_stat.html new file mode 100644 index 00000000..30d01d52 --- /dev/null +++ b/templates/panel_debug_stat.html @@ -0,0 +1 @@ +
{{.}}
\ No newline at end of file diff --git a/templates/panel_debug_stat_head.html b/templates/panel_debug_stat_head.html new file mode 100644 index 00000000..9f197d82 --- /dev/null +++ b/templates/panel_debug_stat_head.html @@ -0,0 +1 @@ +
{{lang .}}
\ No newline at end of file diff --git a/templates/panel_debug_stat_head_q.html b/templates/panel_debug_stat_head_q.html new file mode 100644 index 00000000..e2f241b5 --- /dev/null +++ b/templates/panel_debug_stat_head_q.html @@ -0,0 +1 @@ +
???
\ No newline at end of file diff --git a/templates/panel_debug_stat_q.html b/templates/panel_debug_stat_q.html new file mode 100644 index 00000000..73687e4f --- /dev/null +++ b/templates/panel_debug_stat_q.html @@ -0,0 +1 @@ +
?
\ No newline at end of file diff --git a/templates/panel_group_edit.html b/templates/panel_group_edit.html index 6bc316f2..c084da6b 100644 --- a/templates/panel_group_edit.html +++ b/templates/panel_group_edit.html @@ -36,4 +36,4 @@
-{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/panel_group_edit_perms.html b/templates/panel_group_edit_perms.html index 024b6385..e7dbdb5c 100644 --- a/templates/panel_group_edit_perms.html +++ b/templates/panel_group_edit_perms.html @@ -53,4 +53,4 @@ -{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/password_reset.html b/templates/password_reset.html index c9a7dbd5..109a04ab 100644 --- a/templates/password_reset.html +++ b/templates/password_reset.html @@ -15,4 +15,4 @@ -{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file