Skip to content

Commit

Permalink
Merge pull request #332 from savoirfairelinux/1679-structured-data
Browse files Browse the repository at this point in the history
Fix #1679 - Add structured data
  • Loading branch information
cormier authored Jul 26, 2016
2 parents a15f8fb + b58530e commit 121d514
Show file tree
Hide file tree
Showing 18 changed files with 513 additions and 41 deletions.
3 changes: 0 additions & 3 deletions eruditorg/apps/public/journal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,4 @@

# Compatibility URLs
url('^', include(urls_compat.urlpatterns)),

# Journal catchall
url(r'^(?P<code>[\w-]+)/$', views.JournalDetailView.as_view(), name='journal_detail'),
]
3 changes: 3 additions & 0 deletions eruditorg/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
{% block meta_tags %}
{% endblock meta_tags %}

{% block structured_data %}
{% endblock structured_data %}

{% block stylesheets %}
{% endblock stylesheets %}

Expand Down
17 changes: 17 additions & 0 deletions eruditorg/templates/public/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
{% load rules %}
{% load base_urls_tags %}

{% block structured_data %}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Organization",
"name" : "Érudit",
"url" : "{{ request.scheme }}://{{ request.site.domain }}",
"logo" : "{{ request.scheme }}://{{ request.site.domain }}{% static 'img/logo-erudit.png' %}",
"sameAs" : [
"https://www.facebook.com/%C3%89rudit-141469165320/",
"https://twitter.com/eruditorg",
"https://github.com/erudit/",
"https://www.linkedin.com/company/3628951"]
}
</script>
{% endblock structured_data %}

{% block stylesheets %}
{% if not WEBPACK_DEV_SERVER_URL %}
<link rel="stylesheet" type="text/css" href="{% static 'css/PublicApp.css' %}" />
Expand Down
36 changes: 33 additions & 3 deletions eruditorg/templates/public/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,44 @@

{% block page_title %}{% trans "Accueil" %}{% endblock page_title %}

{% block data_controller %}public:home{% endblock data_controller %}

{% block body_class %}{{ block.super }} home{% endblock %}
{% block structured_data %}
{{ block.super }}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "WebSite",
"name" : "Érudit",
"url" : "{{ request.scheme }}://{{ request.site.domain }}",
"potentialAction": {
"@type": "SearchAction",
"target": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:search:results' %}?basic_search_term={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}",
"name": "Érudit"
}
}]
}
</script>
{% endblock structured_data %}

{% block extrahead %}
<link rel="stylesheet" href="{% static 'css/videojs.css' %}" />
{% endblock extrahead %}

{% block data_controller %}public:home{% endblock data_controller %}
{% block body_class %}{{ block.super }} home{% endblock %}

{% block content %}
{% trans "inconnu" as i18n_unknown %}
<div id="homepage-content">
Expand Down
59 changes: 54 additions & 5 deletions eruditorg/templates/public/journal/article_detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "public/journal/journal_base.html" %}
{% extends "public/base.html" %}
{% load i18n staticfiles %}
{% load public_journal_tags %}
{% load cache %}
Expand Down Expand Up @@ -65,20 +65,69 @@
{% endcache %}
{% endblock meta_tags %}

{% block structured_data %}
{{ block.super }}
{% cache FOREVER_TTL "public_article_detail_structured_data" article.id LANGUAGE_CODE %}
{% include "public/journal/partials/article_structured_data.html" %}
{% endcache %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}",
"name": "Érudit"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_list' %}",
"name": "{% trans 'Revues' %}"
}
},{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_detail' article.issue.journal.code %}",
"name": "{{ article.issue.journal.name }}"
}
},{
"@type": "ListItem",
"position": 4,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:issue_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier %}",
"name": "{{ article.issue.volume_title_with_pages }}"
}
},{
"@type": "ListItem",
"position": 5,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:article_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier article.localidentifier %}",
"name": "{{ article.title }}"
}
}]
}
</script>
{% endblock structured_data %}

{% block body_class %}public static-header{% endblock %}

{% block header_class %}static{% endblock %}

{% block breadcrumb %}{{ block.super }}
/ <a href="{% url 'public:journal:journal_detail' article.issue.journal.code %}">{{ article.issue.journal.name }}</a>
/ <a href="{% url 'public:journal:issue_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier %}">
/ <a href="{% url 'public:journal:journal_detail' article.issue.journal.code %}">{{ article.issue.journal.name }}</a>
/ <a href="{% url 'public:journal:issue_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier %}">
{% if article.issue.erudit_object.html_theme %}
{{ article.issue.erudit_object.html_theme|safe|truncatechars:50 }}
{% else %}
{{ article.issue.volume_title_with_pages }}
{% endif %}
</a>
/ <a>{{ article.title|truncatechars:50 }}</a>
</a>
/ <a href="{% url 'public:journal:article_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier article.localidentifier %}">{{ article.title|truncatechars:50 }}</a>
{% endblock %}

{% block content %}
Expand Down
52 changes: 47 additions & 5 deletions eruditorg/templates/public/journal/article_summary.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "public/journal/journal_base.html" %}
{% extends "public/base.html" %}
{% load i18n staticfiles %}
{% load public_journal_tags %}
{% load cache %}
Expand Down Expand Up @@ -63,20 +63,62 @@
{% endcache %}
{% endblock meta_tags %}

