hexo-adsense 1.0.26 → 2.0.0

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.
Files changed (157) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +0 -0
  3. package/dist/index.cjs +757 -0
  4. package/dist/index.d.cts +2 -0
  5. package/dist/index.d.mts +2 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +740 -0
  8. package/dist/index.mjs +740 -0
  9. package/dist/source/adblock.css +2 -0
  10. package/{lib → dist}/source/adblock.js +0 -0
  11. package/{lib → dist}/source/article-ads.css +0 -0
  12. package/dist/source/article-ads.js +1 -0
  13. package/{lib/source/article-ads.js → dist/source/article-ads.old.js} +0 -0
  14. package/{lib → dist}/source/blogger-redirect.html +0 -0
  15. package/{lib → dist}/source/https.js +0 -0
  16. package/{lib → dist}/source/in_article_ads_test.html +0 -0
  17. package/package.json +122 -37
  18. package/{README.md → readme.md} +29 -11
  19. package/lib/index.d.ts +0 -1
  20. package/lib/index.js +0 -85
  21. package/lib/packages/hexo-cli-extras/lib/env.d.ts +0 -3
  22. package/lib/packages/hexo-cli-extras/lib/env.js +0 -49
  23. package/lib/packages/hexo-extend-injector2/index.d.ts +0 -2
  24. package/lib/packages/hexo-extend-injector2/index.js +0 -12
  25. package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.d.ts +0 -2
  26. package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -64
  27. package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.d.ts +0 -2
  28. package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -12
  29. package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.d.ts +0 -2
  30. package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -28
  31. package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.d.ts +0 -2
  32. package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -32
  33. package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.d.ts +0 -2
  34. package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -8
  35. package/lib/packages/hexo-extend-injector2/lib/default-config.d.ts +0 -39
  36. package/lib/packages/hexo-extend-injector2/lib/default-config.js +0 -46
  37. package/lib/packages/hexo-extend-injector2/lib/filter.d.ts +0 -2
  38. package/lib/packages/hexo-extend-injector2/lib/filter.js +0 -22
  39. package/lib/packages/hexo-extend-injector2/lib/helper/injector.d.ts +0 -2
  40. package/lib/packages/hexo-extend-injector2/lib/helper/injector.js +0 -5
  41. package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.d.ts +0 -2
  42. package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -12
  43. package/lib/packages/hexo-extend-injector2/lib/injector.d.ts +0 -29
  44. package/lib/packages/hexo-extend-injector2/lib/injector.js +0 -125
  45. package/lib/packages/hexo-extend-injector2/lib/load.d.ts +0 -3
  46. package/lib/packages/hexo-extend-injector2/lib/load.js +0 -37
  47. package/lib/packages/hexo-extend-injector2/lib/next-point.d.ts +0 -2
  48. package/lib/packages/hexo-extend-injector2/lib/next-point.js +0 -18
  49. package/lib/packages/hexo-extend-injector2/lib/next.d.ts +0 -2
  50. package/lib/packages/hexo-extend-injector2/lib/next.js +0 -99
  51. package/lib/packages/hexo-extend-injector2/lib/order.d.ts +0 -5
  52. package/lib/packages/hexo-extend-injector2/lib/order.js +0 -8
  53. package/lib/source/adblock.css +0 -2
  54. package/lib/src/article-ads.d.ts +0 -20
  55. package/lib/src/article-ads.js +0 -304
  56. package/lib/src/checkLocalHost.d.ts +0 -10
  57. package/lib/src/checkLocalHost.js +0 -37
  58. package/lib/src/config.d.ts +0 -13
  59. package/lib/src/config.js +0 -42
  60. package/lib/src/html-parser.d.ts +0 -9
  61. package/lib/src/html-parser.js +0 -26
  62. package/lib/src/log.d.ts +0 -1
  63. package/lib/src/log.js +0 -11
  64. package/lib/src/logger.d.ts +0 -3
  65. package/lib/src/logger.js +0 -25
  66. package/lib/src/md5.d.ts +0 -2
  67. package/lib/src/md5.js +0 -165
  68. package/lib/src/safestringify.d.ts +0 -2
  69. package/lib/src/safestringify.js +0 -125
  70. package/lib/src/utils.d.ts +0 -31
  71. package/lib/src/utils.js +0 -159
  72. package/lib/src/versionParser.d.ts +0 -27
  73. package/lib/src/versionParser.js +0 -40
  74. package/packages/hexo-cli-extras/.eslintrc +0 -13
  75. package/packages/hexo-cli-extras/LICENSE.md +0 -20
  76. package/packages/hexo-cli-extras/README.md +0 -146
  77. package/packages/hexo-cli-extras/docs/basic.gif +0 -0
  78. package/packages/hexo-cli-extras/docs/gui.gif +0 -0
  79. package/packages/hexo-cli-extras/docs/remove.png +0 -0
  80. package/packages/hexo-cli-extras/docs/rename.png +0 -0
  81. package/packages/hexo-cli-extras/index.js +0 -48
  82. package/packages/hexo-cli-extras/lib/edit.js +0 -209
  83. package/packages/hexo-cli-extras/lib/env.js +0 -52
  84. package/packages/hexo-cli-extras/lib/extensions.js +0 -23
  85. package/packages/hexo-cli-extras/lib/integrate.js +0 -87
  86. package/packages/hexo-cli-extras/lib/isolate.js +0 -179
  87. package/packages/hexo-cli-extras/lib/remove.js +0 -145
  88. package/packages/hexo-cli-extras/lib/rename.js +0 -171
  89. package/packages/hexo-cli-extras/package.json +0 -34
  90. package/packages/hexo-extend-injector2/.eslintrc +0 -4
  91. package/packages/hexo-extend-injector2/.github/workflows/linter.yml +0 -27
  92. package/packages/hexo-extend-injector2/.github/workflows/tester.yml +0 -24
  93. package/packages/hexo-extend-injector2/.vscode/settings.json +0 -10
  94. package/packages/hexo-extend-injector2/LICENSE +0 -165
  95. package/packages/hexo-extend-injector2/README-ZH.md +0 -189
  96. package/packages/hexo-extend-injector2/README.md +0 -191
  97. package/packages/hexo-extend-injector2/USAGE.md +0 -38
  98. package/packages/hexo-extend-injector2/index.js +0 -14
  99. package/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -79
  100. package/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -13
  101. package/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -29
  102. package/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -42
  103. package/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -10
  104. package/packages/hexo-extend-injector2/lib/default-config.js +0 -52
  105. package/packages/hexo-extend-injector2/lib/filter.js +0 -24
  106. package/packages/hexo-extend-injector2/lib/helper/injector.js +0 -6
  107. package/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -14
  108. package/packages/hexo-extend-injector2/lib/injector.js +0 -128
  109. package/packages/hexo-extend-injector2/lib/load.js +0 -45
  110. package/packages/hexo-extend-injector2/lib/next-point.js +0 -19
  111. package/packages/hexo-extend-injector2/lib/next.js +0 -87
  112. package/packages/hexo-extend-injector2/lib/order.js +0 -9
  113. package/packages/hexo-extend-injector2/package.json +0 -49
  114. package/packages/hexo-extend-injector2/renovate.json +0 -6
  115. package/packages/hexo-extend-injector2/test/.eslintrc +0 -3
  116. package/packages/hexo-extend-injector2/test/index.js +0 -18
  117. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-css.js +0 -86
  118. package/packages/hexo-extend-injector2/test/lib/bundle/bundle-js.js +0 -36
  119. package/packages/hexo-extend-injector2/test/lib/bundle/test.css +0 -3
  120. package/packages/hexo-extend-injector2/test/lib/bundle/test.js +0 -5
  121. package/packages/hexo-extend-injector2/test/lib/helper/injector.js +0 -45
  122. package/packages/hexo-extend-injector2/test/lib/helper/next-inject.js +0 -69
  123. package/packages/hexo-extend-injector2/test/lib/hexo-compatible.js +0 -250
  124. package/packages/hexo-extend-injector2/test/lib/hexo-injector.js +0 -37
  125. package/packages/hexo-extend-injector2/test/lib/injector.js +0 -93
  126. package/packages/memoize/CHANGELOG.md +0 -82
  127. package/packages/memoize/CHANGES +0 -124
  128. package/packages/memoize/LICENSE +0 -15
  129. package/packages/memoize/README.md +0 -503
  130. package/packages/memoize/ext/async.js +0 -154
  131. package/packages/memoize/ext/dispose.js +0 -33
  132. package/packages/memoize/ext/max-age.js +0 -90
  133. package/packages/memoize/ext/max.js +0 -27
  134. package/packages/memoize/ext/promise.js +0 -147
  135. package/packages/memoize/ext/ref-counter.js +0 -48
  136. package/packages/memoize/index.js +0 -34
  137. package/packages/memoize/lib/configure-map.js +0 -182
  138. package/packages/memoize/lib/methods.js +0 -32
  139. package/packages/memoize/lib/registered-extensions.js +0 -1
  140. package/packages/memoize/lib/resolve-length.js +0 -15
  141. package/packages/memoize/lib/resolve-normalize.js +0 -17
  142. package/packages/memoize/lib/resolve-resolve.js +0 -21
  143. package/packages/memoize/lib/weak.js +0 -134
  144. package/packages/memoize/methods-plain.js +0 -3
  145. package/packages/memoize/methods.js +0 -3
  146. package/packages/memoize/normalizers/get-1.js +0 -29
  147. package/packages/memoize/normalizers/get-fixed.js +0 -71
  148. package/packages/memoize/normalizers/get-primitive-fixed.js +0 -16
  149. package/packages/memoize/normalizers/get.js +0 -90
  150. package/packages/memoize/normalizers/primitive.js +0 -9
  151. package/packages/memoize/package.json +0 -60
  152. package/packages/memoize/plain.js +0 -37
  153. package/packages/memoize/profile.js +0 -107
  154. package/packages/memoize/repository.md +0 -1
  155. package/packages/memoize/weak-plain.js +0 -3
  156. package/packages/memoize/weak.js +0 -3
  157. package/unused.md +0 -12
