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

Fixes and enhancements. [11] #1649

Merged
merged 26 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8480df6
Merge pull request #11 from iissnan/master
ivan-nginx May 3, 2017
d3b4b15
ADD: TOC to Pages.
ivan-nginx May 3, 2017
50dd71e
ADD: Sidebar affix on all pages.
ivan-nginx May 3, 2017
7d5abe7
ADD: Sidebar affix on home page.
ivan-nginx May 3, 2017
7c02491
FIX: tags & categories H1 left margin.
ivan-nginx May 6, 2017
4912038
ADD: Sidebar affix on all pages (global).
ivan-nginx May 15, 2017
f2d6a60
FIX: move affix to global renderer (_layout).
ivan-nginx May 15, 2017
618a2b4
FIX: move affix to global renderer (_layout).
ivan-nginx May 15, 2017
98c2694
ADD: separated_meta option. [1]
ivan-nginx May 16, 2017
d09b5d1
ADD: separated_meta option. [2]
ivan-nginx May 16, 2017
90e1972
ADD: separated_meta option. [3]
ivan-nginx May 16, 2017
957fbbe
ADD: separated_meta option. [4]
ivan-nginx May 16, 2017
5dd2d14
FIX: separated_meta option. [4]
ivan-nginx May 16, 2017
0d6c0f6
ADD: wrap nav lines in TOC. [1]
ivan-nginx May 16, 2017
402eb9c
ADD: wrap nav lines in TOC. [2]
ivan-nginx May 16, 2017
ec70baa
FIX: lazyload image [1].
ivan-nginx May 28, 2017
eac8d8f
ADD: lazyload image [2].
ivan-nginx May 28, 2017
3ecd980
Rename lazy-image to lazy-image.js
ivan-nginx May 28, 2017
cdd36b6
ADD: star rating widget. [1]
ivan-nginx May 31, 2017
8bc43cc
ADD: star rating widget. [2]
ivan-nginx May 31, 2017
3e06c4b
ADD: star rating widget. [3]
ivan-nginx May 31, 2017
32b1837
ADD: star rating widget. [4]
ivan-nginx May 31, 2017
a153fbf
FIX: star rating widget. [5]
ivan-nginx May 31, 2017
ede932a
ADD: star rating widget. [6]
ivan-nginx May 31, 2017
707c0bc
ADD: star rating widget. [7]
ivan-nginx May 31, 2017
5527001
ADD: star rating widget. [8]
ivan-nginx May 31, 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
11 changes: 11 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ toc:
# Automatically add list number to toc.
number: true

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


# Creative Commons 4.0 International License.
# http://creativecommons.org/
Expand Down Expand Up @@ -245,6 +248,7 @@ post_wordcount:
item_text: true
wordcount: false
min2read: false
separated_meta: true

# Wechat Subscriber
#wechat_subscriber:
Expand Down Expand Up @@ -400,6 +404,13 @@ vkontakte_api:
comments: true
num_of_posts: 10

# Star rating support to each article.
# To get your ID visit https://widgetpack.com
rating:
enable: false
id: #<app_id>
color: fc6423


# Show number of visitors to each article.
# You can visit https://leancloud.cn get AppID and AppKey.
Expand Down
5 changes: 4 additions & 1 deletion layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@
{% set scheme_script = '_scripts/schemes/' + theme.scheme | lower + '.swig' %}
{% include scheme_script %}

{% block script_extra %}{% endblock %}
{% block script_extra %}
{% include '_scripts/pages/post-details.swig' %}
{% endblock %}

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

{% include '_third-party/comments/index.swig' %}
{% include '_third-party/search/index.swig' %}
{% include '_third-party/analytics/lean-analytics.swig' %}
{% include '_third-party/seo/baidu-push.swig' %}
{% include '_third-party/rating.swig' %}
{% include '_third-party/mathjax.swig' %}
{% include '_third-party/scroll-cookie.swig' %}
{% include '_third-party/exturl.swig' %}
Expand Down
14 changes: 12 additions & 2 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@
{% if theme.post_wordcount.wordcount or theme.post_wordcount.min2read %}
<div class="post-wordcount">
{% if theme.post_wordcount.wordcount %}
<span class="post-meta-divider">|</span>
{% if not theme.post_wordcount.separated_meta %}
<span class="post-meta-divider">|</span>
{% endif %}
<span class="post-meta-item-icon">
<i class="fa fa-file-word-o"></i>
</span>
Expand Down Expand Up @@ -337,7 +339,14 @@
</div>
{% endif %}

{% if not is_index %}
{% 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) %}
<div class="post-widgets">
{% if theme.rating.enable %}
<div class="wp_rating">
<div id="wpac-rating"></div>
</div>
{% endif %}

{% if (theme.vkontakte_api.enable and theme.vkontakte_api.like) or (theme.facebook_sdk.enable and theme.facebook_sdk.like_button) %}
<div class="social-like">
{% if theme.vkontakte_api.enable and theme.vkontakte_api.like %}
Expand All @@ -353,6 +362,7 @@
{% endif %}
</div>
{% endif %}
</div>
{% endif %}

