add some open graph protocol header stuff

This commit is contained in:
Trent Palmer 2021-02-25 00:49:13 -08:00
parent 8131883f21
commit de42193d3d
3 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,13 @@
{% extends "base.html" %}
{% block morehead %}
{% if is_episode %}
<meta property="og:title" content="{{ ogtitle }}" />
<meta property="og:url" content="{{ ogurl }}" />
<meta property="og:audio" content="{{ MP3_URL }}{{ ogmp3 }}" />
<meta property="og:audio:secure" content="{{ MP3_URL }}{{ ogmp3 }}" />
<meta property="og:audio:type" content="audio/mpeg" />
{% endif %}
{% endblock morehead %}
{% block content %}
{% include "base_navbar.html" %}

View File

@ -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
})

View File

@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
{% block morehead %}{% endblock morehead %}
{% url 'audio:home' as home_url %}
{% url 'accounts:login' as login_url %}