From de42193d3d91bfbf676079cd6b248ac6c8ee0787 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Thu, 25 Feb 2021 00:49:13 -0800 Subject: [PATCH] add some open graph protocol header stuff --- audio/templates/audio/index.html | 9 +++++++++ audio/views.py | 10 +++++++--- tp/templates/base.html | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/audio/templates/audio/index.html b/audio/templates/audio/index.html index 2f0ef2a..d4e8c6c 100644 --- a/audio/templates/audio/index.html +++ b/audio/templates/audio/index.html @@ -1,4 +1,13 @@ {% extends "base.html" %} +{% block morehead %} + {% if is_episode %} + + + + + + {% endif %} +{% endblock morehead %} {% block content %} {% include "base_navbar.html" %} diff --git a/audio/views.py b/audio/views.py index 3efe1ae..ce7753d 100644 --- a/audio/views.py +++ b/audio/views.py @@ -1,4 +1,5 @@ -from django.shortcuts import render, redirect +from django.shortcuts import render, redirect, reverse +from django.contrib.sites.shortcuts import get_current_site from .forms import FeedForm from .models import Feed, Episode from tp.settings import IMAGES_URL, MP3_URL @@ -25,11 +26,14 @@ def feed(request, pk, slug): def episode(request, pk, slug): episode = Episode.objects.get(id=pk) + ogurl = reverse('audio:episode', kwargs={'pk': pk, 'slug': slug}) + og_url = f'{get_current_site(request)}{ogurl}' return render( request, 'audio/index.html', { - 'episodes': (episode, ), 'IMAGES_URL': IMAGES_URL, - 'MP3_URL': MP3_URL, 'title': episode.title, 'heading': episode.title + 'episodes': (episode, ), 'IMAGES_URL': IMAGES_URL, 'is_episode': True, + 'MP3_URL': MP3_URL, 'title': episode.title, 'heading': episode.title, + 'ogtitle': episode.title, 'ogurl': og_url, 'ogmp3': episode.mp3 }) diff --git a/tp/templates/base.html b/tp/templates/base.html index 479f1bc..2c60e38 100644 --- a/tp/templates/base.html +++ b/tp/templates/base.html @@ -4,6 +4,7 @@ + {% block morehead %}{% endblock morehead %} {% url 'audio:home' as home_url %} {% url 'accounts:login' as login_url %}