Skip to content

Commit

Permalink
add: Share Tool "AddThis"
Browse files Browse the repository at this point in the history
http://www.addthis.com/

AddThis supports HTTPS

Closes #47
  • Loading branch information
MOxFIVE committed Apr 2, 2016
1 parent 20b2e4f commit 4017757
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 46 deletions.
8 changes: 7 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ fancybox: true
mathjax: false

# Socail Share | 是否开启分享
share: true
share:
on: true
baidu: true
addthis: false
addthis_pubid: "ra-56ff76c972fc0cf9"
## Go to www.addthis.com/dashboard to get your pubid (in src of Code)
## and customize AddThis share buttons

# 百度、谷歌站长验证。填写 HTML 标签 content
# Site Verification for Google and Baidu. HTML label content.
Expand Down
3 changes: 2 additions & 1 deletion layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
<% if (!index && ((post.toc != false && !is_page() && theme.toc) || post.toc)){ %>
<%- partial('_partial/toc') %>
<% } %>
<% if (!index && theme.share){ %>

<% if (!index && theme.share.on && (post.share != false || post.share)){ %>
<%- partial('post/share') %>
<% } %>

Expand Down
4 changes: 4 additions & 0 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
</script>
<% } %>

<% if (theme.share.on && theme.share.addthis){ %>
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<%-theme.share.addthis_pubid%>"></script>
<% } %>

<% if (theme.baidu_tongji){ %>
<script>
var _hmt = _hmt || [];
Expand Down
16 changes: 12 additions & 4 deletions layout/_partial/post/share.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<% if (theme.share) { %>
<div class="share">

<div class="share">
<% if (theme.share.baidu) { %>
<div class="bdsharebuttonbox">
<li id="bds_twi"><a href="#" class="bds_twi" data-cmd="twi" title="分享到推特"></a></li>
<li id="bds_tsina"><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a></li>
Expand All @@ -13,5 +14,12 @@
window._bd_share_config={
"common":{"bdSnsKey":{},"bdText":"<%- post.title %> | <%- config.title %> ","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
</script>
</div>
<% } %>
<% } %>

<% if (theme.share.addthis) { %>
<div class="addthis_sharing_toolbox"></div>
<% } %>
</div>



85 changes: 47 additions & 38 deletions source/css/_partial/share.styl
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
baidu-share = hexo-config("share.baidu")
addthis-share = hexo-config("share.addthis")

.share
padding-left 40px
margin 1em auto .5em
opacity .5
&:hover
opacity 1

.bdsharebuttonbox
font-family Arial
li
display inline-block
width 28px
height @width
margin-right 2px
font 20px FontAwesome
background #6f7170
text-align center
vertical-align middle
box-shadow 1px 1px 1px rgba(0,0,0, .1), 1px 1px 1px rgba(0,0,0, .3)
a, .bds_more
float none
margin 0
padding 0
font @font
background-image none
color white
line-height @width
if baidu-share
.bdsharebuttonbox
font-family Arial
li
display inline-block
width 28px
height @width
margin-right 2px
font 20px FontAwesome
background #6f7170
text-align center
vertical-align middle
box-shadow 1px 1px 1px rgba(0,0,0, .1), 1px 1px 1px rgba(0,0,0, .3)
a, .bds_more
float none
margin 0
padding 0
font @font
background-image none
color white
line-height @width
&:hover
opacity 1
&:hover
opacity 1
&:hover
opacity 1
transform scale(1.1)
a
color white
transform scale(1.1)
a
color white

// http://share.baidu.com/help/webid
font-logo = bds_tsina f18a #db332f,
bds_sqq f1d6 #1cbcef,
bds_copy f016 #8f8f8f,
bds_mail f003 #6fc0e4,
bds_weixin f1d7 #8cdc49,
bds_more f1e0 #8cbcf5,
bds_twi f099 #21abf4
// http://share.baidu.com/help/webid
font-logo = bds_tsina f18a #db332f,
bds_sqq f1d6 #1cbcef,
bds_copy f016 #8f8f8f,
bds_mail f003 #6fc0e4,
bds_weixin f1d7 #8cdc49,
bds_more f1e0 #8cbcf5,
bds_twi f099 #21abf4

for i in font-logo
.{i[0]}:before
content '\' + i[1]
#{i[0]}
background i[2]
for i in font-logo
.{i[0]}:before
content '\' + i[1]
#{i[0]}
background i[2]

if addthis-share
.addthis_sharing_toolbox
margin-top .5em
margin-left -2px
4 changes: 3 additions & 1 deletion source/css/_variables.styl
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ archives-color = rgba(255,255,255,.4)

root-url = hexo-config("root_url")
i-opacity = .75
toc-top = 378px
toc-top = 378px

share = hexo-config("share.on")
5 changes: 4 additions & 1 deletion source/css/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ a {
@import "_partial/archive"
@import "_partial/highlight"
@import "_partial/footer"
@import "_partial/share"

if share
@import "_partial/share"

@import "_partial/page"
@import "_partial/instagram"
@import "_partial/tagcloud"
Expand Down

1 comment on commit 4017757

@MOxFIVE
Copy link
Owner Author

@MOxFIVE MOxFIVE commented on 4017757 Apr 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddThis Sharing Buttons:
snip20160402_5

Please sign in to comment.