Skip to content

Commit

Permalink
Merge pull request #328 from savoirfairelinux/1681-remove-hardcoded-u…
Browse files Browse the repository at this point in the history
…rls-from-xslt

Fix #1681 - Remove hardcoded URLs from the XSLT template
  • Loading branch information
cormier authored Jul 26, 2016
2 parents b62dcb1 + bf1c572 commit a15f8fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions eruditorg/apps/public/journal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<localid>[\w-]+)/$',
views.IdEruditArticleRedirectView.as_view(), name='iderudit_article_detail'),

# Google Scholar URLs
url(_(r'^scholar/'), include([
Expand Down
14 changes: 14 additions & 0 deletions eruditorg/apps/public/journal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions eruditorg/templates/public/journal/article_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
8 changes: 3 additions & 5 deletions eruditorg/templates/public/journal/eruditxsd300_to_html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<xsl:variable name="titreAbrege" select="article/admin/revue/titrerevabr"/>
<xsl:variable name="uriStart">http://id.erudit.org/iderudit/</xsl:variable>
<xsl:variable name="doiStart">http://dx.doi.org/</xsl:variable>
<xsl:variable name="urlSavant">http://erudit.org/revue/</xsl:variable>
<xsl:variable name="urlCulturel">http://erudit.org/culture/</xsl:variable>

<v:variables>
{% for imid, infoimg in article.fedora_object.infoimg_dict.items %}
Expand Down Expand Up @@ -104,8 +102,8 @@
<dl class="mono-space idpublic">
<dt>URI</dt>
<dd>
<a href="{$uriStart}{$iderudit}" class="clipboard-data">
<xsl:value-of select="$uriStart"/><xsl:value-of select="$iderudit"/>
<a href="{{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:iderudit_article_detail' localid=article.localidentifier %}" class="clipboard-data">
{{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:iderudit_article_detail' localid=article.localidentifier %}
<span class="clipboard-msg clipboard-success">{% trans "adresse copiée" %}</span>
<span class="clipboard-msg clipboard-error">{% trans "une erreur s'est produite" %}</span>
</a>
Expand All @@ -129,7 +127,7 @@
<div class="meta-journal col-sm-6 border-top">
<p>
{% blocktrans %}<xsl:apply-templates select="../article/@typeart"/> de la revue{% endblocktrans %}
<a href="{$urlSavant}{$titreAbrege}"><xsl:value-of select="admin/revue/titrerev"/></a>
<a href="{{ request.is_secure|yesno:'https,http' }}://{{ request.site.domain }}{% url 'public:journal:journal_detail' article.issue.journal.code %}"><xsl:value-of select="admin/revue/titrerev"/></a>
</p>
<p class="refpapier">
<xsl:apply-templates select="admin/numero" mode="refpapier"/>
Expand Down

0 comments on commit a15f8fb

Please sign in to comment.