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' %}
|
{% extends 'lemoncurry/layout.html' %}
|
||||||
{% load markdown static %}
|
{% load jsonify markdown static %}
|
||||||
{% block html_class %}h-feed{% endblock %}
|
{% block html_class %}h-feed{% endblock %}
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
<link rel="stylesheet" type="text/stylus" href="{% static 'home/css/index.styl' %}" />
|
<link rel="stylesheet" type="text/stylus" href="{% static 'home/css/index.styl' %}" />
|
||||||
|
@ -36,6 +36,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
<script type="application/ld+json">{{ person | jsonify }}</script>
|
||||||
</aside>
|
</aside>
|
||||||
<ol class="list-unstyled entries">
|
<ol class="list-unstyled entries">
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from lemoncurry import breadcrumbs
|
from lemoncurry import breadcrumbs
|
||||||
|
from lemoncurry.templatetags.lemoncurry_tags import request_uri
|
||||||
|
|
||||||
breadcrumbs.add('home:index', 'home')
|
breadcrumbs.add('home:index', 'home')
|
||||||
|
|
||||||
|
@ -8,9 +9,24 @@ breadcrumbs.add('home:index', 'home')
|
||||||
def index(request):
|
def index(request):
|
||||||
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
|
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
|
||||||
user = get_object_or_404(query, pk=1)
|
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()
|
entries = user.entries.all()
|
||||||
return render(request, 'home/index.html', {
|
return render(request, 'home/index.html', {
|
||||||
'user': user,
|
'user': user,
|
||||||
|
'person': person,
|
||||||
'entries': entries,
|
'entries': entries,
|
||||||
'meta': user.as_meta(request),
|
'meta': user.as_meta(request),
|
||||||
})
|
})
|
||||||
|
|
|
@ -105,5 +105,5 @@ def nav_crumbs(context, route):
|
||||||
'breadcrumb_list': breadcrumb_list,
|
'breadcrumb_list': breadcrumb_list,
|
||||||
'crumbs': crumbs,
|
'crumbs': crumbs,
|
||||||
'current': current,
|
'current': current,
|
||||||
'title': context['title'],
|
'title': context.get('title'),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue