From a20078d83bc83905a720a146ea9659d6822b22ce Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 6 Dec 2018 21:09:10 +1000 Subject: [PATCH] Revamped the IP Search Page for Nox. Revamped the Word Filter Manager for Nox. Revamped the Setting Manager for Nox and Cosora. Upped the number of items in the User Manager. Upped the number of items in the Group Manager. Upped the number of items in the Page Manager. Swap a fmt.Println for a DebugLog in hold.ScanItem. EQCSS.js should ignore panel.css in Cosora now. Added the lang template function for stylesheet templates to reduce the amount of boilerplate. Localised a couple of spots in the Nox Theme which got overlooked. Tweaked the grid CSS for Nox. The Control Panel Dashboard items now change colour in Nox like in the other themes. Use Site.Host instead of req.Host for www redirects for security reasons. Removed a superfluous function call in WriterIntercept.WriteHeader. Tweaked several bits and pieces of CSS like the padding on a few items in the Forum Editor. Added the topic_list.moderate phrase. Added the panel_word_filters_to phrase. --- common/menus.go | 4 +- common/theme.go | 20 +++++++ gen_router.go | 5 +- langs/english.json | 2 + public/EQCSS.js | 2 +- router_gen/main.go | 5 +- routes/panel/groups.go | 2 +- routes/panel/pages.go | 3 +- routes/panel/settings.go | 1 + routes/panel/users.go | 2 +- routes/panel/word_filters.go | 1 + templates/ip_search.html | 2 +- templates/panel_settings.html | 4 +- templates/panel_word_filters.html | 2 +- themes/cosora/public/panel.css | 17 +++++- themes/nox/public/acc_panel_common.css | 3 +- themes/nox/public/main.css | 46 +++++++++------ themes/nox/public/panel.css | 81 ++++++++++++++++++++------ themes/nox/theme.json | 1 + themes/shadow/public/panel.css | 3 + themes/tempra-simple/public/panel.css | 3 + 21 files changed, 156 insertions(+), 53 deletions(-) diff --git a/common/menus.go b/common/menus.go index 8e312b7c..d179fd1d 100644 --- a/common/menus.go +++ b/common/menus.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/Azareal/Gosora/query_gen" "github.com/Azareal/Gosora/common/phrases" + "github.com/Azareal/Gosora/query_gen" ) type MenuItemList []MenuItem @@ -375,7 +375,7 @@ func (hold *MenuListHolder) ScanItem(menuTmpls map[string]MenuTmpl, mitem MenuIt _, hasInnerVar := skipUntilIfExists(renderItem, 0, '{') if hasInnerVar { - fmt.Println("inner var: ", string(renderItem)) + DebugLog("inner var: ", string(renderItem)) dotAt, hasDot := skipUntilIfExists(renderItem, 0, '.') endFence, hasEndFence := skipUntilIfExists(renderItem, dotAt, '}') if !hasDot || !hasEndFence || (endFence-dotAt) <= 1 { diff --git a/common/theme.go b/common/theme.go index ac05a828..5e8c7365 100644 --- a/common/theme.go +++ b/common/theme.go @@ -32,6 +32,7 @@ type Theme struct { Disabled bool HideFromThemes bool BgAvatars bool // For profiles, at the moment + GridLists bool // User Manager ForkOf string Tag string URL string @@ -77,6 +78,24 @@ type ThemeMapTmplToDock struct { // TODO: It might be unsafe to call the template parsing functions with fsnotify, do something more concurrent func (theme *Theme) LoadStaticFiles() error { theme.ResourceTemplates = template.New("") + fmap := make(map[string]interface{}) + fmap["lang"] = func(phraseNameInt interface{}, tmplInt interface{}) interface{} { + phraseName, ok := phraseNameInt.(string) + if !ok { + panic("phraseNameInt is not a string") + } + tmpl, ok := tmplInt.(CSSData) + if !ok { + panic("tmplInt is not a CSSData") + } + phrase, ok := tmpl.Phrases[phraseName] + if !ok { + // TODO: XSS? Only server admins should have access to theme files anyway, but think about it + return "{lang." + phraseName + "}" + } + return phrase + } + theme.ResourceTemplates.Funcs(fmap) template.Must(theme.ResourceTemplates.ParseGlob("./themes/" + theme.Name + "/public/*.css")) // It should be safe for us to load the files for all the themes in memory, as-long as the admin hasn't setup a ridiculous number of themes @@ -106,6 +125,7 @@ func (theme *Theme) AddThemeStaticFiles() error { var b bytes.Buffer var pieces = strings.Split(path, "/") var filename = pieces[len(pieces)-1] + // TODO: Prepare resource templates for each loaded langpack? err = theme.ResourceTemplates.ExecuteTemplate(&b, filename, CSSData{Phrases: phraseMap}) if err != nil { return err diff --git a/gen_router.go b/gen_router.go index 87fa38d0..34cd7bcb 100644 --- a/gen_router.go +++ b/gen_router.go @@ -543,9 +543,10 @@ func NewWriterIntercept(w http.ResponseWriter) *WriterIntercept { return &WriterIntercept{w} } +var wiMaxAge = "max-age=" + strconv.Itoa(int(common.Day)) func (writ *WriterIntercept) WriteHeader(code int) { if code == 200 { - writ.ResponseWriter.Header().Set("Cache-Control", "max-age=" + strconv.Itoa(int(common.Day))) + writ.ResponseWriter.Header().Set("Cache-Control", wiMaxAge) writ.ResponseWriter.Header().Set("Vary", "Accept-Encoding") } writ.ResponseWriter.WriteHeader(code) @@ -644,7 +645,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { if common.Site.EnableSsl { s = "s" } - dest := "http"+s+"://" + req.Host + req.URL.Path + dest := "http"+s+"://" + common.Site.Host + req.URL.Path if len(req.URL.RawQuery) > 0 { dest += "?" + req.URL.RawQuery } diff --git a/langs/english.json b/langs/english.json index 1cd6e020..59916a62 100644 --- a/langs/english.json +++ b/langs/english.json @@ -505,6 +505,7 @@ "topic_list.create_topic_tooltip":"Create Topic", "topic_list.create_topic_aria":"Create a topic", + "topic_list.moderate":"Moderate", "topic_list.moderate_tooltip":"Moderate", "topic_list.moderate_aria":"Moderate Posts", "topic_list.what_to_do":"What do you want to do with these {0} topics?", @@ -765,6 +766,7 @@ "panel_group_extended_permissions":"Extended Permissions", "panel_word_filters_head":"Word Filters", + "panel_word_filters_to":"...to...", "panel_word_filters_edit_button_aria":"Edit Word Filter", "panel_word_filters_update_button":"Update", "panel_word_filters_delete_button_aria":"Delete Word Filter", diff --git a/public/EQCSS.js b/public/EQCSS.js index 4430df84..2ee1ece9 100644 --- a/public/EQCSS.js +++ b/public/EQCSS.js @@ -61,7 +61,7 @@ License: MIT for (i = 0; i < link.length; i++) { // Test if the link is not read yet, and has rel=stylesheet - if (link[i].getAttribute('data-eqcss-read') === null && link[i].rel === 'stylesheet') { + if (link[i].getAttribute('data-eqcss-read') === null && link[i].rel === 'stylesheet' && link[i].getAttribute("href").endsWith("main.css")) { // retrieve the file content with AJAX and process it if (link[i].href) { (function() { diff --git a/router_gen/main.go b/router_gen/main.go index 7ad282ea..e728e49b 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -325,9 +325,10 @@ func NewWriterIntercept(w http.ResponseWriter) *WriterIntercept { return &WriterIntercept{w} } +var wiMaxAge = "max-age=" + strconv.Itoa(int(common.Day)) func (writ *WriterIntercept) WriteHeader(code int) { if code == 200 { - writ.ResponseWriter.Header().Set("Cache-Control", "max-age=" + strconv.Itoa(int(common.Day))) + writ.ResponseWriter.Header().Set("Cache-Control", wiMaxAge) writ.ResponseWriter.Header().Set("Vary", "Accept-Encoding") } writ.ResponseWriter.WriteHeader(code) @@ -426,7 +427,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { if common.Site.EnableSsl { s = "s" } - dest := "http"+s+"://" + req.Host + req.URL.Path + dest := "http"+s+"://" + common.Site.Host + req.URL.Path if len(req.URL.RawQuery) > 0 { dest += "?" + req.URL.RawQuery } diff --git a/routes/panel/groups.go b/routes/panel/groups.go index b7d7fe93..a8afb92e 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -16,7 +16,7 @@ func Groups(w http.ResponseWriter, r *http.Request, user common.User) common.Rou } page, _ := strconv.Atoi(r.FormValue("page")) - perPage := 9 + perPage := 15 offset, page, lastPage := common.PageOffset(basePage.Stats.Groups, page, perPage) // Skip the 'Unknown' group diff --git a/routes/panel/pages.go b/routes/panel/pages.go index b3044435..8dbae85a 100644 --- a/routes/panel/pages.go +++ b/routes/panel/pages.go @@ -20,9 +20,10 @@ func Pages(w http.ResponseWriter, r *http.Request, user common.User) common.Rout basePage.AddNotice("panel_page_deleted") } + // TODO: Test the pagination here pageCount := common.Pages.GlobalCount() page, _ := strconv.Atoi(r.FormValue("page")) - perPage := 10 + perPage := 15 offset, page, lastPage := common.PageOffset(pageCount, page, perPage) cPages, err := common.Pages.GetOffset(offset, perPage) diff --git a/routes/panel/settings.go b/routes/panel/settings.go index 97afcee4..e1c9632d 100644 --- a/routes/panel/settings.go +++ b/routes/panel/settings.go @@ -19,6 +19,7 @@ func Settings(w http.ResponseWriter, r *http.Request, user common.User) common.R return common.NoPermissions(w, r, user) } + // TODO: What if the list gets too long? How should we structure this? settings, err := basePage.Settings.BypassGetAll() if err != nil { return common.InternalError(err, w, r) diff --git a/routes/panel/users.go b/routes/panel/users.go index 8b257cc9..a988591c 100644 --- a/routes/panel/users.go +++ b/routes/panel/users.go @@ -15,7 +15,7 @@ func Users(w http.ResponseWriter, r *http.Request, user common.User) common.Rout } page, _ := strconv.Atoi(r.FormValue("page")) - perPage := 10 + perPage := 15 offset, page, lastPage := common.PageOffset(basePage.Stats.Users, page, perPage) users, err := common.Users.GetOffset(offset, perPage) diff --git a/routes/panel/word_filters.go b/routes/panel/word_filters.go index 81c2faae..dbd7a1c1 100644 --- a/routes/panel/word_filters.go +++ b/routes/panel/word_filters.go @@ -18,6 +18,7 @@ func WordFilters(w http.ResponseWriter, r *http.Request, user common.User) commo return common.NoPermissions(w, r, user) } + // TODO: What if this list gets too long? filterList, err := common.WordFilters.GetAll() if err != nil { return common.InternalError(err, w, r) diff --git a/templates/ip_search.html b/templates/ip_search.html index 7e4455df..51354012 100644 --- a/templates/ip_search.html +++ b/templates/ip_search.html @@ -13,7 +13,7 @@ {{if .IP}} -
+
{{range .ItemList}}
{{.Name}}'s Avatar {{.Name}} diff --git a/templates/panel_settings.html b/templates/panel_settings.html index f9598c96..4f6acddc 100644 --- a/templates/panel_settings.html +++ b/templates/panel_settings.html @@ -5,10 +5,10 @@

{{lang "panel_settings_head"}}

-
+
{{range .Something}} {{end}} diff --git a/templates/panel_word_filters.html b/templates/panel_word_filters.html index 139c3672..5fdf3b42 100644 --- a/templates/panel_word_filters.html +++ b/templates/panel_word_filters.html @@ -6,7 +6,7 @@

{{lang "panel_word_filters_head"}}

-
+
{{range .Something}}
{{.Find}} diff --git a/themes/cosora/public/panel.css b/themes/cosora/public/panel.css index f6701d1f..ddc42499 100644 --- a/themes/cosora/public/panel.css +++ b/themes/cosora/public/panel.css @@ -25,9 +25,9 @@ margin-bottom: 8px; margin-left: 16px; padding-bottom: 12px; - padding-top: 12px; + padding-top: 12px; padding-left: 8px; - border-bottom: 1px solid var(--element-border-color); + border-bottom: 1px solid var(--element-border-color); border-left: none; border-right: none; border-top: none; @@ -186,6 +186,19 @@ #panel_setting .formlabel { display: none; } +#panel_settings .panel_upshift { + border-bottom: 1px solid var(--element-border-color); + padding-bottom: 12px; +} +#panel_settings.rowlist.bgavatars .rowitem > a, #panel_settings.rowlist.bgavatars .rowitem > span { + margin-left: 0px; + margin-right: 0px; +} +#panel_settings .to_right { + float: none; + margin-top: auto; + padding-top: 14px; +} #panel_page_list textarea, #panel_page_edit textarea { margin-top: 8px; } diff --git a/themes/nox/public/acc_panel_common.css b/themes/nox/public/acc_panel_common.css index 322ce8c0..094d18a3 100644 --- a/themes/nox/public/acc_panel_common.css +++ b/themes/nox/public/acc_panel_common.css @@ -2,6 +2,7 @@ width: 200px; padding-bottom: 6px; background-color: rgb(62, 62, 62); + /*border-left: 4px solid rgb(82, 82, 82);*/ } .colstack_left .colstack_head { /*font-size: 19px;*/ @@ -27,7 +28,7 @@ } .rowmenu { - margin-left: 16px; + margin-left: 18px; margin-bottom: 2px; font-size: 17px; } diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index 6e8bd03a..c71ef444 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -350,7 +350,7 @@ h2 { width: 100%; } .topic_list_title_block .pre_opt:before { - content: "{{index .Phrases "topics_click_topics_to_select"}}"; + content: "{{lang "topics_click_topics_to_select" . }}"; font-size: 17px; margin-right: 20px; } @@ -360,10 +360,10 @@ h2 { white-space: nowrap; } .topic_list_title_block .create_topic_opt a:before { - content: "Create Topic"; + content: "{{lang "quick_topic.create_topic_button" . }}"; } .topic_list_title_block .mod_opt a:before { - content: "Moderate"; + content: "{{lang "topic_list.moderate" . }}"; } .filter_opt { @@ -621,7 +621,7 @@ button, .formbutton, .panel_right_button:not(.has_inner_button) { margin-top: 6px; } .topic_view_count:after { - content: "{{index .Phrases "topic.view_count_suffix"}}"; + content: "{{lang "topic.view_count_suffix" . }}"; } .topic_name_input { width: 100%; @@ -772,50 +772,58 @@ input[type=checkbox]:checked + label .sel { } .add_like:before, .remove_like:before { - content: "{{index .Phrases "topic.plus_one"}}"; + content: "{{lang "topic.plus_one" . }}"; } .button_container .open_edit:after, .edit_item:after { - content: "{{index .Phrases "topic.edit_button_text"}}"; + content: "{{lang "topic.edit_button_text" . }}"; } .delete_item:after { - content: "{{index .Phrases "topic.delete_button_text"}}"; + content: "{{lang "topic.delete_button_text" . }}"; } .ip_item_button:after { - content: "{{index .Phrases "topic.ip_button_text"}}"; + content: "{{lang "topic.ip_button_text" . }}"; } .lock_item:after { - content: "{{index .Phrases "topic.lock_button_text"}}"; + content: "{{lang "topic.lock_button_text" . }}"; } .unlock_item:after { - content: "{{index .Phrases "topic.unlock_button_text"}}"; + content: "{{lang "topic.unlock_button_text" . }}"; } .pin_item:after { - content: "{{index .Phrases "topic.pin_button_text"}}"; + content: "{{lang "topic.pin_button_text" . }}"; } .unpin_item:after { - content: "{{index .Phrases "topic.unpin_button_text"}}"; + content: "{{lang "topic.unpin_button_text" . }}"; } .report_item:after { - content: "{{index .Phrases "topic.report_button_text"}}"; + content: "{{lang "topic.report_button_text" . }}"; } .like_count:after { - content: "{{index .Phrases "topic.like_count_suffix"}}"; + content: "{{lang "topic.like_count_suffix" . }}"; } .topic_reply_container { display: flex; } -.rowlist.bgavatars { +.rowlist.bgavatars, .micro_grid { display: grid; - grid-gap: 16px; - grid-row-gap: 0px; + /*grid-gap: 16px; + grid-row-gap: 8px;*/ + grid-gap: 24px; + grid-row-gap: 16px; grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } -.rowlist.bgavatars .rowitem { +.rowlist.bgavatars.micro_grid, .micro_grid { + grid-gap: 16px; + grid-row-gap: 4px; + grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); +} +.rowlist.bgavatars .rowitem, .micro_grid .rowitem { display: flex; flex-direction: column; - width: 180px; + /*width: 180px;*/ background-image: none !important; margin-bottom: 10px; padding: 16px; diff --git a/themes/nox/public/panel.css b/themes/nox/public/panel.css index 33cf2d9c..438e0a51 100644 --- a/themes/nox/public/panel.css +++ b/themes/nox/public/panel.css @@ -51,12 +51,21 @@ grid-gap: 8px; grid-template-columns: repeat(3, 1fr); } +.rowlist.bgavatars, .micro_grid { + grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); +} .grid_item { border-radius: 3px; color: rgb(190,190,190); - background-color: #444444; + background-color: rgb(68,68,68); padding: 12px; } +.stat_green { + background-color: rgb(68,88,68); +} +.stat_red { + background-color: rgb(88,68,68); +} .to_right, .panel_buttons, .panel_floater { margin-left: auto; @@ -68,10 +77,6 @@ padding-left: 6px; padding-right: 6px; } -.colstack_right input { - padding-left: 6px; - padding-right: 6px; -} button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .profile_url { background: rgb(100,100,200); @@ -79,7 +84,10 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p #panel_users .panel_tag:not(.panel_right_button) { background: rgb(50,150,50); } -.panel_right_button:not(.has_inner_button), #panel_users .panel_tag:not(.panel_right_button), #panel_users .profile_url { +.panel_right_button:not(.has_inner_button), +.panel_right_button button, +#panel_users .panel_tag:not(.panel_right_button), +#panel_users .profile_url { margin-left: 2px; padding: 5px; padding-left: 6px; @@ -92,10 +100,10 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p border-radius: 3px; } .edit_button:after { - content: "{{index .Phrases "panel_edit_button_text"}}"; + content: "{{lang "panel_edit_button_text" . }}"; } .delete_button:after { - content: "{{index .Phrases "panel_delete_button_text"}}"; + content: "{{lang "panel_delete_button_text" . }}"; } /*#themeSelector select { background: rgb(90,90,90); @@ -129,6 +137,42 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p height: 80px; } +.micro_grid .to_right, .micro_grid .panel_buttons { + margin-left: 0px; +} +#panel_settings .panel_upshift { + margin-bottom: 12px; +} +#panel_settings .to_right { + white-space: nowrap; + margin-top: auto; + padding-top: 10px; + background-color: #555555; + border-radius: 5px; + padding-left: 5px; + padding: 12px; +} +#panel_settings.rowlist.bgavatars.micro_grid, .micro_grid { + grid-gap: 24px; + grid-row-gap: 16px; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); +} + +#panel_word_filters { + grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); +} +#panel_word_filters .filters_find { + margin-bottom: 1px; +} +#panel_word_filters .itemSeparator:before { + content: "{{lang "panel_word_filters_to" . }}"; + font-size: 17px; + margin-bottom: 1px; +} +#panel_word_filters .panel_buttons { + margin-top: 14px; +} + #panel_users .rowitem .to_right { order: 0; margin-right: auto; @@ -143,31 +187,31 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p } .perm_preset_no_access:before { - content: "{{index .Phrases "panel_perms_no_access" }}"; + content: "{{lang "panel_perms_no_access" . }}"; /*color: hsl(0,100%,20%);*/ } /*.perm_preset_read_only:before, .perm_preset_can_post:before { color: hsl(120,100%,20%); }*/ .perm_preset_read_only:before { - content: "{{index .Phrases "panel_perms_read_only" }}"; + content: "{{lang "panel_perms_read_only" . }}"; } .perm_preset_can_post:before { - content: "{{index .Phrases "panel_perms_can_post" }}"; + content: "{{lang "panel_perms_can_post" . }}"; } .perm_preset_can_moderate:before { - content: "{{index .Phrases "panel_perms_can_moderate" }}"; + content: "{{lang "panel_perms_can_moderate" . }}"; /*color: hsl(240,100%,20%);*/ } .perm_preset_quasi_mod:before { - content: "{{index .Phrases "panel_perms_quasi_mod" }}"; + content: "{{lang "panel_perms_quasi_mod" . }}"; } .perm_preset_custom:before { - content: "{{index .Phrases "panel_perms_custom" }}"; + content: "{{lang "panel_perms_custom" . }}"; /*color: hsl(0,0%,20%);*/ } .perm_preset_default:before { - content: "{{index .Phrases "panel_perms_default" }}"; + content: "{{lang "panel_perms_default" . }}"; } .panel_submitrow { @@ -183,12 +227,15 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p margin-right: auto; } -.has_inner_button button { +/*.has_inner_button button { margin-right: 8px; -} +}*/ #forum_quick_perms .formitem, #forum_quick_perms .panel_floater { display: flex; } +#forum_quick_perms .edit_fields { + margin-left: 4px; +} .panel_plugin_meta { display: flex; diff --git a/themes/nox/theme.json b/themes/nox/theme.json index 214af9bc..37759595 100644 --- a/themes/nox/theme.json +++ b/themes/nox/theme.json @@ -6,6 +6,7 @@ "URL": "github.com/Azareal/Gosora", "Tag": "WIP", "Docks":["topMenu","rightSidebar","footer"], + "GridLists":true, "MapTmplToDock": { "rightOfNav": { "File": "./templates/userDock.html" diff --git a/themes/shadow/public/panel.css b/themes/shadow/public/panel.css index cf48c57c..524bcca4 100644 --- a/themes/shadow/public/panel.css +++ b/themes/shadow/public/panel.css @@ -66,6 +66,9 @@ margin-bottom: 5px; } +#panel_settings .panel_compactrow { + padding-left: 10px; +} #panel_word_filters .itemSeparator:before { content: " || "; padding-left: 2px; diff --git a/themes/tempra-simple/public/panel.css b/themes/tempra-simple/public/panel.css index c71197eb..15925d8b 100644 --- a/themes/tempra-simple/public/panel.css +++ b/themes/tempra-simple/public/panel.css @@ -145,6 +145,9 @@ padding-bottom: 3px; } +#panel_settings .panel_compactrow { + padding-left: 10px; +} #panel_word_filters .itemSeparator:before { content: " || "; padding-left: 2px;