hexo-dashboard 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 (102) hide show
  1. package/README.md +133 -0
  2. package/bin/hexo-dashboard +217 -0
  3. package/client/dist/assets/ArticleEditorComponent-BNtYfsit.css +1 -0
  4. package/client/dist/assets/ArticleEditorComponent-DM84zeTX.js +1 -0
  5. package/client/dist/assets/ArticleListComponent-CFyUxUGw.css +1 -0
  6. package/client/dist/assets/ArticleListComponent-KQh4CUN-.js +1 -0
  7. package/client/dist/assets/ConfigEditorComponent-CVEAF7yT.css +1 -0
  8. package/client/dist/assets/ConfigEditorComponent-kwRiMzrZ.js +1 -0
  9. package/client/dist/assets/MainConfigView-IFjwYCwE.js +1 -0
  10. package/client/dist/assets/PageEditorView-B19MWwlA.js +2 -0
  11. package/client/dist/assets/PagesView-ytYxxHpK.js +1 -0
  12. package/client/dist/assets/PostEditorView-BzOl_nAC.js +4 -0
  13. package/client/dist/assets/PostsView-CEq9xxs-.js +1 -0
  14. package/client/dist/assets/ThemeConfigView-DXGK_6a7.js +1 -0
  15. package/client/dist/assets/base16-dark-Bv11q3dD.js +84 -0
  16. package/client/dist/assets/base16-dark-CSajNCSC.css +1 -0
  17. package/client/dist/assets/index-CPpQGkhS.js +30 -0
  18. package/client/dist/assets/index-CdMTwo1E.css +1 -0
  19. package/client/dist/assets/page-CHW6FyZR.js +1 -0
  20. package/client/dist/assets/post-Cnm9xIIP.js +1 -0
  21. package/client/dist/index.html +15 -0
  22. package/package.json +76 -0
  23. package/server/dist/controllers/ArticleController.d.ts +14 -0
  24. package/server/dist/controllers/ArticleController.d.ts.map +1 -0
  25. package/server/dist/controllers/ArticleController.js +162 -0
  26. package/server/dist/controllers/ArticleController.js.map +1 -0
  27. package/server/dist/controllers/AuthController.d.ts +8 -0
  28. package/server/dist/controllers/AuthController.d.ts.map +1 -0
  29. package/server/dist/controllers/AuthController.js +33 -0
  30. package/server/dist/controllers/AuthController.js.map +1 -0
  31. package/server/dist/controllers/ConfigController.d.ts +9 -0
  32. package/server/dist/controllers/ConfigController.d.ts.map +1 -0
  33. package/server/dist/controllers/ConfigController.js +46 -0
  34. package/server/dist/controllers/ConfigController.js.map +1 -0
  35. package/server/dist/controllers/TaxonomyController.d.ts +8 -0
  36. package/server/dist/controllers/TaxonomyController.d.ts.map +1 -0
  37. package/server/dist/controllers/TaxonomyController.js +28 -0
  38. package/server/dist/controllers/TaxonomyController.js.map +1 -0
  39. package/server/dist/errors/BadRequestError.d.ts +5 -0
  40. package/server/dist/errors/BadRequestError.d.ts.map +1 -0
  41. package/server/dist/errors/BadRequestError.js +13 -0
  42. package/server/dist/errors/BadRequestError.js.map +1 -0
  43. package/server/dist/errors/HttpError.d.ts +5 -0
  44. package/server/dist/errors/HttpError.d.ts.map +1 -0
  45. package/server/dist/errors/HttpError.js +11 -0
  46. package/server/dist/errors/HttpError.js.map +1 -0
  47. package/server/dist/errors/InternalServerError.d.ts +5 -0
  48. package/server/dist/errors/InternalServerError.d.ts.map +1 -0
  49. package/server/dist/errors/InternalServerError.js +13 -0
  50. package/server/dist/errors/InternalServerError.js.map +1 -0
  51. package/server/dist/errors/NotFoundError.d.ts +5 -0
  52. package/server/dist/errors/NotFoundError.d.ts.map +1 -0
  53. package/server/dist/errors/NotFoundError.js +13 -0
  54. package/server/dist/errors/NotFoundError.js.map +1 -0
  55. package/server/dist/errors/UnauthorizedError.d.ts +5 -0
  56. package/server/dist/errors/UnauthorizedError.d.ts.map +1 -0
  57. package/server/dist/errors/UnauthorizedError.js +13 -0
  58. package/server/dist/errors/UnauthorizedError.js.map +1 -0
  59. package/server/dist/index.d.ts +2 -0
  60. package/server/dist/index.d.ts.map +1 -0
  61. package/server/dist/index.js +46 -0
  62. package/server/dist/index.js.map +1 -0
  63. package/server/dist/middlewares/auth.d.ts +4 -0
  64. package/server/dist/middlewares/auth.d.ts.map +1 -0
  65. package/server/dist/middlewares/auth.js +15 -0
  66. package/server/dist/middlewares/auth.js.map +1 -0
  67. package/server/dist/middlewares/errorHandler.d.ts +4 -0
  68. package/server/dist/middlewares/errorHandler.d.ts.map +1 -0
  69. package/server/dist/middlewares/errorHandler.js +16 -0
  70. package/server/dist/middlewares/errorHandler.js.map +1 -0
  71. package/server/dist/routes/article.d.ts +4 -0
  72. package/server/dist/routes/article.d.ts.map +1 -0
  73. package/server/dist/routes/article.js +20 -0
  74. package/server/dist/routes/article.js.map +1 -0
  75. package/server/dist/routes/auth.d.ts +4 -0
  76. package/server/dist/routes/auth.d.ts.map +1 -0
  77. package/server/dist/routes/auth.js +15 -0
  78. package/server/dist/routes/auth.js.map +1 -0
  79. package/server/dist/routes/config.d.ts +4 -0
  80. package/server/dist/routes/config.d.ts.map +1 -0
  81. package/server/dist/routes/config.js +16 -0
  82. package/server/dist/routes/config.js.map +1 -0
  83. package/server/dist/routes/taxonomy.d.ts +4 -0
  84. package/server/dist/routes/taxonomy.d.ts.map +1 -0
  85. package/server/dist/routes/taxonomy.js +15 -0
  86. package/server/dist/routes/taxonomy.js.map +1 -0
  87. package/server/dist/services/ArticleService.d.ts +31 -0
  88. package/server/dist/services/ArticleService.d.ts.map +1 -0
  89. package/server/dist/services/ArticleService.js +109 -0
  90. package/server/dist/services/ArticleService.js.map +1 -0
  91. package/server/dist/services/AuthService.d.ts +7 -0
  92. package/server/dist/services/AuthService.d.ts.map +1 -0
  93. package/server/dist/services/AuthService.js +16 -0
  94. package/server/dist/services/AuthService.js.map +1 -0
  95. package/server/dist/services/ConfigService.d.ts +10 -0
  96. package/server/dist/services/ConfigService.d.ts.map +1 -0
  97. package/server/dist/services/ConfigService.js +57 -0
  98. package/server/dist/services/ConfigService.js.map +1 -0
  99. package/server/dist/services/TaxonomyService.d.ts +8 -0
  100. package/server/dist/services/TaxonomyService.d.ts.map +1 -0
  101. package/server/dist/services/TaxonomyService.js +14 -0
  102. package/server/dist/services/TaxonomyService.js.map +1 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = require("path");
