@silexlabs/silex 3.0.0-alpha.49 → 3.0.0-alpha.51
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/dist/client/client/config.d.ts +14 -1
- package/dist/client/client/grapesjs/PublicationManager.d.ts +2 -7
- package/dist/client/client/publication-transformers.d.ts +41 -0
- package/dist/client/css/admin.css +4 -1
- package/dist/client/js/main.js +3 -3
- package/dist/client/types.d.ts +18 -16
- package/dist/plugins/client/client/api.d.ts +83 -0
- package/dist/plugins/client/client/api.js +105 -0
- package/dist/plugins/client/client/api.js.map +1 -0
- package/dist/plugins/client/client/config.d.ts +58 -0
- package/dist/plugins/client/client/config.js +80 -0
- package/dist/plugins/client/client/config.js.map +1 -0
- package/dist/plugins/client/client/events.js +2 -0
- package/dist/plugins/client/client/events.js.map +1 -1
- package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js +193 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +70 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js +310 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +61 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.js +324 -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/index.d.ts +5 -0
- package/dist/plugins/client/client/grapesjs/index.js +264 -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 +220 -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 +106 -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 +197 -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 +124 -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 +165 -0
- package/dist/plugins/client/client/publication-transformers.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/plugins/client/11ty.d.ts +17 -0
- package/dist/plugins/client/plugins/client/11ty.js +70 -0
- package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.js +59 -21
- package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -1
- package/dist/plugins/client/plugins/client/website-info.js +1 -1
- package/dist/plugins/client/plugins/client/website-info.js.map +1 -1
- package/dist/plugins/client/types.d.ts +18 -16
- package/dist/plugins/client/types.js.map +1 -1
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +2 -1
- package/dist/plugins/server/plugins/server/FtpConnector.js +5 -6
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +1 -7
- package/dist/plugins/server/plugins/server/GitlabConnector.js +124 -112
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
- package/dist/plugins/server/server/connectors/FsHosting.d.ts +2 -1
- package/dist/plugins/server/server/connectors/FsHosting.js +4 -5
- package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
- package/dist/plugins/server/server/connectors/FsStorage.js +1 -0
- package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
- package/dist/plugins/server/server/connectors/connectors.d.ts +2 -1
- package/dist/plugins/server/server/connectors/connectors.js.map +1 -1
- package/dist/plugins/server/server/jobs.d.ts +6 -0
- package/dist/plugins/server/server/jobs.js +3 -1
- package/dist/plugins/server/server/jobs.js.map +1 -1
- package/dist/plugins/server/types.d.ts +18 -16
- package/dist/plugins/server/types.js.map +1 -1
- package/dist/server/server/api/publicationApi.js +14 -20
- package/dist/server/server/connectors/FsHosting.js +4 -5
- package/dist/server/server/connectors/FsStorage.js +1 -0
- package/dist/server/server/jobs.js +2 -1
- package/package.json +1 -1
- package/public/silex.js +23 -0
- package/src/css/website-info.scss +4 -1
- package/src/ts/client/config.ts +22 -2
- package/src/ts/client/events.ts +3 -0
- package/src/ts/client/grapesjs/PublicationManager.ts +23 -3
- package/src/ts/client/grapesjs/internal-links.ts +0 -2
- package/src/ts/client/grapesjs/storage.ts +1 -1
- package/src/ts/client/index.ts +4 -0
- package/src/ts/client/publication-transformers.test.ts +146 -0
- package/src/ts/client/publication-transformers.ts +188 -0
- package/src/ts/plugins/client/11ty.ts +89 -0
- package/src/ts/plugins/client/publicationRenderer.ts +64 -22
- package/src/ts/plugins/client/website-info.ts +1 -1
- package/src/ts/plugins/server/FtpConnector.ts +3 -3
- package/src/ts/plugins/server/GitlabConnector.ts +128 -109
- package/src/ts/server/api/publicationApi.ts +16 -23
- package/src/ts/server/connectors/FsHosting.ts +2 -2
- package/src/ts/server/connectors/FsStorage.ts +1 -0
- package/src/ts/server/connectors/connectors.ts +3 -1
- package/src/ts/server/jobs.ts +10 -0
- package/src/ts/server/utils/BackwardCompat.ts +530 -529
- package/src/ts/types.ts +20 -17
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ConnectorData, PublicationJobData, PublicationSettings, WebsiteFile, WebsiteId, WebsiteSettings } from '../../types';
|
|
2
|
+
import { Editor } from 'grapesjs';
|
|
3
|
+
import { PublicationUi } from './PublicationUi';
|
|
4
|
+
/**
|
|
5
|
+
* @fileoverview Publication manager for Silex
|
|
6
|
+
* This plugin adds a publication feature to Silex
|
|
7
|
+
* It lets the user publish the website to a hosting service
|
|
8
|
+
* It can optionally display a button and a dialog
|
|
9
|
+
* Useful commands:
|
|
10
|
+
* - publish: starts the publication process and optionally open the dialog
|
|
11
|
+
* - publish-login: open the login dialog
|
|
12
|
+
* - publish-logout: logout from the hosting service and let the user choose a hosting service again
|
|
13
|
+
*/
|
|
14
|
+
export declare const cmdPublicationStart = "publish";
|
|
15
|
+
export declare const cmdPublicationLogin = "publish-login";
|
|
16
|
+
export declare const cmdPublicationLogout = "publish-logout";
|
|
17
|
+
export type PublishableEditor = Editor & {
|
|
18
|
+
PublicationManager: PublicationManager;
|
|
19
|
+
};
|
|
20
|
+
export declare enum PublicationStatus {
|
|
21
|
+
STATUS_NONE = "STATUS_NONE",
|
|
22
|
+
STATUS_PENDING = "STATUS_PENDING",
|
|
23
|
+
STATUS_ERROR = "STATUS_ERROR",
|
|
24
|
+
STATUS_SUCCESS = "STATUS_SUCCESS",
|
|
25
|
+
STATUS_LOGGED_OUT = "STATUS_AUTH_ERROR"
|
|
26
|
+
}
|
|
27
|
+
export type PublicationManagerOptions = {
|
|
28
|
+
appendTo?: string;
|
|
29
|
+
websiteId: WebsiteId;
|
|
30
|
+
};
|
|
31
|
+
export default function publishPlugin(editor: any, opts: any): void;
|
|
32
|
+
export declare class PublicationManager {
|
|
33
|
+
private editor;
|
|
34
|
+
/**
|
|
35
|
+
* Publication dialog
|
|
36
|
+
* This class is responsible for the UI
|
|
37
|
+
*/
|
|
38
|
+
dialog?: PublicationUi;
|
|
39
|
+
/**
|
|
40
|
+
* Publication settings
|
|
41
|
+
* This is the data which is stored in the website settings
|
|
42
|
+
*/
|
|
43
|
+
_settings: PublicationSettings;
|
|
44
|
+
get settings(): PublicationSettings;
|
|
45
|
+
set settings(newSettings: PublicationSettings);
|
|
46
|
+
/**
|
|
47
|
+
* Plugin options
|
|
48
|
+
* This is the data which is passed to the plugin by grapesjs
|
|
49
|
+
*/
|
|
50
|
+
options: PublicationManagerOptions;
|
|
51
|
+
/**
|
|
52
|
+
* Publication job during the publication process
|
|
53
|
+
*/
|
|
54
|
+
job: PublicationJobData | null;
|
|
55
|
+
/**
|
|
56
|
+
* Publication state
|
|
57
|
+
* This is the state of the publication process
|
|
58
|
+
*/
|
|
59
|
+
status: PublicationStatus;
|
|
60
|
+
constructor(editor: PublishableEditor, opts: PublicationManagerOptions);
|
|
61
|
+
goLogin(connector: ConnectorData): Promise<unknown>;
|
|
62
|
+
goLogout(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Start the publication process
|
|
65
|
+
* This is the command "publish"
|
|
66
|
+
*/
|
|
67
|
+
startPublication(): Promise<void>;
|
|
68
|
+
getSiteFiles(siteSettings: WebsiteSettings): Promise<WebsiteFile[]>;
|
|
69
|
+
trackProgress(): Promise<void>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
3
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
import { getPageSlug } from '../../page';
|
|
18
|
+
import { ConnectorType, JobStatus } from '../../types';
|
|
19
|
+
import { PublicationUi } from './PublicationUi';
|
|
20
|
+
import { getUser, logout, publicationStatus, publish } from '../api';
|
|
21
|
+
import { API_CONNECTOR_LOGIN, API_CONNECTOR_PATH, API_PATH } from '../../constants';
|
|
22
|
+
import { ClientEvent } from '../events';
|
|
23
|
+
/**
|
|
24
|
+
* @fileoverview Publication manager for Silex
|
|
25
|
+
* This plugin adds a publication feature to Silex
|
|
26
|
+
* It lets the user publish the website to a hosting service
|
|
27
|
+
* It can optionally display a button and a dialog
|
|
28
|
+
* Useful commands:
|
|
29
|
+
* - publish: starts the publication process and optionally open the dialog
|
|
30
|
+
* - publish-login: open the login dialog
|
|
31
|
+
* - publish-logout: logout from the hosting service and let the user choose a hosting service again
|
|
32
|
+
*/
|
|
33
|
+
// Constants
|
|
34
|
+
export const cmdPublicationStart = 'publish';
|
|
35
|
+
export const cmdPublicationLogin = 'publish-login';
|
|
36
|
+
export const cmdPublicationLogout = 'publish-logout';
|
|
37
|
+
export var PublicationStatus;
|
|
38
|
+
(function (PublicationStatus) {
|
|
39
|
+
PublicationStatus["STATUS_NONE"] = "STATUS_NONE";
|
|
40
|
+
PublicationStatus["STATUS_PENDING"] = "STATUS_PENDING";
|
|
41
|
+
PublicationStatus["STATUS_ERROR"] = "STATUS_ERROR";
|
|
42
|
+
PublicationStatus["STATUS_SUCCESS"] = "STATUS_SUCCESS";
|
|
43
|
+
PublicationStatus["STATUS_LOGGED_OUT"] = "STATUS_AUTH_ERROR";
|
|
44
|
+
})(PublicationStatus || (PublicationStatus = {}));
|
|
45
|
+
// plugin init cod
|
|
46
|
+
export default function publishPlugin(editor, opts) {
|
|
47
|
+
editor.PublicationManager = new PublicationManager(editor, opts);
|
|
48
|
+
}
|
|
49
|
+
function jobStatusToPublicationStatus(status) {
|
|
50
|
+
switch (status) {
|
|
51
|
+
case JobStatus.IN_PROGRESS:
|
|
52
|
+
return PublicationStatus.STATUS_PENDING;
|
|
53
|
+
case JobStatus.ERROR:
|
|
54
|
+
return PublicationStatus.STATUS_ERROR;
|
|
55
|
+
case JobStatus.SUCCESS:
|
|
56
|
+
return PublicationStatus.STATUS_SUCCESS;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Unknown job status ${status}`);
|
|
59
|
+
}
|
|
60
|
+
// The publication manager class
|
|
61
|
+
// This class is responsible for the publication dialog and for the publication process
|
|
62
|
+
// It is added to the editor instance as editor.PublicationManager
|
|
63
|
+
export class PublicationManager {
|
|
64
|
+
editor;
|
|
65
|
+
/**
|
|
66
|
+
* Publication dialog
|
|
67
|
+
* This class is responsible for the UI
|
|
68
|
+
*/
|
|
69
|
+
dialog;
|
|
70
|
+
/**
|
|
71
|
+
* Publication settings
|
|
72
|
+
* This is the data which is stored in the website settings
|
|
73
|
+
*/
|
|
74
|
+
_settings;
|
|
75
|
+
get settings() {
|
|
76
|
+
return this._settings;
|
|
77
|
+
}
|
|
78
|
+
set settings(newSettings) {
|
|
79
|
+
this._settings = newSettings;
|
|
80
|
+
this.dialog && (this.dialog.settings = newSettings);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Plugin options
|
|
84
|
+
* This is the data which is passed to the plugin by grapesjs
|
|
85
|
+
*/
|
|
86
|
+
options;
|
|
87
|
+
/**
|
|
88
|
+
* Publication job during the publication process
|
|
89
|
+
*/
|
|
90
|
+
job = null;
|
|
91
|
+
/**
|
|
92
|
+
* Publication state
|
|
93
|
+
* This is the state of the publication process
|
|
94
|
+
*/
|
|
95
|
+
status = PublicationStatus.STATUS_NONE;
|
|
96
|
+
constructor(editor, opts) {
|
|
97
|
+
this.editor = editor;
|
|
98
|
+
this.options = {
|
|
99
|
+
appendTo: 'options',
|
|
100
|
+
...opts,
|
|
101
|
+
};
|
|
102
|
+
// Save the publication settings in the website settings
|
|
103
|
+
editor.on('storage:start:store', (data) => {
|
|
104
|
+
data.publication = this.settings;
|
|
105
|
+
});
|
|
106
|
+
// load publication settings from the website
|
|
107
|
+
editor.on('storage:end:load', (data) => {
|
|
108
|
+
this.settings = data.publication ?? {};
|
|
109
|
+
// Check if the user is logged in
|
|
110
|
+
getUser({ type: ConnectorType.HOSTING, connectorId: this.settings.connector?.connectorId })
|
|
111
|
+
.then((user) => { })
|
|
112
|
+
.catch((err) => {
|
|
113
|
+
this.status = PublicationStatus.STATUS_LOGGED_OUT;
|
|
114
|
+
this.settings = {};
|
|
115
|
+
this.dialog && this.dialog.displayError('Please login', this.job, this.status);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
// Add the publish command to the editor
|
|
119
|
+
editor.Commands.add(cmdPublicationStart, () => this.startPublication());
|
|
120
|
+
editor.Commands.add(cmdPublicationLogin, (editor, sender, connector) => this.goLogin(connector));
|
|
121
|
+
editor.Commands.add(cmdPublicationLogout, () => this.goLogout());
|
|
122
|
+
// Add the publication dialog to the editor
|
|
123
|
+
if (this.options.appendTo) {
|
|
124
|
+
this.dialog = new PublicationUi(editor, {
|
|
125
|
+
appendTo: this.options.appendTo,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.info('PublicationUi is disabled because no appendTo option is set');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async goLogin(connector) {
|
|
133
|
+
this.settings = {};
|
|
134
|
+
this.status = PublicationStatus.STATUS_LOGGED_OUT;
|
|
135
|
+
this.dialog && this.dialog.displayPending(this.job, this.status);
|
|
136
|
+
const params = {
|
|
137
|
+
connectorId: connector.connectorId,
|
|
138
|
+
type: connector.type,
|
|
139
|
+
};
|
|
140
|
+
window.open(connector.oauthUrl || `${API_PATH}${API_CONNECTOR_PATH}${API_CONNECTOR_LOGIN}?connectorId=${params.connectorId}&type=${params.type}`, '_blank');
|
|
141
|
+
return new Promise(resolve => {
|
|
142
|
+
const onMessage = async (event) => {
|
|
143
|
+
const data = event.data;
|
|
144
|
+
if (data?.type === 'login') {
|
|
145
|
+
window.removeEventListener('message', onMessage);
|
|
146
|
+
if (data.error) {
|
|
147
|
+
this.status = PublicationStatus.STATUS_LOGGED_OUT;
|
|
148
|
+
this.settings = {};
|
|
149
|
+
this.dialog && this.dialog.displayError(data.message, this.job, this.status);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.editor.trigger(ClientEvent.PUBLISH_LOGIN_END);
|
|
153
|
+
//const uesr = await getUser({type: connector.type, connectorId: data.connectorId})
|
|
154
|
+
this.settings.connector = connector;
|
|
155
|
+
this.settings.options = data.options;
|
|
156
|
+
this.status = PublicationStatus.STATUS_NONE;
|
|
157
|
+
// Save the website with the new settings
|
|
158
|
+
this.editor.store(null);
|
|
159
|
+
// Display the dialog
|
|
160
|
+
this.dialog && this.dialog.displayPending(this.job, this.status);
|
|
161
|
+
//await this.startPublication()
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
window.addEventListener('message', onMessage, false);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async goLogout() {
|
|
169
|
+
try {
|
|
170
|
+
await logout({ type: ConnectorType.HOSTING, connectorId: this.settings.connector.connectorId });
|
|
171
|
+
this.settings = {};
|
|
172
|
+
this.dialog && this.dialog.displayPending(this.job, this.status);
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
console.error('logout error', e);
|
|
176
|
+
this.status = PublicationStatus.STATUS_ERROR;
|
|
177
|
+
this.dialog && this.dialog.displayError(e.message, this.job, this.status);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Start the publication process
|
|
182
|
+
* This is the command "publish"
|
|
183
|
+
*/
|
|
184
|
+
async startPublication() {
|
|
185
|
+
if (this.status === PublicationStatus.STATUS_PENDING)
|
|
186
|
+
throw new Error('Publication is already in progress');
|
|
187
|
+
this.status = PublicationStatus.STATUS_PENDING;
|
|
188
|
+
this.job = null;
|
|
189
|
+
this.dialog && this.dialog.displayPending(this.job, this.status);
|
|
190
|
+
this.editor.trigger(ClientEvent.PUBLISH_START);
|
|
191
|
+
const projectData = this.editor.getProjectData();
|
|
192
|
+
const siteSettings = this.editor.getModel().get('settings');
|
|
193
|
+
// Build the files structure
|
|
194
|
+
const files = (await this.getSiteFiles(siteSettings))
|
|
195
|
+
.flatMap(file => ([{
|
|
196
|
+
path: file.htmlPath,
|
|
197
|
+
content: file.html,
|
|
198
|
+
type: 'html',
|
|
199
|
+
}, {
|
|
200
|
+
path: file.cssPath,
|
|
201
|
+
content: file.css,
|
|
202
|
+
type: 'css',
|
|
203
|
+
}]))
|
|
204
|
+
.concat(projectData.assets.map(asset => ({
|
|
205
|
+
...asset,
|
|
206
|
+
path: `/${asset.src}`,
|
|
207
|
+
src: asset.src,
|
|
208
|
+
type: 'asset',
|
|
209
|
+
})));
|
|
210
|
+
// Create the data to send to the server
|
|
211
|
+
const data = {
|
|
212
|
+
...projectData,
|
|
213
|
+
settings: siteSettings,
|
|
214
|
+
publication: this.settings,
|
|
215
|
+
files,
|
|
216
|
+
};
|
|
217
|
+
this.editor.trigger(ClientEvent.PUBLISH_DATA, data);
|
|
218
|
+
const storageUser = this.editor.getModel().get('user');
|
|
219
|
+
if (!storageUser)
|
|
220
|
+
throw new Error('User not logged in to a storage connector');
|
|
221
|
+
if (!this.settings.connector?.connectorId)
|
|
222
|
+
throw new Error('User not logged in to a hosting connector');
|
|
223
|
+
try {
|
|
224
|
+
const websiteId = this.options.websiteId;
|
|
225
|
+
const [url, job] = await publish({
|
|
226
|
+
websiteId,
|
|
227
|
+
hostingId: this.settings.connector.connectorId,
|
|
228
|
+
storageId: storageUser.storage.connectorId,
|
|
229
|
+
data: data,
|
|
230
|
+
options: this.settings.options,
|
|
231
|
+
});
|
|
232
|
+
this.job = job;
|
|
233
|
+
this.status = jobStatusToPublicationStatus(this.job.status);
|
|
234
|
+
// Save the publication settings
|
|
235
|
+
// Useless because the url is useful after publish only
|
|
236
|
+
//if(this.settings.url !== url) {
|
|
237
|
+
// this.settings.url = url
|
|
238
|
+
// await this.editor.store(null)
|
|
239
|
+
//}
|
|
240
|
+
this.trackProgress();
|
|
241
|
+
}
|
|
242
|
+
catch (e) {
|
|
243
|
+
console.error('publish error', e);
|
|
244
|
+
if (e.code === 401 || e.httpStatusCode === 401) {
|
|
245
|
+
this.status = PublicationStatus.STATUS_LOGGED_OUT;
|
|
246
|
+
this.settings = {};
|
|
247
|
+
this.dialog && this.dialog.displayError('Please login.', this.job, this.status);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.status = PublicationStatus.STATUS_ERROR;
|
|
251
|
+
this.dialog && this.dialog.displayError(`An error occured, your site is not published. ${e.message}`, this.job, this.status);
|
|
252
|
+
}
|
|
253
|
+
this.editor.trigger(ClientEvent.PUBLISH_ERROR, { success: false, message: e.message });
|
|
254
|
+
this.editor.trigger(ClientEvent.PUBLISH_END, { success: false, message: e.message });
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async getSiteFiles(siteSettings) {
|
|
259
|
+
return this.editor.Pages.getAll().map(page => {
|
|
260
|
+
const pageSettings = page.get('settings');
|
|
261
|
+
function getSetting(name) {
|
|
262
|
+
return (pageSettings || {})[name] || (siteSettings || [])[name] || '';
|
|
263
|
+
}
|
|
264
|
+
const component = page.getMainComponent();
|
|
265
|
+
const slug = page.get('slug') || getPageSlug(page.get('name') || page.get('type'));
|
|
266
|
+
return {
|
|
267
|
+
html: `
|
|
268
|
+
<!DOCTYPE html>
|
|
269
|
+
<html lang="${getSetting('lang')}">
|
|
270
|
+
<head>
|
|
271
|
+
<link rel="stylesheet" href="/css/${slug}.css" />
|
|
272
|
+
${siteSettings?.head || ''}
|
|
273
|
+
${pageSettings?.head || ''}
|
|
274
|
+
<title>${getSetting('title')}</title>
|
|
275
|
+
<link rel="icon" href="${getSetting('favicon')}" />
|
|
276
|
+
${['description', 'og:title', 'og:description', 'og:image']
|
|
277
|
+
.map(prop => `<meta property="${prop}" content="${getSetting(prop)}"/>`)
|
|
278
|
+
.join('\n')}
|
|
279
|
+
</head>
|
|
280
|
+
${this.editor.getHtml({ component })}
|
|
281
|
+
</html>
|
|
282
|
+
`,
|
|
283
|
+
css: this.editor.getCss({ component }),
|
|
284
|
+
cssPath: `/${slug}.css`,
|
|
285
|
+
htmlPath: `/${slug}.html`,
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async trackProgress() {
|
|
290
|
+
try {
|
|
291
|
+
this.job = await publicationStatus({ jobId: this.job.jobId });
|
|
292
|
+
this.status = jobStatusToPublicationStatus(this.job.status);
|
|
293
|
+
}
|
|
294
|
+
catch (e) {
|
|
295
|
+
this.status = PublicationStatus.STATUS_ERROR;
|
|
296
|
+
this.dialog && this.dialog.displayError(`An error occured, your site is not published. ${e.message}`, this.job, this.status);
|
|
297
|
+
this.editor.trigger(ClientEvent.PUBLISH_END, { success: false, message: e.message });
|
|
298
|
+
this.editor.trigger(ClientEvent.PUBLISH_ERROR, { success: false, message: e.message });
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (this.job.status === JobStatus.IN_PROGRESS) {
|
|
302
|
+
setTimeout(() => this.trackProgress(), 2000);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this.editor.trigger(ClientEvent.PUBLISH_END, { success: this.job.status === JobStatus.SUCCESS, message: this.job.message });
|
|
306
|
+
}
|
|
307
|
+
this.dialog && this.dialog.displayPending(this.job, this.status);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=PublicationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicationManager.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/PublicationManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAA2R,aAAa,EAA0B,SAAS,EAAkH,MAAM,aAAa,CAAA;AAEvd,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;;;GASG;AAEH,YAAY;AACZ,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAOpD,MAAM,CAAN,I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D,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAClE,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit-html';
|
|
2
|
+
import { PublicationStatus, PublishableEditor } from './PublicationManager';
|
|
3
|
+
import { PublicationJobData, PublicationSettings } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* @fileoverview define the publication dialog
|
|
6
|
+
* This is the UI of the publication feature
|
|
7
|
+
* It is a dialog which allows the user to login to a connector and publish the website
|
|
8
|
+
* It also displays the publication status and logs during the publication process
|
|
9
|
+
* This class is used by the PublicationManager
|
|
10
|
+
* This is optional, you can use the PublicationManager without this UI
|
|
11
|
+
* @TODO Use publication events instead of calls from the PublicationManager
|
|
12
|
+
*/
|
|
13
|
+
export declare const cmdPublish = "publish-open-dialog";
|
|
14
|
+
export type PublicationDialogOptions = {
|
|
15
|
+
appendTo: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Class to manage the publication dialog
|
|
19
|
+
*/
|
|
20
|
+
export declare class PublicationUi {
|
|
21
|
+
private editor;
|
|
22
|
+
private options;
|
|
23
|
+
/**
|
|
24
|
+
* Dialog state
|
|
25
|
+
*/
|
|
26
|
+
isOpen: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Dialog content
|
|
29
|
+
*/
|
|
30
|
+
private errorMessage;
|
|
31
|
+
/**
|
|
32
|
+
* Dialog element
|
|
33
|
+
* This is the DOM element of the dialog
|
|
34
|
+
*/
|
|
35
|
+
private el;
|
|
36
|
+
settings: PublicationSettings;
|
|
37
|
+
/**
|
|
38
|
+
* Initialize the dialog and the publish button
|
|
39
|
+
*/
|
|
40
|
+
constructor(editor: PublishableEditor, options: PublicationDialogOptions);
|
|
41
|
+
isSuccess(status: PublicationStatus): boolean;
|
|
42
|
+
isPending(status: PublicationStatus): boolean;
|
|
43
|
+
isError(status: PublicationStatus): boolean;
|
|
44
|
+
isLoggedOut(status: PublicationStatus): boolean;
|
|
45
|
+
isReady(status: PublicationStatus): boolean;
|
|
46
|
+
getDialogElements(): {
|
|
47
|
+
el: HTMLElement;
|
|
48
|
+
primary: HTMLElement;
|
|
49
|
+
secondary: HTMLElement;
|
|
50
|
+
};
|
|
51
|
+
createDialogElements(): HTMLElement;
|
|
52
|
+
move(rect: any): void;
|
|
53
|
+
private renderDialog;
|
|
54
|
+
renderOpenDialog(job: PublicationJobData, status: PublicationStatus): Promise<TemplateResult>;
|
|
55
|
+
renderLoginDialog(status: PublicationStatus): Promise<TemplateResult>;
|
|
56
|
+
displayPending(job: PublicationJobData, status: PublicationStatus): void;
|
|
57
|
+
displayError(message: string, job: PublicationJobData, status: PublicationStatus): void;
|
|
58
|
+
closeDialog(): Promise<void>;
|
|
59
|
+
toggleDialog(): Promise<void>;
|
|
60
|
+
openDialog(): Promise<void>;
|
|
61
|
+
}
|