From d01e265587a822ca8bcc0e8ce323a01a47547f67 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 7 Jul 2015 02:35:17 -0400 Subject: [PATCH 1/2] Add bots documentation --- bots/bots.go | 5 +++++ bots/findBots.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bots/bots.go b/bots/bots.go index 08b12af..ed1067f 100644 --- a/bots/bots.go +++ b/bots/bots.go @@ -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{ @@ -26,6 +29,8 @@ var bots = map[string]bool{ "Twitterbot/1.0": 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 diff --git a/bots/findBots.sh b/bots/findBots.sh index 81db94a..d9ef912 100755 --- a/bots/findBots.sh +++ b/bots/findBots.sh @@ -9,6 +9,9 @@ cat /var/log/$1 | grep -i bot | awk -F\" '{print $4}' | sort | uniq > bots.txt 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.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 From ba872dc59fed8bcbb450bbdab37b64bd1e8f85c5 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 7 Jul 2015 02:37:00 -0400 Subject: [PATCH 2/2] Add bots package README --- bots/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 bots/README.md diff --git a/bots/README.md b/bots/README.md new file mode 100644 index 0000000..65394df --- /dev/null +++ b/bots/README.md @@ -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.