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,125 +0,0 @@
1
- /**
2
- * JSON safestringify
3
- * @see {@link https://github.com/bugsnag/safe-json-stringify#readme}
4
- */
5
- module.exports = function (data, replacer, space, opts) {
6
- var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : [];
7
- var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : [];
8
- return JSON.stringify(prepareObjForSerialization(data, redactedKeys, redactedPaths), replacer, space);
9
- };
10
- var MAX_DEPTH = 20;
11
- var MAX_EDGES = 25000;
12
- var MIN_PRESERVED_DEPTH = 8;
13
- var REPLACEMENT_NODE = "...";
14
- function isError(o) {
15
- return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o));
16
- }
17
- function throwsMessage(err) {
18
- return "[Throws: " + (err ? err.message : "?") + "]";
19
- }
20
- function find(haystack, needle) {
21
- for (var i = 0, len = haystack.length; i < len; i++) {
22
- if (haystack[i] === needle)
23
- return true;
24
- }
25
- return false;
26
- }
27
- // returns true if the string `path` starts with any of the provided `paths`
28
- function isDescendent(paths, path) {
29
- for (var i = 0, len = paths.length; i < len; i++) {
30
- if (path.indexOf(paths[i]) === 0)
31
- return true;
32
- }
33
- return false;
34
- }
35
- function shouldRedact(patterns, key) {
36
- for (var i = 0, len = patterns.length; i < len; i++) {
37
- if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase())
38
- return true;
39
- if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key))
40
- return true;
41
- }
42
- return false;
43
- }
44
- function isArray(obj) {
45
- return Object.prototype.toString.call(obj) === "[object Array]";
46
- }
47
- function safelyGetProp(obj, prop) {
48
- try {
49
- return obj[prop];
50
- }
51
- catch (err) {
52
- return throwsMessage(err);
53
- }
54
- }
55
- function prepareObjForSerialization(obj, redactedKeys, redactedPaths) {
56
- var seen = []; // store references to objects we have seen before
57
- var edges = 0;
58
- function visit(obj, path) {
59
- function edgesExceeded() {
60
- return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES;
61
- }
62
- edges++;
63
- if (path.length > MAX_DEPTH)
64
- return REPLACEMENT_NODE;
65
- if (edgesExceeded())
66
- return REPLACEMENT_NODE;
67
- if (obj === null || typeof obj !== "object")
68
- return obj;
69
- if (find(seen, obj))
70
- return "[Circular]";
71
- seen.push(obj);
72
- if (typeof obj.toJSON === "function") {
73
- try {
74
- // we're not going to count this as an edge because it
75
- // replaces the value of the currently visited object
76
- edges--;
77
- var fResult = visit(obj.toJSON(), path);
78
- seen.pop();
79
- return fResult;
80
- }
81
- catch (err) {
82
- return throwsMessage(err);
83
- }
84
- }
85
- var er = isError(obj);
86
- if (er) {
87
- edges--;
88
- var eResult = visit({ name: obj.name, message: obj.message }, path);
89
- seen.pop();
90
- return eResult;
91
- }
92
- if (isArray(obj)) {
93
- var aResult = [];
94
- for (var i = 0, len = obj.length; i < len; i++) {
95
- if (edgesExceeded()) {
96
- aResult.push(REPLACEMENT_NODE);
97
- break;
98
- }
99
- aResult.push(visit(obj[i], path.concat("[]")));
100
- }
101
- seen.pop();
102
- return aResult;
103
- }
104
- var result = {};
105
- try {
106
- for (var prop in obj) {
107
- if (!Object.prototype.hasOwnProperty.call(obj, prop))
108
- continue;
109
- if (isDescendent(redactedPaths, path.join(".")) && shouldRedact(redactedKeys, prop)) {
110
- result[prop] = "[REDACTED]";
111
- continue;
112
- }
113
- if (edgesExceeded()) {
114
- result[prop] = REPLACEMENT_NODE;
115
- break;
116
- }
117
- result[prop] = visit(safelyGetProp(obj, prop), path.concat(prop));
118
- }
119
- }
120
- catch (e) { }
121
- seen.pop();
122
- return result;
123
- }
124
- return visit(obj, []);
125
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Memorize cache
3
- *
4
- * @param {any} fn
5
- * @see {@link https://www.freecodecamp.org/news/understanding-memoize-in-javascript-51d07d19430e/}
6
- * @returns {typeof import('underscore').memoize}
7
- */
8
- export function memoize(fn: any, debug: any): typeof import('underscore').memoize;
9
- /**
10
- * Dump large objects
11
- * @param {string} filename
12
- * @param {any} obj
13
- */
14
- export function dump(filename: string, ...obj: any): any;
15
- /**
16
- *
17
- * @param {string} path0
18
- * @param {string[]|string} exclude
19
- * @param {Hexo} hexo
20
- * @returns
21
- */
22
- export function isIgnore(path0: string, exclude: string[] | string, hexo: Hexo): boolean;
23
- declare function randomInt(min: any, max: any): number;
24
- export function streamToString(stream: any): Promise<any>;
25
- export function isFileChanged(filePath: any): any;
26
- export function getFileCache(filePath: any, defaultData: any): any;
27
- export function setFileCache(filePath: any, newData: any): void;
28
- export function setHexo(inHexo: any): void;
29
- import Hexo = require("hexo");
30
- import Promise = require("bluebird");
31
- export { randomInt as randInt };
package/lib/src/utils.js DELETED
@@ -1,159 +0,0 @@
1
- /* global hexo */
2
- "use strict";
3
- var minimatch = require("minimatch");
4
- var Promise = require("bluebird");
5
- var md5File = require("md5-file");
6
- var underscore = require("underscore");
7
- var Hexo = require("hexo");
8
- var md5Cache = {};
9
- var fileCache = {};
10
- var log = require("./log");
11
- var path = require("path");
12
- var util = require("util");
13
- var fs = require("fs");
14
- var rimraf = require("rimraf");
15
- if (typeof hexo == "undefined") {
16
- /**
17
- * @type {Hexo}
18
- */
19
- var hexo_1;
20
- }
21
- function setHexo(inHexo) {
22
- hexo = inHexo;
23
- }
24
- /**
25
- *
26
- * @param {string} path0
27
- * @param {string[]|string} exclude
28
- * @param {Hexo} hexo
29
- * @returns
30
- */
31
- var isIgnore = function (path0, exclude, hexo) {
32
- if (exclude && !Array.isArray(exclude))
33
- exclude = [exclude];
34
- if (path0 && exclude && exclude.length) {
35
- for (var i = 0, len = exclude.length; i < len; i++) {
36
- var excludePattern = exclude[i];
37
- if (hexo) {
38
- var fromBase = path.join(hexo.base_dir, excludePattern);
39
- var fromSource = path.join(hexo.source_dir, excludePattern);
40
- //log.log([path0, fromBase, fromSource, excludePattern]);
41
- if (minimatch(path0, fromSource))
42
- return true;
43
- if (minimatch(path0, fromBase))
44
- return true;
45
- }
46
- if (minimatch(path0, excludePattern))
47
- return true;
48
- }
49
- }
50
- return false;
51
- };
52
- function streamToString(stream) {
53
- return new Promise(function (resolve, reject) {
54
- var chunks = [];
55
- stream.on("data", function (chunk) {
56
- chunks.push(chunk.toString());
57
- });
58
- stream.on("end", function () {
59
- resolve(chunks.join(""));
60
- });
61
- });
62
- }
63
- function isFileChanged(filePath) {
64
- return md5File(filePath)
65
- .then(function (hash1) {
66
- var hash = md5Cache[filePath];
67
- md5Cache[filePath] = hash1;
68
- if (!hash) {
69
- return true;
70
- }
71
- if (hash === hash1) {
72
- return false;
73
- }
74
- return true;
75
- })["catch"](function (err) {
76
- return true;
77
- });
78
- }
79
- function getFileCache(filePath, defaultData) {
80
- var cache = fileCache[filePath] || defaultData;
81
- return cache;
82
- }
83
- function setFileCache(filePath, newData) {
84
- fileCache[filePath] = newData;
85
- }
86
- function randomInt(min, max) {
87
- if (!min)
88
- min = 0;
89
- if (!max)
90
- throw "max range number required";
91
- // min and max included
92
- return Math.floor(Math.random() * (max - min + 1) + min);
93
- }
94
- /**
95
- * Memorize cache
96
- *
97
- * @param {any} fn
98
- * @see {@link https://www.freecodecamp.org/news/understanding-memoize-in-javascript-51d07d19430e/}
99
- * @returns {typeof import('underscore').memoize}
100
- */
101
- var memoize = function (fn, debug) {
102
- var cache = {};
103
- return function () {
104
- var args = [];
105
- for (var _i = 0; _i < arguments.length; _i++) {
106
- args[_i] = arguments[_i];
107
- }
108
- var n = args[0];
109
- if (n in cache) {
110
- if (debug)
111
- console.log("Fetching from cache", n);
112
- //console.log(cache);
113
- return cache[n];
114
- }
115
- else {
116
- if (debug)
117
- console.log("Calculating result", n);
118
- var result = fn(n);
119
- cache[n] = result;
120
- return result;
121
- }
122
- };
123
- };
124
- var isFirst = true;
125
- /**
126
- * Dump large objects
127
- * @param {string} filename
128
- * @param {any} obj
129
- */
130
- function dump(filename) {
131
- var obj = [];
132
- for (var _i = 1; _i < arguments.length; _i++) {
133
- obj[_i - 1] = arguments[_i];
134
- }
135
- var loc = path.join(__dirname, "../tmp", filename);
136
- if (!fs.existsSync(path.dirname(loc))) {
137
- fs.mkdirSync(path.dirname(loc));
138
- }
139
- else if (isFirst) {
140
- isFirst = false;
141
- rimraf(loc, function (err) {
142
- console.log(loc, "deleted", err ? "fail" : "success");
143
- });
144
- return dump(filename, obj);
145
- }
146
- fs.writeFileSync(loc, util.inspect(obj));
147
- console.log("dump results saved to " + loc);
148
- }
149
- module.exports = {
150
- memoize: memoize,
151
- dump: dump,
152
- isIgnore: isIgnore,
153
- randInt: randomInt,
154
- streamToString: streamToString,
155
- isFileChanged: isFileChanged,
156
- getFileCache: getFileCache,
157
- setFileCache: setFileCache,
158
- setHexo: setHexo
159
- };
@@ -1,27 +0,0 @@
1
- export = versionParser;
2
- /**
3
- * Version Parser
4
- */
5
- declare class versionParser {
6
- /**
7
- * Version Parser Constructor
8
- * @param {string} str
9
- */
10
- constructor(str: string);
11
- result: {
12
- major: number;
13
- minor: number;
14
- build: number;
15
- };
16
- /**
17
- * Parse Version String
18
- * @param {string} str
19
- * @returns
20
- */
21
- parseVersion(str: string): {
22
- major: number;
23
- minor: number;
24
- build: number;
25
- };
26
- toString(): string;
27
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * Version Parser
3
- */
4
- var versionParser = /** @class */ (function () {
5
- /**
6
- * Version Parser Constructor
7
- * @param {string} str
8
- */
9
- function versionParser(str) {
10
- this.result = {
11
- major: 0,
12
- minor: 0,
13
- build: 0
14
- };
15
- if (typeof str == "string")
16
- this.parseVersion(str);
17
- }
18
- /**
19
- * Parse Version String
20
- * @param {string} str
21
- * @returns
22
- */
23
- versionParser.prototype.parseVersion = function (str) {
24
- if (typeof str != "string") {
25
- //return false;
26
- throw "argument required string, found " + typeof str;
27
- }
28
- var arr = str.split(".");
29
- // parse int or default to 0
30
- this.result.major = parseInt(arr[0]) || 0;
31
- this.result.minor = parseInt(arr[1]) || 0;
32
- this.result.build = parseInt(arr[2]) || 0;
33
- return this.result;
34
- };
35
- versionParser.prototype.toString = function () {
36
- return this.result.major + "." + this.result.minor + "." + this.result.build;
37
- };
38
- return versionParser;
39
- }());
40
- module.exports = versionParser;
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "eslint:recommended",
3
- "rules": {
4
- "comma-dangle": 0,
5
- "no-console": 0
6
- },
7
- "env": {
8
- "node": true
9
- },
10
- "globals": {
11
- "hexo": true
12
- }
13
- }
@@ -1,20 +0,0 @@
1
- Copyright (c) 2015 Gregory Scheerlinck
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
20
-
@@ -1,146 +0,0 @@
1
- # hexo-cli-extras
2
-
3
- This is a simple plugin for [Hexo](https://github.com/hexojs/hexo), a Node.js-based static site generator/blog framework.
4
-
5
- The plugin adds a handful of useful commands to the Hexo command-line interface: `edit`, `rename`, `remove`, `isolate` and `integrate`.
6
-
7
- Basic terminal editing:
8
-
9
- ![example](./docs/basic.gif)
10
-
11
- Basic GUI editing and selection on tag (sorry for the bad resolution):
12
-
13
- ![example](./docs/gui.gif)
14
-
15
- A more detailed explanation of the commands and their options is included below, but remember that you can run `hexo help` followed by any command in your terminal to get an overview (eg `hexo help edit`). You may also find the tips and notes at the very bottom of this README useful.
16
-
17
- ## Installation
18
-
19
- ```
20
- npm install --save hexo-cli-extras
21
- ```
22
-
23
- Note that the plugin *must* be installed locally. So if you have multiple blogs, you have to install it separately for each of them.
24
-
25
- ## edit command
26
-
27
- Select a post, page or draft using search terms and/or filters and open it in your favorite terminal $EDITOR or associated GUI text editor. If multiple items match your query, a menu will be displayed. By the way, if you're a vim-user with a distaste for arrow-keys, the menu supports vim-style keybindings (yay).
28
-
29
- ```
30
- hexo edit [title] [-a | --after MM-DD-YYYY] [-b | --before MM-DD-YYYY] [-c | --category | --categories CATEGORY] [-f | --folder SUBFOLDER] [-l | --layout] [-t | --tag | --tags TAG] [--draft | --drafts] [-g | --gui] [-p | --page | --pages]
31
- ```
32
-
33
- ### quick examples
34
-
35
- ```
36
- hexo edit
37
- ```
38
- --> gives you a menu with *all* your posts in descending chronological order, select one to edit using the arrow keys or `j`/`k`
39
-
40
- ```
41
- hexo edit search term
42
- ```
43
- --> uses the regular expressions `search` and `term` to filter the titles (or slugs) of your articles and displays a menu with all matches -- if only one article matches, it will open automatically in your editor
44
-
45
- ```
46
- hexo edit -a 11-11-2015 -g
47
- ```
48
- --> gives you a menu with all posts published after 11/11/2015 -- the selected article will open in gui mode
49
-
50
- ```
51
- hexo edit neovim -c vim
52
- ```
53
- --> looks in the database for articles in the "vim" category which match the regular expression "neovim" in their titles or slugs
54
-
55
- ### detailed information (get this info on the command line with `hexo help edit`)
56
-
57
- - `title` is a regular expression (case insensitive and spaces are allowed) for matching the title of a post
58
- - `-a` or `--after` (optional) filters out all posts that were made before the given date. A little parsing is done to help you, but use `MM-DD-YYYY` for best results
59
- - `-b` or `--before` (optional) filters out all posts that were made after the given date. A little parsing is done to help you, but use `MM-DD-YYYY` for best results
60
- - `-c` or `--category` (optional) filters posts on category
61
- - `-f` or `--folder` (optional) is (part of) the name of a subfolder in `hexo_dir/source` to narrow down your search in case you have multiple folders (for filtering on drafts, prefer to use `-d`)
62
- - `-l` or `--layout` (optional) filters posts/pages with a specific layout
63
- - `-t` or `--tag` (optional) filters posts on tag
64
- - `--draft` or `--drafts` (optional) excludes all published posts
65
- - `-g` or `--gui` (optional) causes selected files to open using an associated GUI editor, rather than a terminal editor set in the $EDITOR environment variable
66
- - `-p` or `--page` (optional) selects pages instead of posts
67
-
68
-
69
- *Note*: boolean options can be combined (for example `hexo edit -dp` to search for drafts that are pages)
70
-
71
- *Note*: Drafts only appear in searches without the `--drafts` option if you have `render_drafts` set to true in `_config.yml`. If set to false, you must use the `--draft` option to filter on drafts. Also, drafts are excluded automatically when you use any of the date filters, because dates make little sense with drafts.
72
-
73
- *Note*: Filter on title first and use boolean options last or you may get unexpected results. For example, `hexo edit -g my post` will filter just on "post" whereas `hexo edit my draft -g` will correctly filter on "my draft".
74
-
75
- *Note*: By default, files open in your current terminal window using your `$EDITOR` environment variable. Set it in your dotfiles (for example, in `.bashrc` or `.zshrc`).
76
-
77
- *Note*: The `gui` option (or the lack of an `$EDITOR` variable) will cause files to open with `xdg-open` (linux, osx) or `start` (windows). If you're on linux and nothing seems to happen, you can change the handler for plain text markdown files to a `*.desktop` file of your choice. For example, for Sublime Text: `xdg-mime default sublime-text.desktop text/plain`
78
-
79
- ## rename command
80
-
81
- Rename a post, page or draft. The title and the filename can be renamed independently or both at the same time.
82
-
83
- ![example](./docs/rename.png)
84
-
85
- ```
86
- hexo rename <old title/slug> <-n | --new "new title">
87
- ```
88
-
89
- `old title/slug` is one or more regular expressions to find a post or page. If more match your regex, a selection menu will be displayed.
90
-
91
- `new title` is the new title for your post. In case you just want to rename the file, it will be `slugize`d automatically (ie it will get converted to lower case, and all special characters and spaces will be made url-friendly).
92
-
93
- After selecting a file, you will be presented with another menu. From there you can choose whether to rename the filename, the title of the post, both, or cancel altogether.
94
-
95
- *Note*: if you have set `render_drafts` to false in `_config.yml`, you won't be able to rename drafts from the command line. It works only with that setting set to true or if you publish the post first.
96
-
97
- *Note*: wrap the new title in single or double quotes! If you forget, the presence of spaces or special characters may cause strange behavior.
98
-
99
-
100
- ## remove command
101
-
102
- Delete a post.
103
-
104
- ![example](./docs/remove.png)
105
-
106
- ```
107
- hexo remove <search terms>
108
- ```
109
-
110
- Search for a post and delete it after confirmation. This will cause the irreversible removal of the selected post *and* its associated asset folder (if it exists), along with all its contents.
111
-
112
- ## isolate command
113
-
114
- Isolate a post by temporarily removing all others from the build process.
115
-
116
- ```
117
- hexo isolate <search terms> [-a | --all]
118
- ```
119
-
120
- This command was inspired by Octopress. For testing purposes, you may want to isolate a post so you can work on it and test it in isolation from all others. This accomplishes that aim by moving all posts and asset directories (pages are not supported right now) to an `_exile` subfolder, where they will be ignored.
121
-
122
- The `-a` or `--all` option will cause *all* posts to be moved, and your search terms to be ignored.
123
-
124
- Run `hexo integrate` to restore the posts to their previous location.
125
-
126
- ## integrate command
127
-
128
- Restores all exiled posts.
129
-
130
- ```
131
- hexo integrate
132
- ```
133
-
134
- ## Info
135
-
136
- - It doesn't matter where in the hexo directory you are on the command line. As long as you are inside a hexo directory somewhere, the commands should work.
137
-
138
- - Installing this plugin will also cause any new post you create with `hexo new ...` to open automatically in your text editor.
139
-
140
- - The terminal menu may not work as expected in the default Windows command shell (`cmd.exe`), but it should work just fine in more powerful shells.
141
-
142
- - If you don't like the command-line centric workflow this plugin encourages, you may want to consider using an administration plugin instead - check out [hexo-admin](https://github.com/jaredly/hexo-admin) or [hexo-hey](https://github.com/nihgwu/hexo-hey).
143
-
144
- - Filter on title first and use boolean options last or you may get unexpected results. For example, `hexo edit -g my post` will filter just on "post" whereas `hexo edit my draft -g` will correctly filter on "my draft".
145
-
146
- - By default, files open in your current terminal window using your `EDITOR` environment variable. Set it somewhere in your dotfiles (`.bashrc` or `.zshrc` are good locations, and don't forget to source the file or reboot before testing). If `$EDITOR` doesn't exist, or if you use the `gui` option, files will open with [xdg-open](https://wiki.archlinux.org/index.php/default_applications#xdg-open_2) (linux, osx) or `start` (windows) instead.
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- require('./lib/extensions')(hexo);
4
-
5
- hexo.extend.console.register('edit', 'Edit a post or draft with your favorite $EDITOR', {
6
- desc: 'Edit a post or draft with your favorite $EDITOR. Filter on title (if applicable), before using optional arguments.',
7
- usage: '[title] [-a | --after MM-DD-YYYY] [-b | --before MM-DD-YYYY] [-c | --category CATEGORY] [-d | --draft | --drafts] [-f | --folder FOLDER] [-g | --gui] [-l | --layout LAYOUT] [-p | --page | --pages] [-t | --tag | --tags TAG]',
8
- arguments: [
9
- {name: 'title', desc: '(Part of) the title of a post. If more posts match this regex, a menu will be called.'},
10
- ],
11
- options: [
12
- {name: '-a, --after', desc: 'Only consider posts after this date (MM-DD-YYYY)'},
13
- {name: '-b, --before', desc: 'Only consider posts before this date (MM-DD-YYYY)'},
14
- {name: '-c, --category, --categories', desc: 'Category to filter on.'},
15
- {name: '-d, --draft, --drafts', desc: 'Only consider drafts'},
16
- {name: '-f, --folder', desc: 'Name of subfolder to filter on.'},
17
- {name: '-g, --gui', desc: 'Open file with associated GUI text editor. Default is to open in terminal using $EDITOR. If no $EDITOR is found, it will fall back to gui mode.'},
18
- {name: '-l, --layout', desc: 'Only consider posts with a given layout'},
19
- {name: '-p, --page, --pages', desc: 'Only consider pages'},
20
- {name: '-t, --tag, --tags', desc: 'Tag to filter on.'},
21
- ],
22
- }, require('./lib/edit'));
23
-
24
- hexo.extend.console.register('rename', 'Rename a post or draft', {
25
- desc: 'Rename a post or draft. Search for a post and set a new name with the -n or --new option, followed by the new title wrapped in single or double quotes',
26
- usage: '<old name> <-n | --new new name>',
27
- options: [
28
- {name: '-n, --new', desc: '(required) The new title. Wrap in single or double quotes if the title includes spaces.'},
29
- ],
30
- }, require('./lib/rename'));
31
-
32
- hexo.extend.console.register('remove', 'Remove a post or draft', {
33
- desc: 'Search for a post or draft and remove it.',
34
- usage: '<search terms for a post to be deleted>',
35
- }, require('./lib/remove'));
36
-
37
- hexo.extend.console.register('isolate', 'Isolate a post or page by temporarily removing all others from the build process', {
38
- desc: 'Move all posts to an ignored _exile subfolder, except for the one matching a given search term. If multiple posts match, a menu will be called. This can be useful for speeding up testing, but don\'t forget to use the integrate command to restore the exiled posts back to their previous location before deploying your site.',
39
- usage: '[search term]',
40
- options: [
41
- {name: '-a, --all', desc: 'Stash all posts in _exile, including the one for which the pattern matches.'},
42
- ],
43
- }, require('./lib/isolate'));
44
-
45
- hexo.extend.console.register('integrate', 'Restore isolated posts', {
46
- desc: 'Restore all exiled posts from _posts/_exile back to _posts. Opposite of the isolate command.',
47
- usage: '',
48
- }, require('./lib/integrate'));