@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.
Files changed (282) hide show
  1. package/.env.default +19 -0
  2. package/.silex.js +37 -0
  3. package/LICENSE +661 -0
  4. package/README.md +96 -0
  5. package/dist/client/client/api.d.ts +85 -0
  6. package/dist/client/client/assetUrl.d.ts +51 -0
  7. package/dist/client/client/config.d.ts +58 -0
  8. package/dist/client/client/events.d.ts +14 -0
  9. package/dist/client/client/expose.d.ts +8 -0
  10. package/dist/client/client/grapesjs/LoginDialog.d.ts +15 -0
  11. package/dist/client/client/grapesjs/PublicationManager.d.ts +72 -0
  12. package/dist/client/client/grapesjs/PublicationUi.d.ts +62 -0
  13. package/dist/client/client/grapesjs/blocks.d.ts +1 -0
  14. package/dist/client/client/grapesjs/breadcrumbs.d.ts +1 -0
  15. package/dist/client/client/grapesjs/footer.d.ts +2 -0
  16. package/dist/client/client/grapesjs/index.d.ts +5 -0
  17. package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
  18. package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  19. package/dist/client/client/grapesjs/openImport.d.ts +9 -0
  20. package/dist/client/client/grapesjs/page-panel.d.ts +3 -0
  21. package/dist/client/client/grapesjs/project-bar.d.ts +1 -0
  22. package/dist/client/client/grapesjs/rich-text.d.ts +1 -0
  23. package/dist/client/client/grapesjs/semantic.d.ts +1 -0
  24. package/dist/client/client/grapesjs/settings.d.ts +2 -0
  25. package/dist/client/client/grapesjs/storage.d.ts +1 -0
  26. package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  27. package/dist/client/client/index.d.ts +5 -0
  28. package/dist/client/client/publication-transformers.d.ts +41 -0
  29. package/dist/client/client/utils.d.ts +2 -0
  30. package/dist/client/constants.d.ts +29 -0
  31. package/dist/client/css/admin.css +4491 -0
  32. package/dist/client/index.html +9 -0
  33. package/dist/client/js/main.js +321 -0
  34. package/dist/client/js/main.js.LICENSE.txt +24 -0
  35. package/dist/client/page.d.ts +2 -0
  36. package/dist/client/types.d.ts +334 -0
  37. package/dist/plugins/client/client/api.d.ts +85 -0
  38. package/dist/plugins/client/client/api.js +114 -0
  39. package/dist/plugins/client/client/api.js.map +1 -0
  40. package/dist/plugins/client/client/assetUrl.d.ts +51 -0
  41. package/dist/plugins/client/client/assetUrl.js +224 -0
  42. package/dist/plugins/client/client/assetUrl.js.map +1 -0
  43. package/dist/plugins/client/client/config.d.ts +58 -0
  44. package/dist/plugins/client/client/config.js +90 -0
  45. package/dist/plugins/client/client/config.js.map +1 -0
  46. package/dist/plugins/client/client/events.d.ts +14 -0
  47. package/dist/plugins/client/client/events.js +34 -0
  48. package/dist/plugins/client/client/events.js.map +1 -0
  49. package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
  50. package/dist/plugins/client/client/grapesjs/LoginDialog.js +195 -0
  51. package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
  52. package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +72 -0
  53. package/dist/plugins/client/client/grapesjs/PublicationManager.js +356 -0
  54. package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
  55. package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +62 -0
  56. package/dist/plugins/client/client/grapesjs/PublicationUi.js +336 -0
  57. package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
  58. package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
  59. package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
  60. package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
  61. package/dist/plugins/client/client/grapesjs/breadcrumbs.d.ts +1 -0
  62. package/dist/plugins/client/client/grapesjs/breadcrumbs.js +75 -0
  63. package/dist/plugins/client/client/grapesjs/breadcrumbs.js.map +1 -0
  64. package/dist/plugins/client/client/grapesjs/footer.d.ts +2 -0
  65. package/dist/plugins/client/client/grapesjs/footer.js +28 -0
  66. package/dist/plugins/client/client/grapesjs/footer.js.map +1 -0
  67. package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
  68. package/dist/plugins/client/client/grapesjs/index.js +313 -0
  69. package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
  70. package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
  71. package/dist/plugins/client/client/grapesjs/internal-links.js +219 -0
  72. package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
  73. package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  74. package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
  75. package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
  76. package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
  77. package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
  78. package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
  79. package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
  80. package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
  81. package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
  82. package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
  83. package/dist/plugins/client/client/grapesjs/project-bar.js +104 -0
  84. package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
  85. package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
  86. package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
  87. package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
  88. package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
  89. package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
  90. package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
  91. package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
  92. package/dist/plugins/client/client/grapesjs/settings.js +198 -0
  93. package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
  94. package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
  95. package/dist/plugins/client/client/grapesjs/storage.js +126 -0
  96. package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
  97. package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  98. package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
  99. package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
  100. package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
  101. package/dist/plugins/client/client/publication-transformers.js +238 -0
  102. package/dist/plugins/client/client/publication-transformers.js.map +1 -0
  103. package/dist/plugins/client/client/utils.d.ts +2 -0
  104. package/dist/plugins/client/client/utils.js +25 -0
  105. package/dist/plugins/client/client/utils.js.map +1 -0
  106. package/dist/plugins/client/constants.d.ts +29 -0
  107. package/dist/plugins/client/constants.js +46 -0
  108. package/dist/plugins/client/constants.js.map +1 -0
  109. package/dist/plugins/client/page.d.ts +2 -0
  110. package/dist/plugins/client/page.js +31 -0
  111. package/dist/plugins/client/page.js.map +1 -0
  112. package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
  113. package/dist/plugins/client/plugins/client/11ty.js +86 -0
  114. package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
  115. package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +2 -0
  116. package/dist/plugins/client/plugins/client/publicationRenderer.js +170 -0
  117. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -0
  118. package/dist/plugins/client/plugins/client/template.d.ts +2 -0
  119. package/dist/plugins/client/plugins/client/template.js +183 -0
  120. package/dist/plugins/client/plugins/client/template.js.map +1 -0
  121. package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
  122. package/dist/plugins/client/plugins/client/website-info.js +72 -0
  123. package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
  124. package/dist/plugins/client/types.d.ts +334 -0
  125. package/dist/plugins/client/types.js +74 -0
  126. package/dist/plugins/client/types.js.map +1 -0
  127. package/dist/plugins/server/constants.d.ts +29 -0
  128. package/dist/plugins/server/constants.js +49 -0
  129. package/dist/plugins/server/constants.js.map +1 -0
  130. package/dist/plugins/server/plugins/server/AuthPlugin.d.ts +1 -0
  131. package/dist/plugins/server/plugins/server/AuthPlugin.js +40 -0
  132. package/dist/plugins/server/plugins/server/AuthPlugin.js.map +1 -0
  133. package/dist/plugins/server/plugins/server/Cache.d.ts +2 -0
  134. package/dist/plugins/server/plugins/server/Cache.js +32 -0
  135. package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
  136. package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
  137. package/dist/plugins/server/plugins/server/DownloadConnector.js +129 -0
  138. package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
  139. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +86 -0
  140. package/dist/plugins/server/plugins/server/FtpConnector.js +526 -0
  141. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
  142. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +87 -0
  143. package/dist/plugins/server/plugins/server/GitlabConnector.js +564 -0
  144. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -0
  145. package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
  146. package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
  147. package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
  148. package/dist/plugins/server/plugins/server/SslPlugin.d.ts +1 -0
  149. package/dist/plugins/server/plugins/server/SslPlugin.js +86 -0
  150. package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
  151. package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +1 -0
  152. package/dist/plugins/server/plugins/server/StaticPlugin.js +78 -0
  153. package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
  154. package/dist/plugins/server/server/config.d.ts +59 -0
  155. package/dist/plugins/server/server/config.js +181 -0
  156. package/dist/plugins/server/server/config.js.map +1 -0
  157. package/dist/plugins/server/server/connectors/FsHosting.d.ts +13 -0
  158. package/dist/plugins/server/server/connectors/FsHosting.js +54 -0
  159. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
  160. package/dist/plugins/server/server/connectors/FsStorage.d.ts +43 -0
  161. package/dist/plugins/server/server/connectors/FsStorage.js +257 -0
  162. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
  163. package/dist/plugins/server/server/connectors/connectors.d.ts +87 -0
  164. package/dist/plugins/server/server/connectors/connectors.js +127 -0
  165. package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
  166. package/dist/plugins/server/server/events.d.ts +26 -0
  167. package/dist/plugins/server/server/events.js +31 -0
  168. package/dist/plugins/server/server/events.js.map +1 -0
  169. package/dist/plugins/server/server/jobs.d.ts +12 -0
  170. package/dist/plugins/server/server/jobs.js +77 -0
  171. package/dist/plugins/server/server/jobs.js.map +1 -0
  172. package/dist/plugins/server/server/utils/validation.d.ts +7 -0
  173. package/dist/plugins/server/server/utils/validation.js +38 -0
  174. package/dist/plugins/server/server/utils/validation.js.map +1 -0
  175. package/dist/plugins/server/types.d.ts +334 -0
  176. package/dist/plugins/server/types.js +78 -0
  177. package/dist/plugins/server/types.js.map +1 -0
  178. package/dist/server/constants.js +29 -0
  179. package/dist/server/plugins/server/Cache.js +15 -0
  180. package/dist/server/server/api/api.js +20 -0
  181. package/dist/server/server/api/connectorApi.js +216 -0
  182. package/dist/server/server/api/publicationApi.js +108 -0
  183. package/dist/server/server/api/websiteApi.js +296 -0
  184. package/dist/server/server/cli.js +68 -0
  185. package/dist/server/server/config.js +120 -0
  186. package/dist/server/server/connectors/FsHosting.js +35 -0
  187. package/dist/server/server/connectors/FsStorage.js +225 -0
  188. package/dist/server/server/connectors/connectors.js +89 -0
  189. package/dist/server/server/events.js +14 -0
  190. package/dist/server/server/expose.js +27 -0
  191. package/dist/server/server/express.js +47 -0
  192. package/dist/server/server/index.js +90 -0
  193. package/dist/server/server/jobs.js +48 -0
  194. package/dist/server/server/utils/validation.js +15 -0
  195. package/dist/server/types.js +34 -0
  196. package/package.json +209 -0
  197. package/public/assets/container.png +0 -0
  198. package/public/assets/favicon.png +0 -0
  199. package/public/assets/logo-silex-small.png +0 -0
  200. package/public/robots.txt +2 -0
  201. package/public/silex.js +24 -0
  202. package/src/css/_mixins.scss +8 -0
  203. package/src/css/_variables.scss +33 -0
  204. package/src/css/dialog.scss +41 -0
  205. package/src/css/footer.scss +12 -0
  206. package/src/css/grapesjs-light.scss +180 -0
  207. package/src/css/grapesjs.scss +152 -0
  208. package/src/css/index.scss +32 -0
  209. package/src/css/light.scss +7 -0
  210. package/src/css/loader.scss +12 -0
  211. package/src/css/page-panel.scss +65 -0
  212. package/src/css/project-bar.scss +102 -0
  213. package/src/css/silex.scss +189 -0
  214. package/src/css/website-info.scss +14 -0
  215. package/src/html/debug.pug +8 -0
  216. package/src/html/index.pug +39 -0
  217. package/src/html/templates/includes.pug +1 -0
  218. package/src/html/templates/workspace.pug +2 -0
  219. package/src/ts/client/api.ts +144 -0
  220. package/src/ts/client/assetUrl.test.ts +125 -0
  221. package/src/ts/client/assetUrl.ts +235 -0
  222. package/src/ts/client/config.ts +105 -0
  223. package/src/ts/client/events.ts +34 -0
  224. package/src/ts/client/expose.ts +30 -0
  225. package/src/ts/client/grapesjs/LoginDialog.ts +204 -0
  226. package/src/ts/client/grapesjs/PublicationManager.ts +370 -0
  227. package/src/ts/client/grapesjs/PublicationUi.ts +342 -0
  228. package/src/ts/client/grapesjs/blocks.ts +37 -0
  229. package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
  230. package/src/ts/client/grapesjs/eleventy.ts +47 -0
  231. package/src/ts/client/grapesjs/footer.ts +27 -0
  232. package/src/ts/client/grapesjs/index.ts +335 -0
  233. package/src/ts/client/grapesjs/internal-links.test.ts +105 -0
  234. package/src/ts/client/grapesjs/internal-links.ts +225 -0
  235. package/src/ts/client/grapesjs/new-page-dialog.ts +90 -0
  236. package/src/ts/client/grapesjs/openImport.ts +81 -0
  237. package/src/ts/client/grapesjs/page-panel.ts +118 -0
  238. package/src/ts/client/grapesjs/project-bar.ts +107 -0
  239. package/src/ts/client/grapesjs/rich-text.ts +33 -0
  240. package/src/ts/client/grapesjs/semantic.ts +114 -0
  241. package/src/ts/client/grapesjs/settings.ts +208 -0
  242. package/src/ts/client/grapesjs/storage.ts +121 -0
  243. package/src/ts/client/grapesjs/symbolDialogs.ts +38 -0
  244. package/src/ts/client/index.ts +98 -0
  245. package/src/ts/client/publication-transformers.test.ts +199 -0
  246. package/src/ts/client/publication-transformers.ts +263 -0
  247. package/src/ts/client/utils.ts +28 -0
  248. package/src/ts/constants.ts +52 -0
  249. package/src/ts/externs.ts +18 -0
  250. package/src/ts/page.ts +31 -0
  251. package/src/ts/plugins/client/11ty.ts +104 -0
  252. package/src/ts/plugins/client/publicationRenderer.ts +174 -0
  253. package/src/ts/plugins/client/template.ts +192 -0
  254. package/src/ts/plugins/client/website-info.ts +84 -0
  255. package/src/ts/plugins/server/AuthPlugin.ts +38 -0
  256. package/src/ts/plugins/server/Cache.ts +28 -0
  257. package/src/ts/plugins/server/DownloadConnector.ts +148 -0
  258. package/src/ts/plugins/server/FtpConnector.test.ts +82 -0
  259. package/src/ts/plugins/server/FtpConnector.ts +609 -0
  260. package/src/ts/plugins/server/GitlabConnector.ts +644 -0
  261. package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
  262. package/src/ts/plugins/server/SslPlugin.ts +84 -0
  263. package/src/ts/plugins/server/StaticPlugin.ts +79 -0
  264. package/src/ts/server/api/api.ts +19 -0
  265. package/src/ts/server/api/connectorApi.ts +345 -0
  266. package/src/ts/server/api/publicationApi.ts +159 -0
  267. package/src/ts/server/api/websiteApi.ts +432 -0
  268. package/src/ts/server/cli.ts +65 -0
  269. package/src/ts/server/config.ts +189 -0
  270. package/src/ts/server/connectors/FsHosting.ts +60 -0
  271. package/src/ts/server/connectors/FsStorage.test.ts +51 -0
  272. package/src/ts/server/connectors/FsStorage.ts +261 -0
  273. package/src/ts/server/connectors/connectors.ts +203 -0
  274. package/src/ts/server/events.ts +37 -0
  275. package/src/ts/server/expose.ts +19 -0
  276. package/src/ts/server/express.ts +70 -0
  277. package/src/ts/server/index.ts +100 -0
  278. package/src/ts/server/jobs.test.ts +75 -0
  279. package/src/ts/server/jobs.ts +87 -0
  280. package/src/ts/server/utils/BackwardCompat.ts +552 -0
  281. package/src/ts/server/utils/validation.ts +34 -0
  282. package/src/ts/types.ts +339 -0
