@silexlabs/silex 3.0.1-alpha.0 → 3.0.2

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 (323) hide show
  1. package/.env.default +20 -0
  2. package/.silex.js +67 -8
  3. package/LICENSE +661 -203
  4. package/README.md +37 -35
  5. package/dist/client/client/api.d.ts +90 -0
  6. package/dist/client/client/assetUrl.d.ts +54 -0
  7. package/dist/client/client/config.d.ts +102 -0
  8. package/dist/client/client/events.d.ts +23 -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 +73 -0
  12. package/dist/client/client/grapesjs/PublicationUi.d.ts +59 -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/css-props.d.ts +6 -0
  16. package/dist/client/client/grapesjs/footer.d.ts +2 -0
  17. package/dist/client/client/grapesjs/img.d.ts +6 -0
  18. package/dist/client/client/grapesjs/index.d.ts +9 -0
  19. package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
  20. package/dist/client/client/grapesjs/keymaps.d.ts +123 -0
  21. package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  22. package/dist/client/client/grapesjs/openImport.d.ts +9 -0
  23. package/dist/client/client/grapesjs/page-panel.d.ts +9 -0
  24. package/dist/client/client/grapesjs/project-bar.d.ts +21 -0
  25. package/dist/client/client/grapesjs/resize-panel.d.ts +1 -0
  26. package/dist/client/client/grapesjs/rich-text.d.ts +4 -0
  27. package/dist/client/client/grapesjs/semantic.d.ts +1 -0
  28. package/dist/client/client/grapesjs/settings-sections.d.ts +16 -0
  29. package/dist/client/client/grapesjs/settings.d.ts +4 -0
  30. package/dist/client/client/grapesjs/storage.d.ts +2 -0
  31. package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  32. package/dist/client/client/grapesjs/view-buttons.d.ts +1 -0
  33. package/dist/client/client/index.d.ts +10 -0
  34. package/dist/client/client/publication-transformers.d.ts +42 -0
  35. package/dist/client/client/publish-custom-code-block.d.ts +4 -0
  36. package/dist/client/client/publish-fonts.d.ts +4 -0
  37. package/dist/client/client/utils.d.ts +22 -0
  38. package/dist/client/constants.d.ts +32 -0
  39. package/dist/client/css/admin.css +1114 -328
  40. package/dist/client/css/admin.css.map +1 -0
  41. package/dist/client/grapesjs-filter-styles/dist/index.d.ts +4 -0
  42. package/dist/client/grapesjs-fonts/dist/index.d.ts +4 -0
  43. package/dist/client/grapesjs-fonts/src/commands.d.ts +3 -0
  44. package/dist/client/grapesjs-fonts/src/fonts.d.ts +4 -0
  45. package/dist/client/grapesjs-storage-rate-limit/dist/index.d.ts +4 -0
  46. package/dist/client/grapesjs-ui-suggest-classes/dist/index.d.ts +4 -0
  47. package/dist/client/index.html +3 -2
  48. package/dist/client/js/main.js +356 -131
  49. package/dist/client/js/main.js.LICENSE.txt +15 -1
  50. package/dist/client/page.d.ts +2 -0
  51. package/dist/client/silex-lib/src/ts/client/api.d.ts +90 -0
  52. package/dist/client/silex-lib/src/ts/client/assetUrl.d.ts +54 -0
  53. package/dist/client/silex-lib/src/ts/client/config.d.ts +102 -0
  54. package/dist/client/silex-lib/src/ts/client/events.d.ts +23 -0
  55. package/dist/client/silex-lib/src/ts/client/expose.d.ts +8 -0
  56. package/dist/client/silex-lib/src/ts/client/grapesjs/LoginDialog.d.ts +15 -0
  57. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationManager.d.ts +73 -0
  58. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationUi.d.ts +59 -0
  59. package/dist/client/silex-lib/src/ts/client/grapesjs/blocks.d.ts +1 -0
  60. package/dist/client/silex-lib/src/ts/client/grapesjs/breadcrumbs.d.ts +1 -0
  61. package/dist/client/silex-lib/src/ts/client/grapesjs/css-props.d.ts +6 -0
  62. package/dist/client/silex-lib/src/ts/client/grapesjs/footer.d.ts +2 -0
  63. package/dist/client/silex-lib/src/ts/client/grapesjs/img.d.ts +6 -0
  64. package/dist/client/silex-lib/src/ts/client/grapesjs/index.d.ts +9 -0
  65. package/dist/client/silex-lib/src/ts/client/grapesjs/internal-links.d.ts +1 -0
  66. package/dist/client/silex-lib/src/ts/client/grapesjs/keymaps.d.ts +123 -0
  67. package/dist/client/silex-lib/src/ts/client/grapesjs/new-page-dialog.d.ts +2 -0
  68. package/dist/client/silex-lib/src/ts/client/grapesjs/openImport.d.ts +9 -0
  69. package/dist/client/silex-lib/src/ts/client/grapesjs/page-panel.d.ts +9 -0
  70. package/dist/client/silex-lib/src/ts/client/grapesjs/project-bar.d.ts +21 -0
  71. package/dist/client/silex-lib/src/ts/client/grapesjs/resize-panel.d.ts +1 -0
  72. package/dist/client/silex-lib/src/ts/client/grapesjs/rich-text.d.ts +4 -0
  73. package/dist/client/silex-lib/src/ts/client/grapesjs/semantic.d.ts +1 -0
  74. package/dist/client/silex-lib/src/ts/client/grapesjs/settings-sections.d.ts +16 -0
  75. package/dist/client/silex-lib/src/ts/client/grapesjs/settings.d.ts +4 -0
  76. package/dist/client/silex-lib/src/ts/client/grapesjs/storage.d.ts +2 -0
  77. package/dist/client/silex-lib/src/ts/client/grapesjs/symbolDialogs.d.ts +3 -0
  78. package/dist/client/silex-lib/src/ts/client/grapesjs/view-buttons.d.ts +1 -0
  79. package/dist/client/silex-lib/src/ts/client/index.d.ts +10 -0
  80. package/dist/client/silex-lib/src/ts/client/publication-transformers.d.ts +42 -0
  81. package/dist/client/silex-lib/src/ts/client/publish-custom-code-block.d.ts +4 -0
  82. package/dist/client/silex-lib/src/ts/client/publish-fonts.d.ts +4 -0
  83. package/dist/client/silex-lib/src/ts/client/utils.d.ts +22 -0
  84. package/dist/client/silex-lib/src/ts/constants.d.ts +32 -0
  85. package/dist/client/silex-lib/src/ts/page.d.ts +2 -0
  86. package/dist/client/silex-lib/src/ts/types.d.ts +339 -0
  87. package/dist/client/types.d.ts +339 -0
  88. package/dist/plugins/client/client/events.d.ts +23 -0
  89. package/dist/plugins/client/client/events.js +43 -0
  90. package/dist/plugins/client/client/events.js.map +1 -0
  91. package/dist/plugins/client/plugins/client/template.d.ts +2 -0
  92. package/dist/plugins/client/plugins/client/template.js +234 -0
  93. package/dist/plugins/client/plugins/client/template.js.map +1 -0
  94. package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
  95. package/dist/plugins/client/plugins/client/website-info.js +72 -0
  96. package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
  97. package/dist/plugins/client/types.d.ts +339 -0
  98. package/dist/plugins/client/types.js +80 -0
  99. package/dist/plugins/client/types.js.map +1 -0
  100. package/dist/plugins/server/constants.d.ts +32 -0
  101. package/dist/plugins/server/constants.js +76 -0
  102. package/dist/plugins/server/constants.js.map +1 -0
  103. package/dist/plugins/server/plugins/server/Cache.d.ts +2 -0
  104. package/dist/plugins/server/plugins/server/Cache.js +36 -0
  105. package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
  106. package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
  107. package/dist/plugins/server/plugins/server/DownloadConnector.js +127 -0
  108. package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
  109. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +86 -0
  110. package/dist/plugins/server/plugins/server/FtpConnector.js +536 -0
  111. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
  112. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +135 -0
  113. package/dist/plugins/server/plugins/server/GitlabConnector.js +649 -0
  114. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -0
  115. package/dist/plugins/server/plugins/server/GitlabHostingConnector.d.ts +16 -0
  116. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js +209 -0
  117. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js.map +1 -0
  118. package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
  119. package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
  120. package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
  121. package/dist/plugins/server/plugins/server/SslPlugin.d.ts +1 -0
  122. package/dist/plugins/server/plugins/server/SslPlugin.js +86 -0
  123. package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
  124. package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +8 -0
  125. package/dist/plugins/server/plugins/server/StaticPlugin.js +45 -0
  126. package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
  127. package/dist/plugins/server/server/config.d.ts +59 -0
  128. package/dist/plugins/server/server/config.js +181 -0
  129. package/dist/plugins/server/server/config.js.map +1 -0
  130. package/dist/plugins/server/server/connectors/FsHosting.d.ts +14 -0
  131. package/dist/plugins/server/server/connectors/FsHosting.js +66 -0
  132. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
  133. package/dist/plugins/server/server/connectors/FsStorage.d.ts +44 -0
  134. package/dist/plugins/server/server/connectors/FsStorage.js +261 -0
  135. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
  136. package/dist/plugins/server/server/connectors/connectors.d.ts +86 -0
  137. package/dist/plugins/server/server/connectors/connectors.js +126 -0
  138. package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
  139. package/dist/plugins/server/server/events.d.ts +26 -0
  140. package/dist/plugins/server/server/events.js +31 -0
  141. package/dist/plugins/server/server/events.js.map +1 -0
  142. package/dist/plugins/server/server/jobs.d.ts +12 -0
  143. package/dist/plugins/server/server/jobs.js +79 -0
  144. package/dist/plugins/server/server/jobs.js.map +1 -0
  145. package/dist/plugins/server/server/utils/validation.d.ts +7 -0
  146. package/dist/plugins/server/server/utils/validation.js +37 -0
  147. package/dist/plugins/server/server/utils/validation.js.map +1 -0
  148. package/dist/plugins/server/types.d.ts +339 -0
  149. package/dist/plugins/server/types.js +84 -0
  150. package/dist/plugins/server/types.js.map +1 -0
  151. package/dist/server/constants.js +55 -0
  152. package/dist/server/plugins/server/Cache.js +19 -0
  153. package/dist/server/server/api/api.js +20 -0
  154. package/dist/server/server/api/connectorApi.js +334 -0
  155. package/dist/server/server/api/publicationApi.js +106 -0
  156. package/dist/server/server/api/websiteApi.js +315 -0
  157. package/dist/server/server/cli.js +71 -0
  158. package/dist/server/server/config.js +120 -0
  159. package/dist/server/server/connectors/FsHosting.js +47 -0
  160. package/dist/server/server/connectors/FsStorage.js +228 -0
  161. package/dist/server/server/connectors/connectors.js +88 -0
  162. package/dist/server/server/events.js +14 -0
  163. package/dist/server/server/expose.js +27 -0
  164. package/dist/server/server/express.js +46 -0
  165. package/dist/server/server/index.js +92 -0
  166. package/dist/server/server/jobs.js +50 -0
  167. package/dist/server/server/utils/validation.js +14 -0
  168. package/dist/server/types.js +40 -0
  169. package/package.json +99 -49
  170. package/public/assets/download.png +0 -0
  171. package/public/assets/favicon.ico +0 -0
  172. package/public/assets/favicon.png +0 -0
  173. package/public/assets/ftp.png +0 -0
  174. package/public/assets/gitlab.png +0 -0
  175. package/public/assets/gitlab2.png +0 -0
  176. package/public/assets/laptop.png +0 -0
  177. package/public/assets/logo-silex-small.png +0 -0
  178. package/public/silex.js +22 -23
  179. package/src/css/_variables.scss +24 -20
  180. package/src/css/dialog.scss +35 -2
  181. package/src/css/fonts.scss +31 -0
  182. package/src/css/footer.scss +12 -0
  183. package/src/css/grapesjs-light.scss +180 -0
  184. package/src/css/grapesjs-plugins.scss +227 -0
  185. package/src/css/grapesjs.scss +159 -1
  186. package/src/css/index.scss +12 -1
  187. package/src/css/light.scss +7 -0
  188. package/src/css/loader.scss +2 -0
  189. package/src/css/project-bar.scss +32 -16
  190. package/src/css/silex.scss +79 -5
  191. package/src/css/website-info.scss +14 -0
  192. package/src/html/index.pug +3 -3
  193. package/src/html/templates/includes.pug +0 -1
  194. package/src/ts/client/api.ts +156 -0
  195. package/src/ts/client/assetUrl.test.ts +164 -0
  196. package/src/ts/client/assetUrl.ts +254 -0
  197. package/src/ts/client/config.ts +175 -13
  198. package/src/ts/client/events.ts +43 -0
  199. package/src/ts/client/expose.ts +27 -1
  200. package/src/ts/client/grapesjs/LoginDialog.ts +204 -0
  201. package/src/ts/client/grapesjs/PublicationManager.ts +433 -0
  202. package/src/ts/client/grapesjs/PublicationUi.ts +366 -0
  203. package/src/ts/client/grapesjs/blocks.ts +17 -0
  204. package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
  205. package/src/ts/client/grapesjs/css-props.ts +910 -0
  206. package/src/ts/client/grapesjs/eleventy.ts +30 -7
  207. package/src/ts/client/grapesjs/footer.ts +42 -0
  208. package/src/ts/client/grapesjs/img.ts +147 -0
  209. package/src/ts/client/grapesjs/index.ts +311 -122
  210. package/src/ts/client/grapesjs/internal-links.test.ts +19 -1
  211. package/src/ts/client/grapesjs/internal-links.ts +31 -7
  212. package/src/ts/client/grapesjs/keymaps.ts +207 -0
  213. package/src/ts/client/grapesjs/new-page-dialog.ts +19 -3
  214. package/src/ts/client/grapesjs/openImport.ts +22 -0
  215. package/src/ts/client/grapesjs/page-panel.ts +109 -7
  216. package/src/ts/client/grapesjs/project-bar.ts +133 -72
  217. package/src/ts/client/grapesjs/resize-panel.ts +20 -0
  218. package/src/ts/client/grapesjs/rich-text.ts +38 -13
  219. package/src/ts/client/grapesjs/semantic.ts +20 -3
  220. package/src/ts/client/grapesjs/settings-sections.ts +117 -0
  221. package/src/ts/client/grapesjs/settings.ts +191 -96
  222. package/src/ts/client/grapesjs/storage.ts +187 -0
  223. package/src/ts/client/grapesjs/symbolDialogs.ts +21 -5
  224. package/src/ts/client/grapesjs/view-buttons.ts +42 -0
  225. package/src/ts/client/index.ts +80 -21
  226. package/src/ts/client/publication-transformers.test.ts +207 -0
  227. package/src/ts/client/publication-transformers.ts +280 -0
  228. package/src/ts/client/publish-custom-code-block.ts +31 -0
  229. package/src/ts/client/publish-fonts.ts +36 -0
  230. package/src/ts/client/utils.ts +70 -1
  231. package/src/ts/constants.ts +78 -0
  232. package/src/ts/externs.ts +17 -0
  233. package/src/ts/page.ts +20 -3
  234. package/src/ts/plugins/client/template.ts +246 -0
  235. package/src/ts/plugins/client/website-info.ts +84 -0
  236. package/src/ts/plugins/server/Cache.ts +32 -0
  237. package/src/ts/plugins/server/DownloadConnector.ts +146 -0
  238. package/src/ts/plugins/server/FtpConnector.test.ts +82 -0
  239. package/src/ts/plugins/server/FtpConnector.ts +621 -0
  240. package/src/ts/plugins/server/GitlabConnector.ts +749 -0
  241. package/src/ts/plugins/server/GitlabHostingConnector.ts +215 -0
  242. package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
  243. package/src/ts/plugins/server/SslPlugin.ts +84 -0
  244. package/src/ts/plugins/server/StaticPlugin.ts +45 -0
  245. package/src/ts/server/api/api.ts +19 -0
  246. package/src/ts/server/api/connectorApi.ts +464 -0
  247. package/src/ts/server/api/publicationApi.ts +159 -0
  248. package/src/ts/server/api/websiteApi.ts +462 -0
  249. package/src/ts/server/cli.ts +48 -14
  250. package/src/ts/server/config.ts +158 -60
  251. package/src/ts/server/connectors/FsHosting.ts +66 -0
  252. package/src/ts/server/connectors/FsStorage.test.ts +51 -0
  253. package/src/ts/server/connectors/FsStorage.ts +290 -0
  254. package/src/ts/server/connectors/connectors.ts +203 -0
  255. package/src/ts/server/events.ts +37 -0
  256. package/src/ts/server/expose.ts +19 -0
  257. package/src/ts/server/express.ts +57 -5
  258. package/src/ts/server/index.ts +80 -19
  259. package/src/ts/server/jobs.test.ts +75 -0
  260. package/src/ts/server/jobs.ts +89 -0
  261. package/src/ts/server/utils/BackwardCompat.ts +546 -528
  262. package/src/ts/server/utils/validation.ts +34 -0
  263. package/src/ts/types.ts +295 -85
  264. package/.dockerignore +0 -5
  265. package/.editorconfig +0 -14
  266. package/.eslintrc.json +0 -43
  267. package/.github/FUNDING.yml +0 -13
  268. package/.github/workflows/docker-hub-publish.yml +0 -36
  269. package/.github/workflows/npm-publish.yml +0 -19
  270. package/.github/workflows/test.yml +0 -26
  271. package/.nvmrc +0 -1
  272. package/.silex/default/.silex.data.json +0 -1
  273. package/CODE_OF_CONDUCT.md +0 -128
  274. package/CONTRIBUTING.md +0 -131
  275. package/Dockerfile +0 -15
  276. package/directus.silex.js +0 -7
  277. package/dist/constants.js +0 -4
  278. package/dist/events.js +0 -5
  279. package/dist/page.js +0 -15
  280. package/dist/server/cli.js +0 -43
  281. package/dist/server/config.js +0 -70
  282. package/dist/server/express.js +0 -18
  283. package/dist/server/index.js +0 -58
  284. package/dist/types.js +0 -34
  285. package/jest.config.js +0 -10
  286. package/logos/logo_by_ceubri/silex-icon-2018@200px.png +0 -0
  287. package/logos/logo_by_ceubri/silex-icon-2018@4x.png +0 -0
  288. package/logos/logo_by_ceubri/silex-logo-2018-white-transp.pdf +0 -0
  289. package/logos/logo_by_ceubri/silex-logo-2018-white.jpg +0 -0
  290. package/logos/logo_by_ceubri/silex-logo-2018-white.pdf +0 -0
  291. package/logos/logo_by_ceubri/silex-logo-2018-white.png +0 -0
  292. package/logos/logo_by_ceubri/silex-logo-2018-white@0.5x.png +0 -0
  293. package/logos/logo_by_ceubri/silex-logo-2018-white@0.75x.png +0 -0
  294. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.jpg +0 -0
  295. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.png +0 -0
  296. package/logos/logo_by_ceubri/silex-logo-2018.ai +5 -2521
  297. package/logos/logo_by_ceubri/silex-logo-2018.jpg +0 -0
  298. package/logos/logo_by_ceubri/silex-logo-2018.pdf +0 -0
  299. package/logos/logo_by_ceubri/silex-logo-2018.png +0 -0
  300. package/logos/logo_by_ceubri/silex-logo-2018@0.5x.png +0 -0
  301. package/logos/logo_by_ceubri/silex-logo-2018@0.75x.png +0 -0
  302. package/logos/logo_by_ceubri/silex-logo-2018@4x.jpg +0 -0
  303. package/logos/logo_by_ceubri/silex-logo-2018@4x.png +0 -0
  304. package/logos/silexlabs.png +0 -0
  305. package/src/example-client-config.js +0 -47
  306. package/src/plugins/AuthPlugin.js +0 -21
  307. package/src/plugins/Cache.js +0 -11
  308. package/src/plugins/DefaultBackend.js +0 -149
  309. package/src/plugins/ExpressPlugin.js +0 -39
  310. package/src/plugins/HooksPlugin.js +0 -58
  311. package/src/plugins/PublishPlugin.js +0 -69
  312. package/src/plugins/SslPlugin.js +0 -66
  313. package/src/plugins/StaticPlugin.js +0 -48
  314. package/src/plugins/WebsitePlugin.js +0 -207
  315. package/src/ts/client/grapesjs/publish.ts +0 -386
  316. package/src/ts/client/grapesjs/template.ts +0 -166
  317. package/src/ts/events.ts +0 -2
  318. package/tsconfig-server-debug.json +0 -19
  319. package/tsconfig-server-release.json +0 -19
  320. package/tsconfig.jest.json +0 -9
  321. package/tsconfig.json +0 -26
  322. package/webpack.config.js +0 -28
  323. package/webpack.debug.config.js +0 -8
