From a40c48a79284b0c4b001522e268ec6b513220cb9 Mon Sep 17 00:00:00 2001 From: Krophil Date: Tue, 12 Sep 2017 16:40:28 +0200 Subject: [PATCH] Add facebook button --- com/models.py | 3 +++ com/templates/com/news_detail.jinja | 4 +++- core/static/core/style.scss | 17 +++++++++++++++++ core/templates/core/macros.jinja | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/com/models.py b/com/models.py index df904cd9..1bdc6e20 100644 --- a/com/models.py +++ b/com/models.py @@ -81,6 +81,9 @@ class News(models.Model): def get_absolute_url(self): return reverse('com:news_detail', kwargs={'news_id': self.id}) + def get_full_url(self): + return "https://" + settings.SITH_URL + self.get_absolute_url() + def __str__(self): return "%s: %s" % (self.type, self.title) diff --git a/com/templates/com/news_detail.jinja b/com/templates/com/news_detail.jinja index fe73a343..00d2e91a 100644 --- a/com/templates/com/news_detail.jinja +++ b/com/templates/com/news_detail.jinja @@ -1,5 +1,5 @@ {% extends "core/base.jinja" %} -{% from 'core/macros.jinja' import user_profile_link %} +{% from 'core/macros.jinja' import user_profile_link, facebook_share %} {% block title %} {% trans %}News{% endtrans %} - @@ -29,6 +29,8 @@ {% if user.can_edit(news) %}

{% trans %}Edit (will be remoderated){% endtrans %}

{% endif %} +
+ {{ facebook_share(news) }} {% endblock %} diff --git a/core/static/core/style.scss b/core/static/core/style.scss index 513005b9..3a0ad93a 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -23,6 +23,7 @@ $secondary-neutral-dark-color: hsl(40, 57.6%, 17%); $white-color: hsl(219.6, 20.8%, 98%); $black-color: hsl(40.0, 0%, 17%); +$faceblue : #3B5998; @@ -399,6 +400,22 @@ header { } } +.fb-share-button { + background: $faceblue; + border: none; + color: white; + padding: 0.5em 1em; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + border-radius: 2px; +} + +.fb-share-button:hover { + color: lightgrey; +} + .helptext { display: block; } diff --git a/core/templates/core/macros.jinja b/core/templates/core/macros.jinja index 9be68685..e0ec2f32 100644 --- a/core/templates/core/macros.jinja +++ b/core/templates/core/macros.jinja @@ -12,6 +12,10 @@ {%- endmacro %} +{% macro facebook_share(news) -%} +{% trans %}Share on Facebook{% endtrans %} +{%- endmacro %} + {% macro user_mini_profile(user) %}