Skip to content

Commit 8984276

Browse files
authored
Merge pull request #1649 from ivan-nginx/master
Fixes and enhancements. [11]
2 parents 02bd529 + 5527001 commit 8984276

File tree

14 files changed

+123
-32
lines changed

14 files changed

+123
-32
lines changed

_config.yml

+11
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ toc:
171171
# Automatically add list number to toc.
172172
number: true
173173

174+
# If true, all words will placed on next lines if header width longer then sidebar width.
175+
wrap: false
176+
174177

175178
# Creative Commons 4.0 International License.
176179
# http://creativecommons.org/
@@ -245,6 +248,7 @@ post_wordcount:
245248
item_text: true
246249
wordcount: false
247250
min2read: false
251+
separated_meta: true
248252

249253
# Wechat Subscriber
250254
#wechat_subscriber:
@@ -400,6 +404,13 @@ vkontakte_api:
400404
comments: true
401405
num_of_posts: 10
402406

407+
# Star rating support to each article.
408+
# To get your ID visit https://widgetpack.com
409+
rating:
410+
enable: false
411+
id: #<app_id>
412+
color: fc6423
413+
403414

404415
# Show number of visitors to each article.
405416
# You can visit https://leancloud.cn get AppID and AppKey.

layout/_layout.swig

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,17 @@
6767
{% set scheme_script = '_scripts/schemes/' + theme.scheme | lower + '.swig' %}
6868
{% include scheme_script %}
6969

70-
{% block script_extra %}{% endblock %}
70+
{% block script_extra %}
71+
{% include '_scripts/pages/post-details.swig' %}
72+
{% endblock %}
7173

7274
{% include '_scripts/boostrap.swig' %}
7375

7476
{% include '_third-party/comments/index.swig' %}
7577
{% include '_third-party/search/index.swig' %}
7678
{% include '_third-party/analytics/lean-analytics.swig' %}
7779
{% include '_third-party/seo/baidu-push.swig' %}
80+
{% include '_third-party/rating.swig' %}
7881
{% include '_third-party/mathjax.swig' %}
7982
{% include '_third-party/scroll-cookie.swig' %}
8083
{% include '_third-party/exturl.swig' %}

layout/_macro/post.swig

+12-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@
207207
{% if theme.post_wordcount.wordcount or theme.post_wordcount.min2read %}
208208
<div class="post-wordcount">
209209
{% if theme.post_wordcount.wordcount %}
210-
<span class="post-meta-divider">|</span>
210+
{% if not theme.post_wordcount.separated_meta %}
211+
<span class="post-meta-divider">|</span>
212+
{% endif %}
211213
<span class="post-meta-item-icon">
212214
<i class="fa fa-file-word-o"></i>
213215
</span>
@@ -337,7 +339,14 @@
337339
</div>
338340
{% endif %}
339341

340-
{% if not is_index %}
342+
{% if not is_index and (theme.rating.enable) or (theme.vkontakte_api.enable and theme.vkontakte_api.like) or (theme.facebook_sdk.enable and theme.facebook_sdk.like_button) %}
343+
<div class="post-widgets">
344+
{% if theme.rating.enable %}
345+
<div class="wp_rating">
346+
<div id="wpac-rating"></div>
347+
</div>
348+
{% endif %}
349+
341350
{% if (theme.vkontakte_api.enable and theme.vkontakte_api.like) or (theme.facebook_sdk.enable and theme.facebook_sdk.like_button) %}
342351
<div class="social-like">
343352
{% if theme.vkontakte_api.enable and theme.vkontakte_api.like %}
@@ -353,6 +362,7 @@
353362
{% endif %}
354363
</div>
355364
{% endif %}
365+
</div>
356366
{% endif %}
357367

358368
{% if not is_index and (post.prev or post.next) %}

layout/_macro/sidebar.swig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<aside id="sidebar" class="sidebar">
1111
<div class="sidebar-inner">
1212

13-
{% set display_toc = is_post and theme.toc.enable %}
13+
{% set display_toc = is_post and theme.toc.enable or is_page and theme.toc.enable %}
1414

1515
{% if display_toc and toc(page.content).length > 1 %}
1616
<ul class="sidebar-nav motion-element">

layout/_third-party/rating.swig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% if theme.rating.enable and (not is_home() and is_post()) %}
2+
<script type="text/javascript">
3+
wpac_init = window.wpac_init || [];
4+
wpac_init.push({widget: 'Rating', id: {{ theme.rating.id }},
5+
el: 'wpac-rating',
6+
color: '{{ theme.rating.color }}'
7+
});
8+
(function() {
9+
if ('WIDGETPACK_LOADED' in window) return;
10+
WIDGETPACK_LOADED = true;
11+
var mc = document.createElement('script');
12+
mc.type = 'text/javascript';
13+
mc.async = true;
14+
mc.src = '//embed.widgetpack.com/widget.js';
15+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
16+
})();
17+
</script>
18+
{% endif %}

