{ "info": { "author": "Udemy Developers", "author_email": "dev@udemy.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "===========\ndjango-meta\n===========\n\n.. image:: https://pypip.in/version/django-meta/badge.png\n :target: https://pypi.python.org/pypi/django-meta/\n :alt: Latest Version\n\n.. image:: https://travis-ci.org/nephila/django-meta.svg?branch=develop\n :target: https://travis-ci.org/nephila/django-meta\n :alt: Travis status\n\n.. image:: https://coveralls.io/repos/nephila/django-meta/badge.png?branch=develop\n :target: https://coveralls.io/r/nephila/django-meta\n :alt: Coveralls status\n\n.. image:: https://pypip.in/download/django-meta/badge.png\n :target: https://pypi.python.org/pypi//django-meta/\n :alt: Download\n\n.. image:: https://pypip.in/wheel/django-meta/badge.png\n :target: https://pypi.python.org/pypi/django-meta/\n :alt: Wheel Status\n\n.. image:: https://pypip.in/license/django-meta/badge.png\n :target: https://pypi.python.org/pypi/django-meta/\n :alt: License\n\nThis pluggable app allows Django developers to quickly add meta tags and\nOpenGraph_, Twitter, and Google Plus properties to their HTML responses.\n\n\n.. note:: django-meta is now maintained by Nephila on `github`_. Old bitbucket\n repository won't be updated anymore.\n\n.. contents::\n\nInstallation\n============\n\nInstall using pip::\n\n pip install django-meta\n\nAdd ``meta`` to ``INSTALLED_APPS``::\n\n INSTALLED_APPS = (\n ....\n 'meta',\n )\n\nBasic concept\n=============\n\nYou render the meta tags by including a ``meta.html`` parial template in your\nview templates. This template will only render meta tags if it can find a\n``meta`` object in the context, so you can safely include it in your base\ntemplate to have it render on all your pages.\n\nThe ``meta.html`` template expects to find a dict or object called ``meta`` in\nthe template context. In that dict or object, it will expect to find any of the\nfollowing keys/attributes:\n\n+ use_og\n+ use_twitter\n+ use_googleplus\n+ title\n+ description\n+ keywords\n+ url\n+ image\n+ object_type\n+ site_name\n+ twitter_site\n+ locale\n+ meta_extras\n+ meta_custom_extras\n\nIn all cases, if the key is omitted, the matching metadata/property is not \nrendered.\n\nuse_og\n------\n\nThis key contains a boolean value, and instructs the template to render the\nOpenGraph_ properties. These are usually used by FaceBook to get more\ninformation about your site's pages.\n\nuse_twitter\n-----------\n\nThis key contains a boolean value, and instructs the template to render the\nTwitter properties. These are usually used by Twitter to get more\ninformation about your site's pages.\n\nuse_googleplus\n--------------\n\nThis key contains a boolean value, and instructs the template to render the\nGoogle+. These are usually used by Google to get more information about your\nsite's pages.\n\ntitle\n-----\n\nThis key is used in the ``og:title`` OpenGraph property, if ``use_og`` is\n``True``, ``twitter:title`` if ``use_twitter`` is ``True`` or\n``itemprop=\"title\"`` if ``use_googleplus`` is ``True``.\n\ndescription\n-----------\n\nThis key is used to render the ``description`` meta tag as well as the\n``og:description`` and ``twitter:description`` property.\n\nkeywords\n--------\n\nThis key should be an iterable containing the keywords for the page. It is used\nto render the ``keywords`` meta tag.\n\nurl\n---\n\nThis key should be the *full* URL of the page. It is used to render the\n``og:url``, ``twitter:url``, ``itemprop=url`` property.\n\nimage\n-----\n\nThis key should be the *full* URL of an image to be used with the ``og:image``,\n``twitter:image``, ``itemprop=mage`` property.\n\nobject_type\n-----------\n\nThis key is used to render the ``og:type`` property.\n\nsite_name\n---------\n\nThis key is used to render the ``og:site_name`` property.\n\ntwitter_site\n------------\n\nThis key is used to render the ``twitter:site`` property.\n\nlocale\n------\n\nThis key is used to render the ``og:locale`` property.\n\nmeta_extras\n-----------\n\nA dictionary of extra optional properties.\n\n {\n 'foo': 'bar',\n 'key': 'value'\n }\n\n ...\n\n \n \n\ncustom_meta_extras\n------------------\n\nA list of tuples for rendering custom extra properties.\n\n [\n ('key', 'foo', 'bar')\n ('property', 'name', 'value')\n ]\n\n ...\n\n \n \n\nMeta objects\n============\n\nThe core of django-meta is the ``Meta`` class. Although you can prepare the\nmetadata for the template yourself, this class can make things somewhat\neasier.\n\nTo set up a meta object for use in templates, simply instantiate it with the\nproperties you want to use::\n\n from meta.views import Meta\n\n meta = Meta(\n title=\"Sam's awesome ponies\",\n description='Awesome page about ponies',\n keywords=['pony', 'ponies', 'awesome'],\n meta_extras = {\n 'viewport': 'width=device-width, initial-scale=1.0, minimum-scale=1.0'\n }\n 'extra_custom_props': [\n ('http-equiv', 'Content-Type', 'text/html; charset=UTF-8'),\n ]\n )\n\nWhen the time comes to render the template, simply include the instance as\n``'meta'`` context variable.\n\nThe ``Meta`` instances have the same properties as the keys listed in the\n`Basic concept`_ section. For convenience, some of the properties are 'smart',\nand will modify values you set. These properties are:\n\n+ keywords\n+ url\n+ image\n\nFor brevity, we will only discuss those here.\n\nMeta.keywords\n-------------\n\nWhen you assign keywords either via the constructor, or by assigning an\niterable to the ``keywords`` property, it will be cleaned up of all duplicates\nand returned as a ``set``. If you have specified the META_INCLUDE_KEYWORDS_,\nthe resulting set will also include them. If you omit this argument when\ninstantiating the object, or if you assign ``None`` to the ``keywords``\nproperty, keywords defined by META_DEFAULT_KEYWORDS_ setting will be used\ninstead.\n\nMeta.url\n--------\n\nSetting the url behaves differently depending on whether you are passsing a\npath or a full URL. If your URL starts with ``'http'``, it will be used\nverbatim (not that the actual validity of the url is not checked so\n``'httpfoo'`` will be considered a valid URL). If you use an absolute or\nrelative path, domain and protocol parts would be prepended to the URL. Here's\nan example::\n\n m = Meta(url='/foo/bar')\n m.url # returns 'http://example.com/foo/bar'\n\nThe actual protocol and domain are dependent on the META_SITE_PROTOCOL_ and\nMETA_SITE_DOMAIN_ settings. If you wish to use the Django's sites contrib app\nto calculate the domain, you can either set the META_USE_SITES_ setting to\n``True``, or pass the ``use_sites`` argument to the constructor::\n\n m = Meta(url='/foo/bar', use_sites=True)\n\nNote that using the sites app will trigger database queries and/or cache hits,\nand it is therefore disabled by default.\n\nMeta.image\n----------\n\nThe ``image`` property behaves the same way as ``url`` property with one\nnotable difference. This property treats absolute and relative paths\ndifferently. It will place relative paths under the META_IMAGE_URL_.\n\nView mixin\n==========\n\nAs a convenience to those who embrace the Django's class-based views,\ndjango-meta includes a mixin that can be used with your views. Using the mixin\nis very simple::\n\n from django.views.generic import View\n\n from meta.views import MetadataMixin\n\n\n class MyView(MetadataMixin, View):\n title = 'Some page'\n description = 'This is an awesome page'\n image = 'img/some_page_thumb.gif'\n url = 'some/page/'\n \n ....\n\n\nThe mixin sports all properties listed in the `Basic concept`_ section with a\nfew additional bells and whistles that make working with them easier. The mixin\nwill return an instance of the ``Meta`` class (see `Meta objects`_) as ``meta`` \ncontext variable. This is, in turn, used in the partial template to render the\nmeta tags (see `Rendering meta tags`_).\n\nEach of the properties on the mixin can be calculated dynamically by using the\n``MetadataMixin.get_meta_PROPERTYNAME`` methods, where ``PROPERTYNAME`` is the\nname of the property you wish the calculate at runtime. Each method will\nreceive a ``context`` keyword argument containig the request context.\n\nFor example, to calculate the description dynamically, you may use the mixin\nlike so::\n\n class MyView(MetadataMixin, SingleObjectMixin, View):\n ...\n\n def get_meta_description(self, context):\n return self.get_object().description\n\nThere are two more methods that you can overload in your view classes, and\nthose are ``get_domain`` and ``get_protocol``.\n\nRendering meta tags\n===================\n\nTo render the meta tags, simply add the ``meta`` dictionary/object to the\ntemplate context, and add this inside the ```` tags::\n\n {% include 'meta.html' %}\n\nThe partial template will not output anything if the context dictionary does\nnot contain a ``meta`` object, so you can safely include it in your base\ntemplate.\n\nConfiguration\n=============\n\ndjango-meta has a few configuration options that allow you to customize it. Two\nof them are required. Those are ``META_SITE_PROTOCOL`` and\n``META_SITE_DOMAIN``. By default, if they are unset, an\n``ImproperlyConfigured`` exception will raised when dealing with ``url`` and\n``image`` properties. You can either set them, or overload the ``Meta`` class'\n``get_domain`` and ``get_protocol`` methods (see `Meta objects`_ section).\n\nMETA_SITE_PROTOCOL\n------------------\n\nDefines the protocol used on your site. This should be set to either ``'http'``\nor ``'https'``. Default is ``None``.\n\nMETA_SITE_DOMAIN\n----------------\n\nDomain of your site. The ``Meta`` objects can also be made to use the Django's\nSites framework as well (see `Meta objects`_ and META_USE_SITES_ sections).\nDefault is ``None``.\n\nMETA_SITE_TYPE\n--------------\n\nThe default ``og:type`` property to use site-wide. You do not need to set this\nif you do not intend to use the OpenGraph properties. Default is ``None``.\n\nMETA_SITE_NAME\n--------------\n\nThe site name to use in ``og:site_name`` property. Althoug this can be\nset per view, we recommend you set it globally. Defalt is ``None``.\n\nMETA_INCLUDE_KEYWORDS\n---------------------\n\nIterable of extra keywords to include in every view. These keywords are\nappended to whatever keywords you specify for the view, but are not used at all\nif no keywords are specified for the view. See META_DEFAULT_KEYWORDS_ if you\nwish to specify keywords to be used when no keywords are supplied. Default is\n``[]``.\n\nMETA_DEFAULT_KEYWORDS\n---------------------\n\nIterable of default keywords to use when no keywords are specified for the\nview. These keywords are not included if you specify keywords for the view. If\nyou need keywords that will always be present, regardless of whether you've\nspecified any other keywords for the view or not, you need to combine this\nsetting with META_INCLUDE_KEYWORDS_ setting. Default is ``[]``.\n\nMETA_IMAGE_URL\n--------------\n\nThis setting is used as the base URL for all image assets that you intend to\nuse as ``og:image`` property in your views. This is django-meta's counterpart\nof the Django's ``STATIC_URL`` setting. In fact, Django's ``STATIC_URL``\nsetting is a fallback if you do not specify this setting, so make sure either\none is configured. Default is to use the ``STATIC_URL`` setting. \n\nNote that you must add the trailing slash when specifying the URL. Even if you\ndo not intend to use the ``og:image`` property, you need to define either this\nsetting or the ``STATIC_URL`` setting or an attribute error will be raised.\n\nMETA_USE_OG_PROPERTIES\n----------------------\n\nThis setting tells django-meta whether to render the OpenGraph properties.\nDefault is ``False``.\n\nMETA_USE_TWITTER_PROPERTIES\n---------------------------\n\nThis setting tells django-meta whether to render the Twitter properties.\nDefault is ``False``.\n\nMETA_USE_GOOGLEPLUS_PROPERTIES\n------------------------------\n\nThis setting tells django-meta whether to render the Google properties.\nDefault is ``False``.\n\nMETA_USE_SITES\n--------------\n\nThis setting tells django-meta to derive the site's domain using the Django's\nsites contrib app. If you enable this setting, the META_SITE_DOMAIN_ is not \nused at all. Default is ``False``. \n\nAuthors and Contributors\n========================\n\n``django-meta`` has been started by `Branko Vukelic`_.\n\nCurrent maintainer: `Iacopo Spalletti`_\n\nWe thank the contributors to this project:\n\n+ leifdenby_\n\nReporting bugs\n==============\n\nPlease report all bugs to our Github `issue tracker`_.\n\n.. _OpenGraph: http://opengraphprotocol.org/\n.. _issue tracker: https://github.com/nephila/django-meta/issues/\n.. _github: https://github.com/nephila/django-meta/\n.. _leifdenby: https://bitbucket.org/leifdenby\n.. _Iacopo Spalletti: https://github.com/yakky\n.. _Branko Vukelic: https://bitbucket.org/monwara", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/udemy/django-meta", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "ud-django-meta", "package_url": "https://pypi.org/project/ud-django-meta/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ud-django-meta/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/udemy/django-meta" }, "release_url": "https://pypi.org/project/ud-django-meta/0.2.1.dev1/", "requires_dist": null, "requires_python": null, "summary": "Pluggable app for handling webpage meta tags and OpenGraph properties", "version": "0.2.1.dev1" }, "last_serial": 1565520, "releases": { "0.2.1.dev0": [ { "comment_text": "", "digests": { "md5": "ad974482aec2c8abd12a02066aed3b6d", "sha256": "2443c3ca0661e9783bd4589cfdb0cada7fe1b06ac01c811d2f9b13a18f634ba6" }, "downloads": -1, "filename": "ud-django-meta-0.2.1.dev0.tar.gz", "has_sig": false, "md5_digest": "ad974482aec2c8abd12a02066aed3b6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11966, "upload_time": "2015-05-27T21:38:38", "url": "https://files.pythonhosted.org/packages/e7/15/aa962040dd84e83e1fa89b8ea505aa47bed26840d5528043027750d654e9/ud-django-meta-0.2.1.dev0.tar.gz" } ], "0.2.1.dev1": [ { "comment_text": "", "digests": { "md5": "56fd481e40ccc8257b6214df0e0c8610", "sha256": "901c9fe31f3475491b18e053c21e6261857d7a6cd2a7418e75815d185a090dc9" }, "downloads": -1, "filename": "ud-django-meta-0.2.1.dev1.tar.gz", "has_sig": false, "md5_digest": "56fd481e40ccc8257b6214df0e0c8610", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11976, "upload_time": "2015-05-27T23:41:07", "url": "https://files.pythonhosted.org/packages/67/ba/f101ff7a9b3fb7e6ba2ee7b03f2027d59d501f233cc6a971bf04a8778dc8/ud-django-meta-0.2.1.dev1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "56fd481e40ccc8257b6214df0e0c8610", "sha256": "901c9fe31f3475491b18e053c21e6261857d7a6cd2a7418e75815d185a090dc9" }, "downloads": -1, "filename": "ud-django-meta-0.2.1.dev1.tar.gz", "has_sig": false, "md5_digest": "56fd481e40ccc8257b6214df0e0c8610", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11976, "upload_time": "2015-05-27T23:41:07", "url": "https://files.pythonhosted.org/packages/67/ba/f101ff7a9b3fb7e6ba2ee7b03f2027d59d501f233cc6a971bf04a8778dc8/ud-django-meta-0.2.1.dev1.tar.gz" } ] }