@@ -1,9 +1,78 @@
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, Editor } from 'grapesjs'
1
19
 
2
20
  // Browse all elements of all pages
3
- export function onAll(editor, cbk) {
21
+ export function onAll(editor: Editor, cbk: (c: Component) => void) {
4
22
  editor.Pages.getAll()
5
23
  .forEach(page => {
6
24
  page.getMainComponent()
7
25
  .onAll(c => cbk(c))
8
26
  })
9
27
  }
28
+
29
+ /**
30
+ * SHA256 hash a string
31
+ */
32
+ export async function hashString(str: string): Promise<string> {
33
+ if (crypto.subtle != undefined) {
34
+ // Convert the string to an ArrayBuffer
35
+ const encoder = new TextEncoder()
36
+ const data = encoder.encode(str)
37
+
38
+ // Hash the data with SHA-256
39
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data)
40
+
41
+ // Convert the ArrayBuffer to hex string
42
+ const hashArray = Array.from(new Uint8Array(hashBuffer))
43
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
44
+
45
+ return hashHex
46
+ }
47
+ else {return 'local'}
48
+ }
49
+
50
+ /**
51
+ * Select the <body> element in the editor.
52
+ * @param editor The GrapesJS editor.
53
+ */
54
+ export function selectBody(editor: Editor): void {
55
+ editor.select(editor.DomComponents.getWrapper())
56
+ }
57
+
58
+ /**
59
+ * Checks if an element is a text or input field.
60
+ * @param element The element to check.
61
+ */
62
+ export function isTextOrInputField(element: HTMLElement): boolean {
63
+ if(element.getAttribute('type') === 'submit') return false
64
+ const isInput: boolean = element.tagName === 'INPUT'
65
+ const isOtherFormElement: boolean = ['TEXTAREA', 'OPTION', 'OPTGROUP', 'SELECT', 'BUTTON'].includes(element.tagName)
66
+
67
+ return isInput || isOtherFormElement
68
+ }
69
+
70
+ /**
71
+ * Makes every word in a string start with an uppercase letter.
72
+ * @param str The string to title-case.
73
+ * @param sep The separator between words.
74
+ */
75
+ export function titleCase(str: string, sep: string = ' '): string {
76
+ const split = str.split(sep)
77
+ return split.map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(sep)
78
+ }
@@ -1,5 +1,83 @@
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
+
1
18
  /**
2
19
  * @fileoverview define constants for Silex client and server
3
20
  */
