lcms-engine 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (327) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +25 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +23 -73
  5. data/.nvmrc +1 -1
  6. data/.overcommit.yml +8 -2
  7. data/.prettierrc +7 -0
  8. data/.rubocop.yml +5 -2
  9. data/.ruby-version +1 -1
  10. data/.stylelintignore +9 -0
  11. data/.stylelintrc +8 -0
  12. data/CHANGELOG.md +36 -2
  13. data/Dockerfile +3 -3
  14. data/Gemfile.lock +344 -297
  15. data/README.md +20 -18
  16. data/app/assets/config/lcms_engine_manifest.js +4 -2
  17. data/app/assets/javascripts/lcms/engine/admin/{application.js → lcms_engine_application.js} +1 -3
  18. data/app/assets/javascripts/lcms/engine/initializers/foundation.js +1 -1
  19. data/app/assets/javascripts/lcms/engine/{application.js → lcms_engine_application.js} +0 -0
  20. data/app/assets/stylesheets/lcms/engine/admin/collections.scss +2 -1
  21. data/app/assets/stylesheets/lcms/engine/admin/components.scss +60 -19
  22. data/app/assets/stylesheets/lcms/engine/admin/curriculums.scss +12 -10
  23. data/app/assets/stylesheets/lcms/engine/admin/lessons.scss +21 -15
  24. data/app/assets/stylesheets/lcms/engine/admin/materials.scss +25 -17
  25. data/app/assets/stylesheets/lcms/engine/admin/resources.scss +8 -7
  26. data/app/assets/stylesheets/lcms/engine/admin/standards.scss +4 -1
  27. data/app/assets/stylesheets/lcms/engine/admin/users.scss +1 -1
  28. data/app/assets/stylesheets/lcms/engine/base/_colors.scss +8 -10
  29. data/app/assets/stylesheets/lcms/engine/base/_ld-colors.scss +10 -10
  30. data/app/assets/stylesheets/lcms/engine/components/_assoc-picker.scss +4 -5
  31. data/app/assets/stylesheets/lcms/engine/components/lesson/_activity.scss +6 -2
  32. data/app/assets/stylesheets/lcms/engine/components/lesson/_callout.scss +19 -5
  33. data/app/assets/stylesheets/lcms/engine/components/lesson/_columns.scss +4 -3
  34. data/app/assets/stylesheets/lcms/engine/components/lesson/_curriculum-map.scss +16 -7
  35. data/app/assets/stylesheets/lcms/engine/components/lesson/_def.scss +2 -2
  36. data/app/assets/stylesheets/lcms/engine/components/lesson/_expand.scss +9 -9
  37. data/app/assets/stylesheets/lcms/engine/components/lesson/_foundational-divider.scss +0 -1
  38. data/app/assets/stylesheets/lcms/engine/components/lesson/_group.scss +3 -1
  39. data/app/assets/stylesheets/lcms/engine/components/lesson/_icons.scss +1 -1
  40. data/app/assets/stylesheets/lcms/engine/components/lesson/_image-wrap.scss +2 -2
  41. data/app/assets/stylesheets/lcms/engine/components/lesson/_inset.scss +7 -2
  42. data/app/assets/stylesheets/lcms/engine/components/lesson/_materials.scss +1 -1
  43. data/app/assets/stylesheets/lcms/engine/components/lesson/_multiple-choice.scss +4 -1
  44. data/app/assets/stylesheets/lcms/engine/components/lesson/_override.scss +28 -9
  45. data/app/assets/stylesheets/lcms/engine/components/lesson/_pd.scss +7 -7
  46. data/app/assets/stylesheets/lcms/engine/components/lesson/_pv.scss +5 -4
  47. data/app/assets/stylesheets/lcms/engine/components/lesson/_section.scss +10 -3
  48. data/app/assets/stylesheets/lcms/engine/components/lesson/_selection-control.scss +14 -8
  49. data/app/assets/stylesheets/lcms/engine/components/lesson/_sidebar.scss +25 -10
  50. data/app/assets/stylesheets/lcms/engine/components/lesson/_title.scss +3 -1
  51. data/app/assets/stylesheets/lcms/engine/components/lesson/_unit-map.scss +1 -1
  52. data/app/assets/stylesheets/lcms/engine/components/material/_material.scss +3 -3
  53. data/app/assets/stylesheets/lcms/engine/components/material/_overlay.scss +12 -4
  54. data/app/assets/stylesheets/lcms/engine/components/material/_preview.scss +1 -1
  55. data/app/assets/stylesheets/lcms/engine/components/support/_survey.scss +3 -1
  56. data/app/assets/stylesheets/lcms/engine/layout/_footer.scss +29 -11
  57. data/app/assets/stylesheets/lcms/engine/layout/_header.scss +5 -5
  58. data/app/assets/stylesheets/lcms/engine/layout/_navigation.scss +4 -6
  59. data/app/assets/stylesheets/lcms/engine/layout/_page.scss +2 -2
  60. data/app/assets/stylesheets/lcms/engine/{admin.scss → lcms_engine_admin.scss} +26 -15
  61. data/app/assets/stylesheets/lcms/engine/lcms_engine_application.scss +9 -0
  62. data/app/assets/stylesheets/lcms/engine/pdf.scss +5 -26
  63. data/app/assets/stylesheets/lcms/engine/pdf_plain.scss +5 -23
  64. data/app/assets/stylesheets/lcms/engine/print/_base.scss +41 -12
  65. data/app/assets/stylesheets/lcms/engine/print/_cover.scss +12 -12
  66. data/app/assets/stylesheets/lcms/engine/print/_footer.scss +8 -3
  67. data/app/assets/stylesheets/lcms/engine/print/_gdoc-base.scss +10 -37
  68. data/app/assets/stylesheets/lcms/engine/print/_helpers.scss +5 -2
  69. data/app/assets/stylesheets/lcms/engine/print/_lesson-base.scss +2 -14
  70. data/app/assets/stylesheets/lcms/engine/print/_material-base.scss +1 -3
  71. data/app/assets/stylesheets/lcms/engine/print/_print.scss +15 -8
  72. data/app/assets/stylesheets/lcms/engine/print/_toc.scss +24 -9
  73. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base-typography.scss +24 -6
  74. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base.scss +10 -3
  75. data/app/assets/stylesheets/lcms/engine/print/gdoc/_colors.scss +3 -3
  76. data/app/assets/stylesheets/lcms/engine/print/gdoc/_header.scss +2 -2
  77. data/app/assets/stylesheets/lcms/engine/print/gdoc/_helpers.scss +1 -0
  78. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_activity.scss +1 -1
  79. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_agenda.scss +8 -2
  80. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_callout.scss +16 -6
  81. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_def.scss +1 -1
  82. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_dialogue.scss +3 -1
  83. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_expand.scss +5 -2
  84. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image-wrap.scss +5 -3
  85. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image.scss +1 -1
  86. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_optbreak.scss +1 -0
  87. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_section.scss +4 -1
  88. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_smp.scss +1 -0
  89. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_tables.scss +11 -3
  90. data/app/assets/stylesheets/lcms/engine/print/gdoc/material/_header.scss +5 -2
  91. data/app/assets/stylesheets/lcms/engine/print/lesson/_base-typography.scss +33 -9
  92. data/app/assets/stylesheets/lcms/engine/print/lesson/_group.scss +3 -1
  93. data/app/assets/stylesheets/lcms/engine/print/lesson/_image.scss +3 -1
  94. data/app/assets/stylesheets/lcms/engine/print/lesson/_materials.scss +1 -1
  95. data/app/assets/stylesheets/lcms/engine/print/lesson/_pd.scss +8 -4
  96. data/app/assets/stylesheets/lcms/engine/print/lesson/_section.scss +1 -1
  97. data/app/assets/stylesheets/lcms/engine/print/material/_header.scss +4 -1
  98. data/app/assets/stylesheets/lcms/engine/themes/_material.scss +11 -11
  99. data/app/assets/stylesheets/lcms/engine/utils/_colorcodes.scss +15 -5
  100. data/app/assets/stylesheets/lcms/engine/utils/_functions.scss +1 -1
  101. data/app/assets/stylesheets/lcms/engine/utils/_helpers.scss +23 -11
  102. data/app/assets/stylesheets/lcms/engine/utils/_placeholders.scss +1 -1
  103. data/app/assets/stylesheets/lcms/engine/utils/_variables.scss +11 -11
  104. data/app/assets/stylesheets/lcms/engine/vendors/{mathjax.css → mathjax.scss} +0 -0
  105. data/app/assets/stylesheets/lcms/engine/vendors/react-tagsinput.css +48 -0
  106. data/app/controllers/concerns/lcms/engine/reimportable.rb +1 -1
  107. data/app/controllers/lcms/engine/admin/access_codes_controller.rb +8 -3
  108. data/app/controllers/lcms/engine/admin/admin_controller.rb +5 -39
  109. data/app/controllers/lcms/engine/admin/association_picker_controller.rb +4 -1
  110. data/app/controllers/lcms/engine/admin/batch_reimports_controller.rb +2 -2
  111. data/app/controllers/lcms/engine/admin/curriculums_controller.rb +21 -2
  112. data/app/controllers/lcms/engine/admin/documents_controller.rb +26 -14
  113. data/app/controllers/lcms/engine/admin/materials_controller.rb +23 -13
  114. data/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +2 -2
  115. data/app/controllers/lcms/engine/admin/resources_controller.rb +9 -7
  116. data/app/controllers/lcms/engine/admin/settings_controller.rb +1 -1
  117. data/app/controllers/lcms/engine/admin/standards_controller.rb +2 -2
  118. data/app/controllers/lcms/engine/admin/users_controller.rb +10 -7
  119. data/app/controllers/lcms/engine/application_controller.rb +1 -1
  120. data/app/controllers/lcms/engine/resources_controller.rb +5 -5
  121. data/app/controllers/lcms/engine/welcome_controller.rb +11 -0
  122. data/app/entities/lcms/engine/hierarchical_position.rb +1 -2
  123. data/app/entities/lcms/engine/media_embed.rb +1 -1
  124. data/app/entities/lcms/engine/pagination.rb +14 -10
  125. data/app/entities/lcms/engine/roman_numerals.rb +1 -1
  126. data/app/exceptions/lcms/engine/document_error.rb +8 -0
  127. data/app/exceptions/lcms/engine/material_error.rb +8 -0
  128. data/app/helpers/admin/components_helper.rb +1 -1
  129. data/app/helpers/lcms/engine/path_helper.rb +32 -0
  130. data/app/helpers/lcms/engine/resource_helper.rb +1 -1
  131. data/app/helpers/lcms/engine/view_helper.rb +0 -8
  132. data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
  133. data/app/javascript/components/admin/ImportStatus.jsx +88 -58
  134. data/app/javascript/components/admin/Initializer.jsx +33 -35
  135. data/app/javascript/components/admin/MultiSelectedOperation.jsx +43 -19
  136. data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +68 -48
  137. data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +18 -7
  138. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +42 -18
  139. data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +47 -28
  140. data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +54 -33
  141. data/app/javascript/components/admin/curriculum/DirectoryPicker.jsx +80 -53
  142. data/app/javascript/components/admin/picker/PickerButton.jsx +16 -11
  143. data/app/javascript/components/admin/picker/pickerModal.jsx +6 -6
  144. data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +61 -40
  145. data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +54 -40
  146. data/app/javascript/components/admin/resource-picker/ResourcePickerResource.jsx +14 -3
  147. data/app/javascript/components/admin/resource-picker/ResourcePickerWindow.jsx +50 -21
  148. data/app/javascript/components/paginate/PageView.jsx +20 -8
  149. data/app/javascript/components/paginate/PaginationBoxView.jsx +78 -66
  150. data/app/javascript/components/paginate/PaginationListView.jsx +59 -45
  151. data/app/javascript/packs/lcms_engine_admin.js +15 -0
  152. data/app/javascript/packs/{application.js → lcms_engine_application.js} +5 -4
  153. data/app/javascript/packs/server_rendering.js +1 -0
  154. data/app/javascript/vendor/jstree/jstree.min.js +6 -0
  155. data/app/javascript/vendor/jstree/themes/default/32px.png +0 -0
  156. data/app/javascript/vendor/jstree/themes/default/40px.png +0 -0
  157. data/app/javascript/vendor/jstree/themes/default/style.css +1106 -0
  158. data/app/javascript/vendor/jstree/themes/default/style.min.css +1 -0
  159. data/app/javascript/vendor/jstree/themes/default/throbber.gif +0 -0
  160. data/app/javascript/vendor/jstree/themes/default-dark/32px.png +0 -0
  161. data/app/javascript/vendor/jstree/themes/default-dark/40px.png +0 -0
  162. data/app/javascript/vendor/jstree/themes/default-dark/style.css +1150 -0
  163. data/app/javascript/vendor/jstree/themes/default-dark/style.min.css +1 -0
  164. data/app/javascript/vendor/jstree/themes/default-dark/throbber.gif +0 -0
  165. data/app/jobs/lcms/engine/document_generate_job.rb +1 -1
  166. data/app/jobs/lcms/engine/document_generate_pdf_job.rb +5 -5
  167. data/app/jobs/lcms/engine/material_generate_pdf_job.rb +4 -4
  168. data/app/models/concerns/lcms/engine/navigable.rb +6 -10
  169. data/app/models/concerns/lcms/engine/searchable.rb +7 -0
  170. data/app/models/lcms/engine/document.rb +1 -1
  171. data/app/models/lcms/engine/resource.rb +1 -1
  172. data/app/models/lcms/engine/search/repository.rb +1 -1
  173. data/app/presenters/lcms/engine/content_presenter.rb +1 -1
  174. data/app/presenters/lcms/engine/curriculum_presenter.rb +21 -18
  175. data/app/presenters/lcms/engine/document_presenter.rb +3 -1
  176. data/app/presenters/lcms/engine/resource_presenter.rb +6 -3
  177. data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
  178. data/app/queries/lcms/engine/admin_materials_query.rb +11 -2
  179. data/app/queries/lcms/engine/base_query.rb +1 -1
  180. data/app/services/lcms/engine/document_build_service.rb +2 -0
  181. data/app/services/lcms/engine/document_generator.rb +2 -2
  182. data/app/services/lcms/engine/google/drive_service.rb +7 -15
  183. data/app/services/lcms/engine/google/script_service.rb +7 -3
  184. data/app/services/lcms/engine/html_sanitizer.rb +1 -1
  185. data/app/services/lcms/engine/lti_exporter.rb +1 -1
  186. data/app/services/lcms/engine/material_preview_generator.rb +1 -1
  187. data/app/services/lcms/engine/s3_service.rb +14 -2
  188. data/app/tasks/resource_tasks.rb +2 -2
  189. data/app/views/layouts/lcms/engine/admin.html.erb +3 -3
  190. data/app/views/layouts/lcms/engine/application.html.erb +2 -2
  191. data/app/views/layouts/lcms/engine/lti.html.erb +1 -1
  192. data/app/views/lcms/engine/admin/access_codes/_form.html.erb +1 -1
  193. data/app/views/lcms/engine/admin/access_codes/index.html.erb +3 -3
  194. data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +1 -1
  195. data/app/views/lcms/engine/admin/curriculums/edit.html.erb +4 -2
  196. data/app/views/lcms/engine/admin/documents/_reimport.html.erb +1 -1
  197. data/app/views/lcms/engine/admin/documents/_search_form.html.erb +1 -1
  198. data/app/views/lcms/engine/admin/documents/import.html.erb +1 -1
  199. data/app/views/lcms/engine/admin/documents/index.html.erb +5 -3
  200. data/app/views/lcms/engine/admin/documents/new.html.erb +6 -2
  201. data/app/views/lcms/engine/admin/materials/_reimport.html.erb +1 -1
  202. data/app/views/lcms/engine/admin/materials/_search_form.html.erb +1 -1
  203. data/app/views/lcms/engine/admin/materials/import.html.erb +1 -1
  204. data/app/views/lcms/engine/admin/materials/index.html.erb +22 -18
  205. data/app/views/lcms/engine/admin/materials/new.html.erb +5 -1
  206. data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +1 -1
  207. data/app/views/lcms/engine/admin/resources/_fields.html.erb +4 -3
  208. data/app/views/lcms/engine/admin/resources/_form.html.erb +1 -1
  209. data/app/views/lcms/engine/admin/resources/_search_form.html.erb +1 -1
  210. data/app/views/lcms/engine/admin/resources/index.html.erb +7 -5
  211. data/app/views/lcms/engine/admin/shared/_header.html.erb +12 -12
  212. data/app/views/lcms/engine/admin/standards/_form.html.erb +3 -1
  213. data/app/views/lcms/engine/admin/standards/_search_form.html.erb +1 -1
  214. data/app/views/lcms/engine/admin/users/_form.html.erb +1 -1
  215. data/app/views/lcms/engine/admin/users/_search_form.html.erb +1 -1
  216. data/app/views/lcms/engine/admin/users/index.html.erb +6 -6
  217. data/app/views/lcms/engine/pages/not_found.html.erb +5 -0
  218. data/app/views/lcms/engine/resources/generic.html.erb +0 -4
  219. data/app/views/lcms/engine/resources/media.html.erb +0 -4
  220. data/app/views/lcms/engine/resources/show.html.erb +0 -2
  221. data/config/initializers/airbrake.rb +62 -10
  222. data/config/initializers/bitly.rb +1 -1
  223. data/config/initializers/carrier_wave.rb +6 -4
  224. data/config/initializers/ckeditor.rb +6 -0
  225. data/config/initializers/elasticsearch.rb +1 -1
  226. data/config/initializers/resque.rb +2 -2
  227. data/config/locales/admin/en.yml +0 -1
  228. data/config/locales/ui/en.yml +1 -0
  229. data/config/routes.rb +5 -2
  230. data/db/migrate/.keep +0 -0
  231. data/db/schema.rb +279 -311
  232. data/db/seeds.rb +0 -1
  233. data/docker-compose.ror4.yml +32 -0
  234. data/docker-compose.yml +6 -3
  235. data/docs/env-variables.md +40 -40
  236. data/docs/google-cloud-platform-setup.md +45 -17
  237. data/docs/how-to-build-and-publish.md +1 -0
  238. data/lcms-engine.gemspec +21 -15
  239. data/lib/doc_template/document.rb +3 -4
  240. data/lib/doc_template/document_toc.rb +2 -2
  241. data/lib/doc_template/objects/activity_metadata.rb +1 -1
  242. data/lib/doc_template/objects/toc_helpers.rb +4 -4
  243. data/lib/doc_template/objects/toc_metadata.rb +4 -6
  244. data/lib/doc_template/tags/answer_space_tag.rb +1 -1
  245. data/lib/doc_template/tags/base_tag.rb +2 -2
  246. data/lib/doc_template/tags/block_tag.rb +1 -1
  247. data/lib/doc_template/tags/table_tag.rb +1 -1
  248. data/lib/doc_template/template.rb +1 -1
  249. data/lib/doc_template.rb +9 -9
  250. data/lib/document_exporter/gdoc/base.rb +5 -2
  251. data/lib/document_exporter/pdf/base.rb +1 -1
  252. data/lib/document_exporter/pdf/document.rb +2 -2
  253. data/lib/document_exporter/pdf/material.rb +2 -2
  254. data/lib/document_exporter/pdf/student_material.rb +2 -2
  255. data/lib/document_exporter/pdf/teacher_material.rb +2 -2
  256. data/lib/document_renderer/part.rb +1 -3
  257. data/lib/lcms/engine/engine.rb +10 -9
  258. data/lib/lcms/engine/version.rb +1 -1
  259. data/lib/lcms/engine.rb +0 -1
  260. data/lib/lt/lcms/metadata/context.rb +56 -52
  261. data/lib/lt/lcms/metadata/service.rb +3 -2
  262. data/lib/tasks/cloud66.rake +2 -2
  263. data/lib/tasks/document.rake +4 -4
  264. data/lib/tasks/google.rake +29 -14
  265. data/lib/tasks/lcms/engine_tasks.rake +1 -1
  266. data/package.json +31 -10
  267. data/postcss.config.js +12 -0
  268. data/spec/controllers/admin/curriculums_controller_spec.rb +23 -0
  269. data/spec/controllers/admin/documents_controller_spec.rb +22 -2
  270. data/spec/controllers/admin/materials_controller_spec.rb +16 -3
  271. data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +1 -1
  272. data/spec/controllers/admin/resources_controller_spec.rb +1 -1
  273. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  274. data/spec/controllers/admin/standards_controller_spec.rb +1 -1
  275. data/spec/controllers/admin/welcome_controller_spec.rb +12 -10
  276. data/spec/controllers/resources_controller_spec.rb +3 -3
  277. data/spec/controllers/welcome_controller_spec.rb +38 -0
  278. data/spec/dummy/.traceroute.yaml +0 -2
  279. data/spec/dummy/bin/webpack +18 -0
  280. data/spec/dummy/bin/webpack-dev-server +18 -0
  281. data/spec/dummy/config/application.rb +1 -1
  282. data/spec/dummy/config/environments/test.rb +1 -1
  283. data/spec/dummy/config/initializers/assets.rb +6 -0
  284. data/spec/dummy/config/lcms-admin.yml +3 -7
  285. data/spec/dummy/config/routes.rb +6 -0
  286. data/spec/dummy/db/schema.rb +5 -5
  287. data/spec/factories/documents.rb +1 -0
  288. data/spec/factories/downloads.rb +1 -1
  289. data/spec/factories/resources.rb +2 -2
  290. data/spec/features/admin/materials/add_material_spec.rb +2 -0
  291. data/spec/features/admin/users_spec.rb +2 -2
  292. data/spec/{controllers/admin/admin_controller_spec.rb → helpers/path_helper_spec.rb} +6 -6
  293. data/spec/lib/doc_template/objects/activity_metadata_spec.rb +1 -1
  294. data/spec/lib/doc_template/objects/agenda_metadata_spec.rb +2 -0
  295. data/spec/lib/doc_template/objects/toc_metadata_spec.rb +1 -1
  296. data/spec/lib/doc_template/tags/page_break_tag_spec.rb +1 -1
  297. data/spec/lib/doc_template/tags/pd_tag_spec.rb +1 -1
  298. data/spec/models/document_spec.rb +1 -1
  299. data/spec/models/standard_spec.rb +2 -0
  300. data/spec/queries/lcms/engine/admin_materials_query_spec.rb +34 -0
  301. data/spec/rails_helper.rb +6 -17
  302. data/spec/services/document_build_service_spec.rb +4 -11
  303. data/spec/services/s3_service_spec.rb +31 -0
  304. data/spec/support/concerns/navigable.rb +2 -0
  305. data/spec/support/routes.rb +4 -0
  306. data/spec/support/shared_examples/content_tag.rb +4 -4
  307. data/templates/routes.rb +0 -1
  308. data/yarn.lock +3412 -2933
  309. metadata +146 -288
  310. data/app/assets/stylesheets/lcms/engine/application.scss +0 -36
  311. data/app/assets/stylesheets/lcms/engine/vendors/jquery.tagsinput.css +0 -1
  312. data/app/exceptions/components_api_error.rb +0 -4
  313. data/app/exceptions/document_error.rb +0 -4
  314. data/app/exceptions/material_error.rb +0 -4
  315. data/app/javascript/packs/admin.js +0 -14
  316. data/app/models/lcms/engine/component.rb +0 -88
  317. data/app/presenters/lcms/engine/social_media_presenter.rb +0 -83
  318. data/app/views/lcms/engine/shared/_social_sharing.html.erb +0 -22
  319. data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +0 -36
  320. data/db/migrate/20200218144849_drop_material_parts_table.rb +0 -7
  321. data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +0 -7
  322. data/db/migrate/20200429130353_drop_pages.rb +0 -13
  323. data/db/seeds/pages.seeds.rb +0 -26
  324. data/lib/document_exporter.rb +0 -6
  325. data/lib/lcms/engine/migration.rb +0 -16
  326. data/spec/models/component_spec.rb +0 -60
  327. data/vendor/assets/javascripts/jquery.tagsinput.js +0 -1
