Add http://schema.org/Person as JSON-LD, underneath my h-card on the home page

This commit is contained in:
Danielle McLean 2017-10-27 09:52:03 +11:00
parent 29da1e52d7
commit 9d91cec6f9
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 19 additions and 2 deletions

View file

@ -1,5 +1,5 @@
{% extends 'lemoncurry/layout.html' %}
{% load markdown static %}
{% load jsonify markdown static %}
{% block html_class %}h-feed{% endblock %}
{% block styles %}
<link rel="stylesheet" type="text/stylus" href="{% static 'home/css/index.styl' %}" />
@ -36,6 +36,7 @@
</ul>
</div>
</article>
<script type="application/ld+json">{{ person | jsonify }}</script>
</aside>
<ol class="list-unstyled entries">
{% for entry in entries %}

View file

@ -1,6 +1,7 @@
from django.shortcuts import get_object_or_404, render
from users.models import User
from lemoncurry import breadcrumbs
from lemoncurry.templatetags.lemoncurry_tags import request_uri
breadcrumbs.add('home:index', 'home')
@ -8,9 +9,24 @@ breadcrumbs.add('home:index', 'home')
def index(request):
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
user = get_object_or_404(query, pk=1)
uri = request_uri(request)
person = {
'@context': 'http://schema.org',
'@type': 'Person',
'@id': uri,
'url': uri,
'name': '{0} {1}'.format(user.first_name, user.last_name),
'email': user.email,
'image': user.avatar.url,
'givenName': user.first_name,
'familyName': user.last_name,
'sameAs': [profile.url for profile in user.profiles.all()]
}
entries = user.entries.all()
return render(request, 'home/index.html', {
'user': user,
'person': person,
'entries': entries,
'meta': user.as_meta(request),
})

View file

@ -105,5 +105,5 @@ def nav_crumbs(context, route):
'breadcrumb_list': breadcrumb_list,
'crumbs': crumbs,
'current': current,
'title': context['title'],
'title': context.get('title'),
}