From fd2a6c69c0bd1586484f1e026ce8ccfa15401611 Mon Sep 17 00:00:00 2001
From: StevenJoeZhang <1119186082@qq.com>
Date: Mon, 4 Feb 2019 18:03:15 +0800
Subject: [PATCH 1/2] Fix #594
---
layout/_partials/post/wechat-subscriber.swig | 2 +-
layout/_partials/search/index.swig | 4 ++--
layout/_third-party/analytics/lean-analytics.swig | 6 +++---
layout/_third-party/baidu-push.swig | 7 +------
scripts/filters/{after_post_render => }/exturl.js | 4 ++--
scripts/helpers/next-url.js | 2 +-
6 files changed, 10 insertions(+), 15 deletions(-)
rename scripts/filters/{after_post_render => }/exturl.js (94%)
diff --git a/layout/_partials/post/wechat-subscriber.swig b/layout/_partials/post/wechat-subscriber.swig
index 6c6a7e3960..e7e03578f2 100644
--- a/layout/_partials/post/wechat-subscriber.swig
+++ b/layout/_partials/post/wechat-subscriber.swig
@@ -1,4 +1,4 @@
-
+
{{ theme.wechat_subscriber.description }}
diff --git a/layout/_partials/search/index.swig b/layout/_partials/search/index.swig
index 76645fe094..b23ac3fd77 100644
--- a/layout/_partials/search/index.swig
+++ b/layout/_partials/search/index.swig
@@ -1,7 +1,7 @@
{% if theme.algolia_search.enable %}
{% include 'algolia-search.swig' %}
-{% elseif theme.swiftype_key %}
+{% elif theme.swiftype_key %}
{% include 'swiftype.swig' %}
-{% elseif theme.local_search.enable %}
+{% elif theme.local_search.enable %}
{% include 'localsearch.swig' %}
{% endif %}
diff --git a/layout/_third-party/analytics/lean-analytics.swig b/layout/_third-party/analytics/lean-analytics.swig
index f90ce64888..eb6bef3bf7 100644
--- a/layout/_third-party/analytics/lean-analytics.swig
+++ b/layout/_third-party/analytics/lean-analytics.swig
@@ -23,7 +23,7 @@
})
{% endif %}
.fail(function ({ responseJSON }) {
- console.log(`Failed to save Visitor num, with error message: ${responseJSON.error}`);
+ console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
})
} else {
{% if theme.leancloud_visitors.security %}
@@ -43,7 +43,7 @@
}
})
.fail(function ({ responseJSON }) {
- console.log(`LeanCloud Counter Error: ${responseJSON.code} ${responseJSON.error}`);
+ console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
});
}
{% else %}
@@ -82,7 +82,7 @@
}
})
.fail(function ({ responseJSON }) {
- console.log(`LeanCloud Counter Error: ${responseJSON.code} ${responseJSON.error}`);
+ console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
});
}
{% endif %}
diff --git a/layout/_third-party/baidu-push.swig b/layout/_third-party/baidu-push.swig
index c400d2f265..758c439285 100644
--- a/layout/_third-party/baidu-push.swig
+++ b/layout/_third-party/baidu-push.swig
@@ -3,12 +3,7 @@
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
- if (curProtocol === 'https') {
- bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
- }
- else {
- bp.src = 'http://push.zhanzhang.baidu.com/push.js';
- }
+ bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
diff --git a/scripts/filters/after_post_render/exturl.js b/scripts/filters/exturl.js
similarity index 94%
rename from scripts/filters/after_post_render/exturl.js
rename to scripts/filters/exturl.js
index 91b981baf3..5e5ab84f0b 100644
--- a/scripts/filters/after_post_render/exturl.js
+++ b/scripts/filters/exturl.js
@@ -33,7 +33,7 @@ hexo.extend.filter.register('after_post_render', function(data) {
// If title atribute filled, set it as title; if not, set url as title.
var title = $(this).attr('title') || href;
- var encoded = new Buffer(href).toString('base64');
+ var encoded = new Buffer.from(href).toString('base64');
$(this).replaceWith(function() {
return $(`
${$(this).html()}`);
@@ -42,4 +42,4 @@ hexo.extend.filter.register('after_post_render', function(data) {
});
data.content = $.html();
-});
+}, 0);
diff --git a/scripts/helpers/next-url.js b/scripts/helpers/next-url.js
index 7660a1c0e5..b610e595af 100644
--- a/scripts/helpers/next-url.js
+++ b/scripts/helpers/next-url.js
@@ -22,7 +22,7 @@ hexo.extend.helper.register('next_url', function(path, text, options) {
if (theme.exturl && data.protocol && data.hostname !== siteHost) {
tag = 'span';
exturl = 'exturl';
- var encoded = new Buffer(path).toString('base64');
+ var encoded = new Buffer.from(path).toString('base64');
attrs = {
class : exturl,
'data-url': encoded
From e2c4dbe66a4b878c2e8a997b47f3b77864a3fb74 Mon Sep 17 00:00:00 2001
From: StevenJoeZhang <1119186082@qq.com>
Date: Fri, 15 Feb 2019 14:46:50 +0800
Subject: [PATCH 2/2] remove keyword `new`
---
scripts/filters/exturl.js | 2 +-
scripts/helpers/next-url.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/filters/exturl.js b/scripts/filters/exturl.js
index 5e5ab84f0b..c9eaae9796 100644
--- a/scripts/filters/exturl.js
+++ b/scripts/filters/exturl.js
@@ -33,7 +33,7 @@ hexo.extend.filter.register('after_post_render', function(data) {
// If title atribute filled, set it as title; if not, set url as title.
var title = $(this).attr('title') || href;
- var encoded = new Buffer.from(href).toString('base64');
+ var encoded = Buffer.from(href).toString('base64');
$(this).replaceWith(function() {
return $(`
${$(this).html()}`);
diff --git a/scripts/helpers/next-url.js b/scripts/helpers/next-url.js
index b610e595af..700732e0f2 100644
--- a/scripts/helpers/next-url.js
+++ b/scripts/helpers/next-url.js
@@ -22,7 +22,7 @@ hexo.extend.helper.register('next_url', function(path, text, options) {
if (theme.exturl && data.protocol && data.hostname !== siteHost) {
tag = 'span';
exturl = 'exturl';
- var encoded = new Buffer.from(path).toString('base64');
+ var encoded = Buffer.from(path).toString('base64');
attrs = {
class : exturl,
'data-url': encoded