Selaa lähdekoodia

Add support for share post plugin

Fix #24
Talha Mansoor 11 vuotta sitten
vanhempi
commit
639eca4a82

+ 4 - 1
static/css/elegant.css

@@ -150,7 +150,7 @@ div.highlight {
     font: 1.1em/1.6em 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, Sans-Serif;
 }
 /* Article */
-article p:not(#list-of-translations) a,
+article p:not(#list-of-translations):not(#post-share-links) a,
 article ol a,
 article div.article-content ul:not(.articles-timeline):not(.related-posts-list) a {
     border-bottom: thin dashed #A9A9A9;
@@ -323,6 +323,9 @@ i.fa-stack-exchange:hover {
     border: 2px solid #EEE;
     padding: 5px;
 }
+p#post-share-links {
+    text-align: right;
+}
 /* Perma link in article */
 h1:hover > a.headerlink,
 h2:hover > a.headerlink,

+ 7 - 0
templates/_includes/_defaults.html

@@ -40,3 +40,10 @@
 {% set RECENT_ARTICLES_COUNT  = RECENT_ARTICLES_COUNT  %}
 {% endif %}
 
+{# Label to show before Share Post links #}
+{% if not SHARE_POST_INTRO %}
+{% set SHARE_POST_INTRO = "Share on:" %}
+{% else %}
+{% set SHARE_POST_INTRO = SHARE_POST_INTRO %}
+{% endif %}
+

+ 22 - 0
templates/_includes/share_links.html

@@ -0,0 +1,22 @@
+{% macro share_links(article) %}
+    {% if article.share_post and article.status != 'draft' %}
+<section>
+    <p id="post-share-links">
+    {% if article.share_post_intro %}
+    {{ article.share_post_intro }}
+    {% else %}
+    {% from '_includes/_defaults.html' import SHARE_POST_INTRO with context %}
+    {{ SHARE_POST_INTRO }}
+    {% endif %}
+    <a href="{{article.share_post['twitter']}}" target="_blank" title="Share on Twitter">Twitter</a>
+    ❄
+    <a href="{{article.share_post['facebook']}}" target="_blank" title="Share on Facebook">Facebook</a>
+    ❄
+    <a href="{{article.share_post['google-plus']}}" target="_blank" title="Share on Google Plus">Google+</a>
+    ❄
+    <a href="{{article.share_post['email']}}" target="_blank" title="Share via Email">Email</a>
+    </p>
+</section>
+    {% endif %}
+{% endmacro %}
+

+ 2 - 0
templates/article.html

@@ -40,6 +40,8 @@
             {% import '_includes/translations.html' as translations with context %}
             {{ translations.translations_for(article) }}
             {{ article.content }}
+            {% from '_includes/share_links.html' import share_links with context %}
+            {{ share_links(article) }}
             {% from '_includes/comments.html' import comments with context %}
             {{ comments(article) }}
             <hr/>