Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: A better share button NeedMoreShare2 #1913

Merged
merged 34 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c5f8ff8
Import the needsharebutton lib
LEAFERx Sep 29, 2017
83dcbb1
Add sharebutton
LEAFERx Sep 30, 2017
86daafd
Merge remote-tracking branch 'refs/remotes/iissnan/master' into need-…
LEAFERx Sep 30, 2017
b136690
change default config
LEAFERx Sep 30, 2017
11a037d
update
LEAFERx Sep 30, 2017
673aa31
Update
LEAFERx Sep 30, 2017
599b6d0
change default config
LEAFERx Sep 30, 2017
ed072f8
fix css
LEAFERx Oct 1, 2017
9edfc84
update description
LEAFERx Oct 1, 2017
721d00f
Merge branch 'need-more-share2' into button-refactor
ivan-nginx Oct 1, 2017
aaa57e7
Merge remote-tracking branch 'refs/remotes/iissnan/master' into need-…
LEAFERx Oct 3, 2017
fb1e131
Merge 2 font file into 1
LEAFERx Oct 3, 2017
0e14bae
fix font icon problem
LEAFERx Oct 3, 2017
0c8fc5a
fix click bug
LEAFERx Oct 3, 2017
c82e17f
add non-minified file
LEAFERx Oct 3, 2017
b6c1e14
add more network description
LEAFERx Oct 3, 2017
5306aaa
add seperate line and make some refactors in css
LEAFERx Oct 3, 2017
ecfbe2d
delete min file
LEAFERx Oct 3, 2017
0bc44b6
delete seperate line
LEAFERx Oct 3, 2017
b52cf5e
switch to non-min file
LEAFERx Oct 3, 2017
9b9155c
format the js
LEAFERx Oct 3, 2017
d34441f
format js
LEAFERx Oct 3, 2017
649df23
format js
LEAFERx Oct 3, 2017
59cfb1d
cut the line
LEAFERx Oct 3, 2017
4884fb0
1. Remove `$read-more*` variables.
ivan-nginx Oct 3, 2017
9e46538
Merge remote-tracking branch 'LEAFERx/need-more-share2' into button-r…
ivan-nginx Oct 3, 2017
4b62858
Auto stash before merge of "button-refactor" and "LEAFERx/need-more-s…
ivan-nginx Oct 3, 2017
89e0e10
Float button refactored.
ivan-nginx Oct 3, 2017
da94ded
remade the fontello font
LEAFERx Oct 3, 2017
cb97fe1
fix qqzone icon
LEAFERx Oct 3, 2017
a138923
delete default creation
LEAFERx Oct 3, 2017
b5dd8ed
fix blink bug
LEAFERx Oct 3, 2017
57cd8df
fix title lowercase bug
LEAFERx Oct 4, 2017
583de52
make network_lc into camel case networkLC
LEAFERx Oct 4, 2017
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
23 changes: 23 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,25 @@ valine:
# Share
#duoshuo_share: true

# NeedMoreShare2
# This plugin is a pure javascript sharing lib which is useful in China.
# See: https://github.com/revir/need-more-share2
needMoreShare2:
Copy link
Collaborator

Choose a reason for hiding this comment

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

To lowercase? (_)

postbottom:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to add global enable/disable switch for better control it.

enable: false
Options:
Copy link
Collaborator

Choose a reason for hiding this comment

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

To lowercase?

iconStyle: box
boxForm: horizontal
position: middleCenter
networks: Weibo,Wechat,Douban,QQZone,Twitter,Facebook
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mailto,Twitter,Pinterest,Facebook,GooglePlus,Reddit,Delicious,Tapiture,StumbleUpon,Linkedin,Slashdot,Technorati,Posterous,Tumblr,GoogleBookmarks,Newsvine,Pingfm,Evernote,Friendfeed,Vkontakte,Odnoklassniki,Mailru

float:
enable: false
Options:
Copy link
Collaborator

Choose a reason for hiding this comment

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

To lowercase?

iconStyle: box
boxForm: horizontal
position: middleRight
networks: Weibo,Wechat,Douban,QQZone,Twitter,Facebook
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mailto,Twitter,Pinterest,Facebook,GooglePlus,Reddit,Delicious,Tapiture,StumbleUpon,Linkedin,Slashdot,Technorati,Posterous,Tumblr,GoogleBookmarks,Newsvine,Pingfm,Evernote,Friendfeed,Vkontakte,Odnoklassniki,Mailru


# Google Webmaster tools verification setting
# See: https://www.google.com/webmasters/
#google_site_verification:
Expand Down Expand Up @@ -710,6 +729,10 @@ vendors:
# https://github.com/ethantw/Han
han:

# needMoreShare2
# https://github.com/revir/need-more-share2
needMoreShare2:


# Assets
css: css
Expand Down
5 changes: 5 additions & 0 deletions layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
</div>
{% endif %}

