Skip to content

Commit be2ce63

Browse files
authored
Merge pull request #465 from JiangTJ/reward
Reward be more intelligent, related issue #280
2 parents 2260c04 + ca64305 commit be2ce63

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

_config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,14 @@ codeblock:
323323
#description: ex. subscribe to my blog by scanning my public wechat account
324324

325325
# Reward
326-
#reward_comment: Donate comment here
327-
#wechatpay: /images/wechatpay.jpg
328-
#alipay: /images/alipay.jpg
329-
#bitcoin: /images/bitcoin.png
326+
# If true, reward would be displayed in every article by default.
327+
# And you can show or hide one article specially through add page variable `reward: true/false`.
328+
reward:
329+
enable: false
330+
#comment: Donate comment here
331+
#wechatpay: /images/wechatpay.jpg
332+
#alipay: /images/alipay.jpg
333+
#bitcoin: /images/bitcoin.png
330334

331335
# Related popular posts
332336
# Dependencies: https://github.com/tea3/hexo-related-popular-posts

layout/_macro/post.swig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,12 @@
359359
</div>
360360
{% endif %}
361361

362-
{% if (theme.alipay or theme.wechatpay or theme.bitcoin) and not is_index %}
362+
{% if page.reward === undefined and theme.reward.enable %}
363+
{% set reward_able = true %}
364+
{% else %}
365+
{% set reward_able = page.reward %}
366+
{% endif %}
367+
{% if reward_able and (theme.reward.alipay or theme.reward.wechatpay or theme.reward.bitcoin) and not is_index %}
363368
<div>
364369
{% include 'reward.swig' %}
365370
</div>

layout/_macro/reward.swig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
2-
<div>{{ theme.reward_comment }}</div>
2+
<div>{{ theme.reward.comment }}</div>
33
<button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
44
<span>{{ __('reward.donate') }}</span>
55
</button>
66
<div id="QR" style="display: none;">
77

8-
{% if theme.wechatpay %}
8+
{% if theme.reward.wechatpay %}
99
<div id="wechat" style="display: inline-block">
10-
<img id="wechat_qr" src="{{ url_for(theme.wechatpay) }}" alt="{{ author }} {{ __('reward.wechatpay') }}"/>
10+
<img id="wechat_qr" src="{{ url_for(theme.reward.wechatpay) }}" alt="{{ author }} {{ __('reward.wechatpay') }}"/>
1111
<p>{{ __('reward.wechatpay') }}</p>
1212
</div>
1313
{% endif %}
1414

15-
{% if theme.alipay %}
15+
{% if theme.reward.alipay %}
1616
<div id="alipay" style="display: inline-block">
17-
<img id="alipay_qr" src="{{ url_for(theme.alipay) }}" alt="{{ author }} {{ __('reward.alipay') }}"/>
17+
<img id="alipay_qr" src="{{ url_for(theme.reward.alipay) }}" alt="{{ author }} {{ __('reward.alipay') }}"/>
1818
<p>{{ __('reward.alipay') }}</p>
1919
</div>
2020
{% endif %}
2121

22-
{% if theme.bitcoin %}
22+
{% if theme.reward.bitcoin %}
2323
<div id="bitcoin" style="display: inline-block">
24-
<img id="bitcoin_qr" src="{{ url_for(theme.bitcoin) }}" alt="{{ author }} {{ __('reward.bitcoin') }}"/>
24+
<img id="bitcoin_qr" src="{{ url_for(theme.reward.bitcoin) }}" alt="{{ author }} {{ __('reward.bitcoin') }}"/>
2525
<p>{{ __('reward.bitcoin') }}</p>
2626
</div>
2727
{% endif %}

source/css/_common/components/post/post.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
@import "post-nav";
6060
@import "post-eof";
6161
@import "post-gallery";
62-
@import "post-reward" if hexo-config('alipay') or hexo-config('wechatpay') or hexo-config('bitcoin');
62+
@import "post-reward" if hexo-config('reward.alipay') or hexo-config('reward.wechatpay') or hexo-config('reward.bitcoin');
6363
@import "post-copyright" if hexo-config('creative_commons.post');
6464
@import "post-widgets" if (hexo-config('facebook_sdk.enable') and hexo-config('facebook_sdk.like_button')) or (hexo-config('vkontakte_api.enable') and hexo-config('vkontakte_api.like')) or hexo-config('rating.enable') or (hexo-config('needmoreshare2.enable') and hexo-config('needmoreshare2.postbottom.enable')) or hexo-config('baidushare');
6565
@import "post-rtl";

0 commit comments

Comments
 (0)