{% if not is_index and (post.prev or post.next) %}
Expand Down
2 changes: 1 addition & 1 deletion layout/_macro/sidebar.swig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">

{% set display_toc = is_post and theme.toc.enable %}
{% set display_toc = is_post and theme.toc.enable or is_page and theme.toc.enable %}

{% if display_toc and toc(page.content).length > 1 %}
<ul class="sidebar-nav motion-element">
Expand Down
18 changes: 18 additions & 0 deletions layout/_third-party/rating.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% if theme.rating.enable and (not is_home() and is_post()) %}
<script type="text/javascript">
wpac_init = window.wpac_init || [];
wpac_init.push({widget: 'Rating', id: {{ theme.rating.id }},
el: 'wpac-rating',
color: '{{ theme.rating.color }}'
});
(function() {
if ('WIDGETPACK_LOADED' in window) return;
WIDGETPACK_LOADED = true;
var mc = document.createElement('script');
mc.type = 'text/javascript';
mc.async = true;
mc.src = '//embed.widgetpack.com/widget.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
})();
</script>
{% endif %}
2 changes: 2 additions & 0 deletions layout/page.swig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#}{% endif %}{#
#}{% endblock %}

{% block page_class %}page-post-detail{% endblock %}

{% block content %}

<div id="posts" class="posts-expand">
Expand Down
26 changes: 26 additions & 0 deletions scripts/tags/lazy-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* global hexo */
// Usage: {% lazyimage /path/to/image, alt, title %}
// Alias: {% li /path/to/image, alt, title %}

function lazyImage(args) {
args = args.join(' ').split(',');
var src = args[0];
var alt = args[1] || '';
var title = args[2] || '';

if (!src) {
hexo.log.warn('Image src can NOT be empty');
}
alt = alt.trim();
title = title.trim();

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"'];

Choose a reason for hiding this comment

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

Line is too long.

Choose a reason for hiding this comment

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

Line is too long.

alt.length > 0 && image.push('alt="' + alt + '"');
title.length > 0 && image.push('title="' + title + '"');
image.push('/><meta itemprop="width" content="auto"><meta itemprop="height" content="auto"></span>');

return image.join(' ');
}

hexo.extend.tag.register('lazyimage', lazyImage);
hexo.extend.tag.register('li', lazyImage);
2 changes: 1 addition & 1 deletion source/css/_common/components/post/post-collapse.styl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
position: relative;
margin: 60px 0;

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

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

Expand Down
22 changes: 0 additions & 22 deletions source/css/_common/components/post/post-meta.styl
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,3 @@
.posts-expand .post-comments-count {
+mobile() { display: none; }
}
.social-like {
font-size: 14px;
height: 20px;
text-align: center;
border-top: 1px solid #eee;
padding-top: 9px;
margin-top: 45px;
display: flex;
justify-content: center;
}

.vk_like {
width: 85px;
height: 21px;
padding-top: 7px;
align-self: center;
}

.fb_like {
height: 30px;
align-self: center;
}
36 changes: 36 additions & 0 deletions source/css/_common/components/post/post-widgets.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.post-widgets {
border-top: 1px solid #eee;
padding-top: 9px;
margin-top: 45px;
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}

.wp_rating {
height: 20px;
margin-right: 10px;
text-align: center;
line-height: 20px;
padding-top: 6px;
}

.social-like {
font-size: 14px;
text-align: center;
display: flex;
justify-content: center;
}

.vk_like {
width: 85px;
height: 21px;
padding-top: 7px;
align-self: center;
}

.fb_like {
height: 30px;
align-self: center;
}
3 changes: 3 additions & 0 deletions source/css/_common/components/post/post-wordcount.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.post-wordcount {
display: inline-block;
}
4 changes: 3 additions & 1 deletion source/css/_common/components/post/post.styl
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
@import "post-eof";
@import "post-gallery";
@import "post-reward" if hexo-config('alipay') or hexo-config('wechatpay');
@import "post-copyright.styl" if hexo-config('post_copyright.enable')
@import "post-copyright" if hexo-config('post_copyright.enable');
@import "post-wordcount" if !hexo-config('post_wordcount.separated_meta');
@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');
2 changes: 1 addition & 1 deletion source/css/_common/components/sidebar/sidebar-toc.styl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
.post-toc .nav-item {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
white-space: nowrap if !hexo-config('toc.wrap');
line-height: 1.8;
}

Expand Down
8 changes: 5 additions & 3 deletions source/js/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ NexT.utils = NexT.$u = {
var $imageWrapLink = $image.parent('a');

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

Choose a reason for hiding this comment

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

Line is too long.

Choose a reason for hiding this comment

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

Line is too long.

$imageWrapLink = $image.wrap('<a href="' + imageLink + '"></a>').parent('a');
}

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

lazyLoadPostsImages: function () {
$('#posts').find('img').lazyload({
placeholder: '/images/loading.gif',
effect: 'fadeIn'
//placeholder: '/images/loading.gif',
effect: 'fadeIn',
threshold : 0
});
},

Expand Down