adapt-authoring-ui 0.0.1

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 (414) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +14 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.yml +55 -0
  4. package/.github/ISSUE_TEMPLATE/config.yml +1 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +22 -0
  6. package/.github/dependabot.yml +11 -0
  7. package/.github/pull_request_template.md +25 -0
  8. package/.github/workflows/labelled_prs.yml +16 -0
  9. package/.github/workflows/new.yml +19 -0
  10. package/adapt-authoring.json +11 -0
  11. package/app/core/app.js +43 -0
  12. package/app/core/assets/adapt-learning-logo-outline.png +0 -0
  13. package/app/core/assets/adapt-learning-logo-white.png +0 -0
  14. package/app/core/assets/ajax-loader.gif +0 -0
  15. package/app/core/assets/favicon.png +0 -0
  16. package/app/core/assets/transparency-light.png +0 -0
  17. package/app/core/browserStorage.js +45 -0
  18. package/app/core/collections/apiCollection.js +74 -0
  19. package/app/core/collections/contentCollection.js +33 -0
  20. package/app/core/collections/contentPluginCollection.js +24 -0
  21. package/app/core/collections/tagsCollection.js +4 -0
  22. package/app/core/constants.js +10 -0
  23. package/app/core/helpers.js +375 -0
  24. package/app/core/index.hbs +192 -0
  25. package/app/core/l10n.js +33 -0
  26. package/app/core/less/_reset.less +43 -0
  27. package/app/core/less/app.less +100 -0
  28. package/app/core/less/buttons.less +268 -0
  29. package/app/core/less/colourLabels.less +14 -0
  30. package/app/core/less/colours.less +132 -0
  31. package/app/core/less/columns.less +190 -0
  32. package/app/core/less/fonts.less +30 -0
  33. package/app/core/less/forms.less +77 -0
  34. package/app/core/less/sharedStyles.less +73 -0
  35. package/app/core/less/tables.less +29 -0
  36. package/app/core/less/tags.less +194 -0
  37. package/app/core/loading.hbs +27 -0
  38. package/app/core/models/articleModel.js +19 -0
  39. package/app/core/models/blockModel.js +25 -0
  40. package/app/core/models/clipboardModel.js +10 -0
  41. package/app/core/models/componentModel.js +18 -0
  42. package/app/core/models/configModel.js +22 -0
  43. package/app/core/models/contentModel.js +26 -0
  44. package/app/core/models/contentObjectModel.js +19 -0
  45. package/app/core/models/contentPluginModel.js +10 -0
  46. package/app/core/models/courseModel.js +24 -0
  47. package/app/core/models/sessionModel.js +86 -0
  48. package/app/core/origin.js +189 -0
  49. package/app/core/router.js +135 -0
  50. package/app/core/views/originView.js +92 -0
  51. package/app/libraries/babel-polyfill.min.js +1 -0
  52. package/app/libraries/backbone-forms-lists.js +669 -0
  53. package/app/libraries/backbone-forms.js +2604 -0
  54. package/app/libraries/backbone.js +1581 -0
  55. package/app/libraries/ckeditor.js +6 -0
  56. package/app/libraries/handlebars.js +4902 -0
  57. package/app/libraries/imageReady.js +2 -0
  58. package/app/libraries/inview.js +140 -0
  59. package/app/libraries/jquery-ui.min.js +6 -0
  60. package/app/libraries/jquery.form.js +1277 -0
  61. package/app/libraries/jquery.js +10346 -0
  62. package/app/libraries/jquery.tagsinput.min.js +1 -0
  63. package/app/libraries/moment.min.js +7 -0
  64. package/app/libraries/polyglot.min.js +2922 -0
  65. package/app/libraries/require.js +36 -0
  66. package/app/libraries/scrollTo.js +11 -0
  67. package/app/libraries/selectize/css/selectize.less +403 -0
  68. package/app/libraries/selectize/js/selectize.js +4500 -0
  69. package/app/libraries/spectrum/spectrum.js +2323 -0
  70. package/app/libraries/spectrum/spectrum.less +507 -0
  71. package/app/libraries/underscore.js +1692 -0
  72. package/app/libraries/velocity.js +4773 -0
  73. package/app/modules/appHeader/assets/top-bar-1080.jpg +0 -0
  74. package/app/modules/appHeader/assets/top-bar-2560.jpg +0 -0
  75. package/app/modules/appHeader/index.js +5 -0
  76. package/app/modules/appHeader/less/appHeader.less +72 -0
  77. package/app/modules/appHeader/templates/appHeader.hbs +17 -0
  78. package/app/modules/appHeader/views/appHeaderView.js +63 -0
  79. package/app/modules/assetManagement/collections/assetCollection.js +16 -0
  80. package/app/modules/assetManagement/index.js +65 -0
  81. package/app/modules/assetManagement/less/asset.less +229 -0
  82. package/app/modules/assetManagement/less/assetManagementModalTags.less +34 -0
  83. package/app/modules/assetManagement/less/assetManagementNew.less +60 -0
  84. package/app/modules/assetManagement/models/assetModel.js +11 -0
  85. package/app/modules/assetManagement/templates/assetManagement.hbs +12 -0
  86. package/app/modules/assetManagement/templates/assetManagementCollection.hbs +2 -0
  87. package/app/modules/assetManagement/templates/assetManagementEditAsset.hbs +9 -0
  88. package/app/modules/assetManagement/templates/assetManagementEditAssetSidebar.hbs +10 -0
  89. package/app/modules/assetManagement/templates/assetManagementListItem.hbs +35 -0
  90. package/app/modules/assetManagement/templates/assetManagementModalAutofill.hbs +1 -0
  91. package/app/modules/assetManagement/templates/assetManagementModalEditAsset.hbs +11 -0
  92. package/app/modules/assetManagement/templates/assetManagementModalFilters.hbs +16 -0
  93. package/app/modules/assetManagement/templates/assetManagementModalTags.hbs +26 -0
  94. package/app/modules/assetManagement/templates/assetManagementPreview.hbs +53 -0
  95. package/app/modules/assetManagement/templates/assetManagementSidebar.hbs +93 -0
  96. package/app/modules/assetManagement/templates/assetPicker.hbs +45 -0
  97. package/app/modules/assetManagement/views/assetManagementCollectionView.js +216 -0
  98. package/app/modules/assetManagement/views/assetManagementEditAssetSidebarView.js +25 -0
  99. package/app/modules/assetManagement/views/assetManagementEditAssetView.js +123 -0
  100. package/app/modules/assetManagement/views/assetManagementItemView.js +68 -0
  101. package/app/modules/assetManagement/views/assetManagementModalAutofillView.js +51 -0
  102. package/app/modules/assetManagement/views/assetManagementModalEditAssetView.js +38 -0
  103. package/app/modules/assetManagement/views/assetManagementModalFiltersView.js +132 -0
  104. package/app/modules/assetManagement/views/assetManagementModalTagsView.js +169 -0
  105. package/app/modules/assetManagement/views/assetManagementModalView.js +62 -0
  106. package/app/modules/assetManagement/views/assetManagementPreviewView.js +69 -0
  107. package/app/modules/assetManagement/views/assetManagementSidebarView.js +126 -0
  108. package/app/modules/assetManagement/views/assetManagementView.js +43 -0
  109. package/app/modules/colorLabel/index.js +48 -0
  110. package/app/modules/colorLabel/less/colorLabels.less +102 -0
  111. package/app/modules/colorLabel/models/colors.js +31 -0
  112. package/app/modules/colorLabel/templates/colorLabelPopUpView.hbs +21 -0
  113. package/app/modules/colorLabel/views/colorLabelPopupView.js +75 -0
  114. package/app/modules/contentHeader/index.js +6 -0
  115. package/app/modules/contentHeader/less/contentHeader.less +152 -0
  116. package/app/modules/contentHeader/less/options.less +51 -0
  117. package/app/modules/contentHeader/templates/actionsButton.hbs +3 -0
  118. package/app/modules/contentHeader/templates/contentHeader.hbs +38 -0
  119. package/app/modules/contentHeader/templates/contentHeaderToggleButton.hbs +11 -0
  120. package/app/modules/contentHeader/templates/filterItem.hbs +23 -0
  121. package/app/modules/contentHeader/templates/options.hbs +14 -0
  122. package/app/modules/contentHeader/templates/partials/part_headerButtonContent.hbs +2 -0
  123. package/app/modules/contentHeader/templates/sortItem.hbs +9 -0
  124. package/app/modules/contentHeader/views/actionsButtonView.js +14 -0
  125. package/app/modules/contentHeader/views/contentHeaderButtonView.js +42 -0
  126. package/app/modules/contentHeader/views/contentHeaderToggleButtonView.js +52 -0
  127. package/app/modules/contentHeader/views/contentHeaderView.js +96 -0
  128. package/app/modules/contentHeader/views/filtersButtonView.js +31 -0
  129. package/app/modules/contentHeader/views/optionsView.js +88 -0
  130. package/app/modules/contentHeader/views/sortsButtonView.js +45 -0
  131. package/app/modules/contentPane/index.js +20 -0
  132. package/app/modules/contentPane/less/contentPane.less +8 -0
  133. package/app/modules/contentPane/templates/contentPane.hbs +2 -0
  134. package/app/modules/contentPane/views/contentPaneView.js +77 -0
  135. package/app/modules/contextMenu/index.js +85 -0
  136. package/app/modules/contextMenu/less/contextMenu.less +54 -0
  137. package/app/modules/contextMenu/templates/contextMenu.hbs +6 -0
  138. package/app/modules/contextMenu/templates/contextMenuItem.hbs +8 -0
  139. package/app/modules/contextMenu/views/contextMenuItemView.js +37 -0
  140. package/app/modules/contextMenu/views/contextMenuView.js +76 -0
  141. package/app/modules/editor/article/index.js +18 -0
  142. package/app/modules/editor/article/templates/editorArticleEdit.hbs +2 -0
  143. package/app/modules/editor/article/templates/editorArticleEditSidebar.hbs +19 -0
  144. package/app/modules/editor/article/views/editorArticleEditSidebarView.js +32 -0
  145. package/app/modules/editor/article/views/editorArticleEditView.js +19 -0
  146. package/app/modules/editor/block/index.js +18 -0
  147. package/app/modules/editor/block/templates/editorBlockEdit.hbs +2 -0
  148. package/app/modules/editor/block/templates/editorBlockEditSidebar.hbs +19 -0
  149. package/app/modules/editor/block/views/editorBlockEditSidebarView.js +28 -0
  150. package/app/modules/editor/block/views/editorBlockEditView.js +19 -0
  151. package/app/modules/editor/component/index.js +22 -0
  152. package/app/modules/editor/component/templates/editorComponentEdit.hbs +2 -0
  153. package/app/modules/editor/component/templates/editorComponentEditSidebar.hbs +19 -0
  154. package/app/modules/editor/component/views/editorComponentEditSidebarView.js +32 -0
  155. package/app/modules/editor/component/views/editorComponentEditView.js +23 -0
  156. package/app/modules/editor/config/index.js +15 -0
  157. package/app/modules/editor/config/templates/editorConfigEdit.hbs +1 -0
  158. package/app/modules/editor/config/templates/editorConfigEditSidebar.hbs +10 -0
  159. package/app/modules/editor/config/views/editorConfigEditSidebarView.js +28 -0
  160. package/app/modules/editor/config/views/editorConfigEditView.js +28 -0
  161. package/app/modules/editor/contentObject/assets/component-icons/icon-accordion.png +0 -0
  162. package/app/modules/editor/contentObject/assets/component-icons/icon-assessment.png +0 -0
  163. package/app/modules/editor/contentObject/assets/component-icons/icon-blank.png +0 -0
  164. package/app/modules/editor/contentObject/assets/component-icons/icon-default.png +0 -0
  165. package/app/modules/editor/contentObject/assets/component-icons/icon-gmcq.png +0 -0
  166. package/app/modules/editor/contentObject/assets/component-icons/icon-graphic.png +0 -0
  167. package/app/modules/editor/contentObject/assets/component-icons/icon-hot-graphic.png +0 -0
  168. package/app/modules/editor/contentObject/assets/component-icons/icon-matching.png +0 -0
  169. package/app/modules/editor/contentObject/assets/component-icons/icon-mcq.png +0 -0
  170. package/app/modules/editor/contentObject/assets/component-icons/icon-media.png +0 -0
  171. package/app/modules/editor/contentObject/assets/component-icons/icon-narrative.png +0 -0
  172. package/app/modules/editor/contentObject/assets/component-icons/icon-slider.png +0 -0
  173. package/app/modules/editor/contentObject/assets/component-icons/icon-text.png +0 -0
  174. package/app/modules/editor/contentObject/index.js +68 -0
  175. package/app/modules/editor/contentObject/less/editing-overlay-component-list.less +60 -0
  176. package/app/modules/editor/contentObject/less/editing-overlay-panel.less +25 -0
  177. package/app/modules/editor/contentObject/less/editorMenu.less +84 -0
  178. package/app/modules/editor/contentObject/less/editorMenuItem.less +114 -0
  179. package/app/modules/editor/contentObject/less/editorMenuLayer.less +70 -0
  180. package/app/modules/editor/contentObject/less/editorPage.less +162 -0
  181. package/app/modules/editor/contentObject/less/editorPageArticle.less +40 -0
  182. package/app/modules/editor/contentObject/less/editorPageBlock.less +33 -0
  183. package/app/modules/editor/contentObject/less/editorPageComponent.less +47 -0
  184. package/app/modules/editor/contentObject/less/editorPageComponentList.less +234 -0
  185. package/app/modules/editor/contentObject/templates/editorMenu.hbs +1 -0
  186. package/app/modules/editor/contentObject/templates/editorMenuItem.hbs +23 -0
  187. package/app/modules/editor/contentObject/templates/editorMenuLayer.hbs +12 -0
  188. package/app/modules/editor/contentObject/templates/editorMenuSidebar.hbs +1 -0
  189. package/app/modules/editor/contentObject/templates/editorPage.hbs +15 -0
  190. package/app/modules/editor/contentObject/templates/editorPageArticle.hbs +15 -0
  191. package/app/modules/editor/contentObject/templates/editorPageBlock.hbs +14 -0
  192. package/app/modules/editor/contentObject/templates/editorPageComponent.hbs +9 -0
  193. package/app/modules/editor/contentObject/templates/editorPageComponentList.hbs +33 -0
  194. package/app/modules/editor/contentObject/templates/editorPageComponentListItem.hbs +24 -0
  195. package/app/modules/editor/contentObject/templates/editorPageComponentPasteZone.hbs +4 -0
  196. package/app/modules/editor/contentObject/templates/editorPageEdit.hbs +1 -0
  197. package/app/modules/editor/contentObject/templates/editorPageEditSidebar.hbs +10 -0
  198. package/app/modules/editor/contentObject/templates/editorPageSidebar.hbs +1 -0
  199. package/app/modules/editor/contentObject/views/editorMenuItemView.js +174 -0
  200. package/app/modules/editor/contentObject/views/editorMenuLayerView.js +212 -0
  201. package/app/modules/editor/contentObject/views/editorMenuSidebarView.js +13 -0
  202. package/app/modules/editor/contentObject/views/editorMenuView.js +211 -0
  203. package/app/modules/editor/contentObject/views/editorPageArticleView.js +278 -0
  204. package/app/modules/editor/contentObject/views/editorPageBlockView.js +280 -0
  205. package/app/modules/editor/contentObject/views/editorPageComponentListItemView.js +80 -0
  206. package/app/modules/editor/contentObject/views/editorPageComponentListView.js +131 -0
  207. package/app/modules/editor/contentObject/views/editorPageComponentPasteZoneView.js +47 -0
  208. package/app/modules/editor/contentObject/views/editorPageComponentView.js +202 -0
  209. package/app/modules/editor/contentObject/views/editorPageEditSidebarView.js +28 -0
  210. package/app/modules/editor/contentObject/views/editorPageEditView.js +19 -0
  211. package/app/modules/editor/contentObject/views/editorPageSidebarView.js +13 -0
  212. package/app/modules/editor/contentObject/views/editorPageView.js +183 -0
  213. package/app/modules/editor/course/index.js +26 -0
  214. package/app/modules/editor/course/templates/editorCourseEdit.hbs +2 -0
  215. package/app/modules/editor/course/templates/editorCourseEditSidebar.hbs +19 -0
  216. package/app/modules/editor/course/views/editorCourseEditSidebarView.js +28 -0
  217. package/app/modules/editor/course/views/editorCourseEditView.js +56 -0
  218. package/app/modules/editor/extensions/index.js +26 -0
  219. package/app/modules/editor/extensions/less/extensions.less +22 -0
  220. package/app/modules/editor/extensions/templates/editorExtensionsEdit.hbs +85 -0
  221. package/app/modules/editor/extensions/templates/editorExtensionsEditSidebar.hbs +1 -0
  222. package/app/modules/editor/extensions/views/editorExtensionsEditSidebarView.js +10 -0
  223. package/app/modules/editor/extensions/views/editorExtensionsEditView.js +85 -0
  224. package/app/modules/editor/global/collections/editorCollection.js +24 -0
  225. package/app/modules/editor/global/editorDataLoader.js +91 -0
  226. package/app/modules/editor/global/helpers.js +99 -0
  227. package/app/modules/editor/global/less/colorLabels.less +55 -0
  228. package/app/modules/editor/global/less/editor.less +204 -0
  229. package/app/modules/editor/global/templates/editor.hbs +1 -0
  230. package/app/modules/editor/global/templates/editorPasteZone.hbs +4 -0
  231. package/app/modules/editor/global/templates/partials/part_editorCommon.hbs +70 -0
  232. package/app/modules/editor/global/templates/partials/part_editorItemSidebar.hbs +40 -0
  233. package/app/modules/editor/global/templates/partials/part_editorMenu.hbs +4 -0
  234. package/app/modules/editor/global/templates/partials/part_settingsGeneral.hbs +27 -0
  235. package/app/modules/editor/global/views/editorOriginView.js +255 -0
  236. package/app/modules/editor/global/views/editorPasteZoneView.js +69 -0
  237. package/app/modules/editor/global/views/editorView.js +288 -0
  238. package/app/modules/editor/index.js +52 -0
  239. package/app/modules/editor/menuSettings/index.js +27 -0
  240. package/app/modules/editor/menuSettings/less/menusettings.less +55 -0
  241. package/app/modules/editor/menuSettings/templates/editorMenuSettingsEdit.hbs +1 -0
  242. package/app/modules/editor/menuSettings/templates/editorMenuSettingsEditSidebar.hbs +5 -0
  243. package/app/modules/editor/menuSettings/templates/editorMenuSettingsItem.hbs +4 -0
  244. package/app/modules/editor/menuSettings/views/editorMenuSettingsEditSidebarView.js +21 -0
  245. package/app/modules/editor/menuSettings/views/editorMenuSettingsEditView.js +71 -0
  246. package/app/modules/editor/menuSettings/views/editorMenuSettingsView.js +44 -0
  247. package/app/modules/editor/themeEditor/collections/editorPresetCollection.js +13 -0
  248. package/app/modules/editor/themeEditor/index.js +15 -0
  249. package/app/modules/editor/themeEditor/less/editorPresetEdit.less +78 -0
  250. package/app/modules/editor/themeEditor/less/editorTheming.less +73 -0
  251. package/app/modules/editor/themeEditor/models/editorModel.js +62 -0
  252. package/app/modules/editor/themeEditor/models/editorPresetModel.js +6 -0
  253. package/app/modules/editor/themeEditor/templates/editorPresetEdit.hbs +31 -0
  254. package/app/modules/editor/themeEditor/templates/editorTheming.hbs +35 -0
  255. package/app/modules/editor/themeEditor/templates/editorThemingSidebar.hbs +23 -0
  256. package/app/modules/editor/themeEditor/views/editorPresetEditView.js +98 -0
  257. package/app/modules/editor/themeEditor/views/editorThemingSidebarView.js +62 -0
  258. package/app/modules/editor/themeEditor/views/editorThemingView.js +304 -0
  259. package/app/modules/frameworkImport/index.js +32 -0
  260. package/app/modules/frameworkImport/less/frameworkImport.less +101 -0
  261. package/app/modules/frameworkImport/templates/frameworkImport.hbs +58 -0
  262. package/app/modules/frameworkImport/templates/frameworkImportSidebar.hbs +12 -0
  263. package/app/modules/frameworkImport/templates/frameworkImportSummary.hbs +40 -0
  264. package/app/modules/frameworkImport/templates/partials/part_frameworkImportButton.hbs +3 -0
  265. package/app/modules/frameworkImport/templates/partials/part_frameworkImportStatusMessages.hbs +22 -0
  266. package/app/modules/frameworkImport/views/frameworkImportSidebarView.js +31 -0
  267. package/app/modules/frameworkImport/views/frameworkImportView.js +109 -0
  268. package/app/modules/globalMenu/index.js +86 -0
  269. package/app/modules/globalMenu/less/globalMenu.less +117 -0
  270. package/app/modules/globalMenu/templates/globalMenu.hbs +6 -0
  271. package/app/modules/globalMenu/templates/globalMenuItem.hbs +10 -0
  272. package/app/modules/globalMenu/templates/partials/part_globalMenuButton.hbs +7 -0
  273. package/app/modules/globalMenu/views/globalMenuItemView.js +108 -0
  274. package/app/modules/globalMenu/views/globalMenuView.js +45 -0
  275. package/app/modules/limiteduser/index.js +17 -0
  276. package/app/modules/limiteduser/less/limitedUser.less +29 -0
  277. package/app/modules/limiteduser/templates/limitedUser.hbs +8 -0
  278. package/app/modules/limiteduser/views/limitedUserView.js +12 -0
  279. package/app/modules/modal/index.js +13 -0
  280. package/app/modules/modal/less/modal.less +61 -0
  281. package/app/modules/modal/models/modalModel.js +14 -0
  282. package/app/modules/modal/templates/modal.hbs +34 -0
  283. package/app/modules/modal/views/modalView.js +102 -0
  284. package/app/modules/notify/index.js +32 -0
  285. package/app/modules/notify/plugins/alert/assets/sweetalert.css +932 -0
  286. package/app/modules/notify/plugins/alert/index.js +117 -0
  287. package/app/modules/notify/plugins/alert/less/alert.less +74 -0
  288. package/app/modules/notify/plugins/alert/sweetalert2-11.1.7.all.min.js +2 -0
  289. package/app/modules/notify/plugins/console/index.js +18 -0
  290. package/app/modules/notify/plugins/snackbar/index.js +69 -0
  291. package/app/modules/notify/plugins/snackbar/less/snackbar.less +40 -0
  292. package/app/modules/notify/plugins/toast/index.js +70 -0
  293. package/app/modules/notify/plugins/toast/less/toast.less +62 -0
  294. package/app/modules/pluginManagement/index.js +36 -0
  295. package/app/modules/pluginManagement/less/pluginManagement.less +23 -0
  296. package/app/modules/pluginManagement/less/pluginType.less +25 -0
  297. package/app/modules/pluginManagement/templates/pluginManagement.hbs +43 -0
  298. package/app/modules/pluginManagement/templates/pluginManagementSidebar.hbs +40 -0
  299. package/app/modules/pluginManagement/templates/pluginManagementUpload.hbs +12 -0
  300. package/app/modules/pluginManagement/templates/pluginManagementUploadSidebar.hbs +13 -0
  301. package/app/modules/pluginManagement/templates/pluginType.hbs +43 -0
  302. package/app/modules/pluginManagement/views/pluginManagementSidebarView.js +48 -0
  303. package/app/modules/pluginManagement/views/pluginManagementUploadSidebarView.js +25 -0
  304. package/app/modules/pluginManagement/views/pluginManagementUploadView.js +52 -0
  305. package/app/modules/pluginManagement/views/pluginManagementView.js +104 -0
  306. package/app/modules/pluginManagement/views/pluginTypeView.js +105 -0
  307. package/app/modules/projects/assets/origami-project.jpg +0 -0
  308. package/app/modules/projects/index.js +82 -0
  309. package/app/modules/projects/less/projects.less +152 -0
  310. package/app/modules/projects/less/qproject.less +143 -0
  311. package/app/modules/projects/templates/project.hbs +63 -0
  312. package/app/modules/projects/templates/projects.hbs +6 -0
  313. package/app/modules/projects/templates/projectsSidebar.hbs +42 -0
  314. package/app/modules/projects/views/projectView.js +167 -0
  315. package/app/modules/projects/views/projectsSidebarView.js +172 -0
  316. package/app/modules/projects/views/projectsView.js +271 -0
  317. package/app/modules/scaffold/backboneFormsOverrides.js +284 -0
  318. package/app/modules/scaffold/index.js +342 -0
  319. package/app/modules/scaffold/lang/en.json +9 -0
  320. package/app/modules/scaffold/less/codeEditor.less +6 -0
  321. package/app/modules/scaffold/less/colourPicker.less +141 -0
  322. package/app/modules/scaffold/less/displayTitle.less +17 -0
  323. package/app/modules/scaffold/less/forms.less +174 -0
  324. package/app/modules/scaffold/less/list.less +35 -0
  325. package/app/modules/scaffold/less/modal.less +45 -0
  326. package/app/modules/scaffold/less/scaffoldAsset.less +23 -0
  327. package/app/modules/scaffold/less/scaffoldAssetItem.less +50 -0
  328. package/app/modules/scaffold/less/selectize.less +29 -0
  329. package/app/modules/scaffold/less/textArea.less +9 -0
  330. package/app/modules/scaffold/less/users.less +6 -0
  331. package/app/modules/scaffold/templates/field.hbs +25 -0
  332. package/app/modules/scaffold/templates/fieldset.hbs +10 -0
  333. package/app/modules/scaffold/templates/form.hbs +6 -0
  334. package/app/modules/scaffold/templates/list.hbs +4 -0
  335. package/app/modules/scaffold/templates/listItem.hbs +5 -0
  336. package/app/modules/scaffold/templates/scaffoldAsset.hbs +65 -0
  337. package/app/modules/scaffold/templates/scaffoldAssetItem.hbs +35 -0
  338. package/app/modules/scaffold/templates/scaffoldDisplayTitle.hbs +8 -0
  339. package/app/modules/scaffold/templates/scaffoldEditHtml.hbs +1 -0
  340. package/app/modules/scaffold/templates/scaffoldFile.hbs +1 -0
  341. package/app/modules/scaffold/templates/scaffoldItemsModal.hbs +14 -0
  342. package/app/modules/scaffold/templates/scaffoldModalOverlay.hbs +1 -0
  343. package/app/modules/scaffold/templates/scaffoldUsersOption.hbs +8 -0
  344. package/app/modules/scaffold/views/scaffoldAssetItemView.js +203 -0
  345. package/app/modules/scaffold/views/scaffoldAssetView.js +157 -0
  346. package/app/modules/scaffold/views/scaffoldCodeEditorView.js +64 -0
  347. package/app/modules/scaffold/views/scaffoldColourPickerView.js +70 -0
  348. package/app/modules/scaffold/views/scaffoldDisplayTitleView.js +112 -0
  349. package/app/modules/scaffold/views/scaffoldFileView.js +18 -0
  350. package/app/modules/scaffold/views/scaffoldItemsModalView.js +100 -0
  351. package/app/modules/scaffold/views/scaffoldListView.js +158 -0
  352. package/app/modules/scaffold/views/scaffoldTagsView.js +71 -0
  353. package/app/modules/scaffold/views/scaffoldUsersView.js +89 -0
  354. package/app/modules/sidebar/index.js +22 -0
  355. package/app/modules/sidebar/less/sidebar.less +298 -0
  356. package/app/modules/sidebar/less/sidebarFilter.less +91 -0
  357. package/app/modules/sidebar/templates/sidebar.hbs +7 -0
  358. package/app/modules/sidebar/templates/sidebarBreadcrumb.hbs +3 -0
  359. package/app/modules/sidebar/templates/sidebarDivide.hbs +5 -0
  360. package/app/modules/sidebar/templates/sidebarFieldsetFilter.hbs +6 -0
  361. package/app/modules/sidebar/templates/sidebarFilter.hbs +30 -0
  362. package/app/modules/sidebar/templates/sidebarRowFilter.hbs +4 -0
  363. package/app/modules/sidebar/templates/sidebarUpdateButton.hbs +3 -0
  364. package/app/modules/sidebar/views/sidebarFieldsetFilterView.js +43 -0
  365. package/app/modules/sidebar/views/sidebarFilterView.js +132 -0
  366. package/app/modules/sidebar/views/sidebarItemView.js +172 -0
  367. package/app/modules/sidebar/views/sidebarView.js +71 -0
  368. package/app/modules/user/assets/adapt-learning-logo.png +0 -0
  369. package/app/modules/user/assets/adapt-logo.png +0 -0
  370. package/app/modules/user/assets/login_bg.jpg +0 -0
  371. package/app/modules/user/index.js +75 -0
  372. package/app/modules/user/less/forgotPassword.less +14 -0
  373. package/app/modules/user/less/login.less +138 -0
  374. package/app/modules/user/less/logout.less +3 -0
  375. package/app/modules/user/less/resetPassword.less +7 -0
  376. package/app/modules/user/less/userProfile.less +49 -0
  377. package/app/modules/user/models/userProfileModel.js +32 -0
  378. package/app/modules/user/templates/forgotPassword.hbs +36 -0
  379. package/app/modules/user/templates/login.hbs +29 -0
  380. package/app/modules/user/templates/resetPassword.hbs +29 -0
  381. package/app/modules/user/templates/userProfile.hbs +71 -0
  382. package/app/modules/user/templates/userProfileSidebar.hbs +16 -0
  383. package/app/modules/user/views/forgotPasswordView.js +63 -0
  384. package/app/modules/user/views/loginView.js +93 -0
  385. package/app/modules/user/views/resetPasswordView.js +78 -0
  386. package/app/modules/user/views/userProfileSidebarView.js +32 -0
  387. package/app/modules/user/views/userProfileView.js +107 -0
  388. package/app/modules/userManagement/collections/userCollection.js +65 -0
  389. package/app/modules/userManagement/helpers.js +46 -0
  390. package/app/modules/userManagement/index.js +67 -0
  391. package/app/modules/userManagement/less/userManagement.less +268 -0
  392. package/app/modules/userManagement/models/userModel.js +34 -0
  393. package/app/modules/userManagement/templates/addUser.hbs +35 -0
  394. package/app/modules/userManagement/templates/addUserSidebar.hbs +9 -0
  395. package/app/modules/userManagement/templates/user.hbs +126 -0
  396. package/app/modules/userManagement/templates/userManagement.hbs +49 -0
  397. package/app/modules/userManagement/templates/userManagementFilter.hbs +19 -0
  398. package/app/modules/userManagement/templates/userManagementSidebar.hbs +13 -0
  399. package/app/modules/userManagement/views/addUserSidebarView.js +25 -0
  400. package/app/modules/userManagement/views/addUserView.js +85 -0
  401. package/app/modules/userManagement/views/filterView.js +49 -0
  402. package/app/modules/userManagement/views/userManagementSidebarView.js +33 -0
  403. package/app/modules/userManagement/views/userManagementView.js +104 -0
  404. package/app/modules/userManagement/views/userView.js +324 -0
  405. package/conf/config.schema.json +18 -0
  406. package/docs/migrating-from-legacy.md +19 -0
  407. package/docs/plugins/index-ui.md +17 -0
  408. package/docs/plugins/uidocs.js +54 -0
  409. package/docs/ui-extensions.md +15 -0
  410. package/index.js +1 -0
  411. package/lib/UiBuild.js +391 -0
  412. package/lib/UiModule.js +158 -0
  413. package/npm_hooks/postinstall.js +4 -0
  414. package/package.json +27 -0