4
21
 
22
+ export const WEBSITE_DATA_FILE = 'website.json'
23
+ export const WEBSITE_META_DATA_FILE = 'meta.json'
24
+
25
+ export const DEFAULT_WEBSITE_ID = 'default'
26
+ export const DEFAULT_LANGUAGE = 'en'
5
27
  export const CLIENT_CONFIG_FILE_NAME = 'silex.js'
28
+
29
+ export const API_PATH = '/api'
30
+
31
+ export const API_CONNECTOR_PATH = '/connector'
32
+ export const API_CONNECTOR_USER = '/user'
33
+ export const API_CONNECTOR_LIST = '/'
34
+ export const API_CONNECTOR_LOGOUT = '/logout'
35
+ export const API_CONNECTOR_LOGIN = '/login'
36
+ export const API_CONNECTOR_SETTINGS = '/settings'
37
+ export const API_CONNECTOR_LOGIN_CALLBACK = '/login/callback'
38
+
39
+ export const API_PUBLICATION_PATH = '/publication'
40
+ export const API_PUBLICATION_PUBLISH = '/'
41
+ export const API_PUBLICATION_STATUS = '/publication/status'
42
+
43
+ export const API_WEBSITE_PATH = '/website'
44
+ export const API_WEBSITE_READ = '/'
45
+ export const API_WEBSITE_WRITE = '/'
46
+ export const API_WEBSITE_CREATE = '/'
47
+ export const API_WEBSITE_DELETE = '/'
48
+ export const API_WEBSITE_DUPLICATE = '/duplicate'
49
+ export const API_WEBSITE_LIST = '/'
50
+ export const API_WEBSITE_ASSET_READ = '/assets'
51
+ export const API_WEBSITE_ASSETS_WRITE = '/assets'
52
+ export const API_WEBSITE_META_READ = '/meta'
53
+ export const API_WEBSITE_META_WRITE = '/meta'
54
+
55
+ // Env vars (build time)
56
+ // Get env vars from webpack
57
+ // @see webpack.config.js
58
+ declare const SILEX_VERSION_ENV: string
59
+ export let SILEX_VERSION
60
+ try { SILEX_VERSION = SILEX_VERSION_ENV } catch (e) {
61
+ // fallback to default value
62
+ SILEX_VERSION = SILEX_VERSION || '3.0.0'
63
+ }
64
+
65
+ export const DEV_MESSAGE = `
66
+ __________________________________________________________
67
+
68
+ Create static websites visually, with dynamic content,
69
+ in the free spirit of the web.
70
+
71
+ ███████ ██ ██ ███████ ██ ██ ██ ██ ██████
72
+ ██ ██ ██ ██ ██ ██ ██ ██ ██
73
+ ███████ ██ ██ █████ ███ ██ ██ █████
74
+ ██ ██ ██ ██ ██ ██ ██ ██ ██
75
+ ███████ ██ ███████ ███████ ██ ██ ████ ██████ ${SILEX_VERSION.slice(1)}
76
+
77
+ Users are expected to contribute:
78
+
79
+ * Web designers: https://docs.silex.me/en/user/contribute
80
+ * Developers: https://docs.silex.me/en/dev/contribute
81
+
82
+ __________________________________________________________
83
+ `
package/src/ts/externs.ts CHANGED
@@ -1 +1,18 @@
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
+
1
18
 
