Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Sharing providers #90

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ JB :
# Set 'provider' to false to turn sharing off globally.
#
sharing :
provider : false
enabled : true
provider :
twitter : true
facebook : true
google-plus: true

# Settings for all other include helpers can be defined by creating
# a hash with key named for the given helper. ex:
Expand Down
45 changes: 39 additions & 6 deletions _includes/JB/sharing
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
{% if site.safe and site.JB.sharing.provider and page.JB.sharing != false %}
{% comment %}<!--
The sharing include is a sharing helper for a number of providers.
Usage:
1) Include JB/sharing
2) Optionally assign the 'sharing_message_prefix' variable with a string
3) Optionally assign the 'sharing_context' variable with a context, where
"context" is a page object. Defaults to the current page if unset. See
"themes/tlvince/metabox.html" for an example.
Example:
<ul>
{% assign sharing_message_prefix = "Photo " %}
{% include JB/sharing %}
</ul>

{% case site.JB.sharing.provider %}
{% when "custom" %}
{% include custom/sharing %}
{% endcase %}
This help can be seen in use in the "tlvince" theme by Tom Vincent:
https://github.com/tlvince/jb-theme-tlvince
-->{% endcomment %}

{% endif %}
{% if site.JB.sharing.enabled %}

{% if sharing_context %}
{% assign page = sharing_context %}
{% endif %}

{% capture sharing_url %}{{ site.production_url }}{{ page.url }}/{% endcapture %}
{% capture sharing_prefix %}Share "{{ page.title }}" on{% endcapture %}

{% if site.JB.sharing.provider.twitter %}
{% capture sharing_title %}{{ sharing_prefix }} Twitter{% endcapture %}
{% include JB/sharing-providers/twitter %}
{% endif %}
{% if site.JB.sharing.provider.facebook %}
{% capture sharing_title %}{{ sharing_prefix }} Facebook{% endcapture %}
{% include JB/sharing-providers/facebook %}
{% endif %}
{% if site.JB.sharing.provider.google-plus %}
{% capture sharing_title %}{{ sharing_prefix }} Google Plus{% endcapture %}
{% include JB/sharing-providers/google-plus %}
{% endif %}

{% endif %}
3 changes: 3 additions & 0 deletions _includes/JB/sharing-providers/facebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li><a href='https://www.facebook.com/sharer.php?u={{ sharing_url }}'
title='{{ sharing_title }}'>
<i class="icon-facebook-alt icon-large"></i></a>
3 changes: 3 additions & 0 deletions _includes/JB/sharing-providers/google-plus
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li><a href='https://plus.google.com/share?url={{ sharing_url }}'
title='{{ sharing_title }}'>
<i class="icon-google-plus icon-large"></i></a>
5 changes: 5 additions & 0 deletions _includes/JB/sharing-providers/twitter
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<li><a href='https://twitter.com/intent/tweet?text=
{% if sharing_message_prefix %}{{ sharing_message_prefix }}{% endif %}
"{{ page.title }}" by {{ site.author.name }} (@{{ site.author.twitter }})
&url={{ sharing_url }}' title='{{ sharing_title }}'>
<i class="icon-twitter-alt icon-large"></i></a>