Commit bb4fe61e authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt Committed by Robert

fix content metadata. refs #395

OpenGraph clients could not properly parse our content because
`content.get_absolute_url` didn’t return anything and the canonical url
of our content therefore always referred to `http_origin`. This
basically broke everything as only the canonical URL is used to create
the OpenGraph dataset.

Images were broken as well, as the way the image was stored was changed
in the backend without updating this template. We now have dedicated
Facebook and Twitter meta image fields.
parent e9e74cbf
<meta name="description" content="{{ content.title }}">
{# todo not a real absolute url #}
<meta property="og:url" content="{{ http_origin }}{{ content.get_absolute_url }}">
<meta property="og:url" content="{{ http_origin }}{% url 'content-permalink' association.pk %}">
<meta property="og:type" content="article">
<meta property="og:title" content="{{ content.title }}">
<meta property="og:description" content="{% markdown content.versions.last.text plain_preview=50 %}">
......@@ -10,13 +9,12 @@
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@stadtgestalten">
{# todo not a real absolute url #}
<meta name="twitter:url" content="{{ http_origin }}{{ content.get_absolute_url }}">
<meta name="twitter:url" content="{{ http_origin }}{% url 'content-permalink' association.pk %}">
<meta name="twitter:title" content="{{ content.title }}">
<meta name="twitter:description" content="{% markdown content.versions.last.text plain_preview=50 %}">
{% if content.image %}
<meta property="og:image" content="{{ http_origin }}{{ content.image.preview.url }}">
<meta name="twitter:image" content="{{ http_origin }}{{ content.image.preview.url }}">
<meta property="og:image" content="{{ http_origin }}{{ content.image.facebook_meta.url }}">
<meta name="twitter:image" content="{{ http_origin }}{{ content.image.twitter_meta.url }}">
{% endif %}
......@@ -7,6 +7,8 @@ urlpatterns = [
views.Detail.as_view(),
name='content'),
# This route is used in the content/_meta.html template. If there is a change in how
# generated urls for this route work the meta urls should be checked afterwards.
urls.url(
r'^stadt/content/(?P<association_pk>[0-9]+)/$',
views.Permalink.as_view(),
......
......@@ -20,6 +20,10 @@ class Image(models.Model):
source='file', processors=[Transpose(), ResizeToFit(554)], format='JPEG')
sidebar = ImageSpecField(
source='file', processors=[Transpose(), ResizeToFit(313)], format='JPEG')
facebook_meta = ImageSpecField(
source='file', processors=[Transpose(), ResizeToFit(800)])
twitter_meta = ImageSpecField(
source='file', processors=[Transpose(), SmartResize(600, 300)])
def __str__(self):
return '{} ({})'.format(self.file, self.creator)[2:]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment