From 3043ce083db98db48a38ee2c08848752d3746f88 Mon Sep 17 00:00:00 2001 From: Azareal Date: Tue, 3 Jul 2018 20:01:49 +1000 Subject: [PATCH] Basic proxy IP support. Switched out a couple of s in the Control Panel with

s, we might want to use

here instead. Added graphs for Nox. Tweaked header markup for Nox. Added support for live topic list to Nox. Added styling for stickies on Nox. Fixed topic list text overflow on Nox. --- common/routes_common.go | 13 ++++++++ templates/panel_dashboard.html | 2 +- templates/panel_debug.html | 2 +- themes/nox/public/main.css | 45 +++++++++++++++++++++++--- themes/nox/public/panel.css | 28 +++++++++++++++- themes/shadow/public/main.css | 4 +++ themes/tempra-conflux/public/panel.css | 4 +++ 7 files changed, 90 insertions(+), 8 deletions(-) diff --git a/common/routes_common.go b/common/routes_common.go index d4d8ce55..00d65c58 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -257,11 +257,24 @@ func preRoute(w http.ResponseWriter, r *http.Request) (User, bool) { *usercpy = *user // TODO: WIP. Refactor this to eliminate the unnecessary query + // TODO: Better take proxies into consideration host, _, err := net.SplitHostPort(r.RemoteAddr) if err != nil { PreError("Bad IP", w, r) return *usercpy, false } + + // TODO: Prefer Cf-Connecting-Ip header, fewer shenanigans + if Site.HasProxy { + // TODO: Check the right-most IP, might get tricky with multiple proxies, maybe have a setting for the number of hops we jump through + xForwardedFor := r.Header.Get("X-Forwarded-For") + if xForwardedFor != "" { + forwardedFor := strings.Split(xForwardedFor, ",") + // TODO: Check if this is a valid IP Address, reject if not + host = forwardedFor[len(forwardedFor)-1] + } + } + if user == &GuestUser { usercpy.LastIP = host return *usercpy, true diff --git a/templates/panel_dashboard.html b/templates/panel_dashboard.html index 9bc29332..aa3cca01 100644 --- a/templates/panel_dashboard.html +++ b/templates/panel_dashboard.html @@ -3,7 +3,7 @@ {{template "panel_menu.html" . }}
- +

{{lang "panel_dashboard_head"}}

{{range .GridItems}} diff --git a/templates/panel_debug.html b/templates/panel_debug.html index 1f0bc7e6..7fd8d35c 100644 --- a/templates/panel_debug.html +++ b/templates/panel_debug.html @@ -3,7 +3,7 @@ {{template "panel_menu.html" . }}
- +

{{lang "panel_debug_head"}}

{{lang "panel_debug_uptime_label"}}
diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index 2b92cecc..02b0a82f 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -114,6 +114,8 @@ li a { background-color: #444444; display: flex; padding: 12px; +} +.sidebar .rowblock:not(.topic_list):not(.rowhead):not(.opthead) .rowitem { margin-left: 12px; } .colstack_right .colstack_item.the_form { @@ -136,7 +138,7 @@ li a { margin-bottom: 8px; } -h1, h3 { +h1, h2, h3, h4, h5 { -webkit-margin-before: 0; -webkit-margin-after: 0; margin-block-start: 0; @@ -150,14 +152,15 @@ h1, h3 { display: none; } -.rowhead, .opthead { - margin-left: 18px; +.rowhead, .opthead, .colstack_head { + margin-left: 8px; margin-bottom: 8px; } -.rowhead h1, .opthead h1 { +.rowhead h1, .opthead h1, .colstack_head h1 { font-size: 23px; } .sidebar .rowhead { + margin-left: 18px; margin-top: 4px; margin-bottom: 8px; } @@ -165,6 +168,23 @@ h1, h3 { font-size: 20px; } +h2 { + font-size: 18px; + margin-top: 12px; + margin-bottom: 8px; + margin-left: 8px; +} + +.more_topic_block_initial { + display: none; +} +.more_topic_block_active { + display: block; +} +.hide_ajax_topic { + display: none !important; +} + .topic_row:not(:last-child) { margin-bottom: 8px; } @@ -176,15 +196,24 @@ h1, h3 { .topic_left, .topic_right, .topic_middle { padding: 16px; padding-bottom: 12px; + padding-top: 15px; display: flex; width: 33%; } .topic_middle { - padding-top: 15px; + line-height: 20px; } .topic_left { margin-right: auto; } +.topic_left.topic_sticky { + border-left: 3px solid gold; + border-radius: 3px; +} +.new_item .topic_left { + border-left: 3px solid rgb(215, 215, 215); + border-radius: 3px; +} .topic_left img, .topic_right img { border-radius: 24px; height: 38px; @@ -195,6 +224,12 @@ h1, h3 { .topic_inner_left { display: flex; flex-direction: column; + width: 92%; +} +.topic_inner_left .rowtopic { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; } .topic_inner_left .parent_forum { display: none; /* Comment this until we figure out how to make it work */ diff --git a/themes/nox/public/panel.css b/themes/nox/public/panel.css index 19f903c3..ade45348 100644 --- a/themes/nox/public/panel.css +++ b/themes/nox/public/panel.css @@ -44,6 +44,13 @@ padding-bottom: 24px; padding-left: 24px; } +.colstack_right .colstack_head { + margin-bottom: 4px; +} +.colstack_right .colstack_head h1 { + font-size: 21px; + color: #BBBBBB; +} .colstack_right .colstack_item.the_form { background-color: #555555; } @@ -97,4 +104,23 @@ button, .formbutton { #themeSelector select { background: rgb(90,90,90); color: rgb(200,200,200); -} \ No newline at end of file +} + +.colstack_graph_holder { + background-color: #555555; + border-radius: 3px; + padding: 16px; + padding-bottom: 0px; + padding-left: 0px; +} +.colstack_graph_holder .ct-label { + color: rgb(195,195,195); + font-size: 13px; + white-space: nowrap; +} +.colstack_graph_holder .ct-horizontal { + margin-top: 3px; +} +.colstack_graph_holder .ct-grid { + stroke: rgb(125,125,125); +} diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index 8f388d8e..f9a9f592 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -971,6 +971,10 @@ input[type=checkbox]:checked + label.poll_option_label .sel { #panel_dashboard_right .colstack_head .rowitem { padding: 10px; } +#panel_dashboard_right .colstack_head .rowitem h1 { + font-size: 15px; + margin-left: auto; +} #panel_dashboard_right .colstack_head a { text-align: center; diff --git a/themes/tempra-conflux/public/panel.css b/themes/tempra-conflux/public/panel.css index ffbdc165..8fd0123c 100644 --- a/themes/tempra-conflux/public/panel.css +++ b/themes/tempra-conflux/public/panel.css @@ -9,6 +9,10 @@ margin-right: 8px; } +#panel_dashboard_right .colstack_head { + display: none; +} + .edit_button:before { content: "{{index .Phrases "panel_edit_button_text"}}"; }