@silexlabs/silex 3.0.0-alpha.52 → 3.0.0-alpha.55
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/assetUrl.d.ts +28 -0
- package/dist/client/js/main.js +14 -14
- package/dist/client/types.d.ts +17 -16
- package/dist/plugins/client/client/assetUrl.d.ts +28 -0
- package/dist/plugins/client/client/assetUrl.js +170 -0
- package/dist/plugins/client/client/assetUrl.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js +10 -3
- package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -1
- package/dist/plugins/client/client/grapesjs/storage.js +7 -5
- package/dist/plugins/client/client/grapesjs/storage.js.map +1 -1
- package/dist/plugins/client/plugins/client/11ty.js +0 -5
- package/dist/plugins/client/plugins/client/11ty.js.map +1 -1
- package/dist/plugins/client/types.d.ts +17 -16
- package/dist/plugins/client/types.js +11 -0
- package/dist/plugins/client/types.js.map +1 -1
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +1 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js +2 -2
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
- package/dist/plugins/server/types.d.ts +17 -16
- package/dist/plugins/server/types.js +11 -0
- package/dist/plugins/server/types.js.map +1 -1
- package/dist/server/server/api/publicationApi.js +1 -1
- package/package.json +1 -1
- package/src/ts/client/assetUrl.ts +182 -0
- package/src/ts/client/grapesjs/PublicationManager.ts +17 -10
- package/src/ts/client/grapesjs/storage.ts +9 -7
- package/src/ts/client/publication-transformers.test.ts +1 -1
- package/src/ts/plugins/client/11ty.ts +0 -6
- package/src/ts/plugins/server/GitlabConnector.ts +3 -2
- package/src/ts/server/api/publicationApi.ts +1 -1
- package/src/ts/server/connectors/FsStorage.ts +1 -0
- package/src/ts/types.ts +34 -13
|
@@ -134,8 +134,24 @@ export type ApiConnectorUserQuery = {
|
|
|
134
134
|
};
|
|
135
135
|
export type ApiConnectorUserResponse = ConnectorUser;
|
|
136
136
|
export declare const defaultWebsiteData: WebsiteData;
|
|
137
|
+
export interface Component {
|
|
138
|
+
type: string;
|
|
139
|
+
content?: string;
|
|
140
|
+
attributes: {
|
|
141
|
+
[key: string]: string;
|
|
142
|
+
};
|
|
143
|
+
components: Component[];
|
|
144
|
+
}
|
|
145
|
+
export interface Page {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
slug: string;
|
|
149
|
+
frames: {
|
|
150
|
+
component: Component;
|
|
151
|
+
}[];
|
|
152
|
+
}
|
|
137
153
|
export interface WebsiteData {
|
|
138
|
-
pages:
|
|
154
|
+
pages: Page[];
|
|
139
155
|
assets: Asset[];
|
|
140
156
|
styles: Style[];
|
|
141
157
|
settings: WebsiteSettings;
|
|
@@ -161,21 +177,6 @@ export interface Font {
|
|
|
161
177
|
value: string;
|
|
162
178
|
variants: string[];
|
|
163
179
|
}
|
|
164
|
-
export interface Frame {
|
|
165
|
-
component: {
|
|
166
|
-
type: string;
|
|
167
|
-
stylable: string[];
|
|
168
|
-
};
|
|
169
|
-
components: Component[];
|
|
170
|
-
}
|
|
171
|
-
export interface Component {
|
|
172
|
-
type: string;
|
|
173
|
-
content?: string;
|
|
174
|
-
attributes: {
|
|
175
|
-
[key: string]: string;
|
|
176
|
-
};
|
|
177
|
-
conponents: Component[];
|
|
178
|
-
}
|
|
179
180
|
export declare enum Unit {
|
|
180
181
|
PX = "px"
|
|
181
182
|
}
|
|
@@ -37,6 +37,17 @@ exports.defaultWebsiteData = {
|
|
|
37
37
|
//symbols: [],
|
|
38
38
|
//publication: {},
|
|
39
39
|
};
|
|
40
|
+
//export interface Frame {
|
|
41
|
+
// component: { type: string, stylable: string[] },
|
|
42
|
+
// components: Component[],
|
|
43
|
+
//}
|
|
44
|
+
//
|
|
45
|
+
//export interface Component {
|
|
46
|
+
// type: string,
|
|
47
|
+
// content?: string,
|
|
48
|
+
// attributes: { [key: string]: string },
|
|
49
|
+
// conponents: Component[],
|
|
50
|
+
//}
|
|
40
51
|
var Unit;
|
|
41
52
|
(function (Unit) {
|
|
42
53
|
Unit["PX"] = "px";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAmBH,MAAa,QAAS,SAAQ,KAAK;IACY;IAA7C,YAAY,OAAe,EAAkB,cAAsB;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QAD6B,mBAAc,GAAd,cAAc,CAAQ;QAEjE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;CACF;AALD,4BAKC;AA+CD,KAAK;AACL,cAAc;AACD,QAAA,kBAAkB,GAAgB;AAC7C,YAAY;AACZ,aAAa;AACb,aAAa;AACb,eAAe;AACf,YAAY;AACZ,cAAc;AACd,kBAAkB;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAmBH,MAAa,QAAS,SAAQ,KAAK;IACY;IAA7C,YAAY,OAAe,EAAkB,cAAsB;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QAD6B,mBAAc,GAAd,cAAc,CAAQ;QAEjE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;CACF;AALD,4BAKC;AA+CD,KAAK;AACL,cAAc;AACD,QAAA,kBAAkB,GAAgB;AAC7C,YAAY;AACZ,aAAa;AACb,aAAa;AACb,eAAe;AACf,YAAY;AACZ,cAAc;AACd,kBAAkB;CACJ,CAAA;AAuDhB,0BAA0B;AAC1B,oDAAoD;AACpD,4BAA4B;AAC5B,GAAG;AACH,EAAE;AACF,8BAA8B;AAC9B,iBAAiB;AACjB,qBAAqB;AACrB,0CAA0C;AAC1C,4BAA4B;AAC5B,GAAG;AAEH,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,iBAAS,CAAA;AACX,CAAC,EAFW,IAAI,oBAAJ,IAAI,QAEf;AAkCD,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,qCAAe,CAAA;IACf,iCAAW,CAAA;AACb,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AA+CD;;GAEG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAuDD;;GAEG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,gCAAmB,CAAA;IACnB,4BAAe,CAAA;AACjB,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
|
|
@@ -74,7 +74,7 @@ function default_1(config) {
|
|
|
74
74
|
const hostingConnector = await getHostingConnector(session, config, hostingId);
|
|
75
75
|
const storage = await getStorageConnector(session, config, storageId);
|
|
76
76
|
const filesList = await Promise.all(files.map(async (file) => {
|
|
77
|
-
const prefix = constants_1.API_WEBSITE_ASSET_READ
|
|
77
|
+
const prefix = constants_1.API_WEBSITE_ASSET_READ;
|
|
78
78
|
const fileWithContent = file;
|
|
79
79
|
const fileWithSrc = file;
|
|
80
80
|
if (!fileWithContent.content && !fileWithSrc.src)
|
package/package.json
CHANGED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { API_PATH, API_WEBSITE_ASSET_READ, API_WEBSITE_PATH } from '../constants'
|
|
2
|
+
import { Asset, Component, ConnectorId, Page, Style, WebsiteId } from '../types'
|
|
3
|
+
|
|
4
|
+
// Orging and path
|
|
5
|
+
const SERVER_URL = `${window.location.origin}${window.location.pathname}`
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Function to convert a path from it stored version to the one we give to grapesjs
|
|
9
|
+
* Stored version is like `/assets/image.webp`
|
|
10
|
+
* Grapesjs version is like `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
11
|
+
* @param path the path to convert
|
|
12
|
+
* @param websiteId the website ID
|
|
13
|
+
* @param storageId the storage connector ID
|
|
14
|
+
* @returns the converted path
|
|
15
|
+
*/
|
|
16
|
+
function storedToDisplayed(path: string, websiteId: WebsiteId, storageId: ConnectorId): string {
|
|
17
|
+
const url = new URL(path, SERVER_URL)
|
|
18
|
+
url.pathname = url.pathname.replace(/^\/assets/, '')
|
|
19
|
+
url.pathname = `${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSET_READ}${url.pathname}`
|
|
20
|
+
url.searchParams.set('websiteId', websiteId)
|
|
21
|
+
url.searchParams.set('connectorId', storageId)
|
|
22
|
+
const result = '/' + url.toString().replace(new RegExp(`^${SERVER_URL}`), '')
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Function to convert a path from the one we give to grapesjs to the stored version
|
|
28
|
+
* Grapesjs version is like `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
29
|
+
* Stored version is like `/assets/image.webp`
|
|
30
|
+
* @param path the path to convert
|
|
31
|
+
* @returns the converted path
|
|
32
|
+
*/
|
|
33
|
+
function displayedToStored(path: string): string {
|
|
34
|
+
const url = new URL(path, SERVER_URL)
|
|
35
|
+
url.pathname = url.pathname.replace(new RegExp(`^${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSET_READ}`), '')
|
|
36
|
+
url.pathname = `/assets${url.pathname}`
|
|
37
|
+
url.searchParams.delete('websiteId')
|
|
38
|
+
url.searchParams.delete('connectorId')
|
|
39
|
+
const result = '/' + url.toString().replace(new RegExp(`^${SERVER_URL}`), '')
|
|
40
|
+
return result
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update asset URL to use the current storage connector and website ID
|
|
46
|
+
* Assets URLs are stored in the project data in the form `/assets/image.webp`
|
|
47
|
+
* This function adds the API path and the connectorId and websiteId like so: `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
48
|
+
*/
|
|
49
|
+
export function addTempDataToAssetUrl(assets: Asset[], websiteId: WebsiteId, storageId: ConnectorId): Asset[] {
|
|
50
|
+
return assets.map((asset: Asset) => {
|
|
51
|
+
return {
|
|
52
|
+
...asset,
|
|
53
|
+
src: storedToDisplayed(asset.src, websiteId, storageId),
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Remove the temporary data from the asset URL
|
|
60
|
+
* Remove the API path and the connectorId and websiteId like so: `/assets/image.webp`
|
|
61
|
+
*/
|
|
62
|
+
export function removeTempDataFromAssetUrl(assets: Asset[]): Asset[] {
|
|
63
|
+
return assets.map((asset: Asset) => {
|
|
64
|
+
// Return the asset with the new URL
|
|
65
|
+
return {
|
|
66
|
+
...asset,
|
|
67
|
+
src: displayedToStored(asset.src),
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Reucrsive function to update the asset URL in the components
|
|
74
|
+
*/
|
|
75
|
+
function addTempDataToComponents(component: Component, websiteId: WebsiteId, storageId: ConnectorId): Component {
|
|
76
|
+
// Update the asset URL in the component
|
|
77
|
+
const newComponent = {
|
|
78
|
+
...component,
|
|
79
|
+
attributes: {
|
|
80
|
+
...component.attributes,
|
|
81
|
+
src: component.attributes?.src ? storedToDisplayed(component.attributes.src, websiteId, storageId) : undefined,
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
// Update the asset URL in the children
|
|
85
|
+
if (newComponent.components) {
|
|
86
|
+
newComponent.components = newComponent.components.map((childComponent: Component) => {
|
|
87
|
+
return addTempDataToComponents(childComponent, websiteId, storageId)
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
return newComponent
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Reucrsive function to update the asset URL in the components
|
|
95
|
+
*/
|
|
96
|
+
function removeTempDataFromComponents(component: Component): Component {
|
|
97
|
+
// Update the asset URL in the component
|
|
98
|
+
const newComponent = {
|
|
99
|
+
...component,
|
|
100
|
+
attributes: {
|
|
101
|
+
...component.attributes,
|
|
102
|
+
src: component.attributes?.src ? displayedToStored(component.attributes.src) : undefined,
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
// Update the asset URL in the children
|
|
106
|
+
if (newComponent.components) {
|
|
107
|
+
newComponent.components = newComponent.components.map((childComponent: Component) => {
|
|
108
|
+
return removeTempDataFromComponents(childComponent)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
return newComponent
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Add temp data to pages
|
|
116
|
+
*/
|
|
117
|
+
export function addTemDataToPages(pages: Page[], websiteId: WebsiteId, storageId: ConnectorId): Page[] {
|
|
118
|
+
return pages.map((page: Page) => {
|
|
119
|
+
return {
|
|
120
|
+
...page,
|
|
121
|
+
frames: page.frames.map(frame => ({
|
|
122
|
+
...frame,
|
|
123
|
+
component: addTempDataToComponents(frame.component, websiteId, storageId),
|
|
124
|
+
}))
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Remove temp data from asset URL in the components
|
|
131
|
+
*/
|
|
132
|
+
export function removeTempDataFromPages(pages: Page[]): Page[] {
|
|
133
|
+
return pages.map((page: Page) => {
|
|
134
|
+
return {
|
|
135
|
+
...page,
|
|
136
|
+
frames: page.frames.map(frame => ({
|
|
137
|
+
...frame,
|
|
138
|
+
component: removeTempDataFromComponents(frame.component),
|
|
139
|
+
}))
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Add data to stylesheets
|
|
146
|
+
*/
|
|
147
|
+
export function addTempDataToStyles(styles: Style[], websiteId: WebsiteId, storageId: ConnectorId): Style[] {
|
|
148
|
+
const pattern = /url\((["']?)([^"']+?)\1\)/g
|
|
149
|
+
return styles.map((style: Style) => {
|
|
150
|
+
if (style.style && style.style['background-image']) {
|
|
151
|
+
const urls = [...style.style['background-image'].matchAll(pattern)].map(match => storedToDisplayed(match[2], websiteId, storageId))
|
|
152
|
+
style = {
|
|
153
|
+
...style,
|
|
154
|
+
style: {
|
|
155
|
+
...style.style,
|
|
156
|
+
'background-image': urls.map(url => `url('${url}')`).join(', '),
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return style
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Remove temp data from stylesheets
|
|
166
|
+
*/
|
|
167
|
+
export function removeTempDataFromStyles(styles: Style[]): Style[] {
|
|
168
|
+
const pattern = /url\((["']?)([^"']+?)\1\)/g
|
|
169
|
+
return styles.map((style: Style) => {
|
|
170
|
+
if (style.style && style.style['background-image']) {
|
|
171
|
+
const urls = [...style.style['background-image'].matchAll(pattern)].map(match => displayedToStored(match[2]))
|
|
172
|
+
style = {
|
|
173
|
+
...style,
|
|
174
|
+
style: {
|
|
175
|
+
...style.style,
|
|
176
|
+
'background-image': urls.map(url => `url('${url}')`).join(', '),
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return style
|
|
181
|
+
})
|
|
182
|
+
}
|
|
@@ -23,6 +23,7 @@ import { getUser, logout, publicationStatus, publish } from '../api'
|
|
|
23
23
|
import { API_CONNECTOR_LOGIN, API_CONNECTOR_PATH, API_PATH } from '../../constants'
|
|
24
24
|
import { ClientEvent } from '../events'
|
|
25
25
|
import { resetRenderComponents, resetRenderCssRules, transformPermalink, transformFiles, transformPath, renderComponents } from '../publication-transformers'
|
|
26
|
+
import { removeTempDataFromAssetUrl } from '../assetUrl'
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @fileoverview Publication manager for Silex
|
|
@@ -207,6 +208,8 @@ export class PublicationManager {
|
|
|
207
208
|
this.setPublicationTransformers()
|
|
208
209
|
const projectData = this.editor.getProjectData() as WebsiteData
|
|
209
210
|
const siteSettings = this.editor.getModel().get('settings') as WebsiteSettings
|
|
211
|
+
// Remove temporary data for editing
|
|
212
|
+
projectData.assets = removeTempDataFromAssetUrl(projectData.assets)
|
|
210
213
|
// Build the files structure
|
|
211
214
|
const files: ClientSideFile[] = (await this.getHtmlFiles(siteSettings))
|
|
212
215
|
.flatMap(file => ([{
|
|
@@ -218,17 +221,21 @@ export class PublicationManager {
|
|
|
218
221
|
content: file.css,
|
|
219
222
|
type: ClientSideFileType.CSS,
|
|
220
223
|
} as ClientSideFile]))
|
|
221
|
-
.concat(projectData.assets
|
|
224
|
+
.concat(projectData.assets
|
|
225
|
+
.map(asset => {
|
|
222
226
|
// Remove /assets that is added by grapesjs
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
path
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
const initialPath = asset.src
|
|
228
|
+
// Remove /assets that is added by grapesjs
|
|
229
|
+
.replace(/^\/assets/, '')
|
|
230
|
+
// Transform the file paths with the transformers
|
|
231
|
+
const path = transformPath(this.editor, initialPath, ClientSideFileType.ASSET)
|
|
232
|
+
console.info('asset transform xxxxxx ================>', asset.src, initialPath, path)
|
|
233
|
+
return {
|
|
234
|
+
...asset,
|
|
235
|
+
path,
|
|
236
|
+
type: ClientSideFileType.ASSET, // Replaces grapesjs's 'image' type
|
|
237
|
+
} as ClientSideFile
|
|
238
|
+
}))
|
|
232
239
|
|
|
233
240
|
// Create the data to send to the server
|
|
234
241
|
const data: PublicationData = {
|
|
@@ -15,22 +15,21 @@
|
|
|
15
15
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { ConnectorId, WebsiteId, WebsiteData, ConnectorUser, ConnectorType, ApiError } from '../../types'
|
|
18
|
+
import { ConnectorId, WebsiteId, WebsiteData, ConnectorUser, ConnectorType, ApiError, Asset, Page, Component, Style } from '../../types'
|
|
19
19
|
import { websiteLoad, websiteSave } from '../api'
|
|
20
20
|
import { cmdLogin, eventLoggedIn, eventLoggedOut, getCurrentUser, updateUser } from './LoginDialog'
|
|
21
|
+
import { addTemDataToPages, addTempDataToAssetUrl, addTempDataToStyles, removeTempDataFromAssetUrl, removeTempDataFromPages, removeTempDataFromStyles } from '../assetUrl'
|
|
21
22
|
|
|
22
|
-
async function wait(ms: number) {
|
|
23
|
-
return new Promise((resolve) => {
|
|
24
|
-
setTimeout(resolve, ms)
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
23
|
export const storagePlugin = (editor) => {
|
|
28
24
|
editor.Storage.add('connector', {
|
|
29
25
|
async load(options: { id: WebsiteId, connectorId: ConnectorId }): Promise<WebsiteData> {
|
|
30
26
|
try {
|
|
31
27
|
const user: ConnectorUser = await getCurrentUser(editor) ?? await updateUser(editor, ConnectorType.STORAGE, options.connectorId)
|
|
32
28
|
if(user) {
|
|
33
|
-
const data = await websiteLoad({websiteId: options.id, connectorId: user.storage.connectorId})
|
|
29
|
+
const data = await websiteLoad({websiteId: options.id, connectorId: user.storage.connectorId}) as WebsiteData
|
|
30
|
+
data.assets = addTempDataToAssetUrl(data.assets, options.id, user.storage.connectorId)
|
|
31
|
+
data.pages = addTemDataToPages(data.pages, options.id, user.storage.connectorId)
|
|
32
|
+
data.styles = addTempDataToStyles(data.styles, options.id, user.storage.connectorId)
|
|
34
33
|
return data
|
|
35
34
|
} else {
|
|
36
35
|
return new Promise((resolve, reject) => {
|
|
@@ -59,6 +58,9 @@ export const storagePlugin = (editor) => {
|
|
|
59
58
|
try {
|
|
60
59
|
if(await getCurrentUser(editor)) {
|
|
61
60
|
const user = await getCurrentUser(editor)
|
|
61
|
+
data.assets = removeTempDataFromAssetUrl(data.assets)
|
|
62
|
+
data.pages = removeTempDataFromPages(data.pages)
|
|
63
|
+
data.styles = removeTempDataFromStyles(data.styles)
|
|
62
64
|
await websiteSave({websiteId: options.id, connectorId: user.storage.connectorId, data})
|
|
63
65
|
} else {
|
|
64
66
|
editor.once(eventLoggedIn, () => {
|
|
@@ -55,19 +55,15 @@ export default (config: ClientConfig, opts: Partial<PluginOptions>) => {
|
|
|
55
55
|
transformPath: (path, type) => {
|
|
56
56
|
switch (type) {
|
|
57
57
|
case 'html':
|
|
58
|
-
console.log('Silex: transform path for 11ty', path, options.html.path + path)
|
|
59
58
|
return options.html.path + path
|
|
60
59
|
case 'css':
|
|
61
|
-
console.log('Silex: transform path for 11ty', path, options.css.path + path.replace(/\.css$/, '.css.liquid'), path.replace(/^\/css/, ''))
|
|
62
60
|
const res = options.css.path + path
|
|
63
61
|
// Remove default path
|
|
64
62
|
.replace(/^\/css/, '')
|
|
65
63
|
// Change extension
|
|
66
64
|
.replace(/\.css$/, '.css.liquid')
|
|
67
|
-
console.log({res})
|
|
68
65
|
return res
|
|
69
66
|
case 'asset':
|
|
70
|
-
console.log('Silex: transform path for 11ty', path, options.assets.path + path)
|
|
71
67
|
return options.assets.path + path
|
|
72
68
|
// Remove default path
|
|
73
69
|
.replace(/^\/assets/, '')
|
|
@@ -75,8 +71,6 @@ export default (config: ClientConfig, opts: Partial<PluginOptions>) => {
|
|
|
75
71
|
throw new Error(`Unknown file type ${type}`)
|
|
76
72
|
},
|
|
77
73
|
transformFile: (file: ClientSideFile) => {
|
|
78
|
-
console.log('Silex: transform file for 11ty', file)
|
|
79
|
-
|
|
80
74
|
const fileWithContent = file as ClientSideFileWithContent
|
|
81
75
|
switch (file.type) {
|
|
82
76
|
case 'html':
|
|
@@ -36,6 +36,7 @@ export interface GitlabOptions {
|
|
|
36
36
|
//metaRepo: string
|
|
37
37
|
//metaRepoFile: string
|
|
38
38
|
repoPrefix: string
|
|
39
|
+
scope: string
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
interface GitlabToken {
|
|
@@ -124,6 +125,7 @@ export default class GitlabConnector implements StorageConnector {
|
|
|
124
125
|
//metaRepo: 'silex-meta',
|
|
125
126
|
//metaRepoFile: 'websites.json',
|
|
126
127
|
repoPrefix: 'silex_',
|
|
128
|
+
scope: 'api', // 'api+read_api+read_user+read_repository+write_repository+email+sudo+profile+openid'
|
|
127
129
|
...opts,
|
|
128
130
|
} as GitlabOptions
|
|
129
131
|
if(!this.options.clientId) throw new Error('Missing Gitlab client ID')
|
|
@@ -299,8 +301,7 @@ export default class GitlabConnector implements StorageConnector {
|
|
|
299
301
|
codeVerifier,
|
|
300
302
|
codeChallenge,
|
|
301
303
|
}
|
|
302
|
-
|
|
303
|
-
return `https://gitlab.com/oauth/authorize?client_id=${this.options.clientId}&redirect_uri=${redirect_uri}&response_type=code&state=${session.gitlab.state}&scope=${scope}&code_challenge=${codeChallenge}&code_challenge_method=S256`
|
|
304
|
+
return `https://gitlab.com/oauth/authorize?client_id=${this.options.clientId}&redirect_uri=${redirect_uri}&response_type=code&state=${session.gitlab.state}&scope=${this.options.scope}&code_challenge=${codeChallenge}&code_challenge_method=S256`
|
|
304
305
|
}
|
|
305
306
|
|
|
306
307
|
getOptions(formData: object): object {
|
|
@@ -124,7 +124,7 @@ export default function (config: ServerConfig): Router {
|
|
|
124
124
|
|
|
125
125
|
// Load the content if necessary
|
|
126
126
|
const filesList: ConnectorFile[] = await Promise.all(files.map(async (file: ClientSideFile) => {
|
|
127
|
-
const prefix = API_WEBSITE_ASSET_READ
|
|
127
|
+
const prefix = API_WEBSITE_ASSET_READ
|
|
128
128
|
const fileWithContent = file as ClientSideFileWithContent
|
|
129
129
|
const fileWithSrc = file as ClientSideFileWithSrc
|
|
130
130
|
if(!fileWithContent.content && !fileWithSrc.src) throw new PublicationError('Missing content or src in file', 400)
|
package/src/ts/types.ts
CHANGED
|
@@ -96,8 +96,29 @@ export const defaultWebsiteData: WebsiteData = {
|
|
|
96
96
|
//publication: {},
|
|
97
97
|
} as WebsiteData
|
|
98
98
|
|
|
99
|
+
|
|
100
|
+
// **
|
|
101
|
+
// Grapesjs types
|
|
102
|
+
// From grapesjs, not imported because it breaks the build on the server side
|
|
103
|
+
export interface Component {
|
|
104
|
+
type: string,
|
|
105
|
+
content?: string,
|
|
106
|
+
attributes: { [key: string]: string },
|
|
107
|
+
components: Component[],
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface Page {
|
|
111
|
+
id: string,
|
|
112
|
+
name: string,
|
|
113
|
+
slug: string,
|
|
114
|
+
// TODO: why is this here? settings: WebsiteSettings,
|
|
115
|
+
frames: {
|
|
116
|
+
component: Component,
|
|
117
|
+
}[]
|
|
118
|
+
}
|
|
119
|
+
|
|
99
120
|
export interface WebsiteData {
|
|
100
|
-
pages:
|
|
121
|
+
pages: Page[],
|
|
101
122
|
assets: Asset[],
|
|
102
123
|
styles: Style[],
|
|
103
124
|
//name: string,
|
|
@@ -128,23 +149,23 @@ export interface Font {
|
|
|
128
149
|
variants: string[],
|
|
129
150
|
}
|
|
130
151
|
|
|
131
|
-
export interface Frame {
|
|
132
|
-
component: { type: string, stylable: string[] },
|
|
133
|
-
components: Component[],
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface Component {
|
|
137
|
-
type: string,
|
|
138
|
-
content?: string,
|
|
139
|
-
attributes: { [key: string]: string },
|
|
140
|
-
conponents: Component[],
|
|
141
|
-
}
|
|
152
|
+
//export interface Frame {
|
|
153
|
+
// component: { type: string, stylable: string[] },
|
|
154
|
+
// components: Component[],
|
|
155
|
+
//}
|
|
156
|
+
//
|
|
157
|
+
//export interface Component {
|
|
158
|
+
// type: string,
|
|
159
|
+
// content?: string,
|
|
160
|
+
// attributes: { [key: string]: string },
|
|
161
|
+
// conponents: Component[],
|
|
162
|
+
//}
|
|
142
163
|
|
|
143
164
|
export enum Unit {
|
|
144
165
|
PX = 'px',
|
|
145
166
|
}
|
|
146
167
|
|
|
147
|
-
export interface Asset
|
|
168
|
+
export interface Asset {
|
|
148
169
|
type: string,
|
|
149
170
|
src: string,
|
|
150
171
|
unitDim: Unit,
|