7
+ const crypto_1 = require("crypto");
8
+ const express_1 = __importDefault(require("express"));
9
+ const express_session_1 = __importDefault(require("express-session"));
10
+ const auth_1 = __importDefault(require("./middlewares/auth"));
11
+ const errorHandler_1 = __importDefault(require("./middlewares/errorHandler"));
12
+ const article_1 = __importDefault(require("./routes/article"));
13
+ const auth_2 = __importDefault(require("./routes/auth"));
14
+ const config_1 = __importDefault(require("./routes/config"));
15
+ const taxonomy_1 = __importDefault(require("./routes/taxonomy"));
16
+ hexo.extend.filter.register('server_middleware', function (app) {
17
+ const expressApp = (0, express_1.default)();
18
+ const dist = (0, path_1.join)(__dirname, '../../client/dist');
19
+ expressApp.set('trust proxy', 1);
20
+ expressApp.use(express_1.default.static(dist));
21
+ expressApp.use('/api', express_1.default.json());
22
+ expressApp.use('/api', (0, express_session_1.default)({
23
+ secret: (0, crypto_1.randomBytes)(32).toString('hex'),
24
+ resave: false,
25
+ saveUninitialized: false,
26
+ cookie: {
27
+ httpOnly: true,
28
+ secure: 'auto',
29
+ sameSite: 'lax',
30
+ maxAge: 1000 * 60 * 60,
31
+ },
32
+ }));
33
+ expressApp.use('/api', auth_1.default);
34
+ const router = express_1.default.Router();
35
+ router.use('/articles', (0, article_1.default)(hexo));
36
+ router.use('/auth', (0, auth_2.default)(hexo));
37
+ router.use('/config', (0, config_1.default)(hexo));
38
+ router.use('/taxonomies', (0, taxonomy_1.default)(hexo));
39
+ expressApp.use('/api', router);
40
+ expressApp.use('/api', errorHandler_1.default);
41
+ expressApp.get('/{*path}', (_req, res) => {
42
+ res.sendFile((0, path_1.join)(dist, 'index.html'));
43
+ });
44
+ app.use(path_1.posix.join('/', hexo.config.root, 'dashboard'), expressApp);
45
+ });
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":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,EAAE,IAAA,cAAS,EAAC,IAAI,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAA,gBAAW,EAAC,IAAI,CAAC,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,IAAA,kBAAa,EAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,sBAAY,CAAC,CAAC;IAErC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACvC,GAAG,CAAC,QAAQ,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAAC,YAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { RequestHandler } from 'express';
2
+ declare const auth: RequestHandler;
3
+ export default auth;
4
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middlewares/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,QAAA,MAAM,IAAI,EAAE,cAIX,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const UnauthorizedError_1 = __importDefault(require("../errors/UnauthorizedError"));
7
+ const auth = (req, _res, next) => {
8
+ if (req.session.loggedin)
9
+ return next();
10
+ if (req.url?.includes('/auth'))
11
+ return next();
12
+ throw new UnauthorizedError_1.default('Please login first!');
13
+ };
14
+ exports.default = auth;
15
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middlewares/auth.ts"],"names":[],"mappings":";;;;;AAEA,oFAA4D;AAE5D,MAAM,IAAI,GAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC/C,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ;QAAE,OAAO,IAAI,EAAE,CAAC;IACxC,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IAC9C,MAAM,IAAI,2BAAiB,CAAC,qBAAqB,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ErrorRequestHandler } from 'express';
2
+ declare const error: ErrorRequestHandler;
3
+ export default error;
4
+ //# sourceMappingURL=errorHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/middlewares/errorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD,QAAA,MAAM,KAAK,EAAE,mBAOZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const HttpError_1 = __importDefault(require("../errors/HttpError"));
7
+ const error = (err, _req, res, next) => {
8
+ if (res.headersSent)
9
+ return next(err);
10
+ res.setHeader('Content-Type', 'application/json');
11
+ res.statusCode = err instanceof HttpError_1.default ? err.code : 500;
12
+ res.statusMessage = err.message;
13
+ return res.end(JSON.stringify({ code: res.statusCode, msg: res.statusMessage }));
14
+ };
15
+ exports.default = error;
16
+ //# sourceMappingURL=errorHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../src/middlewares/errorHandler.ts"],"names":[],"mappings":";;;;;AAEA,oEAA4C;AAE5C,MAAM,KAAK,GAAwB,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAC1D,IAAI,GAAG,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAEtC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAClD,GAAG,CAAC,UAAU,GAAG,GAAG,YAAY,mBAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC;IAChC,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Hexo from 'hexo';
2
+ import { Router } from 'express';
3
+ export default function (hexo: Hexo): Router;
4
+ //# sourceMappingURL=article.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../src/routes/article.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,IAAI,GAAG,MAAM,CAW3C"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
7
+ const express_1 = require("express");
8
+ const ArticleController_1 = __importDefault(require("../controllers/ArticleController"));
9
+ function default_1(hexo) {
10
+ const router = (0, express_1.Router)();
11
+ const controller = new ArticleController_1.default(hexo);
12
+ router.get('/', controller.getArticles);
13
+ router.get('/:id', controller.getData);
14
+ router.post('/', controller.create);
15
+ router.put('/:id', controller.update);
16
+ router.delete('/:id', controller.remove);
17
+ router.post('/:id/status', controller.changeStatus);
18
+ return router;
19
+ }
20
+ //# sourceMappingURL=article.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article.js","sourceRoot":"","sources":["../../src/routes/article.ts"],"names":[],"mappings":";;;;;AAKA,4BAWC;AAdD,qCAAiC;AACjC,yFAAiE;AAEjE,mBAAyB,IAAU;IACjC,MAAM,MAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,2BAAiB,CAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Hexo from 'hexo';
2
+ import { Router } from 'express';
3
+ export default function (hexo: Hexo): Router;
4
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,IAAI,GAAG,MAAM,CAM3C"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
7
+ const express_1 = require("express");
8
+ const AuthController_1 = __importDefault(require("../controllers/AuthController"));
9
+ function default_1(hexo) {
10
+ const router = (0, express_1.Router)();
11
+ const controller = new AuthController_1.default(hexo);
12
+ router.post('/', controller.authenticate);
13
+ return router;
14
+ }
15
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":";;;;;AAKA,4BAMC;AATD,qCAAiC;AACjC,mFAA2D;AAE3D,mBAAyB,IAAU;IACjC,MAAM,MAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,wBAAc,CAAC,IAAI,CAAC,CAAC;IAE5C,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Hexo from 'hexo';
2
+ import { Router } from 'express';
3
+ export default function (hexo: Hexo): Router;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,IAAI,GAAG,MAAM,CAO3C"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
7
+ const express_1 = require("express");
8
+ const ConfigController_1 = __importDefault(require("../controllers/ConfigController"));
9
+ function default_1(hexo) {
10
+ const router = (0, express_1.Router)();
11
+ const controller = new ConfigController_1.default(hexo);
12
+ router.get('/', controller.getConfig);
13
+ router.post('/', controller.updateConfig);
14
+ return router;
15
+ }
16
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":";;;;;AAKA,4BAOC;AAVD,qCAAiC;AACjC,uFAA+D;AAE/D,mBAAyB,IAAU;IACjC,MAAM,MAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,0BAAgB,CAAC,IAAI,CAAC,CAAC;IAE9C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Hexo from 'hexo';
2
+ import { Router } from 'express';
3
+ export default function (hexo: Hexo): Router;
4
+ //# sourceMappingURL=taxonomy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taxonomy.d.ts","sourceRoot":"","sources":["../../src/routes/taxonomy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,IAAI,GAAG,MAAM,CAM3C"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
7
+ const express_1 = require("express");
8
+ const TaxonomyController_1 = __importDefault(require("../controllers/TaxonomyController"));
9
+ function default_1(hexo) {
10
+ const router = (0, express_1.Router)();
11
+ const controller = new TaxonomyController_1.default(hexo);
12
+ router.get('/', controller.getTaxonomies);
13
+ return router;
14
+ }
15
+ //# sourceMappingURL=taxonomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taxonomy.js","sourceRoot":"","sources":["../../src/routes/taxonomy.ts"],"names":[],"mappings":";;;;;AAKA,4BAMC;AATD,qCAAiC;AACjC,2FAAmE;AAEnE,mBAAyB,IAAU;IACjC,MAAM,MAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,4BAAkB,CAAC,IAAI,CAAC,CAAC;IAEhD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type Hexo from 'hexo';
2
+ import type Model from 'model';
3
+ import type Query from 'query';
4
+ import type Document from 'document';
5
+ import type { PageSchema, PostSchema } from 'hexo/dist/types';
6
+ export default class ArticleService {
7
+ private hexo;
8
+ private type;
9
+ private model;
10
+ constructor(hexo: Hexo, type: string, model: Model<PostSchema | PageSchema>);
11
+ getArticles(title?: string | undefined, category?: string | undefined, tag?: string | undefined): Query<PostSchema | PageSchema>;
12
+ getData(query: string | object): {
13
+ data: string;
14
+ content: string;
15
+ separator: string;
16
+ prefixSeparator: boolean;
17
+ } | {
18
+ content: string;
19
+ data?: undefined;
20
+ separator?: undefined;
21
+ prefixSeparator?: undefined;
22
+ } | null;
23
+ create(meta: string, content: string): Promise<Document<PostSchema | PageSchema> | undefined>;
24
+ update(id: string, meta: string, content: string): Promise<Document<PostSchema | PageSchema> | undefined>;
25
+ remove(id: string): Promise<void>;
26
+ publish(id: string): Promise<Document<PostSchema | PageSchema> | undefined>;
27
+ unpublish(id: string): Promise<Document<PostSchema | PageSchema> | undefined>;
28
+ findDocument(query: string | object): Document<PostSchema | PageSchema> | undefined;
29
+ toRelativePath(path: string): string;
30
+ }
31
+ //# sourceMappingURL=ArticleService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArticleService.d.ts","sourceRoot":"","sources":["../../src/services/ArticleService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAkB,UAAU,EAAE,UAAU,EAAa,MAAM,iBAAiB,CAAC;AAMzF,MAAM,CAAC,OAAO,OAAO,cAAc;IAE/B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,KAAK;gBAFL,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAI/C,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAShI,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG;QAC7B,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,OAAO,CAAC;KAC1B,GAAG;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,eAAe,CAAC,EAAE,SAAS,CAAC;KAC7B,GAAG,IAAI;IAMJ,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC;IAa7F,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC;IAczG,MAAM,CAAC,EAAE,EAAE,MAAM;IAajB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC;IAe3E,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC;IAenF,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS;IAQnF,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAGrC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const hexo_front_matter_1 = require("hexo-front-matter");
5
+ const hexo_fs_1 = require("hexo-fs");
6
+ class ArticleService {
7
+ hexo;
8
+ type;
9
+ model;
10
+ constructor(hexo, type, model) {
11
+ this.hexo = hexo;
12
+ this.type = type;
13
+ this.model = model;
14
+ }
15
+ getArticles(title, category, tag) {
16
+ return this.model.filter((article) => {
17
+ if (title && !article.title.toLowerCase().includes(title.toLowerCase()))
18
+ return false;
19
+ if (category && !article.categories.some(c => c.name === category))
20
+ return false;
21
+ if (tag && !article.tags.some(t => t.name === tag))
22
+ return false;
23
+ return true;
24
+ }).sort('date', -1);
25
+ }
26
+ getData(query) {
27
+ const document = this.findDocument(query);
28
+ if (!document)
29
+ return null;
30
+ return (0, hexo_front_matter_1.split)(document.raw);
31
+ }
32
+ async create(meta, content) {
33
+ const compiled = (0, hexo_front_matter_1.parse)(['---', meta, '---', content].join('\n'));
34
+ if (!compiled.title)
35
+ throw new Error('Title cannot be empty!');
36
+ compiled.updated = compiled.updated || new Date();
37
+ compiled.author = this.hexo.config.author;
38
+ compiled.layout = this.type;
39
+ const file = await this.hexo.post.create(compiled);
40
+ await this.hexo.source.process();
41
+ return this.findDocument({ 'source': this.toRelativePath(file.path) });
42
+ }
43
+ async update(id, meta, content) {
44
+ const document = this.findDocument(id);
45
+ if (!document)
46
+ throw new Error('The article with ID ' + id + ' could not be found!');
47
+ const compiled = (0, hexo_front_matter_1.parse)(['---', meta, '---', content].join('\n'));
48
+ compiled.updated = compiled.updated || new Date();
49
+ compiled.date = compiled.date || new Date(document.date.valueOf());
50
+ compiled.author = compiled.author || document.author || this.hexo.config.author;
51
+ await (0, hexo_fs_1.writeFile)(document.full_source, (0, hexo_front_matter_1.stringify)(compiled));
52
+ await this.hexo.source.process();
53
+ return this.findDocument({ 'source': this.toRelativePath(document.full_source) });
54
+ }
55
+ async remove(id) {
56
+ const document = this.findDocument(id);
57
+ if (!document)
58
+ throw new Error('The article with ID ' + id + ' could not be found!');
59
+ if (this.type === 'page') {
60
+ await (0, hexo_fs_1.rmdir)((0, path_1.dirname)(document.full_source));
61
+ }
62
+ else if (this.type === 'post') {
63
+ await (0, hexo_fs_1.unlink)(document.full_source);
64
+ }
65
+ await this.hexo.source.process();
66
+ }
67
+ async publish(id) {
68
+ if (this.type !== 'post')
69
+ return;
70
+ const document = this.findDocument(id);
71
+ if (!document)
72
+ throw new Error('The article with ID ' + id + ' could not be found!');
73
+ const postDir = (0, path_1.join)(this.hexo.source_dir, '_posts');
74
+ const fullSource = (0, path_1.join)(postDir, (0, path_1.basename)(document.full_source));
75
+ if (!await (0, hexo_fs_1.exists)(postDir))
76
+ await (0, hexo_fs_1.mkdir)(postDir);
77
+ await (0, hexo_fs_1.rename)(document.full_source, fullSource);
78
+ await this.hexo.source.process();
79
+ return this.findDocument({ 'source': this.toRelativePath(fullSource) });
80
+ }
81
+ async unpublish(id) {
82
+ if (this.type !== 'post')
83
+ return;
84
+ const document = this.findDocument(id);
85
+ if (!document)
86
+ throw new Error('The article with ID ' + id + ' could not be found!');
87
+ const draftDir = (0, path_1.join)(this.hexo.source_dir, '_drafts');
88
+ const fullSource = (0, path_1.join)(draftDir, (0, path_1.basename)(document.full_source));
89
+ if (!await (0, hexo_fs_1.exists)(draftDir))
90
+ await (0, hexo_fs_1.mkdir)(draftDir);
91
+ await (0, hexo_fs_1.rename)(document.full_source, fullSource);
92
+ await this.hexo.source.process();
93
+ return this.findDocument({ 'source': this.toRelativePath(fullSource) });
94
+ }
95
+ findDocument(query) {
96
+ if (typeof (query) === 'string') {
97
+ return this.model.findById(query);
98
+ }
99
+ else {
100
+ return this.model.findOne(query);
101
+ }
102
+ }
103
+ toRelativePath(path) {
104
+ return path.slice(this.hexo.source_dir.length).replace(/\\/g, '/');
105
+ }
106
+ }
107
+ exports.default = ArticleService;
108
+ ;
109
+ //# sourceMappingURL=ArticleService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArticleService.js","sourceRoot":"","sources":["../../src/services/ArticleService.ts"],"names":[],"mappings":";;AAMA,+BAA+C;AAC/C,yDAA4D;AAC5D,qCAA0E;AAE1E,MAAqB,cAAc;IAEvB;IACA;IACA;IAHV,YACU,IAAU,EACV,IAAY,EACZ,KAAqC;QAFrC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,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY,CAAC,KAAsB;QACjC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;CACF;AAlHD,iCAkHC;AAAA,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type Hexo from 'hexo';
2
+ export default class AuthService {
3
+ private hexo;
4
+ constructor(hexo: Hexo);
5
+ authenticate(username: string, password: string): boolean;
6
+ }
7
+ //# sourceMappingURL=AuthService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthService.d.ts","sourceRoot":"","sources":["../../src/services/AuthService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,MAAM,CAAC,OAAO,OAAO,WAAW;IAE5B,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI;IAIpB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;CAI1D"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bcryptjs_1 = require("bcryptjs");
4
+ class AuthService {
5
+ hexo;
6
+ constructor(hexo) {
7
+ this.hexo = hexo;
8
+ }
9
+ authenticate(username, password) {
10
+ const target = this.hexo.config.dashboard[username];
11
+ return (0, bcryptjs_1.compareSync)(password, target);
12
+ }
13
+ }
14
+ exports.default = AuthService;
15
+ ;
16
+ //# sourceMappingURL=AuthService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../src/services/AuthService.ts"],"names":[],"mappings":";;AAEA,uCAAuC;AAEvC,MAAqB,WAAW;IAEpB;IADV,YACU,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAEpB,CAAC;IAED,YAAY,CAAC,QAAgB,EAAE,QAAgB;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACpD,OAAO,IAAA,sBAAW,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;CACF;AAVD,8BAUC;AAAA,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type Hexo from 'hexo';
2
+ export default class ConfigService {
3
+ private hexo;
4
+ private paths;
5
+ private loadFunc;
6
+ constructor(hexo: Hexo, type: 'mainconfig' | 'themeconfig');
7
+ getConfig(): Promise<string | undefined>;
8
+ updateConfig(data: string): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=ConfigService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigService.d.ts","sourceRoot":"","sources":["../../src/services/ConfigService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,QAAQ,CAAgC;gBAEpC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,aAAa;IAwBpD,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAUxC,YAAY,CAAC,IAAI,EAAE,MAAM;CAUhC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = require("path");
7
+ const hexo_fs_1 = require("hexo-fs");
8
+ const load_config_1 = __importDefault(require("hexo/dist/hexo/load_config"));
9
+ const load_theme_config_1 = __importDefault(require("hexo/dist/hexo/load_theme_config"));
10
+ class ConfigService {
11
+ hexo;
12
+ paths;
13
+ loadFunc;
14
+ constructor(hexo, type) {
15
+ this.hexo = hexo;
16
+ switch (type) {
17
+ case 'mainconfig':
18
+ this.paths = [hexo.config_path];
19
+ this.loadFunc = async (hexo) => {
20
+ return (0, load_config_1.default)(hexo);
21
+ };
22
+ break;
23
+ case 'themeconfig':
24
+ this.paths = [
25
+ (0, path_1.join)(hexo.base_dir, `_config.${hexo.config.theme}.yml`),
26
+ (0, path_1.join)(hexo.theme_dir, '_config.yml'),
27
+ ];
28
+ this.loadFunc = async (hexo) => {
29
+ return (0, load_theme_config_1.default)(hexo);
30
+ };
31
+ break;
32
+ default:
33
+ this.paths = [];
34
+ this.loadFunc = async () => { };
35
+ }
36
+ }
37
+ async getConfig() {
38
+ for (const path of this.paths) {
39
+ if (await (0, hexo_fs_1.exists)(path)) {
40
+ return (0, hexo_fs_1.readFile)(path);
41
+ }
42
+ }
43
+ return undefined;
44
+ }
45
+ async updateConfig(data) {
46
+ for (const path of this.paths) {
47
+ if (await (0, hexo_fs_1.exists)(path)) {
48
+ await (0, hexo_fs_1.writeFile)(path, data);
49
+ }
50
+ }
51
+ await this.loadFunc(this.hexo);
52
+ await this.hexo.load();
53
+ }
54
+ }
55
+ exports.default = ConfigService;
56
+ ;
57
+ //# sourceMappingURL=ConfigService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigService.js","sourceRoot":"","sources":["../../src/services/ConfigService.ts"],"names":[],"mappings":";;;;;AAEA,+BAA4B;AAC5B,qCA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AY;QAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,MAAM,IAAA,gBAAM,EAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAA,mBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AAjDD,gCAiDC;AAAA,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type Model from 'model';
2
+ import type { CategorySchema, TagSchema } from 'hexo/dist/types';
3
+ export default class TaxonomyService {
4
+ private model;
5
+ constructor(model: Model<CategorySchema | TagSchema>);
6
+ getTaxonomies(): string[];
7
+ }
8
+ //# sourceMappingURL=TaxonomyService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaxonomyService.d.ts","sourceRoot":"","sources":["../../src/services/TaxonomyService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,eAAe;IAEhC,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK,CAAC,cAAc,GAAG,SAAS,CAAC;IAIlD,aAAa,IAAI,MAAM,EAAE;CAG1B"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class TaxonomyService {
4
+ model;
5
+ constructor(model) {
6
+ this.model = model;
7
+ }
8
+ getTaxonomies() {
9
+ return this.model.map(taxonomy => taxonomy.name);
10
+ }
11
+ }
12
+ exports.default = TaxonomyService;
13
+ ;
14
+ //# sourceMappingURL=TaxonomyService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaxonomyService.js","sourceRoot":"","sources":["../../src/services/TaxonomyService.ts"],"names":[],"mappings":";;AAGA,MAAqB,eAAe;IAExB;IADV,YACU,KAAwC;QAAxC,UAAK,GAAL,KAAK,CAAmC;IAElD,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACF;AATD,kCASC;AAAA,CAAC"}