{% if theme.needMoreShare2.float.enable %}
{% include '_third-party/share/needsharebutton/floatdom.swig' %}
{% endif %}

</div>

{% include '_scripts/vendors.swig' %}
Expand All @@ -76,6 +80,7 @@
{% include '_third-party/search/index.swig' %}
{% include '_third-party/analytics/lean-analytics.swig' %}
{% include '_third-party/seo/baidu-push.swig' %}
{% include '_third-party/share/index.swig' %}
{% include '_third-party/rating.swig' %}
{% include '_third-party/mathjax.swig' %}
{% include '_third-party/scroll-cookie.swig' %}
Expand Down
1 change: 1 addition & 0 deletions layout/_third-party/share/index.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include 'needsharebutton/assests.swig' %}
30 changes: 30 additions & 0 deletions layout/_third-party/share/needsharebutton/assests.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% if theme.needMoreShare2.postbottom.enable or theme.needMoreShare2.float.enable %}
{% set needMoreShare2_css = url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.min.css') %}
{% if theme.vendors.needMoreShare2 %}
{% set needMoreShare2_css = theme.vendors.needMoreShare2_css %}
{% endif %}
<link rel="stylesheet" href="{{ needMoreShare2_css }}">

{% set needMoreShare2_js = url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.min.js') %}
{% if theme.vendors.needMoreShare2_js %}
{% set needMoreShare2_js = theme.vendors.needMoreShare2_js %}
{% endif %}
<script src="{{ needMoreShare2_js }}"></script>

<script>
{% if theme.needMoreShare2.postbottom.enable %}
pbOptions = {};
{% for k,v in theme.needMoreShare2.postbottom.Options %}
pbOptions.{{ k }} = "{{ v }}";
{% endfor %}
new needShareButton('#need-share-button-postbottom', pbOptions);
{% endif %}
{% if theme.needMoreShare2.float.enable %}
flOptions = {};
{% for k,v in theme.needMoreShare2.float.Options %}
flOptions.{{ k }} = "{{ v }}";
{% endfor %}
new needShareButton('#need-share-button-float', flOptions);
{% endif %}
</script>
{% endif %}
1 change: 1 addition & 0 deletions layout/_third-party/share/needsharebutton/floatdom.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="need-share-button-float"><i class="fa fa-share-alt" aria-hidden="true"></i></div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

And can u please to split this 2 files into 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is ok to use macro to identify whether it is float or postbottom?And where should i import the macro in _layout.swig and post.swig?

Copy link
Collaborator

Choose a reason for hiding this comment

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

U joking? This is floatdom.swig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make a new file called dom.swig like this:

{% macro render type %}
    <span id="needsharebutton-{{type}}"><i class="fa fa-share-alt" aria-hidden="true"></i></span>
{% endmacro %}

(maybe i reply in the wrong place...)

Copy link
Collaborator

@ivan-nginx ivan-nginx Sep 30, 2017

Choose a reason for hiding this comment

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

Seems good. But why filename dom.swig? I think filename may be simple needsharebutton.swig.
layout/_third-party/needsharebutton.swig

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span id="need-share-button-postbottom"><i class="fa fa-share-alt" aria-hidden="true"></i></span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

And can u please to split this 2 files into 1?

2 changes: 2 additions & 0 deletions layout/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
{% include '_partials/share/add-this.swig' %}
{% elseif theme.duoshuo_shortname and theme.duoshuo_share %}
{% include '_partials/share/duoshuo_share.swig' %}
{% elseif theme.needMoreShare2.postbottom.enable %}
{% include '_third-party/share/needsharebutton/postbottomdom.swig' %}
{% endif %}
</div>
</div>
Expand Down
34 changes: 34 additions & 0 deletions source/css/_common/components/third-party/needsharebutton.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#need-share-button-postbottom {
color: #000000;
background: #ffffff;
border: 1px solid #555555;
border-radius: 4px;
padding: 4px 15px;
cursor: pointer;
}

#need-share-button-postbottom:hover {
color: #ffffff;
background: #000000;
border: 1px solid #000000;
}

#need-share-button-float {
position: fixed;
bottom: 38px;
left: -7px;
z-index: 9999;
color: #555555;
background: rgba(255,255,255,0.6);
width: 35px;
cursor: pointer;
text-align: center;
border: 1px solid #999999;
border-radius: 4px;
}

#need-share-button-float:hover {
color: #ffffff;
background: #000000;
border: 1px solid #000000;
}
1 change: 1 addition & 0 deletions source/css/_common/components/third-party/third-party.styl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
@import "localsearch";
@import "busuanzi-counter";
@import "algolia-search" if hexo-config('algolia_search.enable');
@import "needsharebutton";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to add conditional import here.

1 change: 1 addition & 0 deletions source/lib/needsharebutton/needsharebutton.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/lib/needsharebutton/needsharebutton.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.