Permalink
Browse files

LICENCE Polish and some docs

  • Loading branch information...
1 parent 0ae2529 commit 5b567595fdcd9aa929bbf5a142b7611d5b6e11cc @HonzaKral HonzaKral committed Jul 24, 2009
Showing with 70 additions and 6 deletions.
  1. +24 −5 LICENSE
  2. +46 −1 README
View
29 LICENSE
@@ -1,9 +1,28 @@
Copyright (c) 2009, Centrum Holdings
All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-Neither the name of the Centrum Holdings nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+Neither the name of the Centrum Holdings nor the names of its contributors may
+be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
47 README
@@ -1 +1,46 @@
-documentation for browsecap
+Django browsecap
+================
+
+Browsecap is a simple library for django for detecting browser type.
+
+The main interface consists of two function in `browsecap.browser`:
+
+ `is_mobile`: returns True if the given user agent is a known mobile browser
+
+ `is_crawler`: returns True if the given user agent is a known crawler
+
+MobileRedirectMiddleware
+------------------------
+
+For your convenience there is also a middleware that automatically redirects
+all mobile users to alternate domain.
+
+To use just add `browsecap.middleware.MobileRedirectMiddleware` to your
+`settings.MIDDLEWARE_CLASSES` and define a `MOBILE_DOMAIN` that you want your
+mobile users redirected to.
+
+The middleware sets ismobile cookie to value 1 and can be overriden by deleting
+that cookie setting isbrowser cookie to 1.
+
+Internals
+---------
+
+Browsecap works by parsing the browscap.ini file and storing a list of browsers
+as regexps in memory. Each user agent to be checked is then matched against the
+set of regexps until we run out (False) or a match is found (True). The result
+is stored in a dictionary to speedup further processing of the same user agent
+(in our experience, 200k users only have around 8k distinct user agents, so
+caching works).
+
+Performance of the matchig is adequate and shouldn't slow down the request
+processing even if used every time (middleware), the only thing that is
+somewhat slow (under a second on a laptop) is parsing the browscap.ini file.
+This is done only when the module is first loaded and stores it's results in
+cache so that start of the next thread/process should not be hindered.
+
+Credits
+-------
+It is based on henning's snippet #267 -
+http://www.djangosnippets.org/snippets/267/
+
+Thank you very much for the great work!

0 comments on commit 5b56759

Please sign in to comment.