@@ -0,0 +1,342 @@
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 { html, render, TemplateResult } from 'lit-html'
19
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
20
+ //import { map } from 'lit-html/directives/map.js'
21
+ import { cmdPublicationLogin, cmdPublicationLogout, cmdPublicationStart, PublicationStatus, PublishableEditor } from './PublicationManager'
22
+ import { ConnectorData, ConnectorType, PublicationJobData, PublicationSettings } from '../../types'
23
+ import { connectorList } from '../api'
24
+
25
+ /**
26
+ * @fileoverview define the publication dialog
27
+ * This is the UI of the publication feature
28
+ * It is a dialog which allows the user to login to a connector and publish the website
29
+ * It also displays the publication status and logs during the publication process
30
+ * This class is used by the PublicationManager
31
+ * This is optional, you can use the PublicationManager without this UI
32
+ * @TODO Use publication events instead of calls from the PublicationManager
33
+ */
34
+
35
+ // **
36
+ // Constants
37
+ export const cmdPublish = 'publish-open-dialog'
38
+
39
+ // **
40
+ // Types
41
+ export type PublicationDialogOptions = {
42
+ appendTo: string
43
+ }
44
+
45
+ // **
46
+ // Utils
47
+ function cleanupLogEntry(arr: string[][]): string {
48
+ return arr[arr.length - 1]
49
+ ?.map(str => str.replace(/\[.*\]/g, '').trim())
50
+ ?.filter(str => !!str)
51
+ ?.join('\n')
52
+ }
53
+
54
+ /**
55
+ * Class to manage the publication dialog
56
+ */
57
+ export class PublicationUi {
58
+ /**
59
+ * Dialog state
60
+ */
61
+ public isOpen = false
62
+ /**
63
+ * Dialog content
64
+ */
65
+ private errorMessage = ''
66
+ /**
67
+ * Dialog element
68
+ * This is the DOM element of the dialog
69
+ */
70
+ private el: HTMLElement
71
+
72
+ public settings: PublicationSettings
73
+
74
+ private sender = null
75
+
76
+ /**
77
+ * Initialize the dialog and the publish button
78
+ */
79
+ constructor(private editor: PublishableEditor, private options: PublicationDialogOptions) {
80
+ // Reference to the dialog element
81
+ this.el = this.createDialogElements()
82
+ // Add the publish command to the editor
83
+ const openDialog = () => this.openDialog()
84
+ const closeDialog = () => this.closeDialog()
85
+ const setSender = sender => this.sender = sender
86
+ editor.Commands.add(cmdPublish, {
87
+ run(editor: PublishableEditor, sender) {
88
+ setSender(sender)
89
+ openDialog()
90
+ },
91
+ stop(editor: PublishableEditor) { closeDialog() },
92
+ })
93
+ }
94
+
95
+ // **
96
+ // Convenient state checkers
97
+ isSuccess(status: PublicationStatus) {
98
+ return status === PublicationStatus.STATUS_SUCCESS
99
+ }
100
+ isPending(status: PublicationStatus) {
101
+ return status === PublicationStatus.STATUS_PENDING
102
+ }
103
+ isError(status: PublicationStatus) {
104
+ return status === PublicationStatus.STATUS_ERROR
105
+ }
106
+ isLoggedOut(status: PublicationStatus) {
107
+ return status === PublicationStatus.STATUS_LOGGED_OUT
108
+ }
109
+ isReady(status: PublicationStatus) {
110
+ return status === PublicationStatus.STATUS_NONE
111
+ }
112
+
113
+ // **
114
+ // Functions to open and close the dialog
115
+ getDialogElements(): { el: HTMLElement, primary: HTMLElement, secondary: HTMLElement } {
116
+ const el = document.querySelector('#publish-dialog') as HTMLElement
117
+ const primary = el?.querySelector('#publish-button--primary') as HTMLElement
118
+ const secondary = el?.querySelector('#publish-button--secondary') as HTMLElement
119
+ if(!el || !primary || !secondary) throw new Error('Publication dialog elements not found')
120
+ return { el, primary, secondary }
121
+ }
122
+ createDialogElements(): HTMLElement {
123
+ // Create the dialog element
124
+ const el = document.createElement('div')
125
+ el.id = 'publish-dialog'
126
+ el.className = 'silex-dialog-inline silex-dialog gjs-two-color'
127
+ document.body.append(el)
128
+ // Create the publish button
129
+ this.editor.Panels.addButton(this.options.appendTo, {
130
+ id: 'publish-button',
131
+ className: 'silex-button--size publish-button',
132
+ command: cmdPublish,
133
+ attributes: { title: 'Publish' },
134
+ label: '<span class="fa-solid fa-upload"></span><span class="silex-button--small">Publish</span>',
135
+ })
136
+ return el
137
+ }
138
+ move(rect) {
139
+ Object.keys(rect).forEach(key => this.el.style[key] = rect[key] + 'px')
140
+ }
141
+
142
+ // **
143
+ // Functions to render the dialog
144
+ private async renderDialog(job: PublicationJobData, status: PublicationStatus) {
145
+ try {
146
+ if(this.isOpen && (!status || !this.settings)) throw new Error('PublicationUi: open but no status or settings')
147
+ render(html`
148
+ ${!this.isOpen ? '' : this.settings.connector ? await this.renderOpenDialog(job, status) : await this.renderLoginDialog(status)}
149
+ `, this.el)
150
+ if (this.isOpen) {
151
+ this.el.classList.remove('silex-dialog-hide')
152
+ } else {
153
+ this.el.classList.add('silex-dialog-hide')
154
+ }
155
+ } catch (err) {
156
+ console.error('Error while rendering the dialog', err)
157
+ }
158
+ }
159
+ async renderOpenDialog(job: PublicationJobData, status: PublicationStatus): Promise<TemplateResult> {
160
+ return html`
161
+ <main>
162
+ ${this.isPending(status) ? html`
163
+ <p>Publication in progress</p>
164
+ ` : ''}
165
+ ${this.isReady(status) ? html`
166
+ <p>You are connected to ${this.settings.connector.displayName}</p><p>Click on the publish button to publish your website</p>
167
+ ${this.settings.options && Object.entries(this.settings.options).length && html`<p>Publication options: <ul>${ Object.entries(this.settings.options).map(([key, value]) => html`<li>${key}: ${value}</li>`) }</ul></p>`}
168
+ ` : ''}
169
+ ${this.isSuccess(status) ? html`
170
+ <p>Publication success</p>
171
+ ${this.settings.options?.websiteUrl ? html`<p><a href="${this.settings.options.websiteUrl}" target="_blank">Click here to view the published website</a></p>` : ''}
172
+ ` : ''}
173
+ ${this.isError(status) || this.isLoggedOut(status) ? html`
174
+ <p>Publication error</p>
175
+ <div>${unsafeHTML(this.errorMessage)}</div>
176
+ ` : ''}
177
+ ${job?.message ? html`
178
+ <p>${unsafeHTML(job.message)}</p>
179
+ ` : ''}
180
+ ${this.isPending(status) ? html`
181
+ <progress
182
+ value=""
183
+ style="width: 100%;"
184
+ ></progress>
185
+ ` : ''}
186
+ ${job?.logs?.length && job.logs[0].length ? html`
187
+ <br><details>
188
+ <summary>Logs</summary>
189
+ <pre style="
190
+ max-width: 100%;
191
+ max-height: 50vh;
192
+ overflow: auto;
193
+ font-size: x-small;
194
+ " >${unsafeHTML(cleanupLogEntry(job.logs))}
195
+ </pre>
196
+ </details>
197
+ ` : ''}
198
+ ${job?.errors?.length && job.errors[0].length ? html`
199
+ <br><details>
200
+ <summary>Errors</summary>
201
+ <pre style="
202
+ max-width: 100%;
203
+ max-height: 50vh;
204
+ overflow: auto;
205
+ font-size: x-small;
206
+ "
207
+ >${unsafeHTML(cleanupLogEntry(job.errors))}
208
+ </pre>
209
+ </details>
210
+ ` : ''}
211
+ </main>
212
+ <footer>
213
+ ${this.isPending(status) || this.isLoggedOut(status) ? '' : html`
214
+ <button
215
+ class="silex-button silex-button--primary"
216
+ id="publish-button--primary"
217
+ @click=${() => this.editor.Commands.run(cmdPublicationStart)}
218
+ >Publish</button>
219
+ `}
220
+ ${this.isLoggedOut(status) ? html`
221
+ <button
222
+ class="silex-button silex-button--primary"
223
+ id="publish-button--primary"
224
+ @click=${() => this.editor.Commands.run(cmdPublicationLogin, this.settings.connector)}
225
+ >Connect</button>
226
+ `: this.settings.connector.disableLogout ? '' : html`
227
+ <button
228
+ class="silex-button silex-button--secondary"
229
+ id="publish-button--secondary"
230
+ @click=${() => this.editor.Commands.run(cmdPublicationLogout)}
231
+ >Disconnect</button>
232
+ `}
233
+ <button
234
+ class="silex-button silex-button--secondary"
235
+ id="publish-button--secondary"
236
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
237
+ >Close</button>
238
+ </footer>
239
+ `
240
+ }
241
+ async renderLoginDialog(status: PublicationStatus): Promise<TemplateResult> {
242
+ try {
243
+ render(html`<main><p>Loading</p></main>`, this.el)
244
+ const hostingConnectors = await connectorList({ type: ConnectorType.HOSTING })
245
+ const loggedConnectors: ConnectorData[] = hostingConnectors.filter(connector => connector.isLoggedIn)
246
+ if (hostingConnectors.length === 1 && loggedConnectors.length === 1) {
247
+ this.settings.connector = loggedConnectors[0]
248
+ return this.renderOpenDialog(null, PublicationStatus.STATUS_NONE)
249
+ }
250
+ //const loggedConnector: ConnectorData = hostingConnectors.find(connector => connector.isLoggedIn)
251
+ //if (loggedConnector) {
252
+ // this.settings.connector = loggedConnector
253
+ // return this.renderOpenDialog(null, PublicationStatus.STATUS_NONE)
254
+ //}
255
+ return html`
256
+ <main>
257
+ <p>You need to connect a hosting connector to publish your website</p>
258
+ ${this.isError(status) || this.isLoggedOut(status) ? html`
259
+ <p>Login error</p>
260
+ <div>${unsafeHTML(this.errorMessage)}</div>
261
+ ` : ''}
262
+ ${hostingConnectors.map(connector => html`
263
+ <button
264
+ class="silex-button silex-button--primary"
265
+ id="publish-button--primary"
266
+ @click=${() => this.editor.Commands.run(cmdPublicationLogin, connector)}
267
+ >${connector.displayName}</button>
268
+ `)}
269
+ </main>
270
+ <footer>
271
+ <button
272
+ class="silex-button silex-button--secondary"
273
+ id="publish-button--secondary"
274
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
275
+ >Close</button>
276
+ </footer>
277
+ `
278
+ } catch (err) {
279
+ console.error(err)
280
+ return html`
281
+ <header>
282
+ <h3>Oops</h3>
283
+ </header>
284
+ <main>
285
+ <p>Unable to load hosting connectors</p>
286
+ <p>Something went wrong: ${err.message}</p>
287
+ </main>
288
+ <footer>
289
+ <button
290
+ class="silex-button silex-button--secondary"
291
+ id="publish-button--secondary"
292
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
293
+ >Close</button>
294
+ </footer>
295
+ `
296
+ }
297
+ }
298
+ displayPending(job: PublicationJobData, status: PublicationStatus) {
299
+ this.errorMessage = null
300
+ this.renderDialog(job, status)
301
+ }
302
+ displayError(message: string, job: PublicationJobData, status: PublicationStatus) {
303
+ console.info(message)
304
+ this.errorMessage = message
305
+ this.renderDialog(job, status)
306
+ }
307
+ async closeDialog() {
308
+ this.isOpen = false
309
+ this.renderDialog(null, null)
310
+ if(this.sender) this.sender.set('active', 0) // Deactivate the button to make it ready to be clicked again
311
+ this.sender = null
312
+ }
313
+ async toggleDialog() {
314
+ if (this.isOpen) this.closeDialog()
315
+ else this.openDialog()
316
+ }
317
+ async openDialog() {
318
+ this.isOpen = true
319
+
320
+ // Position
321
+ const buttonEl = this.editor.Panels.getPanel('options')?.view.el.querySelector('.publish-button')
322
+ if(buttonEl) {
323
+ const rect = buttonEl.getBoundingClientRect()
324
+
325
+ const width = 450
326
+ const padding = 10 * 2
327
+ const minHeight = 50
328
+ this.move({
329
+ left: rect.right - width - padding,
330
+ top: rect.bottom + 10,
331
+ width,
332
+ minHeight,
333
+ })
334
+ } else {
335
+ console.error('Unable to find publish button')
336
+ }
337
+
338
+ // Publication
339
+ //this.editor.Commands.run(cmdPublicationStart)
340
+ this.renderDialog(null, PublicationStatus.STATUS_NONE)
341
+ }
342
+ }
@@ -0,0 +1,37 @@
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
+ export const blocksPlugin = (editor, opts) => {
19
+ // Defaults
20
+ const options = {
21
+ ...opts,
22
+ }
23
+ // Container block
24
+ const containerId = 'container'
25
+ editor.BlockManager.add(containerId, {
26
+ label: 'Container',
27
+ category: 'Basics',
28
+ attributes: { class: 'container-png' },
29
+ content: {
30
+ type: containerId, // display as "Container"
31
+ style: {
32
+ 'min-height': '100px',
33
+ },
34
+ },
35
+ })
36
+ editor.DomComponents.addType(containerId, {})
37
+ }
@@ -0,0 +1,79 @@
1
+ import { onFooter } from './footer'
2
+
3
+ export default function (editor, options) {
4
+ let breadcrumbsContainer
5
+ onFooter(footer => {
6
+ // Initialize the breadcrumbs container
7
+ breadcrumbsContainer = document.createElement('div')
8
+ breadcrumbsContainer.id = 'breadcrumbs-container'
9
+ footer.prepend(breadcrumbsContainer)
10
+ // Add breadcrumbs styles
11
+ const breadcrumbsStyles = document.createElement('style')
12
+ breadcrumbsStyles.innerHTML = `
13
+ #breadcrumbs-container {
14
+ display: flex;
15
+ align-items: center;
16
+ height: 100%;
17
+ padding: 0 10px;
18
+ font-size: 12px;
19
+ color: #999;
20
+ overflow-x: auto;
21
+ overflow-y: hidden;
22
+ }
23
+ #breadcrumbs-container h3 {
24
+ font-size: inherit;
25
+ margin: 0;
26
+ }
27
+ #breadcrumbs-container .breadcrumb {
28
+ margin: 0 5px;
29
+ font-size: 14px;
30
+ line-height: 1;
31
+ cursor: pointer;
32
+ white-space: nowrap;
33
+ }
34
+ #breadcrumbs-container .breadcrumb::after {
35
+ content: "➔";
36
+ margin-left: 10px;
37
+ }
38
+
39
+ #breadcrumbs-container .breadcrumb:last-child::after {
40
+ content: "";
41
+ }
42
+ `
43
+ footer.prepend(breadcrumbsStyles)
44
+ renderBreadcrumbs()
45
+ })
46
+ // Append the breadcrumbs container to the editor's container
47
+
48
+ editor.on('component:selected style:target component:drag:end', () => renderBreadcrumbs())
49
+ function renderBreadcrumbs() {
50
+ let component = editor.getSelected() ?? editor.Pages.getSelected().getMainComponent()
51
+
52
+ if(!breadcrumbsContainer) return
53
+
54
+ // Clear the breadcrumbs container
55
+ breadcrumbsContainer.innerHTML = ''
56
+
57
+ // Traverse up the tree of components, prepending each to the breadcrumbs
58
+ while (component) {
59
+ const breadcrumb = createBreadcrumb(component)
60
+ breadcrumbsContainer.prepend(breadcrumb)
61
+ component = component.parent()
62
+ }
63
+
64
+ // Label
65
+ const label = document.createElement('span')
66
+ label.innerHTML = '<h3>Selection:&nbsp;</h3>'
67
+ breadcrumbsContainer.prepend(label)
68
+ }
69
+ function createBreadcrumb(component) {
70
+ const breadcrumb = document.createElement('span')
71
+ const model = component.model
72
+ breadcrumb.onclick = () => {
73
+ editor.select(component)
74
+ }
75
+ breadcrumb.classList.add('breadcrumb')
76
+ breadcrumb.innerHTML = `<span>${component.getName() ?? component.get('tagName')}</span>`
77
+ return breadcrumb
78
+ }
79
+ }
@@ -0,0 +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
+ /**
19
+ * @deprecated
20
+ * Replaced by the plugin 11ty.ts
21
+ * This plugin is deprecated. Use the publication renderer plugin instead.
22
+ */
23
+ console.warn('This plugin is deprecated. Use the publication renderer plugin instead.')
24
+ throw 'This plugin is deprecated. Use the publication renderer plugin instead.'
25
+
26
+ import grapesjs from 'grapesjs/dist/grapes.min.js'
27
+
28
+ import { getPageSlug } from '../../page'
29
+ import { ClientEvent } from '../events'
30
+ import { Page } from 'grapesjs'
31
+
32
+ const pluginName = 'eleventy'
33
+
34
+ export const eleventyPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
35
+ editor.on(opts.eventStart || ClientEvent.PUBLISH_DATA, data => {
36
+ data.pages.forEach((page: Page, idx) => {
37
+ const file = data.files[idx]
38
+ file.css = `---
39
+ permalink: /css/${getPageSlug(page.get('name'))}.css
40
+ ---
41
+ ${file.css}
42
+ `
43
+ file.cssPath += '.liquid'
44
+ })
45
+ })
46
+ })
47
+
@@ -0,0 +1,27 @@
1
+ // Styles are in: src/scss/footer.scss
2
+ let _onFooter = []
3
+ let footer
4
+ export default function (editor, options) {
5
+ const panel = editor.Panels.addPanel({
6
+ id: 'footer',
7
+ visible: true,
8
+ buttons: [{
9
+ id: 'myNewButton',
10
+ className: 'someClass',
11
+ command: 'someCommand',
12
+ attributes: { title: 'Some title' },
13
+ active: false,
14
+
15
+ }],
16
+ })
17
+ setTimeout(() => {
18
+ footer = panel.view?.el
19
+ _onFooter.forEach(cbk => cbk(footer))
20
+ _onFooter = []
21
+ })
22
+ }
23
+
24
+ export function onFooter(fn) {
25
+ if(footer) fn(footer)
26
+ else _onFooter.push(fn)
27
+ }