layout/page.swig

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#}{% endif %}{#
1414
#}{% endblock %}
1515

16+
{% block page_class %}page-post-detail{% endblock %}
17+
1618
{% block content %}
1719

1820
<div id="posts" class="posts-expand">

scripts/tags/lazy-image.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* global hexo */
2+
// Usage: {% lazyimage /path/to/image, alt, title %}
3+
// Alias: {% li /path/to/image, alt, title %}
4+
5+
function lazyImage(args) {
6+
args = args.join(' ').split(',');
7+
var src = args[0];
8+
var alt = args[1] || '';
9+
var title = args[2] || '';
10+
11+
if (!src) {
12+
hexo.log.warn('Image src can NOT be empty');
13+
}
14+
alt = alt.trim();
15+
title = title.trim();
16+
17+
var image = ['<span itemprop="image" itemscope itemtype="http://schema.org/ImageObject"><img itemprop="url image" src="/images/loading.gif" data-original="' + src + '" class="full-image"'];
18+
alt.length > 0 && image.push('alt="' + alt + '"');
19+
title.length > 0 && image.push('title="' + title + '"');
20+
image.push('/><meta itemprop="width" content="auto"><meta itemprop="height" content="auto"></span>');
21+
22+
return image.join(' ');
23+
}
24+
25+
hexo.extend.tag.register('lazyimage', lazyImage);
26+
hexo.extend.tag.register('li', lazyImage);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
position: relative;
3636
margin: 60px 0;
3737

38-
h2 { margin-left: 20px; }
38+
h1, h2 { margin-left: 20px; }
3939

4040
small { color: $grey; margin-left: 5px; }
4141

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

-22
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,3 @@
4747
.posts-expand .post-comments-count {
4848
+mobile() { display: none; }
4949
}
50-
.social-like {
51-
font-size: 14px;
52-
height: 20px;
53-
text-align: center;
54-
border-top: 1px solid #eee;
55-
padding-top: 9px;
56-
margin-top: 45px;
57-
display: flex;
58-
justify-content: center;
59-
}
60-
61-
.vk_like {
62-
width: 85px;
63-
height: 21px;
64-
padding-top: 7px;
65-
align-self: center;
66-
}
67-
68-
.fb_like {
69-
height: 30px;
70-
align-self: center;
71-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.post-widgets {
2+
border-top: 1px solid #eee;
3+
padding-top: 9px;
4+
margin-top: 45px;
5+
display: flex;
6+
justify-content: center;
7+
flex-wrap: wrap;
8+
align-items: center;
9+
}
10+
11+
.wp_rating {
12+
height: 20px;
13+
margin-right: 10px;
14+
text-align: center;
15+
line-height: 20px;
16+
padding-top: 6px;
17+
}
18+
19+
.social-like {
20+
font-size: 14px;
21+
text-align: center;
22+
display: flex;
23+
justify-content: center;
24+
}
25+
26+
.vk_like {
27+
width: 85px;
28+
height: 21px;
29+
padding-top: 7px;
30+
align-self: center;
31+
}
32+
33+
.fb_like {
34+
height: 30px;
35+
align-self: center;
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.post-wordcount {
2+
display: inline-block;
3+
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@
4444
@import "post-eof";
4545
@import "post-gallery";
4646
@import "post-reward" if hexo-config('alipay') or hexo-config('wechatpay');
47-
@import "post-copyright.styl" if hexo-config('post_copyright.enable')
47+
@import "post-copyright" if hexo-config('post_copyright.enable');
48+
@import "post-wordcount" if !hexo-config('post_wordcount.separated_meta');
49+
@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');

source/css/_common/components/sidebar/sidebar-toc.styl

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
.post-toc .nav-item {
3434
overflow: hidden;
3535
text-overflow: ellipsis;
36-
white-space: nowrap;
36+
white-space: nowrap if !hexo-config('toc.wrap');
3737
line-height: 1.8;
3838
}
3939

source/js/src/utils.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ NexT.utils = NexT.$u = {
1414
var $imageWrapLink = $image.parent('a');
1515

1616
if ($imageWrapLink.size() < 1) {
17-
$imageWrapLink = $image.wrap('<a href="' + this.getAttribute('src') + '"></a>').parent('a');
17+
var imageLink = ($image.attr('data-original')) ? this.getAttribute('data-original') : this.getAttribute('src');
18+
$imageWrapLink = $image.wrap('<a href="' + imageLink + '"></a>').parent('a');
1819
}
1920

2021
$imageWrapLink.addClass('fancybox fancybox.image');
@@ -39,8 +40,9 @@ NexT.utils = NexT.$u = {
3940

4041
lazyLoadPostsImages: function () {
4142
$('#posts').find('img').lazyload({
42-
placeholder: '/images/loading.gif',
43-
effect: 'fadeIn'
43+
//placeholder: '/images/loading.gif',
44+
effect: 'fadeIn',
45+
threshold : 0
4446
});
4547
},
4648

0 commit comments

Comments
 (0)