{ "info": { "author": "Jeff Balogh", "author_email": "jbalogh@mozilla.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Environment :: Web Environment :: Mozilla", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "What is this?\n-------------\n\nThis library is a collection of middleware and decorators that help in creating\nmobile views and directing users to the mobile version of your site. It makes\nthese assumptions:\n\n * You can use Vary: User-Agent to serve mobile and non-mobile content through\n the same URLs.\n * You want to use separate views and/or templates for the mobile site. If\n you're building a mobile experience through media queries this library won't\n be helpful.\n * Not all views from the normal site need to be replaced with mobile views.\n\n\nSupport\n-------\n\nWritten and tested on Django trunk with Python 2.6.\n\n\nSetup\n-----\n\nThese are the default settings::\n\n # A regex for detecting mobile user agents.\n MOBILE_USER_AGENTS = 'android|fennec|iemobile|iphone|opera (?:mini|mobi)'\n # The name of the cookie to set if the user prefers the mobile site.\n MOBILE_COOKIE = 'mobile'\n\nYou need these middleware (but see the User Agent caveats below)::\n\n MIDDLEWARE_CLASSES = (\n 'mobile.middleware.DetectMobileMiddleware',\n 'mobile.middleware.XMobileMiddleware',\n )\n\n\nHow the Mobile Site is Chosen\n-----------------------------\n\n1. The ``HTTP_USER_AGENT`` matches ``MOBILE_USER_AGENTS`` and the\n ``MOBILE_COOKIE`` is not set to ``off``.\n2. *or* the ``MOBILE_COOKIE`` is set to ``on``.\n3. A mobile view exists for the current URL.\n\nThe ``HTTP_USER_AGENT`` is checked against the regular expression in\n``MOBILE_USER_AGENTS``. The default is a very basic set of user agents to ease\nmaintenance and because the cookie provides a fallback.\n\nIf ``MOBILE_COOKIE`` is set to ``on``, through ``Set-Cookie`` or through\njavascript, the mobile site will be chosen regardless of the user agent. If\n``MOBILE_COOKIE`` is set to ``off`` the normal site will always be chosen.\n\n\nChanges to the ``request`` Object\n---------------------------------\n\nIf the current request is for the mobile site, ``request.MOBILE = True``. At\nall other times ``request.MOBILE = False``.\n\n\nDecorators\n----------\n\nSome decorators are provided to assist with common idioms::\n\n @mobile_template('app/{mobile/}detail.html')\n def view(request, template=None):\n ...\n\n``@mobile_template`` helps with the pattern of using the same view code and\ntemplate context, but switching to a different template for mobile. It follows\nthis logic::\n\n template = 'app/mobile/detail.html' if request.MOBILE else 'app/detail.html'\n\nTo use a completely different function for the mobile view::\n\n def view(request):\n ...\n\n @mobilized(view)\n def view(request):\n ...\n\nIn the example, the first definition of ``view`` will be used for the normal\nsite and the second function will be used for the mobile site. The normal and\nmobile site point to the same view in ``urls.py`` and the decorator handles\nchoosing which view to run.\n\n\nVarying on User Agent\n---------------------\n\nSince mobile users can enter the site from any normal URL, the\n``DetectMobileMiddleware`` always inspects the ``User-Agent`` to see if it\nmatches something in ``MOBILE_USER_AGENTS``, and may redirect the browser to\nthe mobile site. Thus, every URL on the site should be sending ``Vary:\nUser-Agent`` to get proper HTTP caching. Varying on User-Agent can be\ndetrimental to your frontend cache scheme, so it's recommended that you move\nmobile detection up the stack to a frontend proxy.\n\nThe proxy can run the logic in ``DetectMobileMiddleware`` and set\n``HTTP_X_MOBILE`` (so we know whether to serve a mobile view) without varying\non user agent internally. Instead, it can vary on ``X-Mobile`` while\nsending ``Vary: User-Agent`` back to the client. From the outside it looks like\nthe app varies on ``User-Agent`` but the proxy will only need to cache a\nmobile and non-mobile version of the URL.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jbalogh/django-mobility", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-mobility", "package_url": "https://pypi.org/project/django-mobility/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-mobility/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/jbalogh/django-mobility" }, "release_url": "https://pypi.org/project/django-mobility/0.1/", "requires_dist": null, "requires_python": null, "summary": "Middleware and decorators for directing users to your mobile site.", "version": "0.1" }, "last_serial": 790096, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4a0cc81f147463a2ca2ce2d9805c625b", "sha256": "b925e1a4f40a93fd81841ef9a7222b7053da46245d2fc8764d53420dcffd014d" }, "downloads": -1, "filename": "django-mobility-0.1.tar.gz", "has_sig": false, "md5_digest": "4a0cc81f147463a2ca2ce2d9805c625b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5869, "upload_time": "2011-02-03T23:06:20", "url": "https://files.pythonhosted.org/packages/db/c7/0ab9aa50f6185b81a14ed07869caf9fff9f76f4ec9d41dc4e0242cb4a3e8/django-mobility-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4a0cc81f147463a2ca2ce2d9805c625b", "sha256": "b925e1a4f40a93fd81841ef9a7222b7053da46245d2fc8764d53420dcffd014d" }, "downloads": -1, "filename": "django-mobility-0.1.tar.gz", "has_sig": false, "md5_digest": "4a0cc81f147463a2ca2ce2d9805c625b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5869, "upload_time": "2011-02-03T23:06:20", "url": "https://files.pythonhosted.org/packages/db/c7/0ab9aa50f6185b81a14ed07869caf9fff9f76f4ec9d41dc4e0242cb4a3e8/django-mobility-0.1.tar.gz" } ] }