From e5a44fd38c8e3c4ae1741d204d2d0b9ded047e6f Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 24 Jan 2018 14:02:12 +1100 Subject: [PATCH] Dramatically improve AMP support, adding all the missing fields so that the AMP version still parses to a reasonable h-entry --- entries/templates/entries/entry_amp.html | 73 +++++++++++++++++++++++- lemoncurry/templatetags/absolute_url.py | 10 ++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 lemoncurry/templatetags/absolute_url.py diff --git a/entries/templates/entries/entry_amp.html b/entries/templates/entries/entry_amp.html index 4410c44..1ff1a45 100644 --- a/entries/templates/entries/entry_amp.html +++ b/entries/templates/entries/entry_amp.html @@ -1,9 +1,9 @@ -{% load favtags jsonify lemoncurry_tags markdown theme_colour %} +{% load absolute_url favtags friendly_url humanize jsonify lemoncurry_tags markdown shortlink theme_colour %} {{ entry.title }} ~ {% site_name %} - + @@ -76,6 +91,11 @@
+ {% if entry.photo %} + + + + {% endif %} {% if entry.name %}

{{ entry.name }}

{% endif %} @@ -83,6 +103,53 @@
{{ entry.content | markdown }}
+ +
diff --git a/lemoncurry/templatetags/absolute_url.py b/lemoncurry/templatetags/absolute_url.py new file mode 100644 index 0000000..f7ad56a --- /dev/null +++ b/lemoncurry/templatetags/absolute_url.py @@ -0,0 +1,10 @@ +from django import template +from urllib.parse import urljoin +from ..utils import origin + +register = template.Library() + + +@register.simple_tag(takes_context=True) +def absolute_url(context, url): + return urljoin(origin(context.request), url)