@@ -1,171 +0,0 @@
1
- 'use strict';
2
-
3
- var Promise = require('bluebird');
4
- var chalk = require('chalk');
5
- var inquirer = require('inquirer');
6
- var fsReadFile = Promise.promisify(require('fs').readFile);
7
- var fsStat = Promise.promisify(require('fs').stat);
8
- var fsWriteFile = Promise.promisify(require('fs').writeFile);
9
- var fsRename = Promise.promisify(require('fs').rename);
10
- var slugize = require('hexo-util').slugize;
11
- var path = require('path');
12
-
13
- module.exports = function modExports(args) {
14
- var oldName;
15
- var newName = args.n || args.new || '';
16
-
17
- if (!args._.join('') || !newName) {
18
- console.log(chalk.red('Both a new and an old filename/title are required. `hexo rename help` to display help.'));
19
- process.exit();
20
- } else {
21
- // every whitespace-separated word in the input search is a case-insensitive regular expression
22
- oldName = args._.map(function makeRE(arg) {
23
- return new RegExp(arg, 'i');
24
- });
25
- }
26
-
27
- // load database
28
- this.load().then(function loadDB() {
29
- var selectedPost;
30
-
31
- loadArticles(this.locals).then(function select(arts) {
32
- return selectArticle(arts);
33
- }).then(function selectRename(selected) {
34
- selectedPost = selected;
35
- return chooseRenameStyle(selectedPost);
36
- }).then(function process(renameStyle) {
37
- if (renameStyle === 'filename') {
38
- return renameFile(selectedPost, newName);
39
- } else if (renameStyle === 'title') {
40
- return renameTitle(selectedPost, newName);
41
- } else {
42
- return renameTitle(selectedPost, newName).then(function alsoFilename() {
43
- return renameFile(selectedPost, newName);
44
- });
45
- }
46
- }).catch(function catchAll(err) {
47
- console.log(err.stack ? chalk.red(err.stack) : chalk.red('Error: ') + chalk.gray(err));
48
- process.exit();
49
- });
50
-
51
- function selectArticle(items) {
52
- var articles = filterOnName(items, oldName);
53
-
54
- if (articles.length === 0) {
55
- return Promise.reject('No posts or pages found using your query.');
56
- }
57
-
58
- if (articles.length === 1) {
59
- // no menu if there is only one result
60
- return Promise.resolve(articles[0]);
61
- }
62
-
63
- var entries = articles.map(function mapArts(article) {
64
- return [article.title, ' (', chalk.green(article.source), ')'].join('');
65
- });
66
-
67
- return inquirer.prompt([
68
- {
69
- type: 'list',
70
- name: 'selected',
71
- message: 'Select the post or page you wish to rename.',
72
- choices: entries,
73
- },
74
- ]).then(function getAnswer(answer) {
75
- var pos = entries.indexOf(answer.selected);
76
- return articles[pos];
77
- });
78
- }
79
-
80
- function chooseRenameStyle(post) {
81
- var message = '\n - Rename title (' + chalk.green.underline(post.title) + ') to ' +
82
- chalk.cyan.underline(newName) + ' ?\n - Rename filename (' +
83
- chalk.green.underline(post.source.substr(post.source.lastIndexOf(path.sep))) + ') to ' +
84
- chalk.cyan.underline(slugize(newName, {transform: 1}) + '.md') + ' ?';
85
-
86
- return inquirer.prompt([
87
- {
88
- type: 'list',
89
- message: message,
90
- name: 'answer',
91
- choices: [
92
- 'Yes, rename both',
93
- 'Title only please (don\'t rename the file!)',
94
- 'Filename only please (don\'t rename the title!)',
95
- 'No, forget it, cancel everything.',
96
- ],
97
- },
98
- ]).then(function processRes(response) {
99
- var ans = response.answer;
100
-
101
- switch (ans) {
102
- case 'Yes, rename both':
103
- return 'both';
104
- case 'Title only please (don\'t rename the file!)':
105
- return 'title';
106
- case 'Filename only please (don\'t rename the title!)':
107
- return 'filename';
108
- default:
109
- return Promise.reject('User cancelled rename operation');
110
- }
111
- });
112
- }
113
-
114
- function renameFile(art, renamed) {
115
-
116
- var src = art.full_source;
117
- var newSrc = path.join(src.substr(0, src.lastIndexOf(path.sep)), slugize(renamed, {transform: 1}));
118
-
119
- // first the markdown file
120
- return fsRename(src, newSrc + '.md').then(function doRenameMd() {
121
- var fldr;
122
-
123
- console.log(chalk.red(src) + ' renamed to ' + chalk.green(newSrc) + '.md');
124
-
125
- fldr = src.substr(0, src.lastIndexOf('.'));
126
-
127
- // then the folder if it exists
128
- return fsStat(fldr).then(function doCheckDir(stats) {
129
- if (stats.isDirectory()) {
130
- return fsRename(fldr, newSrc).then(function doRenameDir() {
131
- console.log(chalk.underline('Asset folder renamed as well.'));
132
- });
133
- } else {
134
- return 'Done';
135
- }
136
- }).catch(function catchCheckDir() {
137
- return console.log(chalk.underline('No asset folder found.'));
138
- });
139
- });
140
-
141
- }
142
-
143
- function renameTitle(art, newTitle) {
144
- var oldTitle = art.title;
145
- var oldTitleString = new RegExp('title:.*');
146
-
147
- // change the title through the file system because changing it in the db caused issues
148
- return fsReadFile(art.full_source, 'utf8').then(function doReadArt(data) {
149
- var cont = data.replace(oldTitleString, 'title: "' + newTitle + '"');
150
-
151
- return fsWriteFile(art.full_source, cont, 'utf8').then(function doWriteArt() {
152
- console.log(chalk.red(oldTitle) + ' renamed to ' + chalk.green(newTitle));
153
- });
154
- });
155
- }
156
-
157
- function loadArticles(locals) {
158
- return Promise.resolve(locals.get('posts').toArray().concat(locals.get('pages').toArray()));
159
- }
160
-
161
- function filterOnName(articles, terms) {
162
- return articles.filter(function filterArts(article) {
163
- return terms.every(function testRE(term) {
164
- return term.test(article.title) || term.test(article.slug);
165
- });
166
- });
167
- }
168
-
169
- }.bind(this));
170
- };
171
-
@@ -1,34 +0,0 @@
1
- {
2
- "name": "hexo-cli-extras",
3
- "description": "Hexo plugin that adds an edit, rename, remove, isolate and integrate command for easier command line administration of your Hexo-powered website.",
4
- "keywords": [
5
- "hexo",
6
- "plugin",
7
- "cli",
8
- "command line"
9
- ],
10
- "version": "1.0.4",
11
- "main": "index",
12
- "author": "Gregory Scheerlinck <gregory.scheerlinck@gmail.com> (http://gregjs.com)",
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/greg-js/hexo-cli-extras.git"
16
- },
17
- "license": "MIT",
18
- "scripts": {
19
- "lint": "eslint index.js lib/*.js"
20
- },
21
- "dependencies": {
22
- "bluebird": "^3.0.5",
23
- "chalk": "^2.4.2",
24
- "hexo-util": "^0.6.3",
25
- "inquirer": "^6.2.2",
26
- "moment": "^2.10.6",
27
- "opn": "^5.4.0",
28
- "rimraf": "^2.4.3",
29
- "minimist": "^1.2.5"
30
- },
31
- "devDependencies": {
32
- "eslint": "^2.11.0"
33
- }
34
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "hexo",
3
- "root": true
4
- }
@@ -1,27 +0,0 @@
1
- name: Linter
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- linter:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v1
10
- - name: Use Node.js 12.x
11
- uses: actions/setup-node@v2
12
- with:
13
- node-version: '12.x'
14
- - name: Cache NPM dependencies
15
- uses: actions/cache@v1
16
- with:
17
- path: node_modules
18
- key: ${{ runner.OS }}-npm-cache
19
- restore-keys: |
20
- ${{ runner.OS }}-npm-cache
21
- - name: Install Dependencies
22
- run: npm install
23
- - name: Lint
24
- run: |
25
- npm run eslint
26
- env:
27
- CI: true
@@ -1,24 +0,0 @@
1
- name: Tester
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- tester:
7
- runs-on: ${{ matrix.os }}
8
- strategy:
9
- matrix:
10
- os: [ubuntu-latest, windows-latest, macos-latest]
11
- node-version: ['10.x', '12.x', '14.x']
12
- fail-fast: false
13
- steps:
14
- - uses: actions/checkout@v2
15
- - name: Use Node.js ${{ matrix.node-version }}
16
- uses: actions/setup-node@v2
17
- with:
18
- node-version: ${{ matrix.node-version }}
19
- - name: Install Dependencies
20
- run: npm install
21
- - name: Test
22
- run: npm run test
23
- env:
24
- CI: true
@@ -1,10 +0,0 @@
1
- {
2
- "eslint.options": {
3
- "rules": {
4
- "linebreak-style": "off"
5
- }
6
- },
7
- "editor.codeActionsOnSave": {
8
- "source.fixAll.eslint": true
9
- }
10
- }
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1,189 +0,0 @@
1
- # hexo-extend-injector2
2
-
3
- 为插件或者主题提供扩展,能将代码注入到指定位置(如果主题提供相应的注入点)
4
-
5
- ![npm](https://img.shields.io/npm/v/hexo-extend-injector2.svg)
6
-
7
- 这个插件的功能借鉴了原生injector的设计,但由于其无法兼容原本的NexT插件方案,重新设计以提供更多扩展能力,详细见[这个PR](https://github.com/jiangtj/hexo-theme-cake/pull/39)
8
-
9
- ## Install
10
-
11
- ```bash
12
- yarn add hexo-extend-injector2
13
- ```
14
-
15
- ## Usage
16
-
17
- 首先,你需要获取injector实例通过require,下面的API中injector都是这样获取
18
-
19
- ```js
20
- const injector = require('hexo-extend-injector2')(hexo);
21
- ```
22
-
23
- ### 注册
24
-
25
- injector 有两种注册的写法
26
-
27
- ```js
28
- injector.register(entry, value, predicate, priority, isRun);
29
- injector.register(entry, {
30
- value: value,
31
- predicate: predicate,
32
- priority: priority,
33
- isRun: true/false
34
- });
35
- ```
36
-
37
- #### 参数
38
-
39
- | 属性名 | 类型 | 描述 | 默认值 |
40
- | :----- | :----- | :----- | :----- |
41
- | entry | String | 注入点,它忽略大小写以及` ` `-` `_`,即 'bodybegin' = 'bodyBegin' = 'body-begin' = 'body_begin' | - |
42
- | value | String/Function | 注入的内容,如果是函数,会传递上下文及配置参数 | - |
43
- | predicate | String/Function | 生效条件,详见例子 | `() => true` |
44
- | priority | Number | 优先级 | 10 |
45
- | isRun | Boolean | 特别定义的参数,hexo部分内容在文件更改之后重新加载,重新加载时会清空isRun为true的内容,避免重复加载 | false |
46
-
47
-
48
- #### 例子
49
-
50
- 1. 最简单的使用,在你的站点的head中添加fontawesome css,下面三种写法是等效的
51
- ```js
52
- injector.register('head-end', '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.11.2/css/all.min.css" crossorigin="anonymous">');
53
- injector.register('head-end', () => '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.11.2/css/all.min.css" crossorigin="anonymous">');
54
- injector.register('head-end', {
55
- value: '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.11.2/css/all.min.css" crossorigin="anonymous">'
56
- });
57
- ```
58
-
59
- 2. Predicate的使用
60
- ```js
61
- // 当你需要在特定的页面注入内容时,需要用到Predicate,分为两种写法
62
-
63
- // 与官方一样的,指定布局类型,如下,将在特定的music布局中添加APlayer
64
- injector.register('head_end', () => {
65
- return css('https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css');
66
- }, 'music');
67
- injector.register('body_end', '<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js">', 'music');
68
- // 等价于 使用了 injector.is('home', 'category', ...),可以传递多个布局,同时生效
69
- injector.register('body_end', '<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js">', injector.is('music'));
70
-
71
- // 依据上下文或者配置选项判断
72
- injector.register('head-end', {
73
- predicate: (ctx, options) => {
74
- // ctx 在不同情况下,传入的值可能不同,options 在 injector.get() 时传入
75
- return ctx.page['music'];
76
- },
77
- value: () => {
78
- return css('https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css');
79
- }
80
- });
81
- ```
82
-
83
- ### 获取
84
-
85
- 默认情况下,只提供四个注入点 `head-begin` `head-end` `body-begin` `body-end`,你可以设置`disable_injector2_default_point`为true禁用
86
-
87
- 其他情况,需要开发者提供JS API或者Hexo Helper两种途径获取存储在injector的内容,自行处理它
88
-
89
- #### API
90
-
91
- ```js
92
- const result = injector.get(entry, options);
93
- ```
94
-
95
- - result.list(): 获取该注入点的所有注入对象
96
- - result.rendered(): 获取并渲染该注入点的所有注入对象(如果value是函数,将执行转化为String)
97
- - result.text(): 将该注入点的所有注入内容渲染拼接后返回
98
-
99
- 例子
100
-
101
- ```js
102
- // 在bundler中,通过添加env来判断是否是需要的css内容
103
- injector.get('css', {env: 'dark'});
104
- // 覆盖默认的ctx
105
- injector.get('point', {context: this});
106
- ```
107
-
108
- #### Helper
109
-
110
- injector helper 与 injector.get() 十分相似,但context替换为了hexo的本地变量
111
-
112
- ```ejs
113
- <!DOCTYPE html>
114
- <html>
115
- <head>
116
- <%- injector('head-begin').text() -%>
117
- ...
118
- <%- injector('head-end').text() -%>
119
- </head>
120
- <body>
121
- <%- injector('body-begin').text() -%>
122
- ...
123
- <%- injector('body-end').text() -%>
124
- </body>
125
- </html>
126
- ```
127
-
128
- ### bundler
129
-
130
- 该插件提供了js与css的bundler,你可以很方便的将js与css添加至主题中
131
-
132
- #### config
133
-
134
- 下面是bundler的默认配置
135
-
136
- ```yml
137
- injector2:
138
- js:
139
- enable: true
140
- path: js/injector.js
141
- options: {}
142
- css:
143
- enable: true
144
- path:
145
- default:
146
- # 在 head 中添加 <link rel="stylesheet" type="text/css" href="${url_for(file.path)}" />
147
- link: load
148
- path: css/injector/main.css
149
- dark:
150
- # 在 head 中添加 <link rel="preload" as="style" href="${url_for(file.path)}" />
151
- link: preload
152
- path: css/injector/dark.css
153
- light:
154
- link: preload
155
- path: css/injector/light.css
156
- options: {}
157
- ```
158
-
159
- #### API/Example
160
-
161
- ```js
162
- injector.register('js or css', 'content');
163
-
164
- // Example
165
- injector.register('js', 'function log1() {console.log("bar");}');
166
- injector.register('css', '.book{font-size:2rem}');
167
-
168
- // CSS spec
169
- // 额外添加了env的选择,如果env不同,那么会打包到不同的css文件下
170
- // 你需要提前进行配置,默认情况下配置了default、dark和light,如果不设置为default
171
- injector.register('css', {value: '.book{font-size:2rem}', env: 'dark'});
172
-
173
- // CSS 别名
174
- injector.register('variable', 'css content');
175
- //=> injector.register('css', {value: 'css content', priority: injector.order.REGISTER_VARIABLE});
176
- injector.register('style', 'css content');
177
- //=> injector.register('css', {value: 'css content', priority: injector.order.REGISTER_STYLE});
178
- ```
179
-
180
- ### NexT plugin
181
-
182
- 如果你希望在你的主题中使用NexT主题的插件,启用以下配置(默认启用),如果存在不兼容的插件,可以提交issue
183
-
184
- ```yml
185
- injector:
186
- load_next_plugin: true
187
- ```
188
-
189
- 除此外,主题需要提供与[NexT类似的注入点](lib/next-point.js),如[Cake](https://github.com/jiangtj/hexo-theme-cake)主题已经添加,但如果是其它主题,你可能需要自己添加它