forked from 00dani/lemoncurry
Add http://schema.org/Person as JSON-LD, underneath my h-card on the home page
This commit is contained in:
parent
29da1e52d7
commit
9d91cec6f9
3 changed files with 19 additions and 2 deletions
|
@ -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 %}
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -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…
Reference in a new issue