diff --git a/HISTORY.rst b/HISTORY.rst
index f220c44..2a0da62 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,10 +4,10 @@
History
*******
-Unreleased
+2.0.0 (unreleased)
==================
-* Nothing yet
+* Replace Google+ support with schema.org
1.6.1 (2020-01-16)
==================
diff --git a/README.rst b/README.rst
index 9791cf8..1773ef3 100644
--- a/README.rst
+++ b/README.rst
@@ -5,17 +5,10 @@ django-meta
|Gitter| |PyPiVersion| |PyVersion| |Status| |TestCoverage| |CodeClimate| |License|
This pluggable app allows Django developers to quickly add meta tags and
-OpenGraph_, Twitter, and Google Plus properties to their HTML responses.
+OpenGraph_, Twitter, and Schema.org properties to their HTML responses.
-
-.. note:: django-meta is now maintained by Nephila on `github`_. Old bitbucket
- repository won't be updated anymore.
-
-.. warning:: as of version 1.0 django-meta has included django-meta-mixin 0.2.1;
- django-meta 1.0 is a drop in replacement for django-meta-mixin:
- as a result django-meta-mixin is no longer actively developed
-
-.. warning:: As of version 1.4, the support for Python 2.6 and Django<1.8 has been dropped
+.. warning:: **INCOMPATIBLE CHANGE**: as of version 2.0 django-meta has no
+ longer supports Google+, basic Schema.org support has been introduced.
.. contents::
diff --git a/cms_helper.py b/cms_helper.py
index acc9740..bfdf77c 100755
--- a/cms_helper.py
+++ b/cms_helper.py
@@ -14,7 +14,7 @@
META_USE_SITES=True,
META_USE_OG_PROPERTIES=True,
META_USE_TWITTER_PROPERTIES=True,
- META_USE_GOOGLEPLUS_PROPERTIES=True,
+ META_USE_SCHEMAORG_PROPERTIES=True,
FILE_UPLOAD_TEMP_DIR=mkdtemp()
)
diff --git a/docs/index.rst b/docs/index.rst
index 1199f79..df9c48a 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -3,7 +3,10 @@ django meta
###########
A pluggable app allows Django developers to quickly add meta tags and
-OpenGraph_, Twitter, and Google Plus properties to their HTML responses.
+OpenGraph_, Twitter, and Schema.org properties to their HTML responses.
+
+.. warning:: **INCOMPATIBLE CHANGE**: as of version 2.0 django-meta has no
+ longer supports Google+, basic Schema.org support has been introduced.
Usage
-----
@@ -19,6 +22,7 @@ django meta has two different operating mode:
:maxdepth: 2
installation
+ upgrading
models
views
settings
diff --git a/docs/models.rst b/docs/models.rst
index deb8604..e4f7247 100644
--- a/docs/models.rst
+++ b/docs/models.rst
@@ -119,7 +119,6 @@ Usage
Note
++++
-* For Google+ support you must add ``{% render_block 'html_extra' %}`` in your template to add object type definition. See relevant Google+ snippets documentation (https://developers.google.com/+/web/snippet/)
* For OpenGraph / Facebook support, edit your ``
`` tag to use ``meta_namespaces`` templatetags
Reference template
diff --git a/docs/rendering.rst b/docs/rendering.rst
index 38200ea..74e53b3 100644
--- a/docs/rendering.rst
+++ b/docs/rendering.rst
@@ -22,11 +22,11 @@ them in the tag, as follow::
This will take care of rendering OpenGraph namespaces in the ````.
-If you enabled Google+ Support you have to add the following templatetag to the ```` tag::
+If you enabled Schema.org support and you want to mark the whole page as Schema.org object, add the following templatetag to the ```` tag::
{% load meta %}
...
-
+
For compatibility with 1.0 and previous version you can keep the sekizai version of the above::
diff --git a/docs/settings.rst b/docs/settings.rst
index 8892ecf..3cdac2f 100644
--- a/docs/settings.rst
+++ b/docs/settings.rst
@@ -13,6 +13,9 @@ raised when dealing with ``url`` and ``image`` properties.
You can either set them, or overload the ``Meta`` class' ``get_domain`` and
``get_protocol`` methods (see :ref:`Meta object` section).
+.. warning:: **INCOMPATIBLE CHANGE**: as of version 2.0 django-meta has no
+ longer supports Google+, basic Schema.org support has been introduced.
+
.. _META_SITE_PROTOCOL:
META_SITE_PROTOCOL
@@ -101,10 +104,10 @@ Default is ``False``.
.. _META_USE_GOOGLEPLUS_PROPERTIES:
-META_USE_GOOGLEPLUS_PROPERTIES
+META_USE_SCHEMAORG_PROPERTIES
------------------------------
-This setting tells django-meta whether to render the Google properties.
+This setting tells django-meta whether to render the Schema.org properties.
Default is ``False``.
.. _META_USE_TITLE_TAG:
@@ -154,6 +157,4 @@ attribute for both :ref:`views` and :ref:`models`
* twitter_type: ``META_TWITTER_TYPE`` (default: first ``META_TWITTER_TYPES``)
* twitter_site: ``META_TWITTER_SITE`` (default: blank)
* twitter_author: ``META_TWITTER_AUTHOR`` (default: blank)
-* gplus_type: ``META_GPLUS_TYPE`` (default: first ``META_GPLUS_TYPES``)
-* gplus_author: ``META_GPLUS_AUTHOR`` (default: blank)
-* gplus_publisher: ``META_GPLUS_PUBLISHER`` (default: blank)
+* schemaorg_type: ``META_SCHEMAORG_TYPE`` (default: first ``META_SCHEMAORG_TYPE``)
diff --git a/docs/upgrading.rst b/docs/upgrading.rst
new file mode 100644
index 0000000..28ed261
--- /dev/null
+++ b/docs/upgrading.rst
@@ -0,0 +1,12 @@
+Upgrading
+============
+
+When upgrading from version 1.x to 2.0 you must
+
+* Replace ``META_GPLUS_TYPE`` with ``META_SCHEMAORG_TYPE``;
+* Replace ``META_USE_GPLUS_PROPERTIES`` with ``META_USE_SCHEMAORG_PROPERTIES``;
+* Remove all references to ``gplus_author``, ``gplus_publisher``;
+* Replace all ``gplus_title``, ``gplus_description``, ``gplus_type``,
+ ``use_gplus`` with the corresponding ``schemaorg`` attributes`;
+* Replace all ``googleplus_prop``, ``googleplus_html_scope``, ``googleplus_scope``
+ with the corresponding ``schemaorg`` templatetags;
diff --git a/docs/views.rst b/docs/views.rst
index f0dd978..2a47e4b 100644
--- a/docs/views.rst
+++ b/docs/views.rst
@@ -20,12 +20,12 @@ the template context which contains any of the following attributes:
+ use_og
+ use_twitter
+ use_facebook
-+ use_googleplus
++ use_schemaorg
+ use_title_tag
+ title
+ og_title
+ twitter_title
-+ gplus_title
++ schemaorg_title
+ description
+ keywords
+ url
@@ -217,7 +217,7 @@ This key contains a boolean value, and instructs the template to render the
Facebook properties. These are usually used by Facebook to get more
information about your site's pages.
-use_googleplus
+use_schemaorg
~~~~~~~~~~~~~~~~~~~
This key contains a boolean value, and instructs the template to render the
@@ -237,14 +237,14 @@ title
This key is used in the ``og:title`` OpenGraph property if ``use_og`` is
``True``, ``twitter:title`` if ``use_twitter`` is ``True``,
-``itemprop="title"`` if ``use_googleplus`` is ``True`` or ```` tag
+``itemprop="title"`` if ``use_schemaorg`` is ``True`` or ```` tag
if ``use_title_tag`` is ``True``.
The service-specific variants are also supported:
* ``og_title``
* ``twitter_title``
-* ``gplus_title``
+* ``schema_title``
If set on the ``Meta`` object, they will be used insteaf of the generic title
which will be used as a fallback.
diff --git a/meta/models.py b/meta/models.py
index a0ba8f2..94830d4 100644
--- a/meta/models.py
+++ b/meta/models.py
@@ -22,11 +22,11 @@ class ModelMeta(object):
'title': False,
'og_title': False,
'twitter_title': False,
- 'gplus_title': False,
+ 'schemaorg_title': False,
'description': False,
'og_description': False,
'twitter_description': False,
- 'gplus_description': False,
+ 'schemaorg_description': False,
'keywords': False,
'image': settings.DEFAULT_IMAGE,
'image_width': False,
@@ -41,9 +41,7 @@ class ModelMeta(object):
'twitter_type': settings.TWITTER_TYPE,
'twitter_site': settings.TWITTER_SITE,
'twitter_author': settings.TWITTER_AUTHOR,
- 'gplus_type': settings.GPLUS_TYPE,
- 'gplus_author': settings.GPLUS_AUTHOR,
- 'gplus_publisher': settings.GPLUS_PUBLISHER,
+ 'schemaorg_type': settings.SCHEMAORG_TYPE,
'published_time': False,
'modified_time': False,
'expiration_time': False,
@@ -101,11 +99,11 @@ def as_meta(self, request=None):
meta = Meta(request=request)
for field, data in self._retrieve_data(request, metadata):
setattr(meta, field, data)
- for field in ('og_title', 'twitter_title', 'gplus_title'):
+ for field in ('og_title', 'twitter_title', 'schemaorg_title'):
generaltitle = getattr(meta, 'title', False)
if not getattr(meta, field, False) and generaltitle:
setattr(meta, field, generaltitle)
- for field in ('og_description', 'twitter_description', 'gplus_description'):
+ for field in ('og_description', 'twitter_description', 'schemaorg_description'):
generaldesc = getattr(meta, 'description', False)
if not getattr(meta, field, False) and generaldesc:
setattr(meta, field, generaldesc)
@@ -134,7 +132,7 @@ def get_author(self):
class Author(object):
fb_url = None
twitter_profile = None
- gplus_profile = None
+ schemaorg_profile = None
def get_full_name(self): # pragma: no cover
return None
@@ -167,12 +165,12 @@ def get_author_twitter(self):
except AttributeError: # pragma: no cover
return ''
- def get_author_gplus(self):
+ def get_author_schemaorg(self):
"""
- Sample method to return the author google plus URL
+ Sample method to return the author Schema.org URL
"""
try:
- return self.get_author().gplus_profile
+ return self.get_author().schemaorg_profile
except AttributeError: # pragma: no cover
return ''
diff --git a/meta/settings.py b/meta/settings.py
index 20100ad..827e906 100644
--- a/meta/settings.py
+++ b/meta/settings.py
@@ -14,7 +14,7 @@
USE_OG_PROPERTIES = getattr(django_settings, 'META_USE_OG_PROPERTIES', False)
USE_TWITTER_PROPERTIES = getattr(django_settings, 'META_USE_TWITTER_PROPERTIES', False)
USE_FACEBOOK_PROPERTIES = getattr(django_settings, 'META_USE_FACEBOOK_PROPERTIES', False)
-USE_GOOGLEPLUS_PROPERTIES = getattr(django_settings, 'META_USE_GOOGLEPLUS_PROPERTIES', False)
+USE_SCHEMAORG_PROPERTIES = getattr(django_settings, 'META_USE_SCHEMAORG_PROPERTIES', False)
USE_SITES = getattr(django_settings, 'META_USE_SITES', False)
USE_TITLE_TAG = getattr(django_settings, 'META_USE_TITLE_TAG', False)
OG_NAMESPACES = getattr(django_settings, 'META_OG_NAMESPACES', None)
@@ -32,7 +32,7 @@
('app', _('App')),
)
FB_TYPES = OBJECT_TYPES
-GPLUS_TYPES = (
+SCHEMAORG_TYPES = (
('Article', _('Article')),
('Blog', _('Blog')),
('WebPage', _('Page')),
@@ -61,7 +61,5 @@
TWITTER_TYPES = getattr(django_settings, 'META_TWITTER_TYPES', TWITTER_TYPES)
TWITTER_SITE = getattr(django_settings, 'META_TWITTER_SITE', '')
TWITTER_AUTHOR = getattr(django_settings, 'META_TWITTER_AUTHOR', '')
-GPLUS_TYPE = getattr(django_settings, 'META_GPLUS_TYPE', GPLUS_TYPES[0][0])
-GPLUS_TYPES = getattr(django_settings, 'META_GPLUS_TYPES', GPLUS_TYPES)
-GPLUS_AUTHOR = getattr(django_settings, 'META_GPLUS_AUTHOR', '')
-GPLUS_PUBLISHER = getattr(django_settings, 'META_GPLUS_PUBLISHER', '')
+SCHEMAORG_TYPE = getattr(django_settings, 'META_SCHEMAORG_TYPE', SCHEMAORG_TYPES[0][0])
+SCHEMAORG_TYPES = getattr(django_settings, 'META_SCHEMAORG_TYPES', SCHEMAORG_TYPES)
diff --git a/meta/templates/meta/meta.html b/meta/templates/meta/meta.html
index 8977457..f0b09bc 100755
--- a/meta/templates/meta/meta.html
+++ b/meta/templates/meta/meta.html
@@ -47,16 +47,14 @@
{% if meta.twitter_creator %}{% twitter_prop 'creator' meta.twitter_creator %}{% endif %}
{% if meta.twitter_site %}{% twitter_prop 'site' meta.twitter_site %}{% endif %}
{% endif %}
- {% if meta.use_googleplus %}
- {% if meta.gplus_author %}{% endif %}
- {% if meta.gplus_publisher %}{% endif %}
- {% addtoblock 'html_extra' %}{% googleplus_html_scope meta.gplus_type %}{% endaddtoblock %}
- {% if meta.gplus_title %}{% googleplus_prop 'name' meta.gplus_title %}
+ {% if meta.use_schemaorg %}
+ {% addtoblock 'html_extra' %}{% googleplus_html_scope meta.schemaorg_type %}{% endaddtoblock %}
+ {% if meta.schemaorg_title %}{% googleplus_prop 'name' meta.schemaorg_title %}
{% elif meta.title %}{% googleplus_prop 'name' meta.title %}{% endif %}
{% if meta.published_time %}{% googleplus_prop 'datePublished' meta.published_time %}{% endif %}
{% if meta.modified_time %}{% googleplus_prop 'dateModified' meta.modified_time %}{% endif %}
{% if meta.url %}{% googleplus_prop 'url' meta.url %}{% endif %}
- {% if meta.gplus_description %}{% googleplus_prop 'description' meta.gplus_description %}
+ {% if meta.schemaorg_description %}{% googleplus_prop 'description' meta.schemaorg_description %}
{% elif meta.description %}{% googleplus_prop 'description' meta.description %}{% endif %}
{% if meta.image %}{% googleplus_prop 'image' meta.image %}{% endif %}
{% endif %}
diff --git a/meta/templatetags/meta.py b/meta/templatetags/meta.py
index 99b849c..952b7d5 100644
--- a/meta/templatetags/meta.py
+++ b/meta/templatetags/meta.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
+import warnings
+
from django import template
from django.apps import apps
from django.utils.html import escape
@@ -148,9 +150,9 @@ def twitter_prop(name, value):
@register.simple_tag
-def googleplus_prop(name, value):
+def schemaorg_prop(name, value):
"""
- Generic Google+ property
+ Generic Schema.org property
:param name: property name
:param value: property value
@@ -159,7 +161,7 @@ def googleplus_prop(name, value):
@register.simple_tag
-def googleplus_html_scope(value):
+def schemaorg_html_scope(value):
"""
This is meant to be used as attribute to html / body or other tags to
define schema.org type
@@ -170,13 +172,49 @@ def googleplus_html_scope(value):
@register.simple_tag
-def googleplus_scope(value):
+def schemaorg_scope(value):
"""
Alias for googleplus_html_scope
:param value: declared scope
"""
- return googleplus_html_scope(value)
+ return schemaorg_html_scope(value)
+
+
+@register.simple_tag
+def googleplus_prop(name, value):
+ """
+ Legacy Google+ property
+ """
+ warnings.warn(
+ "googleplus_prop will be removed in version 3.0",
+ PendingDeprecationWarning
+ )
+ return schemaorg_prop(name, value)
+
+
+@register.simple_tag
+def googleplus_html_scope(value):
+ """
+ Legacy Google+ scope
+ """
+ warnings.warn(
+ "googleplus_html_scope will be removed in version 3.0",
+ PendingDeprecationWarning
+ )
+ return schemaorg_html_scope(value)
+
+
+@register.simple_tag
+def googleplus_scope(value):
+ """
+ Legacy Google+ scope
+ """
+ warnings.warn(
+ "googleplus_scope will be removed in version 3.0",
+ PendingDeprecationWarning
+ )
+ return schemaorg_html_scope(value)
@register.simple_tag(takes_context=True)
@@ -209,13 +247,25 @@ def meta_namespaces(context):
@register.simple_tag(takes_context=True)
-def meta_namespaces_gplus(context):
+def meta_namespaces_schemaorg(context):
"""
- Include google+ attributes. To be used in the or tag.
+ Include Schema.org attributes. To be used in the or tag.
"""
# do nothing if meta is not in context or if G+ is not enabled
- if not context.get('meta') or not context['meta'].use_googleplus:
+ if not context.get('meta') or not context['meta'].use_schemaorg:
return ''
return mark_safe(
- ' itemscope itemtype="http://schema.org/{0}" '.format(context['meta'].gplus_type)
+ ' itemscope itemtype="http://schema.org/{0}" '.format(context['meta'].schemaorg_type)
+ )
+
+
+@register.simple_tag(takes_context=True)
+def meta_namespaces_gplus(context):
+ """
+ Legacy Google+ attributes.
+ """
+ warnings.warn(
+ "meta_namespaces_gplus will be removed in version 3.0",
+ PendingDeprecationWarning
)
+ return meta_namespaces_schemaorg(context)
diff --git a/meta/views.py b/meta/views.py
index c44caf8..bc58b88 100644
--- a/meta/views.py
+++ b/meta/views.py
@@ -19,7 +19,7 @@ def __init__(self, **kwargs):
self.title = kwargs.get('title')
self.og_title = kwargs.get('og_title')
self.twitter_title = kwargs.get('twitter_title')
- self.gplus_title = kwargs.get('gplus_title')
+ self.schemaorg_title = kwargs.get('schemaorg_title')
self.description = kwargs.get('description')
self.extra_props = kwargs.get('extra_props')
self.extra_custom_props = kwargs.get('extra_custom_props')
@@ -39,11 +39,9 @@ def __init__(self, **kwargs):
self.use_og = kwargs.get('use_og', settings.USE_OG_PROPERTIES)
self.use_twitter = kwargs.get('use_twitter', settings.USE_TWITTER_PROPERTIES)
self.use_facebook = kwargs.get('use_facebook', settings.USE_FACEBOOK_PROPERTIES)
- self.use_googleplus = kwargs.get('use_googleplus', settings.USE_GOOGLEPLUS_PROPERTIES)
+ self.use_schemaorg = kwargs.get('use_schemaorg', settings.USE_SCHEMAORG_PROPERTIES)
self.use_title_tag = kwargs.get('use_title_tag', settings.USE_TITLE_TAG)
- self.gplus_type = kwargs.get('gplus_type', settings.GPLUS_TYPE)
- self.gplus_publisher = kwargs.get('gplus_publisher', settings.GPLUS_PUBLISHER)
- self.gplus_author = kwargs.get('gplus_author', settings.GPLUS_AUTHOR)
+ self.schemaorg_type = kwargs.get('schemaorg_type', settings.SCHEMAORG_TYPE)
self.fb_pages = kwargs.get('fb_pages', settings.FB_PAGES)
self.og_app_id = kwargs.get('og_app_id', settings.FB_APPID)
self.request = kwargs.get('request', None)
@@ -134,7 +132,7 @@ class MetadataMixin(object):
title = None
og_title = None
twitter_title = None
- gplus_title = None
+ schemaorg_title = None
description = None
extra_props = None
extra_custom_props = None
@@ -152,9 +150,7 @@ class MetadataMixin(object):
use_sites = False
use_og = False
use_title_tag = False
- gplus_type = None
- gplus_author = None
- gplus_publisher = None
+ schemaorg_type = None
def __init__(self, **kwargs):
self.use_sites = settings.USE_SITES
@@ -180,8 +176,8 @@ def get_meta_og_title(self, context=None):
def get_meta_twitter_title(self, context=None):
return self.twitter_title
- def get_meta_gplus_title(self, context=None):
- return self.gplus_title
+ def get_meta_schemaorg_title(self, context=None):
+ return self.schemaorg_title
def get_meta_description(self, context=None):
return self.description
@@ -222,14 +218,8 @@ def get_meta_twitter_card(self, context=None):
def get_meta_facebook_app_id(self, context=None):
return self.facebook_app_id
- def get_meta_gplus_type(self, context=None):
- return self.gplus_type
-
- def get_meta_gplus_author(self, context=None):
- return self.gplus_author
-
- def get_meta_gplus_publisher(self, context=None):
- return self.gplus_publisher
+ def get_meta_schemaorg_type(self, context=None):
+ return self.schemaorg_type
def get_meta_locale(self, context=None):
return self.locale
@@ -242,7 +232,7 @@ def get_meta(self, context=None):
title=self.get_meta_title(context=context),
og_title=self.get_meta_og_title(context=context),
twitter_title=self.get_meta_twitter_title(context=context),
- gplus_title=self.get_meta_gplus_title(context=context),
+ schemaorg_title=self.get_meta_schemaorg_title(context=context),
description=self.get_meta_description(context=context),
extra_props=self.get_meta_extra_props(context=context),
extra_custom_props=self.get_meta_extra_custom_props(context=context),
@@ -257,9 +247,7 @@ def get_meta(self, context=None):
twitter_card=self.get_meta_twitter_card(context=context),
locale=self.get_meta_locale(context=context),
facebook_app_id=self.get_meta_facebook_app_id(context=context),
- gplus_type=self.get_meta_gplus_type(context=context),
- gplus_author=self.get_meta_gplus_author(context=context),
- gplus_publisher=self.get_meta_gplus_publisher(context=context),
+ schemaorg_type=self.get_meta_schemaorg_type(context=context),
)
def get_context_data(self, **kwargs):
diff --git a/tests/example_app/migrations/0001_initial.py b/tests/example_app/migrations/0001_initial.py
index 177139c..8683d51 100644
--- a/tests/example_app/migrations/0001_initial.py
+++ b/tests/example_app/migrations/0001_initial.py
@@ -25,7 +25,7 @@ class Migration(migrations.Migration):
('title', models.CharField(max_length=255, verbose_name='Title')),
('og_title', models.CharField(max_length=255, verbose_name='Opengraph title', blank=True)),
('twitter_title', models.CharField(max_length=255, verbose_name='Twitter title', blank=True)),
- ('gplus_title', models.CharField(max_length=255, verbose_name='Gplus title', blank=True)),
+ ('schemaorg_title', models.CharField(max_length=255, verbose_name='Schema.org title', blank=True)),
('slug', models.SlugField(verbose_name='slug')),
('abstract', models.TextField(verbose_name='Abstract')),
('meta_description', models.TextField(blank=True, default='', verbose_name='Post meta description')),
diff --git a/tests/example_app/models.py b/tests/example_app/models.py
index 678cce1..7f694cf 100644
--- a/tests/example_app/models.py
+++ b/tests/example_app/models.py
@@ -21,7 +21,7 @@ class Post(ModelMeta, models.Model):
title = models.CharField(_('Title'), max_length=255)
og_title = models.CharField(_('Opengraph title'), blank=True, max_length=255)
twitter_title = models.CharField(_('Twitter title'), blank=True, max_length=255)
- gplus_title = models.CharField(_('Gplus title'), blank=True, max_length=255)
+ schemaorg_title = models.CharField(_('Schema.org title'), blank=True, max_length=255)
slug = models.SlugField(_('slug'))
abstract = models.TextField(_('Abstract'))
meta_description = models.TextField(
@@ -50,7 +50,7 @@ class Post(ModelMeta, models.Model):
'title': 'title',
'og_title': 'og title',
'twitter_title': 'twitter title',
- 'gplus_title': 'gplus title',
+ 'schemaorg_title': 'schemaorg title',
'description': 'get_description',
'og_description': 'get_description',
'keywords': 'get_keywords',
@@ -65,9 +65,7 @@ class Post(ModelMeta, models.Model):
'twitter_type': 'Summary',
'twitter_site': '@FooBlag',
'twitter_author': 'get_author_twitter',
- 'gplus_type': 'Article',
- 'gplus_author': 'get_author_gplus',
- 'gplus_publisher': '+FooPub',
+ 'schemaorg_type': 'Article',
'published_time': 'date_published',
'modified_time': 'get_date',
'expiration_time': 'get_date',
@@ -123,7 +121,6 @@ def get_author(self):
author = super(Post, self).get_author()
author.fb_url = 'https://facebook.com/foo.bar'
author.twitter_profile = '@FooBar'
- author.gplus_profile = '+FooBar'
author.get_full_name = self.author.get_full_name
return author
diff --git a/tests/example_app/templates/example_app/post_detail.html b/tests/example_app/templates/example_app/post_detail.html
index 0fa176a..dd98cde 100644
--- a/tests/example_app/templates/example_app/post_detail.html
+++ b/tests/example_app/templates/example_app/post_detail.html
@@ -1,6 +1,6 @@
{% load meta %}
-
+
{% include "meta/meta.html" %}
diff --git a/tests/example_app/views.py b/tests/example_app/views.py
index 687bb0b..43f6b7e 100644
--- a/tests/example_app/views.py
+++ b/tests/example_app/views.py
@@ -29,9 +29,6 @@ def get_meta_title(self, context):
def get_meta_description(self, context):
return self.object.meta_description
- def get_meta_gplus_publisher(self, context):
- return '+FooPub'
-
def get_meta_image(self, context):
return self.object.image_url
diff --git a/tests/test_meta.py b/tests/test_meta.py
index 593703c..2f6a1f7 100644
--- a/tests/test_meta.py
+++ b/tests/test_meta.py
@@ -25,7 +25,7 @@ def setUp(self):
IMAGE_URL='/static/',
USE_TWITTER_PROPERTIES=False,
USE_FACEBOOK_PROPERTIES=False,
- USE_GOOGLEPLUS_PROPERTIES=False,
+ USE_SCHEMAORG_PROPERTIES=False,
USE_TITLE_TAG=False,
USE_SITES=False,
DEFAULT_IMAGE=None,
@@ -44,7 +44,7 @@ def test_defaults(self):
m = Meta()
self.assertEqual(m.title, None)
self.assertEqual(m.og_title, None)
- self.assertEqual(m.gplus_title, None)
+ self.assertEqual(m.schemaorg_title, None)
self.assertEqual(m.twitter_title, None)
self.assertEqual(m.description, None)
self.assertEqual(m.extra_props, None)
@@ -64,7 +64,7 @@ def test_defaults(self):
self.assertEqual(m.use_sites, False)
self.assertEqual(m.use_twitter, False)
self.assertEqual(m.use_facebook, False)
- self.assertEqual(m.use_googleplus, False)
+ self.assertEqual(m.use_schemaorg, False)
self.assertEqual(m.fb_pages, '')
self.assertEqual(m.og_app_id, '')
self.assertEqual(m.use_title_tag, False)
diff --git a/tests/test_metadata_mixin.py b/tests/test_metadata_mixin.py
index 953a6c8..f62883a 100644
--- a/tests/test_metadata_mixin.py
+++ b/tests/test_metadata_mixin.py
@@ -54,16 +54,16 @@ def test_get_meta_twitter_title(self):
'Foo'
)
- def test_get_meta_gplus_title(self):
+ def test_get_meta_schemaorg_title(self):
m = MetadataMixin()
self.assertEqual(
- m.get_meta_gplus_title(),
+ m.get_meta_schemaorg_title(),
None
)
- m.gplus_title = 'Foo'
+ m.schemaorg_title = 'Foo'
self.assertEqual(
- m.get_meta_gplus_title(),
+ m.get_meta_schemaorg_title(),
'Foo'
)
diff --git a/tests/test_mixin.py b/tests/test_mixin.py
index e3ae9d9..8f1cc9f 100644
--- a/tests/test_mixin.py
+++ b/tests/test_mixin.py
@@ -23,7 +23,7 @@ def setUp(self):
title='a title',
og_title='og title',
twitter_title='twitter title',
- gplus_title='gplus title',
+ schemaorg_title='schemaorg title',
slug='title',
abstract='post abstract',
meta_description='post meta',
@@ -51,12 +51,12 @@ def test_as_meta(self):
'keywords': ['post keyword1', 'post keyword 2'],
'og_profile_id': '1111111111111',
'twitter_description': 'post meta',
- 'gplus_type': 'Article',
+ 'schemaorg_type': 'Article',
'title': 'a title',
'og_title': 'og title',
'twitter_title': 'twitter title',
- 'gplus_title': 'gplus title',
- 'gplus_description': 'post meta',
+ 'schemaorg_title': 'schemaorg title',
+ 'schemaorg_description': 'post meta',
'expiration_time': self.post.date_published_end,
'og_description': 'post meta',
'description': 'post meta',
@@ -65,8 +65,6 @@ def test_as_meta(self):
'og_author_url': 'https://facebook.com/foo.bar',
'og_app_id': 'appid',
'fb_pages': 'fbpages',
- 'gplus_author': '+FooBar',
- 'gplus_publisher': '+FooPub',
'published_time': self.post.date_published,
'url': 'http://example.com/title/',
'og_publisher': 'https://facebook.com/foo.blag',
@@ -115,12 +113,12 @@ def test_as_meta_with_request(self):
'keywords': ['post keyword1', 'post keyword 2'],
'og_profile_id': '1111111111111',
'twitter_description': 'post meta',
- 'gplus_type': 'Article',
+ 'schemaorg_type': 'Article',
'title': 'a title',
'og_title': 'og title',
'twitter_title': 'twitter title',
- 'gplus_title': 'gplus title',
- 'gplus_description': 'post meta',
+ 'schemaorg_title': 'schemaorg title',
+ 'schemaorg_description': 'post meta',
'expiration_time': self.post.date_published_end,
'og_description': 'post meta',
'description': 'post meta',
@@ -129,8 +127,6 @@ def test_as_meta_with_request(self):
'og_author_url': 'https://facebook.com/foo.bar',
'og_app_id': 'appid',
'fb_pages': 'fbpages',
- 'gplus_author': '+FooBar',
- 'gplus_publisher': '+FooPub',
'published_time': self.post.date_published,
'url': 'https://testserver/title/',
'og_publisher': 'https://facebook.com/foo.blag',
@@ -157,19 +153,17 @@ def test_as_meta_with_request(self):
settings.FB_APPID = ''
def test_templatetag(self):
- meta = self.post.as_meta()
+ self.post.as_meta()
response = self.client.get('/title/')
self.assertContains(response, '')
self.assertNotContains(response, ' itemscope itemtype="http://schema.org/Article"')
self.assertContains(response, 'article:published_time"')
self.assertContains(response, ''.format(self.image_url))
- self.assertContains(response, ''.format(meta.gplus_author))
self.assertContains(response, ''.format(self.post.meta_description))
self.assertContains(response, ''.format(self.post.meta_description))
self.assertContains(response, ''.format(self.post.meta_description))
self.assertContains(response, ''.format(self.post.meta_description))
self.assertContains(response, ''.format(', '.join(self.post.meta_keywords.split(","))))
- self.assertContains(response, ''.format('+FooPub'))
self.assertContains(response, '')
self.assertContains(response, '')
self.assertContains(response, '')
@@ -185,7 +179,6 @@ def test_templatetag_metadatamixin(self):
self.assertContains(response, ''.format(self.post.meta_description))
self.assertContains(response, ''.format(', '.join(self.post.meta_keywords.split(","))))
self.assertContains(response, '')
- self.assertContains(response, ''.format('+FooPub'))
def test_templatetag_secure_image(self):
"""
diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py
index 2e52a76..968f474 100644
--- a/tests/test_templatetags.py
+++ b/tests/test_templatetags.py
@@ -1,11 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
+import sys
+import warnings
+
from django.test import TestCase
from meta.templatetags.meta import (
custom_meta, custom_meta_extras, facebook_prop, generic_prop, googleplus_html_scope, googleplus_prop, meta,
- meta_extras, meta_list, meta_namespaces, og_prop, title_prop, twitter_prop,
+ meta_extras, meta_list, meta_namespaces, og_prop, schemaorg_html_scope, schemaorg_prop, title_prop, twitter_prop,
)
from meta.views import Meta
@@ -100,21 +103,61 @@ def test_facebook_basically_works(self):
class GooglePlusPropTestcase(TestCase):
+
+ def setUp(self):
+ # The __warningregistry__'s need to be in a pristine state for tests
+ # to work properly.
+ for v in sys.modules.values():
+ if getattr(v, '__warningregistry__', None):
+ v.__warningregistry__ = {}
+
def test_google_plus_basically_works(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ self.assertEqual(
+ googleplus_prop('foo', 'bar'),
+ ''
+ )
+ assert len(w) == 1
+ assert issubclass(w[-1].category, PendingDeprecationWarning)
+
+ def test_google_plus_scope_works(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ self.assertEqual(
+ googleplus_html_scope('bar'),
+ ' itemscope itemtype="http://schema.org/bar" '
+ )
+ assert len(w) == 1
+ assert issubclass(w[-1].category, PendingDeprecationWarning)
+
+ def test_google_plus_escapes_xss(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ self.assertEqual(
+ googleplus_prop('fo"o', 'b'
+ )
+ assert len(w) == 1
+ assert issubclass(w[-1].category, PendingDeprecationWarning)
+
+
+class SchemaOrgPropTestcase(TestCase):
+ def test_schemaorg_basically_works(self):
self.assertEqual(
- googleplus_prop('foo', 'bar'),
+ schemaorg_prop('foo', 'bar'),
''
)
- def test_google_plus_scope_works(self):
+ def test_schemaorg_scope_works(self):
self.assertEqual(
- googleplus_html_scope('bar'),
+ schemaorg_html_scope('bar'),
' itemscope itemtype="http://schema.org/bar" '
)
- def test_google_plus_escapes_xss(self):
+ def test_schemaorg_escapes_xss(self):
self.assertEqual(
- googleplus_prop('fo"o', 'b'
)
diff --git a/tox.ini b/tox.ini
index 685bb41..63eafd0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,7 +21,7 @@ commands = flake8
skip_install = true
[testenv:isort]
-deps = isort
+deps = isort<5
commands = isort -c -rc -df meta meta_mixin tests
skip_install = true