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

Fixes and enhancements. [11] #1649

merged 26 commits into from
May 31, 2017

Conversation

ivan-nginx
Copy link
Collaborator

@ivan-nginx ivan-nginx commented May 3, 2017

PART 1. Some small fixes & enhancements.

Files modified:

  1. ADD: TOC to Pages. d3b4b15
  2. ADD: Sidebar affix on all pages (global). 4912038
  3. ADD: Sidebar affix on all pages. 50dd71e
  4. FIX: move affix to global renderer (_layout). f2d6a60
  5. FIX: move affix to global renderer (_layout). 618a2b4
  6. FIX: tags & categories H1 left margin. 7c02491

What's this?

  1. Add TOC to pages: How to add menu to custom navigation page ? #1638
  2. Sidebar affix on all pages.
  3. FIX: tags & categories H1 left margin: Tags are offcenter #1654

PART 2. Option for separated meta in post-wordcount.

This will add switch option to replace wordcount information block on new line or not. (#1613)

Files modified:

  1. ADD: separated_meta option. [1] 98c2694
  2. ADD: separated_meta option. [2] d09b5d1
  3. ADD: separated_meta option. [3] 90e1972
  4. ADD: separated_meta option. [4] 957fbbe
  5. FIX: separated_meta option. [4] 5dd2d14

How it looks?

image

How to use?

In Next _config.yml:

# Post wordcount display settings
# Dependies: https://github.com/willin/hexo-wordcount
post_wordcount:
...
  separated_meta: true

If true wordcount block will placed in new line. Default.
If false wordcount block will added in main meta-block at the right of the time, category, comments blocks, etc.


PART 3. Option for placed new words in new line in TOC.

If header of nav item in TOC is much long, all words will placed in new lines. It's like \r\n.

Files modified:

  1. ADD: wrap nav lines in TOC. [1] 0d6c0f6
  2. ADD: wrap nav lines in TOC. [2] 402eb9c

How it looks?

image

How to use?

In Next _config.yml:

# Table Of Contents in the Sidebar
toc:
...
  # If true, all words will placed on next lines if header width longer then sidebar width.
  wrap: true

PART 4. Lazy load images.

Return and remake lazy load images function for all images types.

Files modified:

  1. FIX: lazyload image [1]. ec70baa
  2. ADD: lazyload image [2]. eac8d8f
  3. Rename lazy-image to lazy-image.js 3ecd980

Need to modify manually for now (28.05.2017):

  • node_modules/hexo/lib/plugins/tag/img.js
...
    var alt;
+	var lazysrc = '';
    var src;
...
+	// Find lazy load classname
+	if (classes[0] === 'lazy') {
+		lazysrc = src;
+		src = '/images/loading.gif';
+	}

    var attrs = {

+	'data-original': lazysrc,
      src: src,

P.S. Already pulled in hexo, mb will merged.

How it looks?

image
U can see live demo in this post. Just refresh browser with CTRL+SHIFT+R.

How to use?

To use with full-image (main post image) need to write something like that:

...
tags:
	- Security
	- NGINX
	- SSL
---
{% li //cdn.almostover.ru/images/2016-08/get-wosign-free-ssl-and-configure-with-nginx.png, Получаем бесплатный WoSign сертификат и настраиваем под NGINX %}
...

li (lazy-image) tag will appear instead of fi (full image) tag, with lazy loading on all pages (include homepage too).
Another words:
if u write fi — image will load instantly;
if u write li — image will load lazy (when will need to see this image).

To use with img tag (simply post images) need to write something like that:

{% img lazy //cdn.almostover.ru/images/2016-08/1470759425.png ""Активация аккаунта WoSign" ""WoSign Account Activation""" %}

Image class = lazy. If image haven't class lazy, then image will load as is, in standart loading.

Attention!

This function worked fine, but there is 1 bad thing: SEO.
If image will load lazy, original image source will no index by search engines. Because, default image src will loading gif file and original image will load after javascript working. So, if u use own original images and u need to index this images like google images and other services, this function of lazy loading images will not allow to do this.


PART 5. Star rating support.

Enable 5 stars rating widget to each article.

Files modified:

  1. ADD: star rating widget. [1] cdd36b6
  2. ADD: star rating widget. [2] 8bc43cc
  3. ADD: star rating widget. [3] 3e06c4b
  4. ADD: star rating widget. [4] 32b1837
  5. FIX: star rating widget. [5] a153fbf
  6. ADD: star rating widget. [6] ede932a
  7. ADD: star rating widget. [7] 707c0bc
  8. ADD: star rating widget. [8] 5527001

How it looks?

image

How to use?

In Next _config.yml:

# Star rating support to each article.
# To get your ID visit https://widgetpack.com
rating: 
  enable: true
  id:     YOUR_ID_HERE
  color:  fc6423

@ivan-nginx ivan-nginx changed the title Small Enhancements. Fixes and enhancements. [11] May 15, 2017
@@ -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.

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.

@@ -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.

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.