From 85d95fb5d798bfcbe10519a27401a7786325a52a Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Fri, 10 Nov 2017 10:17:19 +1100 Subject: [PATCH] Extend the host-meta with extra fields and sort them by rel --- wellknowns/views/host_meta.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/wellknowns/views/host_meta.py b/wellknowns/views/host_meta.py index c619e09..5fc29f2 100644 --- a/wellknowns/views/host_meta.py +++ b/wellknowns/views/host_meta.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.http import HttpResponse, JsonResponse from django.urls import reverse from lemoncurry.utils import load_package_json, origin @@ -12,14 +13,22 @@ def add_links(request, dest): license = 'https://creativecommons.org/licenses/by-sa/4.0/' links = ( + Link( + href=urljoin(base, reverse('entries:atom')), + rel='alternate', type_='application/atom+xml', + ), + Link( + href=urljoin(base, reverse('entries:rss')), + rel='alternate', type_='application/rss+xml', + ), Link( href=urljoin(base, reverse('lemonauth:indie')), rel='authorization_endpoint' ), - Link( - href=urljoin(base, reverse('lemonauth:token')), - rel='token_endpoint' - ), + Link(href=pkg['repository'], type_='text/html', rel='code-repository'), + Link(href=settings.PUSH_HUB, rel='hub'), + Link(href=license, type_='text/html', rel='license'), + Link(href=license+'rdf', type_='application/rdf+xml', rel='license'), Link( template=urljoin(base, webfinger), type_='application/json', rel='lrdd', @@ -29,16 +38,15 @@ def add_links(request, dest): rel='manifest', type_='application/json', ), Link( - href=urljoin(base, reverse('entries:atom')), - rel='alternate', type_='application/atom+xml', + href=urljoin(base, reverse('micropub:micropub')), + rel='micropub' ), Link( - href=urljoin(base, reverse('entries:rss')), - rel='alternate', type_='application/rss+xml', + href=urljoin(base, reverse('lemonauth:token')), + rel='token_endpoint' ), - Link(href=license, type_='text/html', rel='license'), - Link(href=license+'rdf', type_='application/rdf+xml', rel='license'), - Link(href=pkg['repository'], type_='text/html', rel='code-repository'), + Link(href='https://openid.indieauth.com/openid', rel='openid.server'), + Link(href=base, rel='openid.delegate'), ) dest.extend(links)