Extend the host-meta with extra fields and sort them by rel

This commit is contained in:
Danielle McLean 2017-11-10 10:17:19 +11:00
parent a7f6824334
commit 85d95fb5d7
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

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