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 19 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
4 changes: 4 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
4 changes: 3 additions & 1 deletion layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
{% 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' %}

Expand Down
4 changes: 3 additions & 1 deletion 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
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
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;
}
3 changes: 2 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,5 @@
@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');
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