From 188b880e7e102952d748e984553153e68130c9da Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sat, 31 Dec 2016 15:00:27 +0100
Subject: [PATCH] Include meta tags in publication_detail (for Google Scholar)

---
 .../templates/journals/publication_detail.html | 18 ++++++++++++++++++
 journals/templatetags/__init__.py              |  0
 journals/templatetags/journals_extras.py       | 10 ++++++++++
 scipost/templatetags/scipost_extras.py         |  6 ++++++
 4 files changed, 34 insertions(+)
 create mode 100644 journals/templatetags/__init__.py
 create mode 100644 journals/templatetags/journals_extras.py

diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html
index fae74accb..494f39ef1 100644
--- a/journals/templates/journals/publication_detail.html
+++ b/journals/templates/journals/publication_detail.html
@@ -1,8 +1,26 @@
 {% extends 'scipost/base.html' %}
 
+{% load journals_extras %}
+
 {% block pagetitle %}: Publication detail{% endblock pagetitle %}
 
 {% block headsup %}
+<meta name="citation_title" content="{{ publication.title }}"/>
+{% for author in publication.authors.all %}
+<meta name="citation_author" content="{{ author.user.last_name }}, {{ author.user.first_name }}"/>
+{% endfor %}
+{% for author in publication.authors_unregistered.all %}
+<meta name="citation_author" content="{{ author.last_name }}, {{ author.first_name }}"/>
+{% endfor %}
+<meta name="citation_doi" content="{{ publication.doi_string }}"/>
+<meta name="citation_publication_date" content="{{ publication.publication_date|date:'Y/m/d' }}"/>
+<meta name="citation_journal_title" content="{{ publication.in_issue.in_volume.in_journal.name }}"/>
+<meta name="citation_issn" content="{{ publication.in_issue.in_volume.in_journal.issn }}"/>
+<meta name="citation_volume" content="{{ publication.in_issue.in_volume.number }}"/>
+<meta name="citation_issue" content="{{ publication.in_issue.number }}"/>
+<meta name="citation_firstpage" content="{{ publication.paper_nr|paper_nr_string_filter }}"/>
+<meta name="citation_pdf_url" content="https://scipost.org/{{ publication.doi_label }}/pdf"/>
+
 <script>
   $(document).ready(function(){
     $("#citationslist").hide();
diff --git a/journals/templatetags/__init__.py b/journals/templatetags/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/journals/templatetags/journals_extras.py b/journals/templatetags/journals_extras.py
new file mode 100644
index 000000000..c56258212
--- /dev/null
+++ b/journals/templatetags/journals_extras.py
@@ -0,0 +1,10 @@
+from django import template
+
+from journals.models import paper_nr_string
+
+register = template.Library()
+
+
+@register.filter(name='paper_nr_string_filter')
+def paper_nr_string_filter(nr):
+    return paper_nr_string(nr)
diff --git a/scipost/templatetags/scipost_extras.py b/scipost/templatetags/scipost_extras.py
index 3a34f87e7..3178295d7 100644
--- a/scipost/templatetags/scipost_extras.py
+++ b/scipost/templatetags/scipost_extras.py
@@ -2,6 +2,7 @@ from django import template
 from django.contrib.auth.models import Group
 
 from scipost.models import Contributor
+from journals.models import paper_nr_string
 
 register = template.Library()
 
@@ -29,3 +30,8 @@ def is_in_group(user, group_name):
 def associated_contributors(draft):
     return Contributor.objects.filter(
         user__last_name__icontains=draft.last_name)
+
+
+@register.filter(name='paper_nr_string')
+def paper_nr_string_filter(nr):
+    return paper_nr_string(nr)
-- 
GitLab