Skip to content
Snippets Groups Projects
Verified Commit 9254684c authored by jindra12's avatar jindra12
Browse files

Fix links to shared articles

parent c0cee02a
No related branches found
No related tags found
2 merge requests!816Release,!801Prepare basic shared tags
......@@ -3,29 +3,17 @@
<div>
<div class="flex max-w-md items-start xl:mr-2">
{% image article_item.image fill-144x144 as image %}
{% if article.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}" rel="noindex" class="mr-4 shrink-0">
{% else %}
<a href="{{ article_item.url }}" class="mr-4 shrink-0">
{% endif %}
<a href="{{ article_item.get_url }}" {{ article_item.get_rel }} class="mr-4 shrink-0">
<img src="{{ image.url }}"
alt=""
class="w-16 xl:w-36">
</a>
<div class="flex flex-col justify-between items-start">
<span class="text-green-500 mb-2">{{ article_item.date | date }}</span>
{% if article.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}" rel="noindex" class="font-alt leading-5 text-base uppercase lg:text-base mb-2">
{% else %}
<a href="{{ article_item.url }}" class="font-alt leading-5 text-base uppercase lg:text-base mb-2">
{% endif %}
<a href="{{ article_item.get_url }}" {{ article_item.get_rel }} class="font-alt leading-5 text-base uppercase lg:text-base mb-2">
{{ article_item.title }}
</a>
{% if article_item.shared_from %}
{% include 'main/includes/href_button.html' with btn_link="{{ page.url }}sdilene?sdilene={{ article_item.slug|urlencode }}" btn_text="Zjistit více" noindex=True %}
{% else %}
{% include 'main/includes/href_button.html' with btn_link=article_item.url btn_text="Zjistit více" %}
{% endif %}
{% include 'main/includes/href_button.html' with btn_link=article_item.get_url noindex=article_item.get_no_index btn_text="Zjistit více" %}
</div>
</div>
</div>
......
......@@ -20,12 +20,7 @@
<span class="bg-violet-600 mb-1 mr-1 px-2 py-2">{{ tag }}</span>
{% endfor %}
</div>
{% if article_page.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article_page.slug|urlencode }}" rel="noindex">
{% else %}
<a href="{{ article_page.url }}">
{% endif %}
<a href="{{ article_page.get_url }}">
<h4 class="head-3xl mb-4">
{{ article_page.title }}
</h4>
......@@ -33,11 +28,7 @@
<p class="mb-6">
{{ article_page.perex }}
</p>
{% if article_page.shared_from %}
{% include 'main/includes/href_button.html' with btn_link="{{ page.url }}sdilene?sdilene={{ article_page.slug|urlencode }}" btn_text="Číst dále" noindex=True %}
{% else %}
{% include 'main/includes/href_button.html' with btn_link=article_page.url btn_text="Číst dále" %}
{% endif %}
{% include 'main/includes/href_button.html' with btn_link=article_page.get_url noindex=article_page.get_no_index btn_text="Číst dále" %}
</div>
</div>
{% endfor %}
......@@ -13,11 +13,7 @@
<h4 class="font-alt leading-5 text-base uppercase lg:text-base mb-2">
{{ article_page.title }}
</h4>
{% if article_page.shared_from %}
{% include 'main/includes/href_button.html' with btn_link="{{ page.url }}sdilene?sdilene={{ article_page.slug|urlencode }}" btn_text="Číst dále" noindex=True %}
{% else %}
{% include 'main/includes/href_button.html' with btn_link=article_page.url btn_text="Číst dále" %}
{% endif %}
{% include 'main/includes/href_button.html' with btn_link=article_page.get_url noindex=article_page.get_no_index btn_text="Číst dále" %}
</div>
</div>
{% endfor %}
......@@ -2,6 +2,7 @@ import logging
from collections import namedtuple
from enum import Enum
from functools import reduce
from urllib.parse import quote
from django.apps import apps
from django.core.paginator import Paginator
......@@ -101,6 +102,32 @@ class ArticleMixin(models.Model):
class Meta:
abstract = True
@property
def get_no_index(self):
"""
Indicates that a link should contain rel="noindex"
"""
return self.shared_from is not None
@property
def get_rel(self):
"""
Returns "rel" property for a link to this article
"""
return 'rel="noindex"' if self.no_index else ""
@property
def get_url(self):
if self.shared_from is not None:
return f"{self.shared_from.url}/sdilene?sdilene={quote(self.slug)}"
return self.url
@property
def get_full_url(self):
if self.shared_from is not None:
return f"{self.shared_from.url}/sdilene?sdilene={quote(self.slug)}"
return self.full_url
@property
def articles_page(self):
return (
......
......@@ -7,18 +7,10 @@
itemscope=""
>
{% if article.shared_from %}
<link itemprop="mainEntityOfPage" href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}">
{% else %}
<link itemprop="mainEntityOfPage" href="{{ article.url }}">
{% endif %}
<link itemprop="mainEntityOfPage" href="{{ article.get_url }}">
<div class="article-card-cover">
{% if article.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}" rel="noindex" itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% else %}
<a href="{{ article.url }}" itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% endif %}
<a href="{{ article.get_url }}" {{ article.get_rel }} itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% if article.thumb_image %}
{% image article.thumb_image fill-356x192 as img %}
{% image article.thumb_image fill-714x384 as img_2x %}
......@@ -38,17 +30,17 @@
<div class="article-card-sharing">
<div class="social-icon-group">
<a
href="https://www.facebook.com/sharer/sharer.php?u={{ article.url|urlencode }}"
href="https://www.facebook.com/sharer/sharer.php?u={{ article.get_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-facebook text-white text-sm social-icon--4"
><i class="ico--facebook"></i></a>
<a
href="https://twitter.com/intent/tweet?text={{ article.title|urlencode }}&url={{ article.url|urlencode }}"
href="https://twitter.com/intent/tweet?text={{ article.title|urlencode }}&url={{ article.get_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-twitter text-white text-sm social-icon--4"
><i class="ico--twitter"></i></a>
<a
href="https://www.linkedin.com/sharing/share-offsite/?url={{ article.full_url|urlencode }}"
href="https://www.linkedin.com/sharing/share-offsite/?url={{ article.get_full_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-linkedin text-white text-sm social-icon--4">
<i class="ico--linkedin"></i>
......@@ -72,11 +64,7 @@
</div>
<div class="card__body article-card__body{% if article.is_black %} text-white{% endif %}">
{% if article.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}" rel="noindex">
{% else %}
<a href="{{ article.url }}">
{% endif %}
<a href="{{ article.get_url }}" {{ article.get_rel }}>
<h1 class="card-headline mb-4">
{{ article.title }}
</h1>
......
......@@ -4,11 +4,7 @@
<link itemprop="mainEntityOfPage" href="{% pageurl article %}">
<div class="article-card-cover">
{% if article.shared_from %}
<a href="{{ page.url }}sdilene?sdilene={{ article.slug|urlencode }}" rel="noindex" itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% else %}
<a href="{% pageurl article %}" itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% endif %}
<a href="{{ article.get_url }}" {{ article.get_rel }} itemprop="image" itemtype="http://schema.org/ImageObject" itemscope="">
{% image article.image width-800 as img %}
<img src="{{ img.url }}" alt="{{ article.title }}">
<meta itemprop="url" content="{{ img.url }}">
......@@ -17,12 +13,12 @@
<div class="article-card-sharing">
<div class="social-icon-group ">
<a
href="https://www.facebook.com/sharer/sharer.php?u={{ article.full_url|urlencode }}"
href="https://www.facebook.com/sharer/sharer.php?u={{ article.get_full_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-facebook text-white text-sm social-icon--4"
><i class="ico--facebook"></i></a>
<a
href="https://twitter.com/intent/tweet?text={{ article.title|urlencode }}&url={{ article.full_url|urlencode }}"
href="https://twitter.com/intent/tweet?text={{ article.title|urlencode }}&url={{ article.get_full_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-twitter text-white text-sm social-icon--4"
><i class="ico--twitter"></i></a>
......@@ -40,7 +36,7 @@
</div>
<div class="card__body article-card__body">
<a href="{% pageurl article %}">
<a href="{{ article.get_url }}" {{ article.get_rel }}>
<h1 class="card-headline mb-4">{{ article.title }}</h1>
</a>
<p class="card-body-text flex-grow">{{ article.perex }}</p>
......
......@@ -5,7 +5,7 @@
<article itemtype="http://schema.org/BlogPosting" itemscope="">
<header>
<link itemprop="mainEntityOfPage" href="{% pageurl page %}">
<link itemprop="mainEntityOfPage" href="{{ page.get_url }}">
<meta itemprop="datePublished" content="{{ page.first_published_at }}">
<meta itemprop="dateModified" content="{{ page.last_published_at }}">
......@@ -49,7 +49,7 @@
<section class="mt-16 md:mt-24">
{% if related_articles %}
<h1 class="head-alt-base md:head-alt-md pb-4">Další {{ page.get_parent.title }}</h1>
<h1 class="head-alt-base md:head-alt-md pb-4">Další {{ page.articles_page.title }}</h1>
<div class="article-card-list grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8">
{% for article in related_articles %}
{% include "styleguide/2.3.x/article_card.html" %}
......@@ -58,9 +58,9 @@
{% endif %}
<div class="text-center mt-8 md:mt-16">
<a href="{% pageurl page.get_parent %}" class="btn btn--icon text-xl">
<a href="{% pageurl page.articles_page %}" class="btn btn--icon text-xl">
<div class="btn__body-wrap">
<div class="btn__body ">{{ page.get_parent.title }}</div>
<div class="btn__body ">{{ page.articles_page.title }}</div>
<div class="btn__icon ">
<i class="ico--chevron-right"></i>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment