Skip to content

Commit

Permalink
Add social sharing buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlinares committed Jun 24, 2014
1 parent ee16a0d commit 6aabec3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
29 changes: 29 additions & 0 deletions _includes/sharing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=YOUR_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>

<script type="text/javascript">
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
2 changes: 2 additions & 0 deletions _includes/themes/twitter/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ <h1>{{ page.title }} {% if page.tagline %}<small>{{page.tagline}}</small>{% endi
</ul>
{% endunless %}

{{ page.url | share_buttons }}

<hr>
<div class="pagination">
<ul>
Expand Down
35 changes: 35 additions & 0 deletions _plugins/share_buttons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Jekyll
module ShareButtonsFilter
def share_buttons url
full_url = @context.registers[:site].config['production_url'] + url

<<-HTML
<div class="buttons">
<div class="fb-like"
data-href="#{full_url}"
data-send="true"
data-layout="button_count"
data-width="90"
data-show-faces="false">
</div>
<a href="https://twitter.com/share"
class="twitter-share-button"
data-url="#{full_url}"
data-lang="en">
</a>
<div class="google_plus">
<div class="g-plusone"
data-href="#{full_url}"
data-size="medium"
data-annotation="bubble">
</div>
</div>
</div>
HTML
end
end
end

Liquid::Template.register_filter Jekyll::ShareButtonsFilter
14 changes: 14 additions & 0 deletions assets/themes/twitter/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ body {
margin-bottom: 12px;
}

.buttons {
margin: 30px 0 20px 30px;
}

.fb-like {
display: inline;
margin: 0 30px 0 0;
bottom: 6px;
}

.google_plus {
display: inline;
}

/* Custom container */
.container-narrow {
margin: 0 auto;
Expand Down

0 comments on commit 6aabec3

Please sign in to comment.