package/lib/UiBuild.js ADDED
@@ -0,0 +1,391 @@
1
+ import { App, Hook } from 'adapt-authoring-core'
2
+ import babel from '@babel/core'
3
+ import fs from 'fs/promises'
4
+ import { glob } from 'glob'
5
+ import handlebars from 'handlebars'
6
+ import less from 'less'
7
+ import path from 'path'
8
+ import { promisify } from 'util'
9
+ import requirejs from 'requirejs'
10
+
11
+ const lessPromise = promisify(less.render)
12
+ /**
13
+ * Builds the AAT user interface
14
+ * @memberof ui
15
+ */
16
+ class UiBuild {
17
+ /**
18
+ * Location of the UI rebuild file
19
+ * @type {string}
20
+ */
21
+ static get rebuildFilePath () {
22
+ return path.join(App.instance.rootDir, '.rebuild-ui')
23
+ }
24
+ /**
25
+ * Constants for build status
26
+ * @type {object}
27
+ */
28
+ static get BUILD_STATUS () {
29
+ return {
30
+ BUILD_MISSING: 'BUILD_MISSING',
31
+ CODE_API: 'CODE_API',
32
+ FORCE_FLAG: 'FORCE_FLAG',
33
+ NONE: 'NONE',
34
+ PROD_MODE: 'PROD_MODE',
35
+ REBUILD_FILE: 'REBUILD_FILE',
36
+ REST_API: 'REST_API',
37
+ }
38
+ }
39
+ /**
40
+ * Checks whether the rebuild file exists
41
+ * @return {boolean}
42
+ */
43
+ static async checkBuildFileExists () {
44
+ return this.fs('access', this.rebuildFilePath, fs.W_OK)
45
+ }
46
+ /**
47
+ * @constructor
48
+ * @param {object} options Whether this is a development build
49
+ * @param {string} options.status Build status
50
+ * @param {boolean} options.isDev Whether this is a development build
51
+ * @param {string} options.appRoot Root dir for the main adapt-authoring app
52
+ * @param {string} options.srcDir Root dir for the UI source code
53
+ * @param {string} options.buildDir Build dir for the output files
54
+ * @param {array} options.plugins Any custom UI plugins
55
+ */
56
+ constructor ({ status, isDev, appRoot, srcDir, buildDir, plugins}) {
57
+ this.status = status
58
+ this.isDev = isDev
59
+ this.appRoot = appRoot
60
+ this.srcDir = srcDir
61
+ this.buildDir = buildDir
62
+ this.outputFileName = 'adapt'
63
+ this.plugins = plugins
64
+ this.outputJsDir = path.join(this.buildDir, 'js')
65
+ this.outputJsFilePath = path.join(this.outputJsDir, `${this.outputFileName}.js`)
66
+ this.requireJsConfigPath = path.join(this.outputJsDir, 'requireJsConfig.js')
67
+ this.requireJsConfig = {
68
+ baseUrl: srcDir,
69
+ name: 'core/app',
70
+ out: this.outputJsFilePath,
71
+ preserveLicenseComments: isDev,
72
+ waitSeconds: 0,
73
+ paths: {
74
+ 'modules/modules': 'modules-bundle',
75
+ 'plugins/plugins': 'plugins-bundle',
76
+ 'templates/templates': 'templates',
77
+ backbone: 'libraries/backbone',
78
+ backboneForms: 'libraries/backbone-forms',
79
+ backboneFormsLists: 'libraries/backbone-forms-lists',
80
+ ckeditor: 'libraries/ckeditor',
81
+ handlebars: 'libraries/handlebars',
82
+ imageReady: 'libraries/imageReady',
83
+ inview: 'libraries/inview',
84
+ jquery: 'libraries/jquery',
85
+ jqueryForm: 'libraries/jquery.form',
86
+ jqueryTagsInput: 'libraries/jquery.tagsinput.min',
87
+ jqueryUI: 'libraries/jquery-ui.min',
88
+ moment: 'libraries/moment.min',
89
+ polyfill: 'libraries/babel-polyfill.min',
90
+ polyglot: 'libraries/polyglot.min',
91
+ scrollTo: 'libraries/scrollTo',
92
+ selectize: 'libraries/selectize/js/selectize',
93
+ underscore: 'libraries/underscore',
94
+ velocity: 'libraries/velocity'
95
+ },
96
+ shim: {
97
+ 'templates/templates': { deps: ['handlebars'] },
98
+ // third-party
99
+ backbone: {
100
+ deps: ['underscore', 'jquery'],
101
+ exports: 'Backbone'
102
+ },
103
+ backboneForms: {
104
+ deps: ['backbone']
105
+ },
106
+ backboneFormsLists: {
107
+ deps: ['backboneForms']
108
+ },
109
+ handlebars: {
110
+ exports: 'Handlebars'
111
+ },
112
+ imageReady: {
113
+ deps: ['jquery'],
114
+ exports: 'imageready'
115
+ },
116
+ inview: {
117
+ deps: ['jquery'],
118
+ exports: 'inview'
119
+ },
120
+ jqueryForm: {
121
+ deps: ['jquery'],
122
+ exports: '$'
123
+ },
124
+ jqueryTagsInput: {
125
+ deps: ['jquery'],
126
+ exports: '$'
127
+ },
128
+ jqueryUI: {
129
+ deps: ['jquery'],
130
+ exports: '$'
131
+ },
132
+ moment: {
133
+ exports: 'moment'
134
+ },
135
+ polyglot: {
136
+ exports: 'Polyglot'
137
+ },
138
+ scrollTo: {
139
+ deps: ['jquery'],
140
+ exports: 'scrollTo'
141
+ },
142
+ selectize: {
143
+ deps: ['jquery'],
144
+ exports: '$'
145
+ },
146
+ underscore: {
147
+ exports: '_'
148
+ },
149
+ velocity: {
150
+ deps: ['jquery'],
151
+ exports: 'velocity'
152
+ }
153
+ }
154
+ }
155
+ this.preBuildHook = new Hook()
156
+ this.postBuildHook = new Hook()
157
+ }
158
+ /**
159
+ * Wrapper for filesystem (fs) functions
160
+ * @param {string} function Function to run
161
+ * @return {boolean} Whether the process was successful
162
+ */
163
+ async fs (funcName, ...args) {
164
+ try {
165
+ await fs[funcName](...args)
166
+ return true
167
+ } catch (e) {
168
+ if (e.code !== 'ENOENT') throw e
169
+ return false
170
+ }
171
+ }
172
+ /**
173
+ * Initialises the expected build folder structure
174
+ * @return {Promise}
175
+ */
176
+ async initBuildFolder () {
177
+ await this.fs('rm', this.srcDir, { recursive: true })
178
+ await this.fs('rm', this.buildDir, { recursive: true })
179
+ await this.fs('mkdir', path.resolve(this.buildDir, 'css'), { recursive: true })
180
+ await this.fs('mkdir', this.srcDir, { recursive: true })
181
+ await this.fs('mkdir', this.outputJsDir, { recursive: true })
182
+ }
183
+ /**
184
+ * Copies any specified UI plugins into place
185
+ * * @return {Promise}
186
+ */
187
+ async copyPlugins () {
188
+ return Promise.all(this.plugins.map(async p => {
189
+ const contents = await fs.readdir(p)
190
+ return Promise.all(contents.map(c => fs.cp(path.resolve(p, c), path.resolve(this.srcDir, 'plugins', c), { recursive: true, force: true })))
191
+ }))
192
+ }
193
+ /**
194
+ * Creates bundle files for the relevant RequireJS files
195
+ * @return {Promise}
196
+ */
197
+ async bundleRequireImports () {
198
+ return Promise.all(['modules', 'plugins'].map(async type => {
199
+ const modulePaths = []
200
+ let modules = []
201
+ try {
202
+ modules = await fs.readdir(path.resolve(this.srcDir, type))
203
+ } catch (e) {} // folder doesn't exist, no problem
204
+
205
+ await Promise.all(modules.map(async m => {
206
+ try {
207
+ const relPath = `${type}/${m}/index.js`
208
+ await fs.stat(path.resolve(this.srcDir, relPath))
209
+ modulePaths.push(relPath)
210
+ } catch (e) {}
211
+ }))
212
+ fs.writeFile(`${this.isDev ? this.buildDir : this.srcDir}/${type}-bundle.js`, `define(${JSON.stringify(modulePaths)}, function() {});`)
213
+ }))
214
+ }
215
+ /**
216
+ * Copy assets
217
+ * @return {Promise}
218
+ */
219
+ async copyAssets () {
220
+ const outputDir = `${this.buildDir}/css/assets`
221
+ fs.mkdir(outputDir, { recursive: true })
222
+ const assets = await this.getFiles('**/assets/**')
223
+ return Promise.all(assets.map(a => fs.copyFile(a, `${outputDir}/${path.basename(a)}`)))
224
+ }
225
+ /**
226
+ * Copy handlebars templates
227
+ * @return {Promise}
228
+ */
229
+ async copyHbs () {
230
+ const files = ['index.hbs', 'loading.hbs']
231
+ return Promise.all(files.map(f => fs.copyFile(`${this.srcDir}/core/${f}`, `${this.buildDir}/${f}`)))
232
+ }
233
+ /**
234
+ * Copy source code files
235
+ * @return {Promise}
236
+ */
237
+ async copySource () {
238
+ return fs.cp(this.appRoot, this.srcDir, { recursive: true })
239
+ }
240
+ /**
241
+ * Run LESS tooling to generate output CSS file
242
+ * @return {Promise}
243
+ */
244
+ async compileLess () {
245
+ const cssFilename = `${this.outputFileName}.css`
246
+ const cssPath = path.join(this.buildDir, 'css', cssFilename)
247
+ const lessOptions = {
248
+ compress: this.isDev,
249
+ paths: `${this.srcDir}/core/less`
250
+ }
251
+ if (this.isDev) { // source maps
252
+ lessOptions.sourceMap = {
253
+ sourceMapFileInline: false,
254
+ outputSourceFiles: true,
255
+ sourceMapBasepath: 'src',
256
+ sourceMapURL: `${cssFilename}.map`
257
+ }
258
+ }
259
+ const lessImports = (await this.getFiles('**/*.less')).sort().reduce((s, p) => `${s}@import '${p}';\n`, '')
260
+ const { css, map } = await lessPromise(lessImports, lessOptions)
261
+ const tasks = [fs.writeFile(cssPath, css)]
262
+ if (map) {
263
+ const sourceMapPath = `${cssPath}.map`
264
+ const importsPath = `${sourceMapPath}.imports`
265
+ tasks.push(
266
+ fs.writeFile(sourceMapPath, map),
267
+ fs.writeFile(importsPath, lessImports)
268
+ )
269
+ }
270
+ return Promise.all(tasks)
271
+ }
272
+ /**
273
+ * Compile handlebars templates and merge into single file
274
+ * @return {Promise}
275
+ */
276
+ async compileHandlebars () {
277
+ const extName = '.hbs'
278
+ const results = await Promise.all((await this.getFiles(`**/*${extName}`)).map(async t => {
279
+ const compiled = handlebars.precompile((await fs.readFile(t)).toString())
280
+ const name = path.basename(t, extName)
281
+ const template = `Handlebars.template(${compiled})`
282
+ return name.startsWith('part_')
283
+ ? `Handlebars.registerPartial("${name}", ${template});`
284
+ : `Handlebars.templates["${name}"] = ${template};`
285
+ }))
286
+ const output = `define(['handlebars'], function(Handlebars) {
287
+ Handlebars.templates = Handlebars.templates || {};
288
+
289
+ ${results.join('\n\n')}
290
+
291
+ return Handlebars;
292
+ });`
293
+ return fs.writeFile(path.join(this.isDev ? this.buildDir : this.srcDir, 'templates.js'), output)
294
+ }
295
+ /**
296
+ * Write RequireJS config data to file
297
+ * @return {Promise}
298
+ */
299
+ async writeRequireJsConfig () {
300
+ const config = { ...this.requireJsConfig }
301
+ if (this.isDev) config.baseUrl = '/'
302
+ await this.fs('writeFile', this.requireJsConfigPath, `require.config(${JSON.stringify(config, null, 2)});`)
303
+ }
304
+ /**
305
+ * Runs the RequireJS tooling
306
+ * @return {Promise}
307
+ */
308
+ async runRequireJs () {
309
+ return new Promise((resolve, reject) => requirejs.optimize(this.requireJsConfig, resolve, reject))
310
+ }
311
+ /**
312
+ * Runs the babel tooling
313
+ * @return {Promise}
314
+ */
315
+ async runBabel () {
316
+ const opts = Object.assign({
317
+ cwd: this.srcDir,
318
+ presets: [['@babel/preset-env', { targets: { ie: '11' } }]],
319
+ sourceType: 'script'
320
+ }, this.isDev // add task-specific options
321
+ ? { compact: false, retainLines: true }
322
+ : { comments: false, minified: true }
323
+ )
324
+ const { code } = await babel.transformFileAsync(this.outputJsFilePath, opts)
325
+ return fs.writeFile(this.outputJsFilePath, code)
326
+ }
327
+ /**
328
+ * Returns list of source files
329
+ * @param {string} globPattern Glob pattern to specify files
330
+ * @return {Promise}
331
+ */
332
+ async getFiles (globPattern) {
333
+ return glob(globPattern, { cwd: this.srcDir, nodir: true, absolute: true })
334
+ }
335
+ /**
336
+ * Main entry point, runs the build process
337
+ * @return {Promise}
338
+ */
339
+ async run () {
340
+ const mode = this.isDev ? 'dev' : 'production'
341
+ let rebuildReason = ''
342
+ if (this.status === UiBuild.BUILD_STATUS.BUILD_MISSING) rebuildReason = 'no build exists'
343
+ if (this.status === UiBuild.BUILD_STATUS.CODE_API) rebuildReason = 'via code API'
344
+ if (this.status === UiBuild.BUILD_STATUS.FORCE_FLAG) rebuildReason = '--rebuild-ui flag passed'
345
+ if (this.status === UiBuild.BUILD_STATUS.PROD_MODE) rebuildReason = 'in production mode'
346
+ if (this.status === UiBuild.BUILD_STATUS.REBUILD_FILE) rebuildReason = `${path.basename(this.rebuildFilePath)} file found`
347
+ if (this.status === UiBuild.BUILD_STATUS.REST_API) rebuildReason = 'via REST API'
348
+ this.log('debug', 'BUILD', this.status, mode)
349
+ this.log('info', `UI build triggered (${rebuildReason}), building in ${mode} mode`)
350
+
351
+ try {
352
+ await this.initBuildFolder()
353
+ await Promise.all([
354
+ this.copySource(),
355
+ this.copyPlugins()
356
+ ])
357
+ await this.preBuildHook.invoke(this)
358
+ await Promise.all([
359
+ this.bundleRequireImports(),
360
+ this.copyAssets(),
361
+ this.copyHbs(),
362
+ this.compileLess(),
363
+ this.compileHandlebars(),
364
+ this.writeRequireJsConfig()
365
+ ])
366
+ if (!this.isDev) {
367
+ await this.runRequireJs()
368
+ await this.runBabel()
369
+ await this.fs('rm', this.srcDir, { recursive: true })
370
+ }
371
+ try {
372
+ await this.fs('rm', this.rebuildFilePath)
373
+ } catch (e) {} // ignore
374
+ await this.postBuildHook.invoke(this)
375
+
376
+ this.log('info', 'UI built successfully')
377
+ } catch (e) {
378
+ this.log('error', `failed to build UI, ${e}`)
379
+ }
380
+ }
381
+ /**
382
+ * Shim for logging via the ui module
383
+ * @return {Promise}
384
+ */
385
+ async log (...args) {
386
+ const ui = await App.instance.waitForModule('ui')
387
+ ui.log(...args)
388
+ }
389
+ }
390
+
391
+ export default UiBuild
@@ -0,0 +1,158 @@
1
+ import { AbstractModule, Hook } from 'adapt-authoring-core'
2
+ import fs from 'fs/promises'
3
+ import path from 'path'
4
+ import UiBuild from './UiBuild.js'
5
+ /**
6
+ * The main entry-point for the Adapt authoring tool web-app/front-end
7
+ * @extends {AbstractModule}
8
+ */
9
+ class UiModule extends AbstractModule {
10
+ /** @override */
11
+ async init () {
12
+ /**
13
+ * Source code directory for the app
14
+ * @type {String}
15
+ */
16
+ this.appRoot = path.resolve(this.rootDir, 'app')
17
+ /**
18
+ * Source code directory for the app
19
+ * @type {String}
20
+ */
21
+ this.srcDir = this.getConfig('srcDir')
22
+ /**
23
+ * Build code directory for the app
24
+ * @type {String}
25
+ */
26
+ this.buildDir = this.getConfig('buildDir')
27
+ /**
28
+ * Cached reference to isProduction config value
29
+ */
30
+ this.isProduction = this.app.getConfig('isProduction')
31
+ /**
32
+ * Reference to UI plugins which need to be included in build
33
+ * @type {String[]}
34
+ */
35
+ this.uiPlugins = []
36
+ /**
37
+ * Invoked before every UI build
38
+ * @type {Hook}
39
+ */
40
+ this.preBuildHook = new Hook()
41
+ /**
42
+ * Invoked after every UI build
43
+ * @type {Hook}
44
+ */
45
+ this.postBuildHook = new Hook()
46
+
47
+ const [auth, server] = await this.app.waitForModule('auth', 'server')
48
+ // add a rebuild endpoint
49
+ const router = server.api.createChildRouter('ui', [{ route: '/rebuild', handlers: { post: this.buildHandler() } }])
50
+ auth.secureRoute(`${router.path}/rebuild`, 'post', ['rebuild:ui'])
51
+
52
+ if (!this.isProduction) {
53
+ server.root.addMiddleware(server.static(this.srcDir))
54
+ }
55
+ server.root
56
+ .addMiddleware(server.static(this.buildDir))
57
+ .addMiddleware(server.static(path.resolve(this.appRoot, 'libraries')))
58
+ .addRoute({ route: '/', handlers: { get: this.servePage('index') } })
59
+ .addRoute({ route: '/loading', handlers: { get: this.servePage('loading') } })
60
+
61
+ this.app.onReady()
62
+ .then(async () => this.build(await this.getRebuildStatus()))
63
+ .then(() => this.log('info', `app available at ${this.app.config.get('adapt-authoring-server.url')}`))
64
+ }
65
+
66
+ /**
67
+ * Copies a plugin to be built into the UI
68
+ * @param {String} dir Directory to add (can contain nested plugins)
69
+ */
70
+ addUiPlugin (dir) {
71
+ if (!this.uiPlugins.includes(dir)) {
72
+ this.uiPlugins.push(dir)
73
+ this.log('debug', 'PLUGIN_REGISTERED', dir)
74
+ }
75
+ }
76
+ /**
77
+ * Checks whether a rebuild is required
78
+ * @return {string} The build status
79
+ */
80
+ async getRebuildStatus () {
81
+ if (this.isProduction) {
82
+ return UiBuild.BUILD_STATUS.PROD_MODE
83
+ }
84
+ if (this.app.args['rebuild-ui']) {
85
+ return UiBuild.BUILD_STATUS.FORCE_FLAG
86
+ }
87
+ try {
88
+ if (await UiBuild.checkBuildFileExists()) {
89
+ return UiBuild.BUILD_STATUS.REBUILD_FILE
90
+ }
91
+ } catch (e) {}
92
+ try {
93
+ await fs.access(this.isProduction ? this.buildDir : this.srcDir)
94
+ } catch (e) {
95
+ if(e.code !== 'ENOENT') {
96
+ throw e
97
+ }
98
+ return UiBuild.BUILD_STATUS.BUILD_MISSING
99
+ }
100
+ return UiBuild.BUILD_STATUS.NONE
101
+ }
102
+ /**
103
+ * Builds the front-end application
104
+ * @param {string} status Reason for build. If not provided, code will attempt to predict the need for a build.
105
+ * @return {Promise}
106
+ */
107
+ async build (status = UiBuild.BUILD_STATUS.CODE_API) {
108
+ if (status === UiBuild.BUILD_STATUS.NONE) {
109
+ return
110
+ }
111
+ const build = new UiBuild({
112
+ status,
113
+ isDev: !this.isProduction,
114
+ appRoot: this.appRoot,
115
+ srcDir: this.srcDir,
116
+ buildDir: this.buildDir,
117
+ plugins: this.uiPlugins
118
+ })
119
+ build.preBuildHook.tap(() => this.preBuildHook.invoke(build))
120
+ build.postBuildHook.tap(() => this.postBuildHook.invoke(build))
121
+ await build.run()
122
+ }
123
+ /**
124
+ * Express handler for the rebuild endpoint
125
+ * @return {Function} Express handler function
126
+ */
127
+ buildHandler() {
128
+ return async (req, res, next) => {
129
+ try {
130
+ await this.build(UiBuild.BUILD_STATUS.REST_API)
131
+ res.sendStatus(204)
132
+ } catch(e) {
133
+ next(e)
134
+ }
135
+ }
136
+ }
137
+ /**
138
+ * Serves a static HTML page
139
+ * @param {String} pageName
140
+ * @return {Function} Express handler function
141
+ */
142
+ servePage (pageName) {
143
+ return async (req, res, next) => {
144
+ const framework = await this.app.waitForModule('adaptframework')
145
+ res.render(path.resolve(this.buildDir, pageName), {
146
+ isProduction: this.isProduction,
147
+ versions: {
148
+ adapt_framework: framework.version,
149
+ 'adapt-authoring': this.app.pkg.version
150
+ },
151
+ git: { 'adapt-authoring': this.app.git },
152
+ productName: this.app.lang.translate(req, 'app.productname')
153
+ })
154
+ }
155
+ }
156
+ }
157
+
158
+ export default UiModule
@@ -0,0 +1,4 @@
1
+ import fs from 'fs/promises';
2
+
3
+ fs.writeFile(new URL(`../../../.rebuild-ui`, import.meta.url), ' ')
4
+ .catch(console.error);
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "adapt-authoring-ui",
3
+ "version": "0.0.1",
4
+ "description": "Front-end application for the Adapt authoring tool",
5
+ "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
+ "license": "GPL-3.0",
7
+ "type": "module",
8
+ "main": "index.js",
9
+ "scripts": {
10
+ "postinstall": "node npm_hooks/postinstall.js"
11
+ },
12
+ "repository": "github:adapt-security/adapt-authoring-ui",
13
+ "dependencies": {
14
+ "@babel/core": "^7.23.9",
15
+ "@babel/preset-env": "^7.23.9",
16
+ "adapt-authoring-core": "github:adapt-security/adapt-authoring-core",
17
+ "fs-extra": "^11.2.0",
18
+ "glob": "^11.0.0",
19
+ "handlebars": "^4.7.8",
20
+ "less": "^4.2.0",
21
+ "requirejs": "^2.3.6"
22
+ },
23
+ "devDependencies": {
24
+ "eslint": "^9.11.0",
25
+ "standard": "^17.1.0"
26
+ }
27
+ }