@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,188 @@
|
|
|
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
|
+
|
|
18
|
+
import { Component, CssRule, ObjectStrings, Page } from 'grapesjs'
|
|
19
|
+
import { ClientSideFile, PublicationData } from '../types'
|
|
20
|
+
import { ClientConfig } from './config'
|
|
21
|
+
import { ClientEvent } from './events'
|
|
22
|
+
import { onAll } from './utils'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @fileoverview Silex publication transformers are used to control how the site is rendered and published
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// Properties names used to store the original methods on the components and styles
|
|
29
|
+
const ATTRIBUTE_METHOD_STORE_HTML = 'tmp-pre-publication-transformer-tohtml'
|
|
30
|
+
const ATTRIBUTE_METHOD_STORE_CSS = 'tmp-pre-publication-transformer-tocss'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Interface for publication transformers
|
|
34
|
+
* They are added to the config object with config.addPublicationTransformer()
|
|
35
|
+
*/
|
|
36
|
+
export interface PublicationTransformer {
|
|
37
|
+
// Override how components render at publication by grapesjs
|
|
38
|
+
renderComponent?(component: Component, toHtml: () => string): string | undefined
|
|
39
|
+
// Override how styles render at publication by grapesjs
|
|
40
|
+
renderCssRule?(rule: CssRule, initialRule: () => ObjectStrings): ObjectStrings | undefined
|
|
41
|
+
// Define how pages are named
|
|
42
|
+
pageToSlug?(page: Page): string
|
|
43
|
+
// Transform files after they are rendered and before they are published
|
|
44
|
+
transformFile?(file: ClientSideFile, page: Page | null): ClientSideFile
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Init publication transformers
|
|
50
|
+
* Called at startup in the /index.ts file
|
|
51
|
+
*/
|
|
52
|
+
export async function initPublicationTransformers(config: ClientConfig) {
|
|
53
|
+
const editor = config.getEditor()
|
|
54
|
+
// Override default rendering of components and styles
|
|
55
|
+
// Also create page slugs
|
|
56
|
+
editor.on(ClientEvent.PUBLISH_START, () => {
|
|
57
|
+
transformComponents(config)
|
|
58
|
+
transformStyles(config)
|
|
59
|
+
transformPages(config)
|
|
60
|
+
})
|
|
61
|
+
// Reset the components and styles rendering
|
|
62
|
+
editor.on(ClientEvent.PUBLISH_END, () => {
|
|
63
|
+
resetTransformComponents(config)
|
|
64
|
+
resetTransformStyles(config)
|
|
65
|
+
resetTransformPages(config)
|
|
66
|
+
})
|
|
67
|
+
// Transform files after generating all files to be published
|
|
68
|
+
editor.on(ClientEvent.PUBLISH_DATA, (data: PublicationData) => {
|
|
69
|
+
transformFiles(config, data)
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Alter the components rendering
|
|
75
|
+
* Exported for unit tests
|
|
76
|
+
*/
|
|
77
|
+
export function transformComponents(config: ClientConfig) {
|
|
78
|
+
const editor = config.getEditor()
|
|
79
|
+
onAll(editor, (c: Component) => {
|
|
80
|
+
if (c.get(ATTRIBUTE_METHOD_STORE_HTML)) {
|
|
81
|
+
console.warn('Publication transformer: HTML transform already altered', c)
|
|
82
|
+
} else {
|
|
83
|
+
const initialToHTML = c.toHTML.bind(c)
|
|
84
|
+
c[ATTRIBUTE_METHOD_STORE_HTML] = c.toHTML
|
|
85
|
+
c.toHTML = () => {
|
|
86
|
+
return config.publicationTransformers.reduce((html, transformer) => {
|
|
87
|
+
try {
|
|
88
|
+
return transformer.renderComponent ? transformer.renderComponent(c, initialToHTML) ?? html : html
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error('Publication transformer: error rendering component', c, e)
|
|
91
|
+
return html
|
|
92
|
+
}
|
|
93
|
+
}, initialToHTML())
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Alter the styles rendering
|
|
101
|
+
* Exported for unit tests
|
|
102
|
+
*/
|
|
103
|
+
export function transformStyles(config: ClientConfig) {
|
|
104
|
+
const editor = config.getEditor()
|
|
105
|
+
editor.Css.getAll().forEach(c => {
|
|
106
|
+
if (c[ATTRIBUTE_METHOD_STORE_CSS]) {
|
|
107
|
+
console.warn('Publication transformer: CSS transform already altered', c)
|
|
108
|
+
} else {
|
|
109
|
+
const initialGetStyle = c.getStyle.bind(c)
|
|
110
|
+
c[ATTRIBUTE_METHOD_STORE_CSS] = c.getStyle
|
|
111
|
+
c.getStyle = () => {
|
|
112
|
+
try {
|
|
113
|
+
return config.publicationTransformers.reduce((style, transformer) => {
|
|
114
|
+
return {
|
|
115
|
+
...transformer.renderCssRule ? transformer.renderCssRule(c, initialGetStyle) ?? style : style,
|
|
116
|
+
}
|
|
117
|
+
}, initialGetStyle())
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.error('Publication transformer: error rendering style', c, e)
|
|
120
|
+
return initialGetStyle()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Create page slugs
|
|
129
|
+
* Exported for unit tests
|
|
130
|
+
*/
|
|
131
|
+
export function transformPages(config: ClientConfig) {
|
|
132
|
+
const editor = config.getEditor()
|
|
133
|
+
editor.Pages.getAll().forEach((page) => {
|
|
134
|
+
page.set('slug', config.publicationTransformers.reduce((slug, transformer) => {
|
|
135
|
+
try {
|
|
136
|
+
return transformer.pageToSlug ? transformer.pageToSlug(page) ?? slug : slug
|
|
137
|
+
} catch (e) {
|
|
138
|
+
console.error('Publication transformer: error creating page slug', page, e)
|
|
139
|
+
return slug
|
|
140
|
+
}
|
|
141
|
+
}, page.get('slug')))
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Transform files
|
|
147
|
+
* Exported for unit tests
|
|
148
|
+
*/
|
|
149
|
+
export function transformFiles(config: ClientConfig, data: PublicationData) {
|
|
150
|
+
data.files = config.publicationTransformers.reduce((files: ClientSideFile[], transformer: PublicationTransformer) => {
|
|
151
|
+
return files.map((file, idx) => {
|
|
152
|
+
try {
|
|
153
|
+
const page = data.pages[idx] ?? null
|
|
154
|
+
return transformer.transformFile ? transformer.transformFile(file, page) as ClientSideFile ?? file : file
|
|
155
|
+
} catch (e) {
|
|
156
|
+
console.error('Publication transformer: error transforming file', file, e)
|
|
157
|
+
return file
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
}, data.files)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function resetTransformComponents(config: ClientConfig) {
|
|
164
|
+
const editor = config.getEditor()
|
|
165
|
+
onAll(editor, (c: Component) => {
|
|
166
|
+
if (c[ATTRIBUTE_METHOD_STORE_HTML]) {
|
|
167
|
+
c.toHTML = c[ATTRIBUTE_METHOD_STORE_HTML]
|
|
168
|
+
delete c[ATTRIBUTE_METHOD_STORE_HTML]
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function resetTransformStyles(config: ClientConfig) {
|
|
174
|
+
const editor = config.getEditor()
|
|
175
|
+
editor.Css.getAll().forEach(c => {
|
|
176
|
+
if (c[ATTRIBUTE_METHOD_STORE_CSS]) {
|
|
177
|
+
c.getStyle = c[ATTRIBUTE_METHOD_STORE_CSS]
|
|
178
|
+
delete c[ATTRIBUTE_METHOD_STORE_CSS]
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function resetTransformPages(config: ClientConfig) {
|
|
184
|
+
const editor = config.getEditor()
|
|
185
|
+
editor.Pages.getAll().forEach(page => {
|
|
186
|
+
page.unset('slug')
|
|
187
|
+
})
|
|
188
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Page } from 'grapesjs'
|
|
2
|
+
import { ClientConfig } from '../../client/config'
|
|
3
|
+
import { ClientSideFile, ClientSideFileWithContent } from '../../types'
|
|
4
|
+
|
|
5
|
+
interface PluginOptions {
|
|
6
|
+
html: {
|
|
7
|
+
url: string,
|
|
8
|
+
path: string,
|
|
9
|
+
},
|
|
10
|
+
css: {
|
|
11
|
+
url: string,
|
|
12
|
+
path: string,
|
|
13
|
+
},
|
|
14
|
+
assets: {
|
|
15
|
+
url: string,
|
|
16
|
+
path: string,
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default (config: ClientConfig, opts: Partial<PluginOptions>) => {
|
|
21
|
+
const options = {
|
|
22
|
+
...opts,
|
|
23
|
+
html: {
|
|
24
|
+
url: '/',
|
|
25
|
+
path: './',
|
|
26
|
+
...opts.html,
|
|
27
|
+
},
|
|
28
|
+
css: {
|
|
29
|
+
url: '/css',
|
|
30
|
+
path: './css',
|
|
31
|
+
...opts.css,
|
|
32
|
+
},
|
|
33
|
+
assets: {
|
|
34
|
+
url: '/assets',
|
|
35
|
+
path: './', // assets is already in the assets urls
|
|
36
|
+
...opts.assets,
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
config.addPublicationTransformers({
|
|
41
|
+
transformFile: (file: ClientSideFile, page: Page) => {
|
|
42
|
+
const fileWithContent = file as ClientSideFileWithContent
|
|
43
|
+
console.log('Silex: transform file for 11ty', fileWithContent)
|
|
44
|
+
switch (file.type) {
|
|
45
|
+
case 'html':
|
|
46
|
+
return {
|
|
47
|
+
...file,
|
|
48
|
+
path: options.html.path + fileWithContent.path,
|
|
49
|
+
//content: `---\npermalink: ${options.html.url}${fileWithContent.path}\n---\n${fileWithContent.content}`
|
|
50
|
+
}
|
|
51
|
+
case 'css':
|
|
52
|
+
return {
|
|
53
|
+
...file,
|
|
54
|
+
path: options.css.path + fileWithContent.path.replace(/\.css$/, '.css.liquid'),
|
|
55
|
+
content: `---\npermalink: ${options.css.url}${fileWithContent.path}\n---\n${fileWithContent.content}`
|
|
56
|
+
}
|
|
57
|
+
case 'asset':
|
|
58
|
+
return {
|
|
59
|
+
...file,
|
|
60
|
+
path: options.assets.path + fileWithContent.path,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Unknown file type ${file.type}`)
|
|
64
|
+
},
|
|
65
|
+
renderComponent: (c, toHtml) => {
|
|
66
|
+
if (c.get('type') === 'image') {
|
|
67
|
+
// Concat the paths, handles the trailing and leading slashes
|
|
68
|
+
const publishedUrl = path => `${options.assets.url.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`
|
|
69
|
+
const src = c.get('src')
|
|
70
|
+
c.set('src', publishedUrl(src))
|
|
71
|
+
const html = toHtml()
|
|
72
|
+
console.log('Silex: transform component for 11ty', publishedUrl, html)
|
|
73
|
+
c.set('src', src)
|
|
74
|
+
return html
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
renderCssRule(c, getStyle) {
|
|
78
|
+
const publishedUrl = path => `${options.assets.url.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`
|
|
79
|
+
const url = getStyle()['background-image']
|
|
80
|
+
const bgUrl = url?.match(/url\('(.*)'\)/)?.pop()
|
|
81
|
+
if (bgUrl) {
|
|
82
|
+
return {
|
|
83
|
+
...getStyle(),
|
|
84
|
+
'background-image': `url('${publishedUrl(bgUrl)}')`,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
@@ -1,7 +1,47 @@
|
|
|
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
|
+
|
|
18
|
+
// Silex: publication renderer plugin is deprecated. Use the publication renderer plugin instead.
|
|
19
|
+
console.warn('Silex: publication renderer plugin is deprecated. Use the publication renderer plugin instead.')
|
|
20
|
+
|
|
21
|
+
/* Usage:
|
|
22
|
+
import publicationRenderer from '/node_modules/@silexlabs/silex/dist/plugins/client/plugins/client/publicationRenderer.js'
|
|
23
|
+
await config.addPlugin(publicationRenderer, {
|
|
24
|
+
css: {
|
|
25
|
+
frontMatter: true,
|
|
26
|
+
ext: '.css.liquid',
|
|
27
|
+
path: '../../../pages'
|
|
28
|
+
},
|
|
29
|
+
html: {
|
|
30
|
+
frontMatter: false,
|
|
31
|
+
path: '../../../_includes'
|
|
32
|
+
},
|
|
33
|
+
assets: {
|
|
34
|
+
path: '../../../',
|
|
35
|
+
url: '/',
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
*/
|
|
39
|
+
|
|
1
40
|
import { getPageSlug } from '../../page.js'
|
|
2
|
-
import {
|
|
41
|
+
import { ClientSideFile } from '../../types.js'
|
|
3
42
|
import { onAll } from '../../client/utils.js'
|
|
4
43
|
import { ClientEvent } from '../../client/events.js'
|
|
44
|
+
import { Page } from 'grapesjs'
|
|
5
45
|
|
|
6
46
|
export default (config, opts: any = {}) => {
|
|
7
47
|
const options = {
|
|
@@ -103,26 +143,28 @@ export default (config, opts: any = {}) => {
|
|
|
103
143
|
})
|
|
104
144
|
}
|
|
105
145
|
})
|
|
106
|
-
editor.on(ClientEvent.PUBLISH_DATA, data => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
146
|
+
//editor.on(ClientEvent.PUBLISH_DATA, data => {
|
|
147
|
+
// data.pages.forEach((page: Page, idx) => {
|
|
148
|
+
// const file = data.files[idx] as ClientSideFile
|
|
149
|
+
// console.log('Silex: publication renderer: page', page, file)
|
|
150
|
+
// // CSS
|
|
151
|
+
// if(file.type === 'css') {
|
|
152
|
+
// file.cssPath = file.cssPath.replace(/\.css$/, options.css.ext)
|
|
153
|
+
// file.cssPath = options.css.path + file.cssPath
|
|
154
|
+
// if (options.css.frontMatter) {
|
|
155
|
+
// file.css = `---\npermalink: ${options.css.url}/${page.slug}.css\n---\n${file.css}`
|
|
156
|
+
// }
|
|
157
|
+
// // HTML
|
|
158
|
+
// file.htmlPath = file.htmlPath.replace(/\.html$/, options.html.ext)
|
|
159
|
+
// file.htmlPath = options.html.path + file.htmlPath
|
|
160
|
+
// if (options.html.frontMatter) {
|
|
161
|
+
// file.html = `---\npermalink: ${options.html.url}/${page.slug}.html\n---\n${file.html}`
|
|
162
|
+
// }
|
|
163
|
+
// })
|
|
164
|
+
// data.assets.forEach((asset, idx) => {
|
|
165
|
+
// asset.path = options.assets.path + asset.src
|
|
166
|
+
// // The rest is handled by the editor.Css.getAll loop
|
|
167
|
+
// })
|
|
168
|
+
//})
|
|
127
169
|
})
|
|
128
170
|
}
|
|
@@ -55,7 +55,7 @@ export default async function(config) {
|
|
|
55
55
|
topBar?.appendChild(container)
|
|
56
56
|
// Display the website meta data
|
|
57
57
|
container.innerHTML = `
|
|
58
|
-
|
|
58
|
+
${ websiteMeta.imageUrl ? `<div class="gjs-website-meta-image" style="background: url(${websiteMeta.imageUrl});"></div>` : '' }
|
|
59
59
|
<div class="gjs-website-meta-name">${websiteMeta.name}</div>
|
|
60
60
|
`
|
|
61
61
|
}
|
|
@@ -21,11 +21,11 @@ import { ConnectorFile, ConnectorFileContent, HostingConnector, StatusCallback,
|
|
|
21
21
|
import { requiredParam } from '../../server/utils/validation'
|
|
22
22
|
import { WEBSITE_DATA_FILE, WEBSITE_META_DATA_FILE } from '../../constants'
|
|
23
23
|
import { ConnectorType, ConnectorUser, WebsiteMeta, FileMeta, JobData, JobStatus, WebsiteId, PublicationJobData, WebsiteMetaFileContent, defaultWebsiteData, WebsiteData, ConnectorOptions } from '../../types'
|
|
24
|
-
import { jobError, jobSuccess, startJob } from '../../server/jobs'
|
|
25
24
|
import { ServerConfig } from '../../server/config'
|
|
26
25
|
import { join } from 'path'
|
|
27
26
|
import { type } from 'os'
|
|
28
27
|
import { v4 as uuid } from 'uuid'
|
|
28
|
+
import { JobManager } from '../../server/jobs'
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @fileoverview FTP connector for Silex
|
|
@@ -370,7 +370,7 @@ export default class FtpConnector implements StorageConnector<FtpSession> {
|
|
|
370
370
|
async getUser(session: FtpSession): Promise<ConnectorUser> {
|
|
371
371
|
return {
|
|
372
372
|
name: this.sessionData(session).user,
|
|
373
|
-
picture: 'data
|
|
373
|
+
picture: 'data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' height=\'1em\' viewBox=\'0 0 448 512\'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d=\'M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z\'/%3E%3C/svg%3E',
|
|
374
374
|
storage: await toConnectorData(session, this)
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -568,7 +568,7 @@ export default class FtpConnector implements StorageConnector<FtpSession> {
|
|
|
568
568
|
return this.sessionData(session).websiteUrl ?? ''
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
async publish(session: FtpSession, id:
|
|
571
|
+
async publish(session: FtpSession, id: WebsiteId, files: ConnectorFile[], {startJob, jobSuccess, jobError}: JobManager): Promise<JobData> {
|
|
572
572
|
const job = startJob(`Publishing to ${this.displayName}`) as PublicationJobData
|
|
573
573
|
job.logs = [[`Publishing to ${this.displayName}`]]
|
|
574
574
|
job.errors = [[]]
|