data/db/seeds.rb CHANGED
@@ -7,7 +7,6 @@ seeds = %w(
7
7
  curriculums.seeds.rb
8
8
  subjects.seeds.rb
9
9
  download_categories.seeds.rb
10
- pages.seeds.rb
11
10
  development/users.seeds.rb
12
11
  development/grades.seeds.rb
13
12
  ).freeze
@@ -0,0 +1,32 @@
1
+ version: '3'
2
+ services:
3
+ db:
4
+ image: postgres:11.5-alpine
5
+ ports:
6
+ - 5432:5432
7
+ volumes:
8
+ - postgres:/var/lib/postgresql/data
9
+
10
+ redis:
11
+ image: redis:5.0.5-alpine
12
+ ports:
13
+ - 6379
14
+
15
+ app-ror4:
16
+ image: lcms-engine:ror4
17
+ # Used to install native gem which solves build errors for nokogumbo and other gems
18
+ command: bash -c "gem install nokogiri && bundle install && yarn && tail -f /dev/null"
19
+ env_file:
20
+ - spec/dummy/.env.docker
21
+ environment:
22
+ REDIS_URL: redis://redis:6379/1
23
+ volumes:
24
+ - .:/app
25
+ - bundle-ror4:/usr/local/bundle
26
+ depends_on:
27
+ - db
28
+ - redis
29
+
30
+ volumes:
31
+ bundle-ror4:
32
+ postgres:
data/docker-compose.yml CHANGED
@@ -3,17 +3,17 @@ services:
3
3
  db:
