Mercurial > hg > soundsoftware-site
diff app/helpers/attachments_helper.rb @ 967:19884e9d5eff bug_521
Only count downloads from non-bots
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Wed, 17 Oct 2012 10:42:48 +0100 |
parents | cbb26bc654de |
children | bb32da3bea34 |
line wrap: on
line diff
--- a/app/helpers/attachments_helper.rb Tue Oct 16 15:34:00 2012 +0100 +++ b/app/helpers/attachments_helper.rb Wed Oct 17 10:42:48 2012 +0100 @@ -42,4 +42,11 @@ api.created_on attachment.created_on end end + + # Returns true if user agent appears (approximately) to be a search + # bot or crawler + def user_is_search_bot? + agent = request.env['HTTP_USER_AGENT'] + agent and agent =~ /(bot|slurp|crawler|spider)\b/i + end end