hexo-component-inferno 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/migrate.js +10 -28
- package/lib/core/migrate.test.js +10 -12
- package/lib/core/schema.js +33 -109
- package/lib/core/schema.test.js +2 -6
- package/lib/core/view.js +3 -10
- package/lib/core/view.test.js +0 -7
- package/lib/hexo/filter/locals.js +3 -18
- package/lib/hexo/filter/locals.test.js +2 -19
- package/lib/hexo/generator/assets.js +2 -8
- package/lib/hexo/generator/assets.test.js +0 -4
- package/lib/hexo/generator/categories.test.js +0 -3
- package/lib/hexo/generator/category.js +1 -6
- package/lib/hexo/generator/category.test.js +0 -5
- package/lib/hexo/generator/insight.js +1 -9
- package/lib/hexo/generator/insight.test.js +0 -3
- package/lib/hexo/generator/manifest.js +0 -3
- package/lib/hexo/generator/manifest.test.js +0 -3
- package/lib/hexo/generator/tags.test.js +0 -3
- package/lib/hexo/helper/cdn.js +6 -19
- package/lib/hexo/helper/cdn.test.js +0 -3
- package/lib/hexo/helper/page.test.js +0 -3
- package/lib/hexo/tag/message.js +0 -8
- package/lib/hexo/tag/message.test.js +0 -7
- package/lib/hexo/tag/tabs.js +3 -35
- package/lib/hexo/tag/tabs.test.js +0 -8
- package/lib/util/cache.js +0 -11
- package/lib/util/cache.test.js +0 -4
- package/lib/util/classname.js +0 -3
- package/lib/util/classname.test.js +0 -1
- package/lib/util/yaml.js +2 -7
- package/lib/util/yaml.test.js +0 -4
- package/lib/view/comment/changyan.js +12 -31
- package/lib/view/comment/disqus.js +11 -32
- package/lib/view/comment/disqusjs.js +22 -43
- package/lib/view/comment/facebook.js +9 -28
- package/lib/view/comment/gitalk.js +28 -49
- package/lib/view/comment/gitment.js +15 -37
- package/lib/view/comment/isso.js +6 -27
- package/lib/view/comment/livere.js +6 -27
- package/lib/view/comment/twikoo.js +14 -33
- package/lib/view/comment/utterances.js +17 -45
- package/lib/view/comment/valine.js +39 -60
- package/lib/view/comment/waline.js +45 -66
- package/lib/view/common/article_media.js +11 -28
- package/lib/view/donate/afdian.js +9 -30
- package/lib/view/donate/alipay.js +9 -30
- package/lib/view/donate/buymeacoffee.js +9 -30
- package/lib/view/donate/patreon.js +9 -30
- package/lib/view/donate/paypal.js +10 -31
- package/lib/view/donate/wechat.js +9 -30
- package/lib/view/misc/article_licensing.js +21 -43
- package/lib/view/misc/meta.js +7 -34
- package/lib/view/misc/open_graph.js +25 -67
- package/lib/view/misc/paginator.js +12 -36
- package/lib/view/misc/structured_data.js +16 -43
- package/lib/view/misc/web_app.js +16 -50
- package/lib/view/plugin/baidu_analytics.js +7 -28
- package/lib/view/plugin/bing_webmaster.js +7 -28
- package/lib/view/plugin/busuanzi.js +6 -26
- package/lib/view/plugin/cnzz.js +9 -30
- package/lib/view/plugin/cookie_consent.js +28 -49
- package/lib/view/plugin/gallery.js +10 -31
- package/lib/view/plugin/google_analytics.js +7 -28
- package/lib/view/plugin/hotjar.js +7 -28
- package/lib/view/plugin/katex.js +11 -32
- package/lib/view/plugin/mathjax.js +7 -28
- package/lib/view/plugin/outdated_browser.js +10 -31
- package/lib/view/plugin/progressbar.js +7 -28
- package/lib/view/plugin/statcounter.js +10 -31
- package/lib/view/plugin/twitter_conversion_tracking.js +7 -28
- package/lib/view/search/algolia.js +14 -35
- package/lib/view/search/baidu.js +9 -28
- package/lib/view/search/google_cse.js +10 -30
- package/lib/view/search/insight.js +9 -28
- package/lib/view/share/addthis.js +6 -27
- package/lib/view/share/addtoany.js +6 -25
- package/lib/view/share/bdshare.js +6 -25
- package/lib/view/share/sharejs.js +8 -27
- package/lib/view/share/sharethis.js +6 -27
- package/lib/view/widget/adsense.js +11 -32
- package/lib/view/widget/archives.js +26 -52
- package/lib/view/widget/categories.js +25 -57
- package/lib/view/widget/followit.js +12 -31
- package/lib/view/widget/links.js +27 -39
- package/lib/view/widget/recent_posts.js +15 -36
- package/lib/view/widget/subscribe_email.js +12 -31
- package/lib/view/widget/tags.js +16 -39
- package/lib/view/widget/toc.js +27 -67
- package/package.json +1 -1
package/lib/core/migrate.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @module core/migrate
|
|
4
4
|
*/
|
|
5
5
|
const semver = require('semver');
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Configuration migration base class.
|
|
8
9
|
* <p>
|
|
@@ -10,8 +11,6 @@ const semver = require('semver');
|
|
|
10
11
|
* object to upgrade to.
|
|
11
12
|
* The extended classes should have a constructor that takes no parameters exposed.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
14
|
class Migration {
|
|
16
15
|
/**
|
|
17
16
|
* @param {string} version Target version.
|
|
@@ -21,6 +20,7 @@ class Migration {
|
|
|
21
20
|
this.head = head;
|
|
22
21
|
this.version = version;
|
|
23
22
|
}
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* Upgrade a configuration object to the target version.
|
|
26
26
|
* Any class that extends this class must implement this method.
|
|
@@ -29,11 +29,10 @@ class Migration {
|
|
|
29
29
|
* @returns {Object} The upgraded configuration object, which is copied from the original
|
|
30
30
|
* configuration object.
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
32
|
upgrade(config) {
|
|
35
33
|
throw new Error('Not implemented!');
|
|
36
34
|
}
|
|
35
|
+
|
|
37
36
|
/**
|
|
38
37
|
* Upgrade a configuration object to the target version and bump the version number
|
|
39
38
|
* to the target version.
|
|
@@ -42,15 +41,13 @@ class Migration {
|
|
|
42
41
|
* @returns {Object} The upgraded configuration object, which is copied from the original
|
|
43
42
|
* configuration object.
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
44
|
migrate(config) {
|
|
48
45
|
const result = this.upgrade(config);
|
|
49
46
|
result.version = this.version.toString();
|
|
50
47
|
return result;
|
|
51
48
|
}
|
|
52
|
-
|
|
53
49
|
}
|
|
50
|
+
|
|
54
51
|
/**
|
|
55
52
|
* Configuration upgrade utility class.
|
|
56
53
|
* <p>
|
|
@@ -59,8 +56,6 @@ class Migration {
|
|
|
59
56
|
* It is used to run the migrations that are before or equal to a given target version
|
|
60
57
|
* on a configuration object.
|
|
61
58
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
59
|
class Migrator {
|
|
65
60
|
/**
|
|
66
61
|
* @param {module:core/migrate~Migration} head The latest migration class to be loaded.
|
|
@@ -68,53 +63,46 @@ class Migrator {
|
|
|
68
63
|
constructor(head) {
|
|
69
64
|
/** @access private */
|
|
70
65
|
this.versions = [];
|
|
71
|
-
/** @access private */
|
|
72
66
|
|
|
67
|
+
/** @access private */
|
|
73
68
|
this.migrations = {};
|
|
74
|
-
|
|
75
69
|
while (head) {
|
|
76
70
|
const migration = new head(); // eslint-disable-line new-cap
|
|
77
|
-
|
|
78
71
|
if (!(migration instanceof Migration)) {
|
|
79
72
|
throw new Error(`Migration ${migration.constructor.name} is not a Migration class.`);
|
|
80
73
|
}
|
|
81
|
-
|
|
82
74
|
if (!semver.valid(migration.version)) {
|
|
83
75
|
throw new Error(`${migration.version} is not a valid version in ${migration.constructor.name}}`);
|
|
84
76
|
}
|
|
85
|
-
|
|
86
77
|
this.versions.push(migration.version);
|
|
87
78
|
this.migrations[migration.version] = migration;
|
|
88
79
|
head = migration.head;
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
this.versions.sort(semver.compare);
|
|
92
82
|
}
|
|
83
|
+
|
|
93
84
|
/**
|
|
94
85
|
* Get the latest target version among all loaded migrations.
|
|
95
86
|
*
|
|
96
87
|
* @returns {string} The latest target version.
|
|
97
88
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
89
|
getLatestVersion() {
|
|
101
90
|
if (!this.versions.length) {
|
|
102
91
|
return null;
|
|
103
92
|
}
|
|
104
|
-
|
|
105
93
|
return this.versions[this.versions.length - 1];
|
|
106
94
|
}
|
|
95
|
+
|
|
107
96
|
/**
|
|
108
97
|
* Check if the given version is the latest target version.
|
|
109
98
|
*
|
|
110
99
|
* @param {string} version A version number to be checked.
|
|
111
100
|
* @returns {boolean} true if the given version is the latest version.
|
|
112
101
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
102
|
isOudated(version) {
|
|
116
103
|
return this.getLatestVersion() && semver.lt(version, this.getLatestVersion());
|
|
117
104
|
}
|
|
105
|
+
|
|
118
106
|
/**
|
|
119
107
|
* Upgrade a given configuration to a given target version.
|
|
120
108
|
*
|
|
@@ -125,27 +113,21 @@ class Migrator {
|
|
|
125
113
|
* version as parameters.
|
|
126
114
|
* @returns {Object} The upgrade configuration object.
|
|
127
115
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
116
|
migrate(config, toVersion = null, callback = null) {
|
|
131
117
|
const fVer = config.version;
|
|
132
|
-
const tVer = toVersion || this.getLatestVersion();
|
|
118
|
+
const tVer = toVersion || this.getLatestVersion();
|
|
119
|
+
// find all migrations whose version is larger than fromVer, smaller or equal to toVer
|
|
133
120
|
// and run migrations on the config one by one.
|
|
134
|
-
|
|
135
121
|
return this.versions.filter(ver => semver.gt(ver, fVer) && !semver.gt(ver, tVer)).sort(semver.compare).reduce((cfg, ver) => {
|
|
136
122
|
const migration = this.migrations[ver.toString()];
|
|
137
123
|
const result = migration.migrate(cfg);
|
|
138
|
-
|
|
139
124
|
if (typeof callback === 'function') {
|
|
140
125
|
callback(cfg.version, migration.version);
|
|
141
126
|
}
|
|
142
|
-
|
|
143
127
|
return result;
|
|
144
128
|
}, config);
|
|
145
129
|
}
|
|
146
|
-
|
|
147
130
|
}
|
|
148
|
-
|
|
149
131
|
module.exports = {
|
|
150
132
|
Migration,
|
|
151
133
|
Migrator
|
package/lib/core/migrate.test.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const {
|
|
2
2
|
Migrator
|
|
3
3
|
} = require('./migrate');
|
|
4
|
-
|
|
5
4
|
const head = require('../../fixture/migration/head');
|
|
6
|
-
|
|
7
5
|
test('Correctly load all migrations and read the latest version', () => {
|
|
8
6
|
const migrator = new Migrator(head);
|
|
9
7
|
expect(migrator.getLatestVersion()).toBe('3.0.0');
|
|
@@ -15,13 +13,13 @@ test('Do full upgrade correctly', () => {
|
|
|
15
13
|
const callback = jest.fn();
|
|
16
14
|
const result = migrator.migrate({
|
|
17
15
|
version: '1.0.0'
|
|
18
|
-
}, null, callback);
|
|
19
|
-
|
|
20
|
-
expect(callback.mock.calls.length).toBe(2);
|
|
21
|
-
|
|
16
|
+
}, null, callback);
|
|
17
|
+
// callback has been invoked twice
|
|
18
|
+
expect(callback.mock.calls.length).toBe(2);
|
|
19
|
+
// first invocation received the correct version parameters
|
|
22
20
|
expect(callback.mock.calls[0][0]).toBe('1.0.0');
|
|
23
|
-
expect(callback.mock.calls[0][1]).toBe('2.0.0');
|
|
24
|
-
|
|
21
|
+
expect(callback.mock.calls[0][1]).toBe('2.0.0');
|
|
22
|
+
// second invocation received the correct version parameters
|
|
25
23
|
expect(callback.mock.calls[1][0]).toBe('2.0.0');
|
|
26
24
|
expect(callback.mock.calls[1][1]).toBe('3.0.0');
|
|
27
25
|
expect(result).toEqual({
|
|
@@ -35,10 +33,10 @@ test('Do partial upgrade correctly', () => {
|
|
|
35
33
|
const callback = jest.fn();
|
|
36
34
|
const result = migrator.migrate({
|
|
37
35
|
version: '1.0.0'
|
|
38
|
-
}, '2.1.0', callback);
|
|
39
|
-
|
|
40
|
-
expect(callback.mock.calls.length).toBe(1);
|
|
41
|
-
|
|
36
|
+
}, '2.1.0', callback);
|
|
37
|
+
// callback has been invoked twice
|
|
38
|
+
expect(callback.mock.calls.length).toBe(1);
|
|
39
|
+
// first invocation received the correct version parameters
|
|
42
40
|
expect(callback.mock.calls[0][0]).toBe('1.0.0');
|
|
43
41
|
expect(callback.mock.calls[0][1]).toBe('2.0.0');
|
|
44
42
|
expect(result).toEqual({
|