4
4
  image: postgres:11.5-alpine
5
5
  ports:
6
- - 5432:5432
6
+ - "5432:5432"
7
7
  volumes:
8
8
  - postgres:/var/lib/postgresql/data
9
9
 
10
10
  redis:
11
11
  image: redis:5.0.5-alpine
12
12
  ports:
13
- - 6379
13
+ - "6379"
14
14
 
15
15
  app:
16
- build: .
16
+ image: lcms-engine
17
17
  command: bash -c "bundle install && yarn && tail -f /dev/null"
18
18
  env_file:
19
19
  - spec/dummy/.env.docker
@@ -21,9 +21,12 @@ services:
21
21
  REDIS_URL: redis://redis:6379/1
22
22
  volumes:
23
23
  - .:/app
24
+ - ./node_modules:/app/node_modules
25
+ - bundle:/usr/local/bundle
24
26
  depends_on:
25
27
  - db
26
28
  - redis
27
29
 
28
30
  volumes:
31
+ bundle:
29
32
  postgres:
@@ -29,59 +29,59 @@
29
29
  ### AirBrake config
30
30
  The project is set up to support Airbrake, if you use it. You can provide an Airbrake ID and key in the config to enable it (Should be omitted for `development`&`test` environments)
31
31
 
32
- |Name|Description|
33
- |----|-----------|
34
- |AIR_BRAKE_PROJECT_ID|Project id in the AirBrake service|
35
- |AIR_BRAKE_PROJECT_KEY|Project key in the AirBrake service|
32
+ | Name | Description |
33
+ |-----------------------|-------------------------------------|
34
+ | AIR_BRAKE_PROJECT_ID | Project id in the AirBrake service |
35
+ | AIR_BRAKE_PROJECT_KEY | Project key in the AirBrake service |
36
36
 