package/src/ts/page.ts CHANGED
@@ -1,7 +1,24 @@
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
+
1
18
  // Page related functions
2
19
  // This is used on the client and the server
3
- export function getPageSlug(pageName = 'index') {
4
- return pageName
20
+ export function getPageSlug(pageName) {
21
+ return (pageName || 'index')
5
22
  .toLowerCase()
6
23
  .replace(/[^a-z0-9 -]/g, '')
7
24
  // Collapse whitespace and replace by -
@@ -9,6 +26,6 @@ export function getPageSlug(pageName = 'index') {
9
26
  // Collapse dashes
10
27
  .replace(/-+/g, '-')
11
28
  }
12
- export function getPageLink(pageName = 'index') {
29
+ export function getPageLink(pageName) {
13
30
  return `./${getPageSlug(pageName)}.html`
14
31
  }
@@ -0,0 +1,246 @@
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
+ throw new Error('This file is obsolete, templates have been replaced by Silex CMS plugin: https://github.com/silexlabs/silex-cms/')
19
+
20
+ // Silex serves /clients
21
+ // @ts-ignore
22
+ import { onAll } from '../client/utils.js'
23
+ // @ts-ignore
24
+ import { ClientEvent } from '../client/events.js'
25
+
26
+ // You need to serve lit-html at /js/lit-html/
27
+ // @ts-ignore
28
+ import {html, render} from '../js/lit-html/lit-html.js'
29
+ // @ts-ignore
30
+ import {styleMap} from '../js/lit-html/directives/style-map.js'
31
+
32
+ const silex = window['silex']
33
+
34
+ const pluginName = 'template'
35
+ const templateType = 'templateType'
36
+ const templateKey = 'template'
37
+
38
+ function createCodeEditor(editor, mode = 'htmlmixed', singleLine = false) {
39
+ const options = {
40
+ readOnly: false,
41
+ codeName: mode,
42
+ } as any
43
+ if(singleLine) {
44
+ options.lineWrapping = false
45
+ options.lineNumbers = false
46
+ options.indentWithTabs = false
47
+ } else {
48
+ options.lineNumbers = true
49
+ options.lineWrapping = true
50
+ }
51
+
52
+ return editor.CodeManager.createViewer(options)
53
+ }
54
+
55
+ export default async (config, opts: any = {}) => {
56
+ config.on(ClientEvent.GRAPESJS_END, () => {
57
+ const editor = silex.getEditor()
58
+ // Get the necessary code editors
59
+ const editors = {
60
+ before: createCodeEditor(editor),
61
+ replace: createCodeEditor(editor),
62
+ after: createCodeEditor(editor),
63
+ attributes: createCodeEditor(editor, 'text', true),
64
+ classname: createCodeEditor(editor, 'text', true),
65
+ style: createCodeEditor(editor, 'css', true),
66
+ }
67
+ const is1line = {
68
+ before: false,
69
+ replace: false,
70
+ after: false,
71
+ attributes: true,
72
+ classname: true,
73
+ style: true,
74
+ }
75
+ // Add the new trait to all component types
76
+ editor.DomComponents.getTypes().map(type => {
77
+ const originalType = editor.DomComponents.getType(type.id)
78
+ editor.DomComponents.addType(type.id, {
79
+ model: {
80
+ defaults: {
81
+ traits: [
82
+ // Keep the type original traits
83
+ ...originalType.model.prototype.defaults.traits,
84
+ // Add the new trait
85
+ {
86
+ label: false,
87
+ type: templateType,
88
+ name: pluginName,
89
+ },
90
+ ]
91
+ }
92
+ }
93
+ })
94
+ })
95
+
96
+ function doRender(el) {
97
+ const template = editor.getSelected()?.get(templateKey) || {}
98
+ const taStyle = opts.styles?.textarea ?? styleMap({
99
+ xxbackgroundColor: 'var(--darkerPrimaryColor)',
100
+ })
101
+ const sepStyle = opts.styles?.sep ?? styleMap({ height: '10px' })
102
+ const labels = {
103
+ before: html`<strong>Before</strong> the element`,
104
+ replace: html`<strong>Replace</strong> the element's children`,
105
+ after: html`<strong>After</strong> the element`,
106
+ attributes: html`HTML attributes`,
107
+ classname: html`CSS classes`,
108
+ style: html`CSS styles`,
109
+ }
110
+ render(html`
111
+ <style>
112
+ .CodeMirror {
113
+ height: 100%;
114
+ }
115
+ </style>
116
+ <div>
117
+ <h3>Template</h3>
118
+ <p>This will be inserted in the published version</p>
119
+ </div>
120
+ ${[
121
+ 'classname',
122
+ 'attributes',
123
+ 'style',
124
+ 'before',
125
+ 'replace',
126
+ 'after',
127
+ ].map(id => html`
128
+ <label data-contain="${id}" class="template-wrapper-${id}">
129
+ ${labels[id]}
130
+ </label>
131
+ `)}
132
+ `, el)
133
+ el.querySelectorAll('[data-contain]').forEach(container => {
134
+ const id = container.getAttribute('data-contain')
135
+ const codeEditor = editors[id]
136
+ container.appendChild(codeEditor.getElement())
137
+ codeEditor.getElement().style.display = 'block'
138
+ codeEditor.getElement().style.height = is1line[id] ? '' : '200px'
139
+ codeEditor.getElement().style.width = '100%'
140
+ codeEditor.setContent(template[id] ?? '')
141
+ codeEditor.refresh()
142
+ })
143
+ // Make sure we apply the changes when the user presses any key
144
+ // The events should be triggered by the trait manager (call onEvent) but it doesn't work for "delete" key for example
145
+ el.onkeyup = () => {
146
+ applyChanges(editor.getSelected())
147
+ }
148
+ }
149
+
150
+ function applyChanges(component) {
151
+ const template = {
152
+ before: editors.before.getContent(),
153
+ replace: editors.replace.getContent(),
154
+ after: editors.after.getContent(),
155
+ attributes: editors.attributes.getContent(),
156
+ classname: editors.classname.getContent(),
157
+ style: editors.style.getContent(),
158
+ }
159
+
160
+ // Store the new template
161
+ if (Object.values(template).filter(val => !!val && !!cleanup(val)).length > 0) {
162
+ component.set(templateKey, template)
163
+ } else {
164
+ component.set(templateKey)
165
+ }
166
+ }
167
+
168
+ editor.TraitManager.addType(templateType, {
169
+ createInput({ trait }) {
170
+ // Create a new element container and add some content
171
+ const el = document.createElement('div')
172
+ el.classList.add('gjs-one-bg')
173
+ // update the UI when a page is added/renamed/removed
174
+ editor.on('page', () => doRender(el))
175
+ doRender(el)
176
+ // this will be the element passed to onEvent and onUpdate
177
+ return el
178
+ },
179
+ // Update the component based on UI changes
180
+ // `elInput` is the result HTMLElement you get from `createInput`
181
+ onEvent({ elInput, component, event }) {
182
+ applyChanges(component)
183
+ },
184
+ // Update UI on the component change
185
+ onUpdate({ elInput, component }) {
186
+ doRender(elInput)
187
+ },
188
+ })
189
+
190
+ // Make html attribute
191
+ // Quote strings, no values for boolean
192
+ function makeAttribute(key, value) {
193
+ switch (typeof value) {
194
+ case 'boolean': return value ? key : ''
195
+ default: return `${key}="${value}"`
196
+ }
197
+ }
198
+ // Remove empty lines in templates
199
+ function cleanup(template) {
200
+ return template
201
+ // split in lines
202
+ .split('\n')
203
+ // remove lines with only spaces
204
+ .map(line => line.trim())
205
+ .filter(line => !!line)
206
+ // put back together
207
+ .join('\n')
208
+ }
209
+ if (opts.publication !== false) {
210
+ editor.on(ClientEvent.PUBLISH_START, () => {
211
+ // Insert templates
212
+ onAll(editor, c => {
213
+ const template = c.get(templateKey)
214
+ const toHTML = c.toHTML
215
+ const classes = c.getClasses()
216
+ const before = cleanup(template?.before || '')
217
+ const replace = cleanup(template?.replace || '')
218
+ const after = cleanup(template?.after || '')
219
+ const classname = cleanup(template?.classname || '')
220
+ const style = cleanup(template?.style || '')
221
+ const attributes = cleanup(template?.attributes || '')
222
+ // Store the initial method
223
+ if (!c.has('tmpHtml')) c.set('tmpHtml', toHTML)
224
+ // Override the method
225
+ c.toHTML = () => {
226
+ return `${before
227
+ }${c.get('tagName') ? `<${c.get('tagName')}
228
+ ${Object.entries(c.get('attributes') as object).map(([key, value]) => makeAttribute(key, value)).join(' ')}
229
+ ${classes.length || classname ? `class="${classes.join(' ')} ${classname}"` : ''}
230
+ ${attributes}
231
+ ${style ? `style="${style}"` : ''}
232
+ >` : ''}${replace || c.getInnerHTML()
233
+ }${c.get('tagName') ? `</${c.get('tagName')}>` : ''}${after
234
+ }`
235
+ }
236
+ })
237
+ })
238
+ editor.on(ClientEvent.PUBLISH_END, () => {
239
+ onAll(editor, c => {
240
+ // Restore the original method
241
+ c.toHTML = c.get('tmpHtml')
242
+ })
243
+ })
244
+ }
245
+ })
246
+ }
@@ -0,0 +1,84 @@
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 { ClientEvent } from '../../client/events.js'
19
+ import { WebsiteMeta } from '../../types.js'
20
+
21
+ interface WebsiteInfoOptions {
22
+ websiteId: string
23
+ connectorId: string
24
+ appendTo: 'commands' | 'options' | 'views' | 'project-bar-container' | 'project-bar-panel' | 'views-container'
25
+ }
26
+
27
+ // Silex plugin
28
+ export default async function(config) {
29
+ let websiteMeta: WebsiteMeta | null = null
30
+ config.on(ClientEvent.GRAPESJS_START, async () => {
31
+ // GrapesJs plugin
32
+ const grapesPlugin = (editor, opts: Partial<WebsiteInfoOptions>) => {
33
+ const options = {
34
+ appendTo: 'commands',
35
+ ...opts,
36
+ } as WebsiteInfoOptions
37
+ editor.on('storage:end:load', async () => {
38
+ // Get website meta data
39
+ const { websiteId, connectorId } = options
40
+ // Get the website meta data
41
+ websiteMeta = await config.api.websiteMetaRead({ websiteId, connectorId })
42
+ displayWebsiteMeta()
43
+ })
44
+ return {}
45
+ }
46
+
47
+ // Add the plugin to the GrapeJS
48
+ config.grapesJsConfig.plugins.push(grapesPlugin)
49
+ config.grapesJsConfig.pluginsOpts[grapesPlugin.toString()] = {
50
+ websiteId: config.websiteId,
51
+ connectorId: config.storageId,
52
+ }
53
+ })
54
+
55
+ config.on(ClientEvent.GRAPESJS_END, async ({editor}) => {
56
+ // Detect when the page changes
57
+ editor.on('page:select', async () => {
58
+ displayWebsiteMeta()
59
+ })
60
+ })
61
+
62
+
63
+ // Display the website meta data
64
+ function displayWebsiteMeta() {
65
+ // Get or create the container
66
+ const container = document.querySelector('#gjs-website-meta') ?? (function() {
67
+ const c = document.createElement('div')
68
+ c.id = 'gjs-website-meta'
69
+ c.classList.add('gjs-website-meta')
70
+ // Add the container to the UI
71
+ // Add the name of the website in the top bar
72
+ const topBar = document.querySelector('.gjs-pn-devices-c')
73
+ topBar?.appendChild(c)
74
+ return c
75
+ })()
76
+ // Get the current page
77
+ const currentPage = config.getEditor().Pages?.getSelected()
78
+ // Display the website meta data
79
+ container.innerHTML = `
80
+ ${websiteMeta?.imageUrl ? `<div class="gjs-website-meta-image" style="background: url(${websiteMeta?.imageUrl});"></div>` : ''}
81
+ <div class="gjs-website-meta-name">${websiteMeta?.name ?? 'Unknown'} | ${currentPage.get('name') ?? currentPage.get('type')}</div>
82
+ `
83
+ }
84
+ }
@@ -0,0 +1,32 @@
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 function noCache (req, res, next) {
19
+ res.header('Cache-Control', 'private,no-cache,no-store,must-revalidate,proxy-revalidate')
20
+ res.header('Expires', '-1')
21
+ res.header('Pragma', 'no-cache')
22
+ next()
23
+ }
24
+
25
+ export function withCache(req, res, next) {
26
+ if (req.url.endsWith('.html') || req.url.endsWith('/')) {
27
+ noCache(req, res, next)
28
+ } else {
29
+ res.header('Cache-Control', 'public,max-age=86400,immutable') // 24h
30
+ next()
31
+ }
32
+ }