diff --git a/docs/templates.md b/docs/templates.md index f0095c4f..89cfcce6 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -4,6 +4,8 @@ Gosora uses a subset of [Go Templates](https://golang.org/pkg/text/template/) wh The base templates are stored in `/templates/` and you can shadow them by placing modified duplicates in `/templates/overrides/`. The default themes all share the same set of templates present there. +You can also override templates on a per-theme basis by navigating to `/themes/themeName/overrides` (replace themeName with the name of the theme) and placing the modified duplicates there. + # Non-standard Extensions We also have a few non-standard extensions only available on certain pages or areas, but these shouldn't be relied on in favour of more general mechanisms. diff --git a/gen_router.go b/gen_router.go index 4306cb12..efd3e55e 100644 --- a/gen_router.go +++ b/gen_router.go @@ -478,17 +478,18 @@ var agentMapEnum = map[string]int{ "seznambot": 17, "discord": 18, "twitter": 19, - "cloudflare": 20, - "uptimebot": 21, - "slackbot": 22, - "discourse": 23, - "lynx": 24, - "blank": 25, - "malformed": 26, - "suspicious": 27, - "semrush": 28, - "dotbot": 29, - "zgrab": 30, + "facebook": 20, + "cloudflare": 21, + "uptimebot": 22, + "slackbot": 23, + "discourse": 24, + "lynx": 25, + "blank": 26, + "malformed": 27, + "suspicious": 28, + "semrush": 29, + "dotbot": 30, + "zgrab": 31, } var reverseAgentMapEnum = map[int]string{ 0: "unknown", @@ -511,17 +512,18 @@ var reverseAgentMapEnum = map[int]string{ 17: "seznambot", 18: "discord", 19: "twitter", - 20: "cloudflare", - 21: "uptimebot", - 22: "slackbot", - 23: "discourse", - 24: "lynx", - 25: "blank", - 26: "malformed", - 27: "suspicious", - 28: "semrush", - 29: "dotbot", - 30: "zgrab", + 20: "facebook", + 21: "cloudflare", + 22: "uptimebot", + 23: "slackbot", + 24: "discourse", + 25: "lynx", + 26: "blank", + 27: "malformed", + 28: "suspicious", + 29: "semrush", + 30: "dotbot", + 31: "zgrab", } var markToAgent = map[string]string{ "OPR": "opera", @@ -546,6 +548,8 @@ var markToAgent = map[string]string{ "Slackbot": "slackbot", "Discordbot": "discord", "Twitterbot": "twitter", + "facebookexternalhit": "facebook", + "Facebot": "facebook", "Discourse": "discourse", "SemrushBot": "semrush", "DotBot": "dotbot", @@ -663,7 +667,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, prepend string) { prepend += "\n" } r.DumpRequest(req,prepend+"Suspicious Request") - counters.AgentViewCounter.Bump(27) + counters.AgentViewCounter.Bump(28) } // TODO: Pass the default path or config struct to the router rather than accessing it via a package global @@ -690,7 +694,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { w.WriteHeader(200) // 400 w.Write([]byte("")) r.DumpRequest(req,"Malformed Request") - counters.AgentViewCounter.Bump(26) + counters.AgentViewCounter.Bump(27) return } @@ -752,7 +756,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { // TODO: Use a more efficient detector instead of smashing every possible combination in ua := strings.TrimSpace(strings.Replace(strings.TrimPrefix(req.UserAgent(),"Mozilla/5.0 ")," Safari/537.36","",-1)) // Noise, no one's going to be running this and it would require some sort of agent ranking system to determine which identifier should be prioritised over another if ua == "" { - counters.AgentViewCounter.Bump(25) + counters.AgentViewCounter.Bump(26) if common.Dev.DebugMode { var prepend string for _, char := range req.UserAgent() { @@ -870,7 +874,9 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { continue } llLang = seg + break } + common.DebugDetail("llLang:", llLang) if llLang == "" { counters.LangViewCounter.Bump("none") } else { diff --git a/langs/english.json b/langs/english.json index 135e5c25..d3b5c144 100644 --- a/langs/english.json +++ b/langs/english.json @@ -386,6 +386,13 @@ "topic.copy_button_text":"Copy", "topic.upload_button_text":"Upload", + "analytics.now": "now", + "analytics.today": "today", + "analytics.days": " days", + "analytics.days_short": "d", + "analytics.months": " months", + "analytics.months_short": "m", + "panel_rank_admins":"Admins", "panel_rank_mods":"Mods", "panel_rank_banned":"Banned", diff --git a/public/analytics.js b/public/analytics.js index b26b2711..4e2c603c 100644 --- a/public/analytics.js +++ b/public/analytics.js @@ -6,32 +6,30 @@ // TODO: Load rawLabels and seriesData dynamically rather than potentially fiddling with nonces for the CSP? function buildStatsChart(rawLabels, seriesData, timeRange, legendNames) { let labels = []; + let aphrases = phraseBox["analytics"]; if(timeRange=="one-year") { - labels = ["today","01 months"]; + labels = [aphrases["analytics.now"],"1" + aphrases["analytics.months_short"]]; for(let i = 2; i < 12; i++) { - let label = "0" + i + " months"; - if(label.length > "01 months".length) label = label.substr(1); + let label = i + aphrases["analytics.months_short"]; labels.push(label); } } else if(timeRange=="three-months") { - labels = ["today","01 days"]; - for(let i = 2; i < 90; i = i + 3) { - let label = "0" + i + " days"; - if(label.length > "01 days".length) label = label.substr(1); + labels = [aphrases["analytics.now"],"3" + aphrases["analytics.days_short"]] + for(let i = 6; i < 90; i = i + 3) { + let label = i + aphrases["analytics.days_short"]; labels.push(label); } } else if(timeRange=="one-month") { - labels = ["today","01 days"]; + labels = [aphrases["analytics.now"],"1" + aphrases["analytics.days_short"]]; for(let i = 2; i < 30; i++) { - let label = "0" + i + " days"; - if(label.length > "01 days".length) label = label.substr(1); + let label = i + aphrases["analytics.days_short"]; labels.push(label); } } else if(timeRange=="one-week") { - labels = ["today"]; + labels = [aphrases["analytics.now"]]; for(let i = 2; i < 14; i++) { if (i%2==0) labels.push(""); - else labels.push(Math.floor(i/2) + " days"); + else labels.push(Math.floor(i/2) + aphrases["analytics.days"]); } } else { for(const i in rawLabels) { diff --git a/public/init.js b/public/init.js index 64cb45dc..4ef98467 100644 --- a/public/init.js +++ b/public/init.js @@ -167,7 +167,7 @@ function RelativeTime(date) { function initPhrases() { console.log("in initPhrases") - fetchPhrases("status,topic_list,alerts,paginator") + fetchPhrases("status,topic_list,alerts,paginator,analytics") } function fetchPhrases(plist) { diff --git a/router_gen/main.go b/router_gen/main.go index 98c944a2..689cad86 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -213,6 +213,7 @@ func main() { "seznambot", "discord", "twitter", + "facebook", "cloudflare", "uptimebot", "slackbot", @@ -255,6 +256,8 @@ func main() { "Slackbot", "Discordbot", "Twitterbot", + "facebookexternalhit", + "Facebot", "Discourse", "SemrushBot", @@ -273,20 +276,22 @@ func main() { "SamsungBrowser": "samsung", "UCBrowser": "ucbrowser", - "Google": "googlebot", - "Googlebot": "googlebot", - "yandex": "yandex", // from the URL - "DuckDuckBot": "duckduckgo", - "Baiduspider": "baidu", - "bingbot": "bing", - "BingPreview": "bing", - "SeznamBot": "seznambot", - "CloudFlare": "cloudflare", // Track alwayson specifically in case there are other bots? - "Uptimebot": "uptimebot", - "Slackbot": "slackbot", - "Discordbot": "discord", - "Twitterbot": "twitter", - "Discourse": "discourse", + "Google": "googlebot", + "Googlebot": "googlebot", + "yandex": "yandex", // from the URL + "DuckDuckBot": "duckduckgo", + "Baiduspider": "baidu", + "bingbot": "bing", + "BingPreview": "bing", + "SeznamBot": "seznambot", + "CloudFlare": "cloudflare", // Track alwayson specifically in case there are other bots? + "Uptimebot": "uptimebot", + "Slackbot": "slackbot", + "Discordbot": "discord", + "Twitterbot": "twitter", + "facebookexternalhit": "facebook", + "Facebot": "facebook", + "Discourse": "discourse", "SemrushBot": "semrush", "DotBot": "dotbot", @@ -662,7 +667,9 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { continue } llLang = seg + break } + common.DebugDetail("llLang:", llLang) if llLang == "" { counters.LangViewCounter.Bump("none") } else { diff --git a/routes.go b/routes.go index 30c7595a..629fd906 100644 --- a/routes.go +++ b/routes.go @@ -143,6 +143,7 @@ var phraseWhitelist = []string{ "status", "alerts", "paginator", + "analytics", } func routeAPIPhrases(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { diff --git a/themes/cosora/public/panel.css b/themes/cosora/public/panel.css index 9d21e1ca..e045a425 100644 --- a/themes/cosora/public/panel.css +++ b/themes/cosora/public/panel.css @@ -198,6 +198,7 @@ float: none; margin-top: auto; padding-top: 14px; + word-break: break-all; } #panel_page_list textarea, #panel_page_edit textarea { margin-top: 8px; diff --git a/themes/nox/public/panel.css b/themes/nox/public/panel.css index 019a9bff..176d1235 100644 --- a/themes/nox/public/panel.css +++ b/themes/nox/public/panel.css @@ -27,7 +27,7 @@ .colstack_right { background-color: #333333; - width: 75%; + width: 90%; padding-top: 12px; padding-right: 24px; padding-bottom: 24px;