{% block structured_data %}
{{ block.super }}
{% cache FOREVER_TTL "public_article_summary_structured_data" article.id LANGUAGE_CODE %}
{% include "public/journal/partials/article_structured_data.html" %}
{% endcache %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}",
"name": "Érudit"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_list' %}",
"name": "{% trans 'Revues' %}"
}
},{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_detail' article.issue.journal.code %}",
"name": "{{ article.issue.journal.name }}"
}
},{
"@type": "ListItem",
"position": 5,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:article_summary' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier article.localidentifier %}",
"name": "{{ article.title }}"
}
}]
}
</script>
{% endblock structured_data %}

{% block body_class %}public static-header{% endblock %}

{% block header_class %}static{% endblock %}

{% block breadcrumb %}{{ block.super }}
/ <a href="{% url 'public:journal:journal_detail' article.issue.journal.code %}">{{ article.issue.journal.name }}</a>
/ <a href="{% url 'public:journal:issue_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier %}">
/ <a href="{% url 'public:journal:journal_detail' article.issue.journal.code %}">{{ article.issue.journal.name }}</a>
/ <a href="{% url 'public:journal:issue_detail' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier %}">
{% if article.issue.erudit_object.html_theme %}
{{ article.issue.erudit_object.html_theme|safe|truncatechars:50 }}
{% else %}
{{ article.issue.volume_title_with_pages }}
{% endif %}
</a>
/ <a>{% blocktrans with title=article.title|truncatechars:50 %}{{ title }} - Résumé{% endblocktrans %}</a>
</a>
/ <a href="{% url 'public:journal:article_summary' article.issue.journal.code article.issue.volume_slug article.issue.localidentifier article.localidentifier %}">{% blocktrans with title=article.title|truncatechars:50 %}{{ title }} - Résumé{% endblocktrans %}</a>
{% endblock %}

{% block content %}
Expand Down
63 changes: 50 additions & 13 deletions eruditorg/templates/public/journal/issue_detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "public/journal/journal_base.html" %}
{% extends "public/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load cache %}
Expand All @@ -7,10 +7,7 @@

{% block zone_title %}{{ journal.name }}{% endblock %}

{% block page_title %}
{% if issue.erudit_object.html_theme %}{{ issue.erudit_object.html_theme|safe }}. {% endif %}
{{ issue.volume_title_with_pages }}
{% endblock page_title %}
{% block page_title %}{% if issue.erudit_object.html_theme %}{{ issue.erudit_object.html_theme|safe }}. {% endif %}{{ issue.volume_title_with_pages }} - {{ issue.journal.name }}{% endblock page_title %}

{% block meta_tags %}
<!-- Facebook / Open Graph -->
Expand All @@ -28,15 +25,55 @@
<meta name="twitter:title" content="{{ issue.erudit_object.html_theme|safe }} – Érudit">
{% endblock meta_tags %}

{% block structured_data %}
{{ block.super }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}",
"name": "Érudit"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_list' %}",
"name": "{% trans 'Revues' %}"
}
},{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_detail' issue.journal.code %}",
"name": "{{ issue.journal.name }}"
}
},{
"@type": "ListItem",
"position": 4,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:issue_detail' issue.journal.code issue.volume_slug issue.localidentifier %}",
"name": "{{ issue.volume_title_with_pages }}"
}
}]
}
</script>
{% endblock structured_data %}

{% block breadcrumb %}{{ block.super }}
/
<a href="{% url 'public:journal:issue_detail' issue.journal.code issue.volume_slug issue.localidentifier %}">
{% if issue.erudit_object.html_theme %}
{{ issue.erudit_object.html_theme|safe|truncatechars:50 }}
{% else %}
{{ issue.volume_title_with_pages }}
{% endif %}
</a>
/ <a href="{% url 'public:journal:journal_list' %}">{% trans "Revues" %}</a>
/ <a href="{% url 'public:journal:journal_detail' journal.code %}">{{ issue.journal.name }}</a>
/ <a href="{% url 'public:journal:issue_detail' issue.journal.code issue.volume_slug issue.localidentifier %}">
{% if issue.erudit_object.html_theme %}
{{ issue.erudit_object.html_theme|safe|truncatechars:50 }}
{% else %}
{{ issue.volume_title_with_pages }}
{% endif %}
</a>
{% endblock %}

{% block content %}
Expand Down
47 changes: 46 additions & 1 deletion eruditorg/templates/public/journal/journal_authors_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,52 @@
{% load i18n %}
{% load public_journal_tags %}

{% block title %}{% trans "Index des auteurs" %}{% endblock title %}
{% block title %}{% trans "Index des auteurs" %} - {{ journal.name }}{% endblock title %}

{% block structured_data %}
{{ block.super }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}",
"name": "Érudit"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_list' %}",
"name": "{% trans 'Revues' %}"
}
},{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_detail' journal.code %}",
"name": "{{ article.issue.journal.name }}"
}
},{
"@type": "ListItem",
"position": 4,
"item": {
"@id": "{{ request.scheme }}://{{ request.site.domain }}{% url 'public:journal:journal_authors_list' journal.code %}",
"name": "{% trans 'Auteurs' %}"
}
}]
}
</script>
{% endblock structured_data %}

{% block breadcrumb %}
{{ block.super }} / <a href="{% url 'public:journal:journal_list' %}">{% trans "Revues" %}</a>
/ <a href="{% url 'public:journal:journal_detail' journal.code %}">{{ journal.name }}</a>
/ <a href="{% url 'public:journal:journal_authors_list' journal.code %}">{% trans "Auteurs" %}</a>
{% endblock %}

{% block content %}
<div class="container">
Expand Down
7 changes: 0 additions & 7 deletions eruditorg/templates/public/journal/journal_base.html

This file was deleted.

Loading

0 comments on commit 121d514

Please sign in to comment.