Added the AppleBot user agent.

Added the topic.topic_info_aria phrase to explain the meta block in topics correctly to screen readers.
Added a missing phrase for the FacebookBot user agent.
This commit is contained in:
Azareal 2019-06-01 12:03:04 +10:00
parent 494b4967c5
commit 3f6966d541
5 changed files with 31 additions and 23 deletions

View File

@ -509,14 +509,15 @@ var agentMapEnum = map[string]int{
"cloudflare": 21, "cloudflare": 21,
"uptimebot": 22, "uptimebot": 22,
"slackbot": 23, "slackbot": 23,
"discourse": 24, "apple": 24,
"lynx": 25, "discourse": 25,
"blank": 26, "lynx": 26,
"malformed": 27, "blank": 27,
"suspicious": 28, "malformed": 28,
"semrush": 29, "suspicious": 29,
"dotbot": 30, "semrush": 30,
"zgrab": 31, "dotbot": 31,
"zgrab": 32,
} }
var reverseAgentMapEnum = map[int]string{ var reverseAgentMapEnum = map[int]string{
0: "unknown", 0: "unknown",
@ -543,14 +544,15 @@ var reverseAgentMapEnum = map[int]string{
21: "cloudflare", 21: "cloudflare",
22: "uptimebot", 22: "uptimebot",
23: "slackbot", 23: "slackbot",
24: "discourse", 24: "apple",
25: "lynx", 25: "discourse",
26: "blank", 26: "lynx",
27: "malformed", 27: "blank",
28: "suspicious", 28: "malformed",
29: "semrush", 29: "suspicious",
30: "dotbot", 30: "semrush",
31: "zgrab", 31: "dotbot",
32: "zgrab",
} }
var markToAgent = map[string]string{ var markToAgent = map[string]string{
"OPR": "opera", "OPR": "opera",
@ -577,6 +579,7 @@ var markToAgent = map[string]string{
"Twitterbot": "twitter", "Twitterbot": "twitter",
"facebookexternalhit": "facebook", "facebookexternalhit": "facebook",
"Facebot": "facebook", "Facebot": "facebook",
"Applebot": "apple",
"Discourse": "discourse", "Discourse": "discourse",
"SemrushBot": "semrush", "SemrushBot": "semrush",
"DotBot": "dotbot", "DotBot": "dotbot",
@ -705,7 +708,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, prepend string) {
prepend += "\n" prepend += "\n"
} }
r.DumpRequest(req,prepend+"Suspicious Request") r.DumpRequest(req,prepend+"Suspicious Request")
counters.AgentViewCounter.Bump(28) counters.AgentViewCounter.Bump(29)
} }
func isLocalHost(host string) bool { func isLocalHost(host string) bool {
@ -720,7 +723,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200) // 400 w.WriteHeader(200) // 400
w.Write([]byte("")) w.Write([]byte(""))
r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ)) r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ))
counters.AgentViewCounter.Bump(27) counters.AgentViewCounter.Bump(28)
} }
// Split the Host and Port string // Split the Host and Port string
@ -844,7 +847,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
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 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
var agent string var agent string
if ua == "" { if ua == "" {
counters.AgentViewCounter.Bump(26) counters.AgentViewCounter.Bump(27)
if c.Dev.DebugMode { if c.Dev.DebugMode {
var prepend string var prepend string
for _, char := range req.UserAgent() { for _, char := range req.UserAgent() {

View File

@ -193,6 +193,8 @@
"cloudflare":"Cloudflare Alwayson", "cloudflare":"Cloudflare Alwayson",
"uptimebot":"Uptimebot", "uptimebot":"Uptimebot",
"slackbot":"Slackbot", "slackbot":"Slackbot",
"facebook":"FacebookBot",
"apple":"AppleBot",
"discourse":"Discourse Forum Onebox", "discourse":"Discourse Forum Onebox",
"lynx":"Lynx", "lynx":"Lynx",
@ -588,6 +590,7 @@
"forums_none":"None", "forums_none":"None",
"forums_no_forums":"You don't have access to any forums.", "forums_no_forums":"You don't have access to any forums.",
"topic.topic_info_aria":"Topic information",
"topic.opening_post_aria":"The opening post for this topic", "topic.opening_post_aria":"The opening post for this topic",
"topic.status_closed_aria":"This topic is locked", "topic.status_closed_aria":"This topic is locked",
"topic.title_input_aria":"Topic Title Input", "topic.title_input_aria":"Topic Title Input",

View File

@ -225,6 +225,7 @@ func main() {
"cloudflare", "cloudflare",
"uptimebot", "uptimebot",
"slackbot", "slackbot",
"apple",
"discourse", "discourse",
"lynx", "lynx",
"blank", "blank",
@ -266,6 +267,7 @@ func main() {
"Twitterbot", "Twitterbot",
"facebookexternalhit", "facebookexternalhit",
"Facebot", "Facebot",
"Applebot",
"Discourse", "Discourse",
"SemrushBot", "SemrushBot",
@ -299,6 +301,7 @@ func main() {
"Twitterbot": "twitter", "Twitterbot": "twitter",
"facebookexternalhit": "facebook", "facebookexternalhit": "facebook",
"Facebot": "facebook", "Facebot": "facebook",
"Applebot":"apple",
"Discourse": "discourse", "Discourse": "discourse",
"SemrushBot": "semrush", "SemrushBot": "semrush",

View File

@ -12,7 +12,7 @@
<link rel="canonical" href="//{{.Site.URL}}{{.Topic.Link}}{{if gt .Page 1}}?page={{.Page}}{{end}}" /> <link rel="canonical" href="//{{.Site.URL}}{{.Topic.Link}}{{if gt .Page 1}}?page={{.Page}}{{end}}" />
<div {{scope "topic_title_block"}} class="rowblock rowhead topic_block" aria-label="{{lang "topic.opening_post_aria"}}"> <div {{scope "topic_title_block"}} class="rowblock rowhead topic_block" aria-label="{{lang "topic.topic_info_aria"}}">
<div class="rowitem topic_item{{if .Topic.Sticky}} topic_sticky_head{{else if .Topic.IsClosed}} topic_closed_head{{end}}"> <div class="rowitem topic_item{{if .Topic.Sticky}} topic_sticky_head{{else if .Topic.IsClosed}} topic_closed_head{{end}}">
<h1 class='topic_name hide_on_edit' title='{{.Topic.Title}}'>{{.Topic.Title}}</h1> <h1 class='topic_name hide_on_edit' title='{{.Topic.Title}}'>{{.Topic.Title}}</h1>
{{if .Topic.IsClosed}}<span class='username hide_on_micro topic_status_e topic_status_closed hide_on_edit' title='{{lang "status.closed_tooltip"}}' aria-label='{{lang "topic.status_closed_aria"}}'>&#x1F512;&#xFE0E</span>{{end}} {{if .Topic.IsClosed}}<span class='username hide_on_micro topic_status_e topic_status_closed hide_on_edit' title='{{lang "status.closed_tooltip"}}' aria-label='{{lang "topic.status_closed_aria"}}'>&#x1F512;&#xFE0E</span>{{end}}

View File

@ -7,7 +7,7 @@
<link rel="canonical" href="//{{.Site.URL}}{{.Topic.Link}}{{if gt .Page 1}}?page={{.Page}}{{end}}" /> <link rel="canonical" href="//{{.Site.URL}}{{.Topic.Link}}{{if gt .Page 1}}?page={{.Page}}{{end}}" />
<div {{scope "topic_title_block"}} class="rowblock rowhead topic_block" aria-label="{{lang "topic.opening_post_aria"}}"> <div {{scope "topic_title_block"}} class="rowblock rowhead topic_block" aria-label="{{lang "topic.topic_info_aria"}}">
<div class="rowitem topic_item{{if .Topic.Sticky}} topic_sticky_head{{else if .Topic.IsClosed}} topic_closed_head{{end}}"> <div class="rowitem topic_item{{if .Topic.Sticky}} topic_sticky_head{{else if .Topic.IsClosed}} topic_closed_head{{end}}">
<h1 class='topic_name hide_on_edit' title='{{.Topic.Title}}'>{{.Topic.Title}}</h1> <h1 class='topic_name hide_on_edit' title='{{.Topic.Title}}'>{{.Topic.Title}}</h1>
<span class="topic_name_forum_sep hide_on_edit"> - </span> <span class="topic_name_forum_sep hide_on_edit"> - </span>
@ -29,8 +29,7 @@
</div> </div>
<div class="rowblock post_container"> <div class="rowblock post_container">
{{if .Poll.ID}} {{if .Poll.ID}}<form id="poll_{{.Poll.ID}}_form" action="/poll/vote/{{.Poll.ID}}?session={{.CurrentUser.Session}}" method="post"></form>
<form id="poll_{{.Poll.ID}}_form" action="/poll/vote/{{.Poll.ID}}?session={{.CurrentUser.Session}}" method="post"></form>
<article class="rowitem passive deletable_block editable_parent post_item poll_item top_post hide_on_edit"> <article class="rowitem passive deletable_block editable_parent post_item poll_item top_post hide_on_edit">
{{template "topic_alt_userinfo.html" .Topic }} {{template "topic_alt_userinfo.html" .Topic }}
<div id="poll_voter_{{.Poll.ID}}" class="content_container poll_voter"> <div id="poll_voter_{{.Poll.ID}}" class="content_container poll_voter">