forked from 00dani/lemoncurry
Teach users how to generate their own JSON-LD representation rather than doing it in the view code
This commit is contained in:
parent
a86188fcb6
commit
371401d441
3 changed files with 19 additions and 14 deletions
|
@ -35,7 +35,7 @@
|
|||
</li>{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<script class="p-json-ld" type="application/ld+json">{{ person | jsonify }}</script>
|
||||
<script class="p-json-ld" type="application/ld+json">{{ user.json_ld | jsonify }}</script>
|
||||
</article>
|
||||
</aside>
|
||||
<ol class="list-unstyled entries">
|
||||
|
|
|
@ -11,22 +11,9 @@ def index(request):
|
|||
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
|
||||
user = get_object_or_404(query, pk=1)
|
||||
uri = utils.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()]
|
||||
}
|
||||
|
||||
return {
|
||||
'user': user,
|
||||
'person': person,
|
||||
'entries': user.entries.all(),
|
||||
'meta': user.as_meta(request),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue