Skip to content

Commit

Permalink
✨ add share links to article page
Browse files Browse the repository at this point in the history
  • Loading branch information
krmax44 authored and pajowu committed Oct 23, 2024
1 parent 6e69180 commit c9927ca
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions fragdenstaat_de/fds_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ def get_absolute_edit_url(self):
def get_full_url(self):
return "%s%s" % (settings.SITE_URL, self.get_absolute_url())

def get_short_url(self):
return "%s%s" % (
settings.SITE_URL,
reverse("blog-redirects:article-short-url", kwargs={"pk": self.pk}),
)

def other_languages(self):
if not hasattr(self, "_other_languages"):
if self.uuid is None:
Expand Down
19 changes: 15 additions & 4 deletions fragdenstaat_de/fds_blog/templates/fds_blog/_article_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ <h1>
{% if article.teaser %}
<div class="lead">{% render_model article "teaser" "" "" "safe" %}</div>
{% endif %}
<div class="mt-5">
{% with authors=article.get_authors %}
{% include "fds_blog/includes/_authors.html" %}
{% endwith %}
<div class="d-flex mt-5 align-items-center">
<div>
{% with authors=article.get_authors %}
{% include "fds_blog/includes/_authors.html" %}
{% endwith %}
</div>
<div class="d-none d-md-block ms-auto">{% include "fds_blog/includes/share_article.html" %}</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -69,6 +72,14 @@ <h1>
{% endblock article_content %}
{% block article_footer %}
<footer class="mb-3">
<section>
<div class="container-lg">
<div class="d-md-flex align-items-center">
<h3 class="small text-secondary m-0 me-md-3">{% trans "Share article" %}</h3>
{% include "fds_blog/includes/share_article.html" %}
</div>
</div>
</section>
<section>
{% block article_author_bios %}
<div class="container-lg">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n %}
{% trans "Copy short link" as copy_text %}
{% include "snippets/share_buttons.html" with text=article.meta_title links=True url=article.get_full_url short_url=article.get_short_url copy_text=copy_text %}
2 changes: 1 addition & 1 deletion fragdenstaat_de/theme/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
*froide_urlpatterns,
*jurisdiction_urls,
*admin_urls,
path("", include("fragdenstaat_de.fds_blog.redirect_urls")),
path("", include("fragdenstaat_de.fds_blog.redirect_urls"), name="blog-redirects"),
path("", include("fragdenstaat_de.fds_ogimage.urls")),
path(pgettext_lazy("url part", "campaign/"), include(campaign_urls)),
path("", include("cms.urls")),
Expand Down

0 comments on commit c9927ca

Please sign in to comment.