Browse Source

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

pull/1/head
Danielle McLean 5 years ago
parent
commit
9d91cec6f9
Signed by: 00dani
GPG Key ID: 5A5D2D1AFF12EEC5
  1. 3
      home/templates/home/index.html
  2. 16
      home/views.py
  3. 2
      lemoncurry/templatetags/lemoncurry_tags.py

3
home/templates/home/index.html

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

16
home/views.py

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

2
lemoncurry/templatetags/lemoncurry_tags.py

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

Loading…
Cancel
Save