Merge branch 'master' of https://github.com/writeas/web-core
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
bots
|
||||
====
|
||||
|
||||
This package helps the backend determine which clients are bots or crawlers.
|
||||
|
||||
## Write.as Usage
|
||||
|
||||
This is used to prevent certain things when viewing posts, like incrementing the view count.
|
||||
@@ -1,3 +1,6 @@
|
||||
// This package helps the backend determine which clients are bots or crawlers.
|
||||
// In Write.as, this is used to prevent certain things when viewing posts, like
|
||||
// incrementing the view count.
|
||||
package bots
|
||||
|
||||
var bots = map[string]bool{
|
||||
@@ -30,6 +33,8 @@ var bots = map[string]bool{
|
||||
"voltron": true,
|
||||
}
|
||||
|
||||
// IsBot returns whether or not the provided User-Agent string is a known bot
|
||||
// or crawler.
|
||||
func IsBot(ua string) bool {
|
||||
if _, ok := bots[ua]; ok {
|
||||
return true
|
||||
|
||||
@@ -9,6 +9,9 @@ cat /var/log/$1 | grep -i 'bot\|crawler\|voltron' | awk -F\" '{print $4}' | sort
|
||||
rm bots.go
|
||||
|
||||
cat > bots.go << EOM
|
||||
// This package helps the backend determine which clients are bots or crawlers.
|
||||
// In Write.as, this is used to prevent certain things when viewing posts, like
|
||||
// incrementing the view count.
|
||||
package bots
|
||||
|
||||
var bots = map[string]bool {
|
||||
@@ -23,6 +26,8 @@ done <bots.txt
|
||||
cat >> bots.go << EOM
|
||||
};
|
||||
|
||||
// IsBot returns whether or not the provided User-Agent string is a known bot
|
||||
// or crawler.
|
||||
func IsBot(ua string) bool {
|
||||
if _, ok := bots[ua]; ok {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user