diff --git a/README.rst b/README.rst index 7b3b320..aff5d0d 100644 --- a/README.rst +++ b/README.rst @@ -9,15 +9,17 @@ Molo Global Site :target: https://coveralls.io/github/praekeltfoundation/molo.globalsite?branch=develop :alt: Code Coverage -Provides code to help with creating a global site and redirecting the users to the country of their choice using the Molo code base. +Provides code to help with identifying visitors’ locations and redirecting them to the relevant country site or the global site using the Molo code base. +Getting Started +================== -Installation:: +Installation molo.globalsite package:: pip install molo.globalsite -In your app settings:: +In your app settings add:: INSTALLED_APPS = ( 'molo.globalsite', @@ -26,9 +28,39 @@ In your app settings:: MIDDLEWARE = ( 'molo.globalsite.middleware.CountrySiteRedirectMiddleware' ) + + # Global Site URL + GLOBAL_SITE_URL = environ.get('GLOBAL_SITE_URL', '') + + # A path to geoip database. + GEOIP_PATH = join(dirname(dirname(abspath(__file__))), 'geoip_db') + +You can download the geoip database country database from `MaxMind`_ or copy it from molo/globalsite/geoip_db. + +.. _MaxMind: http://dev.maxmind.com/geoip/legacy/geolite/#Downloads -In your app urls.py:: +Add Global site URL in your app urls.py:: urlpatterns += patterns('', url(r'^globalsite/', include('molo.globalsite.urls', namespace='molo.globalsite', app_name='molo.globalsite')), ) + +Add the HTML block in your country site base template to enable users to change their country site:: + + {% block country %} + {% trans "Country" %}: {{request.site}} + {% trans "Change your country" %} + {% endblock %} + + +How users are redirected? +========================= + +The middleware redirects the user by checking the session. If the country site url is in the 'GLOBALSITE_COUNTRY_SELECTION' it will redirect the user to the country site, otherwise if the geolocation is activated it will uses user's IP address to detect their location and redirect the user to h a. if detached location is not available in the supported country sites or the geolocation is not activated it will serve the country site selection page. + +GlobalSite Settings +=================== + + +How to add country sites +========================