37
37
  ### Amazon config
38
38
  The project uses AWS S3 to store and serve generated PDFs of learning content. You will need to set up an S3 bucket and provide a key and secret here:
39
39
 
40
- |Name|Description|
41
- |----|-----------|
42
- |AWS_ACCESS_KEY_ID|Public part of the AWS credentials|
43
- |AWS_REGION|Name of the region used for AWS service|
44
- |AWS_SECRET_ACCESS_KEY|Private part of the AWS credentials|
45
- |AWS_S3_BUCKET_NAME|Bucket used by application to store generated files|
40
+ | Name | Description |
41
+ |-----------------------|-----------------------------------------------------|
42
+ | AWS_ACCESS_KEY_ID | Public part of the AWS credentials |
43
+ | AWS_REGION | Name of the region used for AWS service |
44
+ | AWS_SECRET_ACCESS_KEY | Private part of the AWS credentials |
45
+ | AWS_S3_BUCKET_NAME | Bucket used by application to store generated files |
46
46
 
47
47
  ### Google config
48
48
  The project uses several Google products, including analytics, OAuth for allowing the application to use Google APIs, and several Google Drive folders.
49
49
 
50
- |Name|Description|
51
- |----|-----------|
52
- |GOOGLE_APPLICATION_FOLDER_ID|Id of the Google Drive folder where generated lessons and materials will be placed(It's `0B7` for url like `https://drive.google.com/drive/u/0/folders/0B7/...`)|
53
- |GOOGLE_APPLICATION_SCRIPT_ID|Id of the Google Script created to post-process generated Google documents. More details can be found [here](google-cloud-platform-setup.md)|
54
- |GOOGLE_APPLICATION_SCRIPT_FUNCTION|Name of the function to call to start post-processing|
55
- |GOOGLE_APPLICATION_TEMPLATE_PORTRAIT|Id of the Google document which is a template for portrait materials(can be identified the same way as `GOOGLE_APPLICATION_FOLDER_ID `)|
56
- |GOOGLE_APPLICATION_TEMPLATE_LANDSCAPE|Id of the Google document which is a template for landscape materials(can be identified the same way as `GOOGLE_APPLICATION_FOLDER_ID `)|
57
- |GOOGLE_APPLICATION_PREVIEW_FOLDER_ID| Folder ID where preview documents should get placed
58
- |GOOGLE_API_CLIENT_UPLOAD_RETRIES||
59
- |GOOGLE_API_CLIENT_UPLOAD_TIMEOUT||
50
+ | Name | Description |
51
+ |---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
52
+ | GOOGLE_APPLICATION_FOLDER_ID | Id of the Google Drive folder where generated lessons and materials will be placed(It's `0B7` for url like `https://drive.google.com/drive/u/0/folders/0B7/...`) |
53
+ | GOOGLE_APPLICATION_SCRIPT_ID | Id of the Google Script created to post-process generated Google documents. More details can be found [here](google-cloud-platform-setup.md) |
54
+ | GOOGLE_APPLICATION_SCRIPT_FUNCTION | Name of the function to call to start post-processing |
55
+ | GOOGLE_APPLICATION_TEMPLATE_PORTRAIT | Id of the Google document which is a template for portrait materials(can be identified the same way as `GOOGLE_APPLICATION_FOLDER_ID `) |
56
+ | GOOGLE_APPLICATION_TEMPLATE_LANDSCAPE | Id of the Google document which is a template for landscape materials(can be identified the same way as `GOOGLE_APPLICATION_FOLDER_ID `) |
57
+ | GOOGLE_APPLICATION_PREVIEW_FOLDER_ID | Folder ID where preview documents should get placed |
58
+ | GOOGLE_API_CLIENT_UPLOAD_RETRIES || |
59
+ | GOOGLE_API_CLIENT_UPLOAD_TIMEOUT || |
60
60
 
61
61
  ### Miscellaneous settings
62
- |Name|Description|
63
- |----|-----------|
64
- |APP_NAME|The title which will be shown in the page title and in other places. Something like `OpenSciEd LCMS`|
65
- |BITLY_API_TOKEN|Token of the Bitly service|
66
- |RESQUE_NAMESPACE|Value is used to separate data stored in Redis when the same redis server is used by multiple environments|
67
- |PUPPETEER_TIMEOUT|Default is 30 sec|
68
- |WORKERS_COUNT|Used on the servers. Specifies the number of workers to be started|
69
- |ELASTICSEARCH_ADDRESS|Elasticsearch server address|
62
+ | Name | Description |
63
+ |-----------------------|------------------------------------------------------------------------------------------------------------|
64
+ | APP_NAME | The title which will be shown in the page title and in other places. Something like `OpenSciEd LCMS` |
65
+ | BITLY_API_TOKEN | Token of the Bitly service |
66
+ | RESQUE_NAMESPACE | Value is used to separate data stored in Redis when the same redis server is used by multiple environments |
67
+ | PUPPETEER_TIMEOUT | Default is 30 sec |
68
+ | WORKERS_COUNT | Used on the servers. Specifies the number of workers to be started |
69
+ | ELASTICSEARCH_ADDRESS | Elasticsearch server address |
70
70
 
71
71
  Obs: if you're setting a local dev machine on OSX and getting small fonts when generating pdfs, try downgrading wkhtmltopdf to `0.12.3`
72
72
 
73
73
  ### PDF related config
74
- |Name|Description|
75
- |----|-----------|
76
- |ENABLE_BASE64_CACHING|Turns on/off caching of assets used for PDF generation (`true` by default, recommended as `false` for local env)|
77
- |NODE_ENV|We're using puppeteer(npm package) for PDF Generation, should be set as `production` for other env than local|
78
- |WKHTMLTOPDF_PATH|Path to the [wkhtmltopdf](https://wkhtmltopdf.org) binary. Default to `/usr/local/bin/wkhtmltopdf`. Will be removed when we will be certain on puppeteer|
74
+ | Name | Description |
75
+ |-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
76
+ | ENABLE_BASE64_CACHING | Turns on/off caching of assets used for PDF generation (`true` by default, recommended as `false` for local env) |
77
+ | NODE_ENV | We're using puppeteer(npm package) for PDF Generation, should be set as `production` for other env than local |
78
+ | WKHTMLTOPDF_PATH | Path to the [wkhtmltopdf](https://wkhtmltopdf.org) binary. Default to `/usr/local/bin/wkhtmltopdf`. Will be removed when we will be certain on puppeteer |
79
79
 
80
80
  ### Postgres config
81
- |Name|
82
- |----|
83
- |POSTGRESQL_ADDRESS|
84
- |POSTGRESQL_DATABASE|
85
- |POSTGRESQL_USERNAME|
86
- |POSTGRESQL_PASSWORD|
87
- |POSTGRESQL_PORT|
81
+ | Name |
82
+ |---------------------|
83
+ | POSTGRESQL_ADDRESS |
84
+ | POSTGRESQL_DATABASE |
85
+ | POSTGRESQL_USERNAME |
86
+ | POSTGRESQL_PASSWORD |
87
+ | POSTGRESQL_PORT |
@@ -1,3 +1,5 @@
1
+ # Google Cloud Platform setup
2
+
1
3
  An application calls the Google Application Script in order to post-process generated lesson materials. Instructions below contains all the necessary steps need to set up the integration.
2
4
 
3
5
  All environment variables and user names provided here have been set up to automate deployment on [Cloud66](https://www.cloud66.com) service stacks. If you plan to use another service provider please change all the variables accordingly.
@@ -7,22 +9,42 @@ All environment variables and user names provided here have been set up to autom
7
9
 
8
10
  ## Set up
9
11
 
10
- 1. Login to google (all google docs will be saved under this account)
12
+ ### Update host application's routes
13
+
14
+ In order to intercept OAuth callback host application's routes should be updated.
15
+ In the sample bellow the Engine is mounted to `/lcms` and this prefix is used in the interceptor.
16
+ You can replace it with whatever prefix has been used in your own project.
17
+ ```ruby
18
+ # config/routes.rb
19
+
20
+ mount Lcms::Engine::Engine, at: '/lcms'
21
+
22
+ # OAuth2 redirect interceptor
23
+ get 'oauth2callback', to: redirect(path: '/lcms/oauth2callback')
24
+ ```
25
+
26
+ ### Login to google
27
+
28
+ All google docs will be saved under this account. Also, this Google Account should have access to all source documents which will be imported into the system.
29
+
30
+ ### Create project
11
31
 
12
- 2. Create project (i.e. LCMS-dev) at [google cloud](https://console.cloud.google.com)
32
+ Name it whatever you like, i.e. LCMS-dev at [google cloud](https://console.cloud.google.com)
13
33
 
14
- 3. Enable Google Drive API, Google Apps Script Execution API for that [project](https://console.cloud.google.com/apis/library)
34
+ ### Enable Google API
15
35
 
16
- 4. Set up google auth
36
+ Enable Google Drive API, Google Apps Script Execution API for that [project](https://console.cloud.google.com/apis/library)
37
+
38
+ ### Set up google auth
17
39
 
18
40
  #### Credentials
19
41
 
20
42
  Create credentials:
21
43
  - type oAuth Client ID
22
- - Application type: Other,
23
- - Aplication Name: up to you, i.e. lcms-cli-dev
44
+ - Application type: Web Application,
45
+ - Application Name: up to you, i.e. lcms-cli-dev
24
46
 
25
- Download client secret JSON file.
47
+ Download credentials JSON file.
26
48
 
27
49
  ###### Local development
28
50
 
@@ -59,10 +81,11 @@ If you generate token on a remote server, then make sure you're executing comman
59
81
  $ sudo -i -u cloud66-user
60
82
  ```
61
83
 
62
- Run rake task. You will be asked to go by link, give app permissions and paste code into the terminal
84
+ Run rake task providing the domain name which is registered as _Authorized redirect URIs_ in Google OAuth client.
85
+ You will be asked to go by link, give app permissions and paste code into the terminal
63
86
 
64
87
  ```bash
65
- $ bundle exec rake google:setup_auth
88
+ $ bundle exec rake google:setup_auth["https://example.com"]
66
89
  ```
67
90
 
68
91
  This will create `config/google/app_token.yaml`. Change the ownership of the `app_token.yaml` otherwise it will not be accessible for the application:
@@ -73,23 +96,28 @@ $ chown cloud66-user:app_writers app_token.yaml
73
96
  $ sudo chmod g+w app_token.yaml
74
97
  ```
75
98
 
76
- 5. Add script
99
+ #### Add Google App script
100
+
77
101
  - go to https://www.google.com/script/start/
78
102
  - copy-paste content of `config/scripts/Code.gs` there and save
79
103
  - at top menu Resources->Cloud Platform Project set project from step 2 (you need to paste *project number*)
80
104
  - at top menu Publish->Deploy As API Executable set version v1, access Only myself
81
- - save Current API ID somewhere, click Close on that annoying window (update will not close it)
105
+ - save Current API ID somewhere (wil be used for _GOOGLE_APPLICATION_SCRIPT_ID_), click Close on that annoying window (update will not close it)
82
106
  - choose any function and run it, it'll request permissions - grant them (there will be security warnings, just ignore them)
83
107
 
84
- 6. Create folder (all materials will be saved there) on Google Drive, give view only to all by link, keep folder id (last part of url), copy to the root [LANDSCAPE](https://docs.google.com/document/d/1pXQDNKYOJYT6OTPnp8gsTWAydg5B9GTRibaWspmX4oE), [PORTRAIT](https://docs.google.com/document/d/1ijuZhGQXkPBxcZT4DRyNVY-qmI0xyVvSzVFqckOpsCc) templates and keep their IDs.
108
+ ### Create special folder in Google Drive
85
109
 
86
- 7. Update corresponding env-file in the project
110
+ All materials will be saved there. Give view only to all by link, keep folder id (last part of url) for _GOOGLE_APPLICATION_FOLDER_ID_,
111
+ copy to the root of the this folder these documents and keep their IDs for (_GOOGLE_APPLICATION_TEMPLATE_LANSCAPE_, _GOOGLE_APPLICATION_TEMPLATE_PORTRAIT_):
112
+ - [LANDSCAPE](https://docs.google.com/document/d/1pXQDNKYOJYT6OTPnp8gsTWAydg5B9GTRibaWspmX4oE)
113
+ - [PORTRAIT](https://docs.google.com/document/d/1ijuZhGQXkPBxcZT4DRyNVY-qmI0xyVvSzVFqckOpsCc)
87
114
 
115
+ ### Update corresponding env-file in the project
88
116
  ```
89
- GOOGLE_APPLICATION_FOLDER_ID=saved from step 6
90
- GOOGLE_APPLICATION_SCRIPT_ID=saved id from step 5
91
- GOOGLE_APPLICATION_TEMPLATE_PORTRAIT=saved from step 6
92
- GOOGLE_APPLICATION_TEMPLATE_LANSCAPE=saved from step 6
117
+ GOOGLE_APPLICATION_FOLDER_ID=
118
+ GOOGLE_APPLICATION_SCRIPT_ID=
119
+ GOOGLE_APPLICATION_TEMPLATE_PORTRAIT=
120
+ GOOGLE_APPLICATION_TEMPLATE_LANSCAPE=
93
121
  ```
94
122
 
95
123
  ## How to update Google Application Script
@@ -0,0 +1 @@
1
+ # How to build and publish gem
data/lcms-engine.gemspec CHANGED
@@ -15,18 +15,18 @@ Gem::Specification.new do |s|
15
15
  s.summary = 'Rails engine for LCMS applications'
16
16
  s.description = 'Implements common components and features for Rails-based LCMS systems'
17
17
  s.license = 'Apache-2.0'
18
+ s.metadata['rubygems_mfa_required'] = 'true'
18
19
 
19
20
  s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- spec/*`.split("\n")
21
21
 
22
- s.required_ruby_version = '>= 2.6'
22
+ s.required_ruby_version = '>= 2.7'
23
23
 
24
24
  s.add_dependency 'activejob-retry', '~> 0.6.3'
25
25
  s.add_dependency 'active_model_serializers', '~> 0.10.10'
26
26
  s.add_dependency 'acts_as_list', '~> 1.0'
27
- s.add_dependency 'acts-as-taggable-on', '~> 6.5'
27
+ s.add_dependency 'acts-as-taggable-on', '~> 7.0'
28
28
  s.add_dependency 'addressable', '~> 2.7'
29
- s.add_dependency 'airbrake', '~> 10.0'
29
+ s.add_dependency 'airbrake', '~> 13.0'
30
30
  s.add_dependency 'autoprefixer-rails', '~> 9.7'
31
31
  s.add_dependency 'aws-sdk-rails', '~> 3.1'
32
32
  s.add_dependency 'aws-sdk-s3', '~> 1'
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_dependency 'bootstrap-sass', '~> 3.4'
35
35
  s.add_dependency 'bullet', '~> 6.1', '>= 6.1.0'
36
36
  s.add_dependency 'carrierwave', '~> 2.1'
37
- s.add_dependency 'ckeditor', '~> 4.3'
37
+ s.add_dependency 'ckeditor', '~> 5.1'
38
38
  s.add_dependency 'closure_tree', '~> 7.1'
39
39
  s.add_dependency 'combine_pdf', '~> 1.0'
40
40
  s.add_dependency 'daemons', '~> 1.3', '>= 1.3.1'
@@ -52,31 +52,32 @@ Gem::Specification.new do |s|
52
52
  s.add_dependency 'jbuilder', '~> 2.10'
53
53
  s.add_dependency 'jquery-rails', '~> 4.3', '>= 4.3.5'
54
54
  s.add_dependency 'js-routes', '~> 1.4', '>= 1.4.9'
55
- s.add_dependency 'lt-google-api', '~> 0.2', '>= 0.2.2'
56
- s.add_dependency 'lt-lcms', '~> 0.4', '>= 0.4.1'
55
+ s.add_dependency 'lt-google-api', '~> 0.2', '>= 0.2.3'
56
+ s.add_dependency 'lt-lcms', '~> 0.4', '>= 0.4.4'
57
57
  s.add_dependency 'migration_data', '~> 0.6'
58
58
  s.add_dependency 'mini_magick', '~> 4.10', '>= 4.10.1'
59
59
  s.add_dependency 'nested_form', '~> 0.3.2'
60
60
  s.add_dependency 'nikkou', '~> 0.0.5'
61
- s.add_dependency 'nokogiri', '~> 1.10', '>= 1.10.8'
61
+ s.add_dependency 'nokogiri', '~> 1.11', '>= 1.11.4'
62
62
  s.add_dependency 'oj', '~> 3.10', '>= 3.10.2'
63
63
  s.add_dependency 'oj_mimic_json', '~> 1.0', '>= 1.0.1'
64
64
  s.add_dependency 'pandoc-ruby', '~> 2.0', '>= 2.0.2'
65
65
  s.add_dependency 'pdfjs_viewer-rails', '~> 0.3.1'
66
66
  s.add_dependency 'pg', '~> 1.2', '>= 1.2.2'
67
67
  s.add_dependency 'pg_search', '~> 2.3', '>= 2.3.2'
68
- s.add_dependency 'rack-mini-profiler', '~> 1.1', '>= 1.1.6'
69
- s.add_dependency 'rails', '~> 5.2', '>= 5.2.4'
68
+ s.add_dependency 'rack-mini-profiler', '~> 2.3', '>= 2.3.3'
69
+ s.add_dependency 'rails', '~> 6.1.6', '>= 6.1.6.1'
70
70
  s.add_dependency 'ransack', '~> 2.3', '>= 2.3.2'
71
71
  s.add_dependency 'react-rails', '~> 2.6', '>= 2.6.1'
72
72
  s.add_dependency 'redis', '~> 4.1', '>= 4.1.3'
73
73
  s.add_dependency 'resque', '~> 2.0', '>= 2.0.0'
74
74
  s.add_dependency 'resque-scheduler', '~> 4.4', '>= 4.4.0'
75
75
  s.add_dependency 'rest-client', '~> 2.1', '>= 2.1.0'
76
+ s.add_dependency 'retriable', '~> 3.1'
76
77
  s.add_dependency 'ruby-progressbar', '~> 1.10', '>= 1.10.1'
77
78
  s.add_dependency 'rubyzip', '~> 2'
78
79
  s.add_dependency 'sanitize', '>= 5.1', '< 5.3'
79
- s.add_dependency 'sass-rails', '~> 5.1', '>= 5.1.0'
80
+ s.add_dependency 'sass-rails', '~> 6'
80
81
  s.add_dependency 'simple_form', '~> 5.0', '>= 5.0.2'
81
82
  s.add_dependency 'staccato', '~> 0.5.3'
82
83
  s.add_dependency 'truncate_html', '~> 0.9.3'
@@ -85,26 +86,31 @@ Gem::Specification.new do |s|
85
86
  s.add_dependency 'virtus', '~> 1.0', '>= 1.0.5'
86
87
  s.add_dependency 'will_paginate', '~> 3.2', '>= 3.2.1'
87
88
  s.add_dependency 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.2'
89
+ s.add_dependency 'with_advisory_lock', '~> 4.6'
88
90
 
89
91
  s.add_development_dependency 'capybara', '~> 3.31'
90
92
  s.add_development_dependency 'database_cleaner-active_record', '~> 1.8'
91
93
  s.add_development_dependency 'dotenv-rails', '~> 2.2'
92
- s.add_development_dependency 'email_spec', '~> 2.1'
94
+ s.add_development_dependency 'email_spec', '2.2.0'
93
95
  s.add_development_dependency 'factory_bot', '~> 5'
94
96
  s.add_development_dependency 'faker', '~> 2.1'
95
97
  s.add_development_dependency 'overcommit', '~> 0.57'
96
98
  s.add_development_dependency 'pry-byebug', '~> 3.7'
97
99
  s.add_development_dependency 'pry-rails', '~> 0.3.5'
98
- s.add_development_dependency 'rspec-rails', '~> 3.8'
99
- s.add_development_dependency 'rubocop', '~> 0.93.1'
100
+ s.add_development_dependency 'rspec-rails', '~> 4.0.2'
101
+ s.add_development_dependency 'rubocop', '~> 1.17'
100
102
  s.add_development_dependency 'safe_attributes', '~> 1.0.10'
101
103
  s.add_development_dependency 'sdoc', '~> 2'
102
104
  s.add_development_dependency 'seedbank', '~> 0.3'
103
105
  s.add_development_dependency 'selenium-webdriver', '~> 3.142', '>= 3.142.7'
104
106
  s.add_development_dependency 'shoulda-matchers', '~> 4.1'
107
+ # Workaround for cc-test-reporter with SimpleCov 0.18.
108
+ # Stop upgrading SimpleCov until the following issue will be resolved.
109
+ # https://github.com/codeclimate/test-reporter/issues/418
110
+ s.add_development_dependency 'simplecov', '< 0.18'
105
111
  s.add_development_dependency 'spring', '~> 2.1'
106
112
  s.add_development_dependency 'spring-commands-rspec', '~> 1.0'
107
113
  s.add_development_dependency 'traceroute', '~> 0.8'
108
114
  s.add_development_dependency 'webdrivers', '~> 4.0'
109
- s.add_development_dependency 'webpacker', '~> 4.0'
115
+ s.add_development_dependency 'webpacker', '~> 5.0'
110
116
  end
@@ -62,7 +62,7 @@ module DocTemplate
62
62
  def check_loop_tag(name, value)
63
63
  if @opts.dig(:last_tag, :name) == name && @opts.dig(:last_tag, :value) == value &&
64
64
  @opts.dig(:last_tag, :iteration) > DocTemplate::Document::MAX_PARSE_ITERATIONS
65
- raise ::DocumentError, "Loop detected for tag #{name} with value #{value}"
65
+ raise ::Lcms::Engine::DocumentError, "Loop detected for tag #{name} with value #{value}"
66
66
  end
67
67
  end
68
68
 
@@ -154,7 +154,7 @@ module DocTemplate
154
154
  def handle_invalid_tag(node)
155
155
  return if ::DocTemplate::FULL_TAG.match(node.text).present?
156
156
 
157
- raise DocumentError, "No closing bracket for node:<br>#{node.to_html}"
157
+ raise Lcms::Engine::DocumentError, "No closing bracket for node:<br>#{node.to_html}"
158
158
  end
159
159
 
160
160
  def parse_node(node)
@@ -171,8 +171,7 @@ module DocTemplate
171
171
  store_last_tag tag_name, tag_value
172
172
 
173
173
  parsed_content = parsed_tag.content.presence || parsed_tag.render.to_s
174
- sanitized_content = ::DocTemplate.config['sanitizer'].constantize
175
- .post_processing(parsed_content, @opts)
174
+ sanitized_content = ::DocTemplate.sanitizer.post_processing(parsed_content, @opts)
176
175
 
177
176
  return if TAGS_WITHOUT_PARTS.include?(tag::TAG_NAME)
178
177
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocTemplate
4
- class DocumentTOC
4
+ class DocumentToc
5
5
  REGISTERED_METADATA = %i(agenda sections).freeze
6
6
  private_constant :REGISTERED_METADATA
7
7
 
@@ -11,7 +11,7 @@ module DocTemplate
11
11
  #
12
12
  def self.parse(opts = {})
13
13
  metadata = REGISTERED_METADATA.detect { |m| opts[m]&.children.present? }
14
- Objects::TOCMetadata.new opts[metadata]
14
+ Objects::TocMetadata.new opts[metadata]
15
15
  end
16
16
  end
17
17
  end
@@ -44,7 +44,7 @@ module DocTemplate
44
44
 
45
45
  attribute :children, Array[Activity]
46
46
  attribute :idx, Integer
47
- attribute :task_counter, Hash[String => Integer], default: {}
47
+ attribute :task_counter, Hash[String => Integer], default: {} # rubocop:disable Style/HashConversion
48
48
 
49
49
  def self.build_from(data)
50
50
  copy = Marshal.load Marshal.dump(data)
@@ -7,7 +7,7 @@ module DocTemplate
7
7
 
8
8
  def level1_by_title(title)
9
9
  l1 = children.find { |c| !c.handled && c.title.parameterize == title }
10
- raise DocumentError, "Level1 header #{title} not found at metadata" unless l1.present?
10
+ raise Lcms::Engine::DocumentError, "Level1 header #{title} not found at metadata" unless l1.present?
11
11
 
12
12
  l1.handled = true
13
13
  l1
@@ -18,12 +18,12 @@ module DocTemplate
18
18
  l2 = c.children.find { |c1| c1.title.parameterize == title }
19
19
  return l2 if l2.present?
20
20
  end
21
- raise DocumentError, "Level2 header #{title} not found at metadata"
21
+ raise Lcms::Engine::DocumentError, "Level2 header #{title} not found at metadata"
22
22
  end
23
23
 
24
24
  def find_by_anchor(anchor)
25
25
  l1 = children.find { |c| c.anchor == anchor }
26
- raise DocumentError, "Anchor #{anchor} not found at metadata" if l1.blank?
26
+ raise Lcms::Engine::DocumentError, "Anchor #{anchor} not found at metadata" if l1.blank?
27
27
 
28
28
  l1
29
29
  end
@@ -34,7 +34,7 @@ module DocTemplate
34
34
  # result = s.children.detect { |c| c.anchor == anchor }
35
35
  # return result if result.present?
36
36
  # end
37
- # raise DocumentError, "Anchor #{anchor} not found at metadata"
37
+ # raise Lcms::Engine::DocumentError, "Anchor #{anchor} not found at metadata"
38
38
  # end
39
39
 
40
40
  class_methods do
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DocTemplate
4
4
  module Objects
5
- class TOCMetadata
5
+ class TocMetadata
6
6
  include Virtus.model
7
7
 
8
8
  class Heading
@@ -27,19 +27,17 @@ module DocTemplate
27
27
  children.any? && children.all? { |c| c.excluded?(excludes) }
28
28
  end
29
29
 
30
- def time_with(excludes) # rubocop:disable Metrics/PerceivedComplexity
30
+ def time_with(excludes)
31
31
  # Optional and nothing to exclude explicitly
32
32
  return excludes.include?(anchor) ? time : 0 if optional
33
33
  # General and excluded explicitly
34
34
  return 0 if excludes.include?(anchor)
35
35
 
36
- # do not re-caclculate time if
36
+ # do not recalculate time if
37
37
  # - there are no optional children
38
38
  # - no excludes passed
39
39
  # - there are no children at all
40
- if children.any?(&:optional)
41
- children.sum { |c| c.time_with(excludes) }
42
- elsif children.blank? || excludes.blank?
40
+ if children.blank? || excludes.blank?
43
41
  time
44
42
  else
45
43
  children.sum { |c| c.time_with(excludes) }
@@ -14,7 +14,7 @@ module DocTemplate
14
14
  num_of_lines = SPACE_SIZE[opts[:value].try(:to_sym)]
15
15
  if num_of_lines
16
16
  space = '<br>' * num_of_lines
17
- @content = node.to_html.sub(/\[#{TAG_NAME}:\s?[s|m|l]\]/i, space)
17
+ @content = node.to_html.sub(/\[#{TAG_NAME}:\s?[sml]\]/i, space)
18
18
  end
19
19
  replace_tag node
20
20
  self
@@ -35,7 +35,7 @@ module DocTemplate
35
35
  # need to remove unicode spaces bc they're not handled by [[:graph:]]
36
36
  return unless node.content.gsub(UNICODE_SPACES_RE, '') =~ SOFT_RETURN_RE
37
37
 
38
- raise ::DocumentError,
38
+ raise ::Lcms::Engine::DocumentError,
39
39
  "Soft return for #{self.class::TAG_NAME} detected: #{node.content}, use hard return instead"
40
40
  end
41
41
 
@@ -104,7 +104,7 @@ module DocTemplate
104
104
  if node == opts[:parent_node]
105
105
  opts[:iteration] = opts[:iteration].to_i + 1
106
106
  if opts[:iteration] > DocTemplate::Document::MAX_PARSE_ITERATIONS
107
- raise ::DocumentError, "Loop detected for node:<br>#{node}"
107
+ raise ::Lcms::Engine::DocumentError, "Loop detected for node:<br>#{node}"
108
108
  end
109
109
  end
110
110
  parsed = ::DocTemplate::Document.parse(Nokogiri::HTML.fragment(node), opts.merge(level: 1))
@@ -8,7 +8,7 @@ module DocTemplate
8
8
  def no_end_tag_for(node)
9
9
  msg = "No tag with END value for: #{self.class::TAG_NAME.upcase}<br>" \
10
10
  "<em>#{node.parent.try(:inner_html)}</em>"
11
- raise DocumentError, msg
11
+ raise Lcms::Engine::DocumentError, msg
12
12
  end
13
13
 
14
14
  #
@@ -5,7 +5,7 @@ module DocTemplate
5
5
  class TableTag < BaseTag
6
6
  def parse(node, opts = {})
7
7
  unless (table = node.ancestors('table').first)
8
- raise ::DocumentError, "Tag #{self.class::TAG_NAME.upcase} placed outside table"
8
+ raise ::Lcms::Engine::DocumentError, "Tag #{self.class::TAG_NAME.upcase} placed outside table"
9
9
  end
10
10
 
11
11
  @opts = opts
@@ -101,7 +101,7 @@ module DocTemplate
101
101
  placeholder: nil
102
102
  }
103
103
 
104
- @toc ||= ::DocTemplate::DocumentTOC.parse(options) unless material?
104
+ @toc ||= ::DocTemplate::DocumentToc.parse(options) unless material?
105
105
  end
106
106
 
107
107
  self
data/lib/doc_template.rb CHANGED
@@ -60,12 +60,12 @@ module DocTemplate
60
60
  end
61
61
  end
62
62
 
63
- require_dependency 'doc_template/template'
64
- require_dependency 'doc_template/document'
65
- require_dependency 'doc_template/tags'
66
- require_dependency 'doc_template/document_toc'
67
- require_dependency 'doc_template/xpath_functions'
68
-
69
- Dir["#{__dir__}/doc_template/tables/*.rb"].each(&method(:require_dependency))
70
- Dir["#{__dir__}/doc_template/tags/*.rb"].each(&method(:require_dependency))
71
- Dir["#{__dir__}/doc_template/objects/*.rb"].each(&method(:require_dependency))
63
+ require 'doc_template/template'
64
+ require 'doc_template/document'
65
+ require 'doc_template/tags'
66
+ require 'doc_template/document_toc'
67
+ require 'doc_template/xpath_functions'
68
+
69
+ Dir["#{__dir__}/doc_template/tables/*.rb"].sort.each(&method(:require))
70
+ Dir["#{__dir__}/doc_template/tags/*.rb"].sort.each(&method(:require))
71
+ Dir["#{__dir__}/doc_template/objects/*.rb"].sort.each(&method(:require))
@@ -108,7 +108,8 @@ module DocumentExporter
108
108
  # Deletes files of previous versions
109
109
  #
110
110
  def delete_previous_versions_from(folder)
111
- drive_service.service.list_files(q: "'#{folder}' in parents").files.each do |file|
111
+ files = drive_service.service.list_files(q: "'#{folder}' in parents")&.files
112
+ Array.wrap(files).each do |file|
112
113
  next unless file.name =~ VERSION_RE
113
114
 
114
115
  drive_service.service.delete_file file.id
@@ -136,7 +137,9 @@ module DocumentExporter
136
137
  end
137
138
 
138
139
  def post_processing
139
- Lcms::Engine::Google::ScriptService.new(document).execute(@id)
140
+ Retriable.retriable(base_interval: 5, tries: 10) do
141
+ Lcms::Engine::Google::ScriptService.new(document).execute(@id)
142
+ end
140
143
  end
141
144
  end
142
145
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
4
+ module Pdf
5
5
  class Base < DocumentExporter::Base
6
6
  def self.s3_folder
7
7
  @s3_folder ||= ENV.fetch('SWAP_DOCS', 'documents')