@silexlabs/silex 3.0.0-alpha.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.default +19 -0
- package/.silex.js +37 -0
- package/LICENSE +661 -0
- package/README.md +96 -0
- package/dist/client/client/api.d.ts +85 -0
- package/dist/client/client/assetUrl.d.ts +51 -0
- package/dist/client/client/config.d.ts +58 -0
- package/dist/client/client/events.d.ts +14 -0
- package/dist/client/client/expose.d.ts +8 -0
- package/dist/client/client/grapesjs/LoginDialog.d.ts +15 -0
- package/dist/client/client/grapesjs/PublicationManager.d.ts +72 -0
- package/dist/client/client/grapesjs/PublicationUi.d.ts +62 -0
- package/dist/client/client/grapesjs/blocks.d.ts +1 -0
- package/dist/client/client/grapesjs/breadcrumbs.d.ts +1 -0
- package/dist/client/client/grapesjs/footer.d.ts +2 -0
- package/dist/client/client/grapesjs/index.d.ts +5 -0
- package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
- package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
- package/dist/client/client/grapesjs/openImport.d.ts +9 -0
- package/dist/client/client/grapesjs/page-panel.d.ts +3 -0
- package/dist/client/client/grapesjs/project-bar.d.ts +1 -0
- package/dist/client/client/grapesjs/rich-text.d.ts +1 -0
- package/dist/client/client/grapesjs/semantic.d.ts +1 -0
- package/dist/client/client/grapesjs/settings.d.ts +2 -0
- package/dist/client/client/grapesjs/storage.d.ts +1 -0
- package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
- package/dist/client/client/index.d.ts +5 -0
- package/dist/client/client/publication-transformers.d.ts +41 -0
- package/dist/client/client/utils.d.ts +2 -0
- package/dist/client/constants.d.ts +29 -0
- package/dist/client/css/admin.css +4491 -0
- package/dist/client/index.html +9 -0
- package/dist/client/js/main.js +321 -0
- package/dist/client/js/main.js.LICENSE.txt +24 -0
- package/dist/client/page.d.ts +2 -0
- package/dist/client/types.d.ts +334 -0
- package/dist/plugins/client/client/api.d.ts +85 -0
- package/dist/plugins/client/client/api.js +114 -0
- package/dist/plugins/client/client/api.js.map +1 -0
- package/dist/plugins/client/client/assetUrl.d.ts +51 -0
- package/dist/plugins/client/client/assetUrl.js +224 -0
- package/dist/plugins/client/client/assetUrl.js.map +1 -0
- package/dist/plugins/client/client/config.d.ts +58 -0
- package/dist/plugins/client/client/config.js +90 -0
- package/dist/plugins/client/client/config.js.map +1 -0
- package/dist/plugins/client/client/events.d.ts +14 -0
- package/dist/plugins/client/client/events.js +34 -0
- package/dist/plugins/client/client/events.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js +195 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +72 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js +356 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +62 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.js +336 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
- package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js +75 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/footer.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/footer.js +28 -0
- package/dist/plugins/client/client/grapesjs/footer.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
- package/dist/plugins/client/client/grapesjs/index.js +313 -0
- package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/internal-links.js +219 -0
- package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
- package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
- package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
- package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
- package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/project-bar.js +104 -0
- package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
- package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
- package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/settings.js +198 -0
- package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/storage.js +126 -0
- package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
- package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
- package/dist/plugins/client/client/publication-transformers.js +238 -0
- package/dist/plugins/client/client/publication-transformers.js.map +1 -0
- package/dist/plugins/client/client/utils.d.ts +2 -0
- package/dist/plugins/client/client/utils.js +25 -0
- package/dist/plugins/client/client/utils.js.map +1 -0
- package/dist/plugins/client/constants.d.ts +29 -0
- package/dist/plugins/client/constants.js +46 -0
- package/dist/plugins/client/constants.js.map +1 -0
- package/dist/plugins/client/page.d.ts +2 -0
- package/dist/plugins/client/page.js +31 -0
- package/dist/plugins/client/page.js.map +1 -0
- package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
- package/dist/plugins/client/plugins/client/11ty.js +86 -0
- package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +2 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.js +170 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -0
- package/dist/plugins/client/plugins/client/template.d.ts +2 -0
- package/dist/plugins/client/plugins/client/template.js +183 -0
- package/dist/plugins/client/plugins/client/template.js.map +1 -0
- package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
- package/dist/plugins/client/plugins/client/website-info.js +72 -0
- package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
- package/dist/plugins/client/types.d.ts +334 -0
- package/dist/plugins/client/types.js +74 -0
- package/dist/plugins/client/types.js.map +1 -0
- package/dist/plugins/server/constants.d.ts +29 -0
- package/dist/plugins/server/constants.js +49 -0
- package/dist/plugins/server/constants.js.map +1 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.js +40 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.js.map +1 -0
- package/dist/plugins/server/plugins/server/Cache.d.ts +2 -0
- package/dist/plugins/server/plugins/server/Cache.js +32 -0
- package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.js +129 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +86 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js +526 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +87 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js +564 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
- package/dist/plugins/server/plugins/server/SslPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/SslPlugin.js +86 -0
- package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.js +78 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
- package/dist/plugins/server/server/config.d.ts +59 -0
- package/dist/plugins/server/server/config.js +181 -0
- package/dist/plugins/server/server/config.js.map +1 -0
- package/dist/plugins/server/server/connectors/FsHosting.d.ts +13 -0
- package/dist/plugins/server/server/connectors/FsHosting.js +54 -0
- package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
- package/dist/plugins/server/server/connectors/FsStorage.d.ts +43 -0
- package/dist/plugins/server/server/connectors/FsStorage.js +257 -0
- package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
- package/dist/plugins/server/server/connectors/connectors.d.ts +87 -0
- package/dist/plugins/server/server/connectors/connectors.js +127 -0
- package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
- package/dist/plugins/server/server/events.d.ts +26 -0
- package/dist/plugins/server/server/events.js +31 -0
- package/dist/plugins/server/server/events.js.map +1 -0
- package/dist/plugins/server/server/jobs.d.ts +12 -0
- package/dist/plugins/server/server/jobs.js +77 -0
- package/dist/plugins/server/server/jobs.js.map +1 -0
- package/dist/plugins/server/server/utils/validation.d.ts +7 -0
- package/dist/plugins/server/server/utils/validation.js +38 -0
- package/dist/plugins/server/server/utils/validation.js.map +1 -0
- package/dist/plugins/server/types.d.ts +334 -0
- package/dist/plugins/server/types.js +78 -0
- package/dist/plugins/server/types.js.map +1 -0
- package/dist/server/constants.js +29 -0
- package/dist/server/plugins/server/Cache.js +15 -0
- package/dist/server/server/api/api.js +20 -0
- package/dist/server/server/api/connectorApi.js +216 -0
- package/dist/server/server/api/publicationApi.js +108 -0
- package/dist/server/server/api/websiteApi.js +296 -0
- package/dist/server/server/cli.js +68 -0
- package/dist/server/server/config.js +120 -0
- package/dist/server/server/connectors/FsHosting.js +35 -0
- package/dist/server/server/connectors/FsStorage.js +225 -0
- package/dist/server/server/connectors/connectors.js +89 -0
- package/dist/server/server/events.js +14 -0
- package/dist/server/server/expose.js +27 -0
- package/dist/server/server/express.js +47 -0
- package/dist/server/server/index.js +90 -0
- package/dist/server/server/jobs.js +48 -0
- package/dist/server/server/utils/validation.js +15 -0
- package/dist/server/types.js +34 -0
- package/package.json +209 -0
- package/public/assets/container.png +0 -0
- package/public/assets/favicon.png +0 -0
- package/public/assets/logo-silex-small.png +0 -0
- package/public/robots.txt +2 -0
- package/public/silex.js +24 -0
- package/src/css/_mixins.scss +8 -0
- package/src/css/_variables.scss +33 -0
- package/src/css/dialog.scss +41 -0
- package/src/css/footer.scss +12 -0
- package/src/css/grapesjs-light.scss +180 -0
- package/src/css/grapesjs.scss +152 -0
- package/src/css/index.scss +32 -0
- package/src/css/light.scss +7 -0
- package/src/css/loader.scss +12 -0
- package/src/css/page-panel.scss +65 -0
- package/src/css/project-bar.scss +102 -0
- package/src/css/silex.scss +189 -0
- package/src/css/website-info.scss +14 -0
- package/src/html/debug.pug +8 -0
- package/src/html/index.pug +39 -0
- package/src/html/templates/includes.pug +1 -0
- package/src/html/templates/workspace.pug +2 -0
- package/src/ts/client/api.ts +144 -0
- package/src/ts/client/assetUrl.test.ts +125 -0
- package/src/ts/client/assetUrl.ts +235 -0
- package/src/ts/client/config.ts +105 -0
- package/src/ts/client/events.ts +34 -0
- package/src/ts/client/expose.ts +30 -0
- package/src/ts/client/grapesjs/LoginDialog.ts +204 -0
- package/src/ts/client/grapesjs/PublicationManager.ts +370 -0
- package/src/ts/client/grapesjs/PublicationUi.ts +342 -0
- package/src/ts/client/grapesjs/blocks.ts +37 -0
- package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
- package/src/ts/client/grapesjs/eleventy.ts +47 -0
- package/src/ts/client/grapesjs/footer.ts +27 -0
- package/src/ts/client/grapesjs/index.ts +335 -0
- package/src/ts/client/grapesjs/internal-links.test.ts +105 -0
- package/src/ts/client/grapesjs/internal-links.ts +225 -0
- package/src/ts/client/grapesjs/new-page-dialog.ts +90 -0
- package/src/ts/client/grapesjs/openImport.ts +81 -0
- package/src/ts/client/grapesjs/page-panel.ts +118 -0
- package/src/ts/client/grapesjs/project-bar.ts +107 -0
- package/src/ts/client/grapesjs/rich-text.ts +33 -0
- package/src/ts/client/grapesjs/semantic.ts +114 -0
- package/src/ts/client/grapesjs/settings.ts +208 -0
- package/src/ts/client/grapesjs/storage.ts +121 -0
- package/src/ts/client/grapesjs/symbolDialogs.ts +38 -0
- package/src/ts/client/index.ts +98 -0
- package/src/ts/client/publication-transformers.test.ts +199 -0
- package/src/ts/client/publication-transformers.ts +263 -0
- package/src/ts/client/utils.ts +28 -0
- package/src/ts/constants.ts +52 -0
- package/src/ts/externs.ts +18 -0
- package/src/ts/page.ts +31 -0
- package/src/ts/plugins/client/11ty.ts +104 -0
- package/src/ts/plugins/client/publicationRenderer.ts +174 -0
- package/src/ts/plugins/client/template.ts +192 -0
- package/src/ts/plugins/client/website-info.ts +84 -0
- package/src/ts/plugins/server/AuthPlugin.ts +38 -0
- package/src/ts/plugins/server/Cache.ts +28 -0
- package/src/ts/plugins/server/DownloadConnector.ts +148 -0
- package/src/ts/plugins/server/FtpConnector.test.ts +82 -0
- package/src/ts/plugins/server/FtpConnector.ts +609 -0
- package/src/ts/plugins/server/GitlabConnector.ts +644 -0
- package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
- package/src/ts/plugins/server/SslPlugin.ts +84 -0
- package/src/ts/plugins/server/StaticPlugin.ts +79 -0
- package/src/ts/server/api/api.ts +19 -0
- package/src/ts/server/api/connectorApi.ts +345 -0
- package/src/ts/server/api/publicationApi.ts +159 -0
- package/src/ts/server/api/websiteApi.ts +432 -0
- package/src/ts/server/cli.ts +65 -0
- package/src/ts/server/config.ts +189 -0
- package/src/ts/server/connectors/FsHosting.ts +60 -0
- package/src/ts/server/connectors/FsStorage.test.ts +51 -0
- package/src/ts/server/connectors/FsStorage.ts +261 -0
- package/src/ts/server/connectors/connectors.ts +203 -0
- package/src/ts/server/events.ts +37 -0
- package/src/ts/server/expose.ts +19 -0
- package/src/ts/server/express.ts +70 -0
- package/src/ts/server/index.ts +100 -0
- package/src/ts/server/jobs.test.ts +75 -0
- package/src/ts/server/jobs.ts +87 -0
- package/src/ts/server/utils/BackwardCompat.ts +552 -0
- package/src/ts/server/utils/validation.ts +34 -0
- package/src/ts/types.ts +339 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const express_1 = __importDefault(require("express"));
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const https_1 = require("https");
|
|
25
|
+
const express_force_ssl_1 = __importDefault(require("express-force-ssl"));
|
|
26
|
+
const events_1 = require("../../server/events");
|
|
27
|
+
// interface SslOptions {
|
|
28
|
+
// forceHttps?: boolean
|
|
29
|
+
// trustXFPHeader?: boolean
|
|
30
|
+
// privateKey?: string
|
|
31
|
+
// certificate?: string
|
|
32
|
+
// sslPort?: string
|
|
33
|
+
// }
|
|
34
|
+
async function default_1(config, opts = {}) {
|
|
35
|
+
// Options with defaults
|
|
36
|
+
const options = {
|
|
37
|
+
forceHttps: process.env.SILEX_FORCE_HTTPS === 'true',
|
|
38
|
+
trustXFPHeader: process.env.SILEX_FORCE_HTTPS_TRUST_XFP_HEADER === 'true',
|
|
39
|
+
privateKey: process.env.SILEX_SSL_PRIVATE_KEY,
|
|
40
|
+
certificate: process.env.SILEX_SSL_CERTIFICATE,
|
|
41
|
+
sslPort: process.env.SSL_PORT || '443',
|
|
42
|
+
...opts,
|
|
43
|
+
};
|
|
44
|
+
// Add routes on silex startup
|
|
45
|
+
config.on(events_1.ServerEvent.STARTUP_START, ({ app }) => {
|
|
46
|
+
const router = express_1.default.Router();
|
|
47
|
+
// SSL
|
|
48
|
+
// force ssl if the env var SILEX_FORCE_HTTPS is set
|
|
49
|
+
if (options.forceHttps) {
|
|
50
|
+
console.info('> [SslPlugin] Force SSL option is enabled');
|
|
51
|
+
app.set('forceSSLOptions', {
|
|
52
|
+
trustXFPHeader: !!options.trustXFPHeader,
|
|
53
|
+
});
|
|
54
|
+
router.use(express_force_ssl_1.default);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.info('> [SslPlugin] Force SSL option is disabled, env var SILEX_FORCE_HTTPS not set');
|
|
58
|
+
}
|
|
59
|
+
// SSL certificate
|
|
60
|
+
if (options.privateKey && options.certificate) {
|
|
61
|
+
console.info('> [SslPlugin] SSL certificate is enabled, found certificate:', options.certificate);
|
|
62
|
+
try {
|
|
63
|
+
const privateKey = (0, fs_1.readFileSync)(options.privateKey).toString();
|
|
64
|
+
const certificate = (0, fs_1.readFileSync)(options.certificate).toString();
|
|
65
|
+
const sslServerOptions = {
|
|
66
|
+
key: privateKey,
|
|
67
|
+
cert: certificate,
|
|
68
|
+
requestCert: true,
|
|
69
|
+
rejectUnauthorized: false,
|
|
70
|
+
};
|
|
71
|
+
(0, https_1.createServer)(sslServerOptions, this).listen(options.sslPort, () => {
|
|
72
|
+
console.info('> [SslPlugin] Listening on port ', options.sslPort);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error('> [SslPlugin] Load certificate failed.', e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.info('> [SslPlugin] Certificate disabled, env vars SILEX_SSL_CERTIFICATE and SILEX_SSL_PRIVATE_KEY not set');
|
|
81
|
+
}
|
|
82
|
+
app.use(router);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.default = default_1;
|
|
86
|
+
//# sourceMappingURL=SslPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SslPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/SslPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;AAEH,sDAA6B;AAC7B,2BAAiC;AACjC,iCAAoC;AACpC,0EAAwC;AACxC,gDAAiD;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AU,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAC9D,MAAM,WAAW,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAEhE,MAAM,gBAAgB,GAAG;oBACvB,GAAG,EAAE,UAAU;oBACf,IAAI,EAAE,WAAW;oBACjB,WAAW,EAAE,IAAI;oBACjB,kBAAkB,EAAE,KAAK;iBAC1B,CAAA;gBAED,IAAA,oBAAY,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE;oBAChE,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;gBACnE,CAAC,CAAC,CAAA;aACH;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAA;aAC3D;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,sGAAsG,CAAC,CAAA;SACrH;QACD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC;AApDD,4BAoDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (config: any, opts?: {}): Promise<void>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const express_1 = __importDefault(require("express"));
|
|
23
|
+
const node_modules_path_1 = __importDefault(require("node_modules-path"));
|
|
24
|
+
const serve_static_1 = __importDefault(require("serve-static"));
|
|
25
|
+
const Cache_1 = require("./Cache");
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const events_1 = require("../../server/events");
|
|
28
|
+
async function default_1(config, opts = {}) {
|
|
29
|
+
// Options with defaults
|
|
30
|
+
const options = {
|
|
31
|
+
routes: [
|
|
32
|
+
{
|
|
33
|
+
route: '/',
|
|
34
|
+
path: (0, path_1.join)(__dirname, '../../../../..', 'public'),
|
|
35
|
+
}, {
|
|
36
|
+
route: '/css/',
|
|
37
|
+
path: (0, node_modules_path_1.default)('@fortawesome/fontawesome-free') + '/@fortawesome/fontawesome-free/css/',
|
|
38
|
+
}, {
|
|
39
|
+
route: '/webfonts/',
|
|
40
|
+
path: (0, node_modules_path_1.default)('@fortawesome/fontawesome-free') + '/@fortawesome/fontawesome-free/webfonts/',
|
|
41
|
+
}, {
|
|
42
|
+
route: '/css/files/',
|
|
43
|
+
path: (0, node_modules_path_1.default)('@fontsource/ubuntu') + '/@fontsource/ubuntu/files/',
|
|
44
|
+
//}, {
|
|
45
|
+
// route: '/node_modules/',
|
|
46
|
+
// path: nodeModules(),
|
|
47
|
+
}, {
|
|
48
|
+
route: '/',
|
|
49
|
+
path: (0, path_1.join)(__dirname, '../../../../..', 'dist', 'client'),
|
|
50
|
+
}, {
|
|
51
|
+
route: '/',
|
|
52
|
+
path: (0, path_1.join)(__dirname, '../../../../..', 'dist', 'plugins', 'client'),
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
// add project route for source maps
|
|
56
|
+
.concat(config.debug ? [{
|
|
57
|
+
route: '/',
|
|
58
|
+
path: './',
|
|
59
|
+
}] : []),
|
|
60
|
+
...opts,
|
|
61
|
+
};
|
|
62
|
+
console.info('> [StaticPlugin] Serving static files');
|
|
63
|
+
config.on(events_1.ServerEvent.STARTUP_START, ({ app }) => {
|
|
64
|
+
const router = express_1.default.Router();
|
|
65
|
+
options.routes
|
|
66
|
+
.forEach(folder => {
|
|
67
|
+
if (!folder.route)
|
|
68
|
+
throw new Error('The config for static module has no `route` attribute');
|
|
69
|
+
if (!folder.path)
|
|
70
|
+
throw new Error('The config for static module has no `path` attribute');
|
|
71
|
+
console.info(`> [StaticPlugin] Serving static files from ${folder.path} on ${folder.route}`);
|
|
72
|
+
router.use(folder.route, (0, serve_static_1.default)(folder.path));
|
|
73
|
+
});
|
|
74
|
+
app.use(Cache_1.withCache, router);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.default = default_1;
|
|
78
|
+
//# sourceMappingURL=StaticPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/StaticPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;AAEH,sDAA6B;AAC7B,0EAA2C;AAC3C,gEAAsC;AACtC,mCAAmC;AACnC,+BAA2B;AAC3B,gDAAiD;AASlC,KAAK,oBAAU,MAAM,EAAE,IAAI,GAAG,EAAE;IAC7C,wBAAwB;IACxB,MAAM,OAAO,GAAkB;QAC7B,MAAM,EAAE;YACN;gBACE,KAAK,EAAE,GAAG;gBACV,IAAI,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC;aAClD,EAAE;gBACD,KAAK,EAAE,OA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CAAC,IAAI,CAAC,8CAA8C,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;YAC5F,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QACJ,GAAG,CAAC,GAAG,CAAC,iBAAS,EAAG,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AA/CD,4BA+CC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview This is where the default config is defined. Also use this object as an event emitter to listen to Silex events
|
|
3
|
+
* The values can be overriden with env vars or before passing the config to Silex
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @class default config for Silex server
|
|
7
|
+
*/
|
|
8
|
+
import { Config, Plugin } from '@silexlabs/silex-plugins';
|
|
9
|
+
import { Application } from 'express';
|
|
10
|
+
import { HostingConnector, StorageConnector } from './connectors/connectors';
|
|
11
|
+
import { Connector } from './connectors/connectors';
|
|
12
|
+
import { ConnectorType } from '../types';
|
|
13
|
+
/**
|
|
14
|
+
* Config types definitions
|
|
15
|
+
*/
|
|
16
|
+
export declare class ServerConfig extends Config {
|
|
17
|
+
expressOptions: {
|
|
18
|
+
jsonLimit: string;
|
|
19
|
+
textLimit: string;
|
|
20
|
+
urlencodedLimit: string;
|
|
21
|
+
sessionName: string;
|
|
22
|
+
sessionSecret: string;
|
|
23
|
+
cors: string;
|
|
24
|
+
};
|
|
25
|
+
port: string;
|
|
26
|
+
debug: boolean;
|
|
27
|
+
url: string;
|
|
28
|
+
userConfigPath: Plugin | undefined;
|
|
29
|
+
configFilePath: Plugin;
|
|
30
|
+
getConnectors(type?: ConnectorType | string | null): Connector[];
|
|
31
|
+
private storageConnectors;
|
|
32
|
+
addStorageConnector(storage: StorageConnector | StorageConnector[]): void;
|
|
33
|
+
setStorageConnectors(storageConnectors: StorageConnector[]): void;
|
|
34
|
+
getStorageConnectors(): StorageConnector[];
|
|
35
|
+
private hostingConnectors;
|
|
36
|
+
addHostingConnector(hosting: HostingConnector | HostingConnector[]): void;
|
|
37
|
+
setHostingConnectors(hostings: HostingConnector[]): void;
|
|
38
|
+
getHostingConnectors(): HostingConnector[];
|
|
39
|
+
/**
|
|
40
|
+
* Add routes to serve the client config file
|
|
41
|
+
*/
|
|
42
|
+
addRoutes(app: Application): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Load config files
|
|
45
|
+
* This is the main config file and the user config file
|
|
46
|
+
*/
|
|
47
|
+
loadConfigFiles(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Load user config file
|
|
50
|
+
* This is the config file passed as env var CONFIG
|
|
51
|
+
*/
|
|
52
|
+
loadUserConfig(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Load .silex.js in the root folder
|
|
55
|
+
* This is the main config file
|
|
56
|
+
*/
|
|
57
|
+
loadSilexConfig(): Promise<void>;
|
|
58
|
+
initDefaultConnectors(): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.ServerConfig = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* @fileoverview This is where the default config is defined. Also use this object as an event emitter to listen to Silex events
|
|
22
|
+
* The values can be overriden with env vars or before passing the config to Silex
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @class default config for Silex server
|
|
26
|
+
*/
|
|
27
|
+
const silex_plugins_1 = require("@silexlabs/silex-plugins");
|
|
28
|
+
const path_1 = require("path");
|
|
29
|
+
const constants_1 = require("../constants");
|
|
30
|
+
const promises_1 = require("fs/promises");
|
|
31
|
+
const connectors_1 = require("./connectors/connectors");
|
|
32
|
+
const FsStorage_1 = require("./connectors/FsStorage");
|
|
33
|
+
const types_1 = require("../types");
|
|
34
|
+
const FsHosting_1 = require("./connectors/FsHosting");
|
|
35
|
+
/**
|
|
36
|
+
* Config types definitions
|
|
37
|
+
*/
|
|
38
|
+
class ServerConfig extends silex_plugins_1.Config {
|
|
39
|
+
expressOptions = {
|
|
40
|
+
jsonLimit: process.env.SILEX_EXPRESS_JSON_LIMIT,
|
|
41
|
+
textLimit: process.env.SILEX_EXPRESS_TEXT_LIMIT,
|
|
42
|
+
urlencodedLimit: process.env.SILEX_EXPRESS_URLENCODED_LIMIT,
|
|
43
|
+
sessionName: process.env.SILEX_SESSION_NAME,
|
|
44
|
+
sessionSecret: process.env.SILEX_SESSION_SECRET,
|
|
45
|
+
cors: process.env.SILEX_CORS_URL,
|
|
46
|
+
};
|
|
47
|
+
port = process.env.SILEX_PORT;
|
|
48
|
+
debug = process.env.SILEX_DEBUG === 'true';
|
|
49
|
+
url = process.env.SILEX_URL?.replace(/\/$/, '') ?? `${process.env.SILEX_PROTOCOL}://${process.env.SILEX_HOST}:${process.env.SILEX_PORT}`;
|
|
50
|
+
userConfigPath = process.env.SILEX_CONFIG;
|
|
51
|
+
configFilePath = (0, path_1.resolve)(__dirname, '../../../.silex.js');
|
|
52
|
+
// All connectors or just the storage or hosting connectors
|
|
53
|
+
getConnectors(type = null) {
|
|
54
|
+
// All connectors including storage and hosting connectors
|
|
55
|
+
if (!type) {
|
|
56
|
+
// Concat storage and hosting connectors
|
|
57
|
+
const allConnectors = this.getStorageConnectors().concat(this.getHostingConnectors());
|
|
58
|
+
// Remove duplicates (if a connector is both a storage and a hosting connector)
|
|
59
|
+
return [...new Set(allConnectors)];
|
|
60
|
+
}
|
|
61
|
+
// Convert to enum in case it is a string
|
|
62
|
+
const connectorType = (0, connectors_1.toConnectorEnum)(type.toString());
|
|
63
|
+
// Only one type of connector
|
|
64
|
+
switch (connectorType) {
|
|
65
|
+
case types_1.ConnectorType.HOSTING: return this.getHostingConnectors();
|
|
66
|
+
case types_1.ConnectorType.STORAGE: return this.getStorageConnectors();
|
|
67
|
+
default: throw new Error(`Unknown connector type ${type}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Storage connectors to store the website data and assets
|
|
71
|
+
storageConnectors = [];
|
|
72
|
+
addStorageConnector(storage) {
|
|
73
|
+
this.setStorageConnectors(this.storageConnectors.concat(storage));
|
|
74
|
+
}
|
|
75
|
+
setStorageConnectors(storageConnectors) {
|
|
76
|
+
this.storageConnectors = storageConnectors;
|
|
77
|
+
}
|
|
78
|
+
getStorageConnectors() {
|
|
79
|
+
return this.storageConnectors;
|
|
80
|
+
}
|
|
81
|
+
// Hosting connectors to publish the website online
|
|
82
|
+
hostingConnectors = [];
|
|
83
|
+
addHostingConnector(hosting) {
|
|
84
|
+
this.setHostingConnectors(this.hostingConnectors.concat(hosting));
|
|
85
|
+
}
|
|
86
|
+
setHostingConnectors(hostings) {
|
|
87
|
+
this.hostingConnectors = hostings;
|
|
88
|
+
}
|
|
89
|
+
getHostingConnectors() { return this.hostingConnectors; }
|
|
90
|
+
/**
|
|
91
|
+
* Add routes to serve the client config file
|
|
92
|
+
*/
|
|
93
|
+
async addRoutes(app) {
|
|
94
|
+
const path = process.env.SILEX_CLIENT_CONFIG;
|
|
95
|
+
if (path) {
|
|
96
|
+
console.info(`> Serving client side config ${path} at ${constants_1.CLIENT_CONFIG_FILE_NAME}`);
|
|
97
|
+
try {
|
|
98
|
+
// Load the client config file
|
|
99
|
+
let clientConfig = (await (0, promises_1.readFile)(path)).toString();
|
|
100
|
+
// Serve the config file
|
|
101
|
+
app.get(`/${constants_1.CLIENT_CONFIG_FILE_NAME}`, async (req, res) => {
|
|
102
|
+
// Reload each time in debug mode
|
|
103
|
+
if (this.debug) {
|
|
104
|
+
console.info('[Debug mode] Reloading config file', path);
|
|
105
|
+
clientConfig = (await (0, promises_1.readFile)(path)).toString();
|
|
106
|
+
}
|
|
107
|
+
// Send the config file
|
|
108
|
+
res
|
|
109
|
+
.contentType('application/javascript')
|
|
110
|
+
.send(clientConfig);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
console.error(`Error loading client config file ${path}`, e);
|
|
115
|
+
throw new Error(`Error loading client config file ${path}: ${e.message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Load config files
|
|
121
|
+
* This is the main config file and the user config file
|
|
122
|
+
*/
|
|
123
|
+
async loadConfigFiles() {
|
|
124
|
+
// Load the user config file
|
|
125
|
+
await this.loadUserConfig();
|
|
126
|
+
// Load the main config file
|
|
127
|
+
await this.loadSilexConfig();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Load user config file
|
|
131
|
+
* This is the config file passed as env var CONFIG
|
|
132
|
+
*/
|
|
133
|
+
async loadUserConfig() {
|
|
134
|
+
if (this.userConfigPath) {
|
|
135
|
+
console.info('> Loading user config', this.userConfigPath);
|
|
136
|
+
try {
|
|
137
|
+
// Initiate the process with the config file which is just another plugin
|
|
138
|
+
await this.addPlugin(this.userConfigPath, {});
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
throw new Error(`\nUser config file ${this.userConfigPath} error:\n\n\t${e.message}\n\n`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Load .silex.js in the root folder
|
|
147
|
+
* This is the main config file
|
|
148
|
+
*/
|
|
149
|
+
async loadSilexConfig() {
|
|
150
|
+
console.info('> Loading config', this.configFilePath);
|
|
151
|
+
try {
|
|
152
|
+
// Initiate the process with the config file which is just another plugin
|
|
153
|
+
await this.addPlugin(this.configFilePath, {});
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
// Check if the error is about the config file not found and not another module not found in the config file
|
|
157
|
+
if (e.code === 'MODULE_NOT_FOUND' && (!e.requireStack || !e.requireStack.find(path => path === this.configFilePath))) {
|
|
158
|
+
console.info('> /!\\ Config file not found', this.configFilePath);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(`Error in config file ${this.configFilePath}: ${e.message}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async initDefaultConnectors() {
|
|
166
|
+
// Add default storage connectors
|
|
167
|
+
if (!this.storageConnectors.length) {
|
|
168
|
+
this.addStorageConnector(new FsStorage_1.FsStorage(null, {
|
|
169
|
+
path: process.env.SILEX_FS_ROOT,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
// Add default hosting connectors
|
|
173
|
+
if (!this.hostingConnectors.length) {
|
|
174
|
+
this.addHostingConnector(new FsHosting_1.FsHosting(null, {
|
|
175
|
+
path: process.env.SILEX_FS_ROOT,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.ServerConfig = ServerConfig;
|
|
181
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/ts/server/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;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AAiB,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,qBAAS,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;aAChC,CAAC,CAAC,CAAA;SACJ;IACH,CAAC;CACF;AApJD,oCAoJC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConnectorFile, HostingConnector, ConnectorSession } from './connectors';
|
|
2
|
+
import { FsStorage } from './FsStorage';
|
|
3
|
+
import { ConnectorType, JobData, WebsiteId } from '../../types';
|
|
4
|
+
import { JobManager } from '../jobs';
|
|
5
|
+
type FsSession = ConnectorSession;
|
|
6
|
+
export declare class FsHosting extends FsStorage implements HostingConnector<FsSession> {
|
|
7
|
+
connectorId: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
connectorType: ConnectorType;
|
|
10
|
+
publish(session: FsSession, id: WebsiteId, files: ConnectorFile[], { startJob, jobSuccess, jobError }: JobManager): Promise<JobData>;
|
|
11
|
+
getUrl(session: FsSession, id: WebsiteId): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.FsHosting = void 0;
|
|
20
|
+
const path_1 = require("path");
|
|
21
|
+
const FsStorage_1 = require("./FsStorage");
|
|
22
|
+
const types_1 = require("../../types");
|
|
23
|
+
class FsHosting extends FsStorage_1.FsStorage {
|
|
24
|
+
connectorId = 'fs-hosting';
|
|
25
|
+
displayName = 'File system hosting';
|
|
26
|
+
connectorType = types_1.ConnectorType.HOSTING;
|
|
27
|
+
async publish(session, id, files, { startJob, jobSuccess, jobError }) {
|
|
28
|
+
const job = startJob(`Publishing to ${this.displayName}`);
|
|
29
|
+
job.logs = [[`Publishing to ${this.displayName}`]];
|
|
30
|
+
job.errors = [[]];
|
|
31
|
+
// Call write without id or folder so that it goes in / (path will be modified by publication transformers)
|
|
32
|
+
this.write(session, '', files, '', async ({ status, message }) => {
|
|
33
|
+
// Update the job status
|
|
34
|
+
job.status = status;
|
|
35
|
+
job.message = message;
|
|
36
|
+
job.logs[0].push(message);
|
|
37
|
+
if (status === types_1.JobStatus.SUCCESS) {
|
|
38
|
+
jobSuccess(job.jobId, message);
|
|
39
|
+
}
|
|
40
|
+
else if (status === types_1.JobStatus.ERROR) {
|
|
41
|
+
job.errors[0].push(message);
|
|
42
|
+
jobError(job.jobId, message);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return job;
|
|
46
|
+
}
|
|
47
|
+
async getUrl(session, id) {
|
|
48
|
+
const filePath = (0, path_1.join)(this.options.path, id, 'index.html');
|
|
49
|
+
const fileUrl = new URL(filePath, 'file://');
|
|
50
|
+
return fileUrl.toString();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FsHosting = FsHosting;
|
|
54
|
+
//# sourceMappingURL=FsHosting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsHosting.js","sourceRoot":"","sources":["../../../../../src/ts/server/conn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7B;QACH,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAkB,EAAE,EAAa;QAC5C,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,YAAY,CAAC,CAAA;QAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC;CACF;AA9BD,8BA8BC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ConnectorFile, StorageConnector, StatusCallback, ConnectorSession, ConnectorFileContent } from './connectors';
|
|
2
|
+
import { ConnectorUser, WebsiteMeta, WebsiteId, ConnectorType, WebsiteMetaFileContent, WebsiteData, ConnectorOptions } from '../../types';
|
|
3
|
+
import { ServerConfig } from '../config';
|
|
4
|
+
type FsSession = ConnectorSession;
|
|
5
|
+
interface FsOptions {
|
|
6
|
+
path: string;
|
|
7
|
+
assetsFolder: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class FsStorage implements StorageConnector<FsSession> {
|
|
10
|
+
connectorId: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
icon: string;
|
|
13
|
+
disableLogout: boolean;
|
|
14
|
+
options: FsOptions;
|
|
15
|
+
connectorType: ConnectorType;
|
|
16
|
+
color: string;
|
|
17
|
+
background: string;
|
|
18
|
+
constructor(config: ServerConfig | null, opts: Partial<FsOptions>);
|
|
19
|
+
private initFs;
|
|
20
|
+
private updateStatus;
|
|
21
|
+
private initStatus;
|
|
22
|
+
getOptions(formData: object): ConnectorOptions;
|
|
23
|
+
getOAuthUrl(session: FsSession): Promise<null>;
|
|
24
|
+
getLoginForm(session: FsSession, redirectTo: string): Promise<string | null>;
|
|
25
|
+
getSettingsForm(session: FsSession, redirectTo: string): Promise<string | null>;
|
|
26
|
+
isLoggedIn(session: FsSession): Promise<boolean>;
|
|
27
|
+
setToken(session: FsSession, query: object): Promise<void>;
|
|
28
|
+
logout(session: FsSession): Promise<void>;
|
|
29
|
+
getUser(session: FsSession): Promise<ConnectorUser>;
|
|
30
|
+
setWebsiteMeta(session: any, id: string, data: WebsiteMetaFileContent): Promise<void>;
|
|
31
|
+
getWebsiteMeta(session: FsSession, id: WebsiteId): Promise<WebsiteMeta>;
|
|
32
|
+
createWebsite(session: FsSession, meta: WebsiteMetaFileContent): Promise<WebsiteId>;
|
|
33
|
+
readWebsite(session: FsSession, websiteId: WebsiteId): Promise<WebsiteData>;
|
|
34
|
+
updateWebsite(session: FsSession, websiteId: WebsiteId, data: WebsiteData): Promise<void>;
|
|
35
|
+
deleteWebsite(session: FsSession, websiteId: WebsiteId): Promise<void>;
|
|
36
|
+
listWebsites(session: any): Promise<WebsiteMeta[]>;
|
|
37
|
+
getAsset(session: FsSession, id: WebsiteId, path: string): Promise<ConnectorFile>;
|
|
38
|
+
writeAssets(session: FsSession, id: WebsiteId, files: ConnectorFile[], statusCbk?: StatusCallback): Promise<void>;
|
|
39
|
+
write(session: FsSession, id: WebsiteId, files: ConnectorFile[], assetsFolder: string, statusCbk?: StatusCallback): Promise<void>;
|
|
40
|
+
deleteAssets(session: FsSession, id: WebsiteId, paths: string[]): Promise<void>;
|
|
41
|
+
readAsset(session: object, websiteId: string, fileName: string): Promise<ConnectorFileContent>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|