From 91b0aa0b7e39fe80ddf1a5577d94409b101681fc Mon Sep 17 00:00:00 2001 From: Morgan Aubert Date: Fri, 22 Jul 2016 11:40:12 -0400 Subject: [PATCH 1/2] Remove hardcoded URLs from the XSLT template --- eruditorg/templates/public/journal/article_detail.html | 2 ++ .../templates/public/journal/eruditxsd300_to_html.xsl | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eruditorg/templates/public/journal/article_detail.html b/eruditorg/templates/public/journal/article_detail.html index cfb70f48b..77c9dbdfc 100644 --- a/eruditorg/templates/public/journal/article_detail.html +++ b/eruditorg/templates/public/journal/article_detail.html @@ -3,6 +3,8 @@ {% load public_journal_tags %} {% load cache %} +{% block page_title %}{{ article.title }}{% endblock page_title %} + {% block data_controller %}public:journal:article_detail{% endblock data_controller %} {% block meta_tags %} diff --git a/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl b/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl index 67a071062..63fc07227 100644 --- a/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl +++ b/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl @@ -25,8 +25,6 @@ http://id.erudit.org/iderudit/ http://dx.doi.org/ - http://erudit.org/revue/ - http://erudit.org/culture/ {% for imid, infoimg in article.fedora_object.infoimg_dict.items %} @@ -104,8 +102,8 @@
URI
- - + + {{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:article_detail' journal_code=article.issue.journal.code issue_slug=article.issue.volume_slug issue_localid=article.issue.localidentifier localid=article.localidentifier %} {% trans "adresse copiée" %} {% trans "une erreur s'est produite" %} @@ -129,7 +127,7 @@

{% blocktrans %} de la revue{% endblocktrans %} - +

From bf1c57263371ac295f164cca552e67bb753df16c Mon Sep 17 00:00:00 2001 From: Morgan Aubert Date: Tue, 26 Jul 2016 13:23:52 -0400 Subject: [PATCH 2/2] Add iderudit redirect view for articles --- eruditorg/apps/public/journal/urls.py | 2 ++ eruditorg/apps/public/journal/views.py | 14 ++++++++++++++ .../public/journal/eruditxsd300_to_html.xsl | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/eruditorg/apps/public/journal/urls.py b/eruditorg/apps/public/journal/urls.py index 40a2a4f76..a3116b22e 100644 --- a/eruditorg/apps/public/journal/urls.py +++ b/eruditorg/apps/public/journal/urls.py @@ -38,6 +38,8 @@ url(_(r'^contenu\.pdf$'), views.ArticleRawPdfView.as_view(), name='article_raw_pdf'), url(_(r'^premierepage\.pdf$'), views.ArticleRawPdfFirstPageView.as_view(), name='article_raw_pdf_firstpage'), # noqa ])), + url(r'^iderudit/(?P[\w-]+)/$', + views.IdEruditArticleRedirectView.as_view(), name='iderudit_article_detail'), # Google Scholar URLs url(_(r'^scholar/'), include([ diff --git a/eruditorg/apps/public/journal/views.py b/eruditorg/apps/public/journal/views.py index fb2b00333..3908db7e4 100644 --- a/eruditorg/apps/public/journal/views.py +++ b/eruditorg/apps/public/journal/views.py @@ -7,6 +7,7 @@ from django.conf import settings from django.core.exceptions import ObjectDoesNotExist +from django.core.urlresolvers import reverse from django.db.models import Q from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 @@ -16,6 +17,7 @@ from django.utils.functional import cached_property from django.views.generic import DetailView from django.views.generic import ListView +from django.views.generic import RedirectView from django.views.generic import TemplateView from eruditarticle.objects import EruditArticle from PyPDF2 import PdfFileMerger @@ -400,6 +402,18 @@ class ArticleSummaryView(BaseArticleDetailView): template_name = 'public/journal/article_summary.html' +class IdEruditArticleRedirectView(RedirectView): + pattern_name = 'public:journal:article_detail' + + def get_redirect_url(self, *args, **kwargs): + article = get_object_or_404( + Article.objects.select_related('issue', 'issue__journal'), + localidentifier=kwargs['localid']) + return reverse(self.pattern_name, args=[ + article.issue.journal.code, article.issue.volume_slug, article.issue.localidentifier, + article.localidentifier, ]) + + class ArticleEnwCitationView(SingleArticleMixin, DetailView): """ Returns the enw file of a specific article. diff --git a/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl b/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl index 63fc07227..d19aee9f4 100644 --- a/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl +++ b/eruditorg/templates/public/journal/eruditxsd300_to_html.xsl @@ -102,8 +102,8 @@

URI
- - {{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:article_detail' journal_code=article.issue.journal.code issue_slug=article.issue.volume_slug issue_localid=article.issue.localidentifier localid=article.localidentifier %} + + {{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:iderudit_article_detail' localid=article.localidentifier %} {% trans "adresse copiée" %} {% trans "une erreur s'est produite" %}