lcms-engine 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.dockerignore +25 -0
- data/.env.docker +1 -1
- data/.eslintignore +2 -1
- data/.eslintrc +23 -73
- data/.nvmrc +1 -1
- data/.overcommit.yml +8 -2
- data/.prettierrc +7 -0
- data/.rubocop.yml +12 -8
- data/.ruby-version +1 -1
- data/.stylelintignore +9 -0
- data/.stylelintrc +8 -0
- data/CHANGELOG.md +50 -1
- data/Dockerfile +3 -3
- data/Gemfile.lock +408 -322
- data/README.md +20 -17
- data/app/assets/config/lcms_engine_manifest.js +4 -2
- data/app/assets/javascripts/lcms/engine/admin/{application.js → lcms_engine_application.js} +1 -3
- data/app/assets/javascripts/lcms/engine/initializers/foundation.js +1 -1
- data/app/assets/javascripts/lcms/engine/{application.js → lcms_engine_application.js} +0 -0
- data/app/assets/stylesheets/lcms/engine/admin/collections.scss +2 -1
- data/app/assets/stylesheets/lcms/engine/admin/components.scss +60 -19
- data/app/assets/stylesheets/lcms/engine/admin/curriculums.scss +12 -10
- data/app/assets/stylesheets/lcms/engine/admin/lessons.scss +21 -15
- data/app/assets/stylesheets/lcms/engine/admin/materials.scss +25 -17
- data/app/assets/stylesheets/lcms/engine/admin/resources.scss +8 -7
- data/app/assets/stylesheets/lcms/engine/admin/standards.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/admin/users.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/base/_colors.scss +8 -10
- data/app/assets/stylesheets/lcms/engine/base/_ld-colors.scss +10 -10
- data/app/assets/stylesheets/lcms/engine/components/_assoc-picker.scss +4 -5
- data/app/assets/stylesheets/lcms/engine/components/lesson/_activity.scss +6 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_callout.scss +19 -5
- data/app/assets/stylesheets/lcms/engine/components/lesson/_columns.scss +4 -3
- data/app/assets/stylesheets/lcms/engine/components/lesson/_curriculum-map.scss +16 -7
- data/app/assets/stylesheets/lcms/engine/components/lesson/_def.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_expand.scss +9 -9
- data/app/assets/stylesheets/lcms/engine/components/lesson/_foundational-divider.scss +0 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_group.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_icons.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_image-wrap.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_inset.scss +7 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_materials.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_multiple-choice.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_override.scss +28 -9
- data/app/assets/stylesheets/lcms/engine/components/lesson/_pd.scss +7 -7
- data/app/assets/stylesheets/lcms/engine/components/lesson/_pv.scss +5 -4
- data/app/assets/stylesheets/lcms/engine/components/lesson/_section.scss +10 -3
- data/app/assets/stylesheets/lcms/engine/components/lesson/_selection-control.scss +14 -8
- data/app/assets/stylesheets/lcms/engine/components/lesson/_sidebar.scss +25 -10
- data/app/assets/stylesheets/lcms/engine/components/lesson/_title.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_unit-map.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/material/_material.scss +3 -3
- data/app/assets/stylesheets/lcms/engine/components/material/_overlay.scss +12 -4
- data/app/assets/stylesheets/lcms/engine/components/material/_preview.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/support/_survey.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/layout/_footer.scss +29 -11
- data/app/assets/stylesheets/lcms/engine/layout/_header.scss +5 -5
- data/app/assets/stylesheets/lcms/engine/layout/_navigation.scss +4 -6
- data/app/assets/stylesheets/lcms/engine/layout/_page.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/{admin.scss → lcms_engine_admin.scss} +26 -15
- data/app/assets/stylesheets/lcms/engine/lcms_engine_application.scss +9 -0
- data/app/assets/stylesheets/lcms/engine/pdf.scss +5 -26
- data/app/assets/stylesheets/lcms/engine/pdf_plain.scss +5 -23
- data/app/assets/stylesheets/lcms/engine/print/_base.scss +41 -12
- data/app/assets/stylesheets/lcms/engine/print/_cover.scss +12 -12
- data/app/assets/stylesheets/lcms/engine/print/_footer.scss +8 -3
- data/app/assets/stylesheets/lcms/engine/print/_gdoc-base.scss +10 -37
- data/app/assets/stylesheets/lcms/engine/print/_helpers.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/_lesson-base.scss +2 -14
- data/app/assets/stylesheets/lcms/engine/print/_material-base.scss +1 -3
- data/app/assets/stylesheets/lcms/engine/print/_print.scss +15 -8
- data/app/assets/stylesheets/lcms/engine/print/_toc.scss +24 -9
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_base-typography.scss +24 -6
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_base.scss +10 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_colors.scss +3 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_header.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_helpers.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_activity.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_agenda.scss +8 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_callout.scss +16 -6
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_def.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_dialogue.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_expand.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image-wrap.scss +5 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_optbreak.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_section.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_smp.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_tables.scss +11 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/material/_header.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/lesson/_base-typography.scss +33 -9
- data/app/assets/stylesheets/lcms/engine/print/lesson/_group.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_image.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_materials.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_pd.scss +8 -4
- data/app/assets/stylesheets/lcms/engine/print/lesson/_section.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/material/_header.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/themes/_material.scss +11 -11
- data/app/assets/stylesheets/lcms/engine/utils/_colorcodes.scss +15 -5
- data/app/assets/stylesheets/lcms/engine/utils/_functions.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/utils/_helpers.scss +23 -11
- data/app/assets/stylesheets/lcms/engine/utils/_placeholders.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/utils/_variables.scss +11 -11
- data/app/assets/stylesheets/lcms/engine/vendors/{mathjax.css → mathjax.scss} +0 -0
- data/app/assets/stylesheets/lcms/engine/vendors/react-tagsinput.css +48 -0
- data/app/controllers/concerns/lcms/engine/reimportable.rb +12 -2
- data/app/controllers/lcms/engine/admin/access_codes_controller.rb +8 -3
- data/app/controllers/lcms/engine/admin/admin_controller.rb +6 -40
- data/app/controllers/lcms/engine/admin/association_picker_controller.rb +4 -1
- data/app/controllers/lcms/engine/admin/batch_reimports_controller.rb +2 -2
- data/app/controllers/lcms/engine/admin/curriculums_controller.rb +21 -2
- data/app/controllers/lcms/engine/admin/documents_controller.rb +41 -14
- data/app/controllers/lcms/engine/admin/materials_controller.rb +32 -13
- data/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +2 -2
- data/app/controllers/lcms/engine/admin/resources_controller.rb +9 -7
- data/app/controllers/lcms/engine/admin/settings_controller.rb +1 -1
- data/app/controllers/lcms/engine/admin/standards_controller.rb +7 -2
- data/app/controllers/lcms/engine/admin/users_controller.rb +15 -7
- data/app/controllers/lcms/engine/application_controller.rb +1 -1
- data/app/controllers/lcms/engine/resources_controller.rb +5 -5
- data/app/controllers/lcms/engine/welcome_controller.rb +11 -0
- data/app/entities/lcms/engine/grades.rb +17 -6
- data/app/entities/lcms/engine/hierarchical_position.rb +1 -2
- data/app/entities/lcms/engine/media_embed.rb +2 -2
- data/app/entities/lcms/engine/pagination.rb +14 -10
- data/app/entities/lcms/engine/roman_numerals.rb +2 -2
- data/app/exceptions/lcms/engine/document_error.rb +8 -0
- data/app/exceptions/lcms/engine/material_error.rb +8 -0
- data/app/forms/lcms/engine/document_form.rb +19 -14
- data/app/forms/lcms/engine/material_form.rb +3 -2
- data/app/helpers/admin/components_helper.rb +3 -3
- data/app/helpers/lcms/engine/path_helper.rb +32 -0
- data/app/helpers/lcms/engine/resource_helper.rb +1 -1
- data/app/helpers/lcms/engine/view_helper.rb +1 -9
- data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +2 -2
- data/app/javascript/components/admin/ImportStatus.jsx +90 -56
- data/app/javascript/components/admin/Initializer.jsx +33 -35
- data/app/javascript/components/admin/MultiSelectedOperation.jsx +43 -18
- data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +68 -47
- data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +18 -7
- data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +42 -17
- data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +47 -27
- data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +54 -32
- data/app/javascript/components/admin/curriculum/DirectoryPicker.jsx +80 -53
- data/app/javascript/components/admin/picker/PickerButton.jsx +16 -11
- data/app/javascript/components/admin/picker/pickerModal.jsx +6 -6
- data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +61 -40
- data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +54 -39
- data/app/javascript/components/admin/resource-picker/ResourcePickerResource.jsx +14 -3
- data/app/javascript/components/admin/resource-picker/ResourcePickerWindow.jsx +50 -21
- data/app/javascript/components/paginate/PageView.jsx +20 -8
- data/app/javascript/components/paginate/PaginationBoxView.jsx +78 -66
- data/app/javascript/components/paginate/PaginationListView.jsx +59 -45
- data/app/javascript/packs/lcms_engine_admin.js +15 -0
- data/app/javascript/packs/{application.js → lcms_engine_application.js} +5 -4
- data/app/javascript/packs/server_rendering.js +1 -0
- data/app/javascript/vendor/jstree/jstree.min.js +6 -0
- data/app/javascript/vendor/jstree/themes/default/32px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default/40px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default/style.css +1106 -0
- data/app/javascript/vendor/jstree/themes/default/style.min.css +1 -0
- data/app/javascript/vendor/jstree/themes/default/throbber.gif +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/32px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/40px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/style.css +1150 -0
- data/app/javascript/vendor/jstree/themes/default-dark/style.min.css +1 -0
- data/app/javascript/vendor/jstree/themes/default-dark/throbber.gif +0 -0
- data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -4
- data/app/jobs/lcms/engine/document_generate_gdoc_job.rb +2 -2
- data/app/jobs/lcms/engine/document_generate_job.rb +2 -2
- data/app/jobs/lcms/engine/document_generate_pdf_job.rb +5 -5
- data/app/jobs/lcms/engine/document_parse_job.rb +1 -1
- data/app/jobs/lcms/engine/material_generate_pdf_job.rb +4 -4
- data/app/models/concerns/lcms/engine/navigable.rb +6 -10
- data/app/models/concerns/lcms/engine/searchable.rb +7 -0
- data/app/models/lcms/engine/document.rb +1 -1
- data/app/models/lcms/engine/download.rb +1 -1
- data/app/models/lcms/engine/resource.rb +1 -1
- data/app/models/lcms/engine/search/document.rb +4 -3
- data/app/models/lcms/engine/search/repository.rb +1 -1
- data/app/presenters/lcms/engine/content_presenter.rb +1 -1
- data/app/presenters/lcms/engine/curriculum_presenter.rb +21 -18
- data/app/presenters/lcms/engine/document_presenter.rb +5 -3
- data/app/presenters/lcms/engine/resource_presenter.rb +6 -3
- data/app/queries/lcms/engine/admin_documents_query.rb +2 -2
- data/app/queries/lcms/engine/admin_materials_query.rb +11 -2
- data/app/queries/lcms/engine/base_query.rb +1 -1
- data/app/serializers/lcms/engine/previews_material_serializer.rb +1 -0
- data/app/services/lcms/engine/document_build_service.rb +6 -0
- data/app/services/lcms/engine/document_generator.rb +2 -2
- data/app/services/lcms/engine/google/drive_service.rb +7 -15
- data/app/services/lcms/engine/google/script_service.rb +7 -3
- data/app/services/lcms/engine/html_sanitizer.rb +6 -6
- data/app/services/lcms/engine/lessons_gdoc_bundler.rb +1 -1
- data/app/services/lcms/engine/lti_exporter.rb +1 -1
- data/app/services/lcms/engine/material_build_service.rb +6 -2
- data/app/services/lcms/engine/material_preview_generator.rb +3 -3
- data/app/services/lcms/engine/react_materials_resolver.rb +3 -2
- data/app/services/lcms/engine/s3_service.rb +14 -2
- data/app/tasks/resource_tasks.rb +2 -2
- data/app/views/layouts/lcms/engine/admin.html.erb +3 -3
- data/app/views/layouts/lcms/engine/application.html.erb +2 -2
- data/app/views/layouts/lcms/engine/lti.html.erb +1 -1
- data/app/views/lcms/engine/admin/access_codes/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/access_codes/index.html.erb +3 -3
- data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +2 -2
- data/app/views/lcms/engine/admin/curriculums/edit.html.erb +5 -5
- data/app/views/lcms/engine/admin/documents/_materials_links.html.erb +2 -2
- data/app/views/lcms/engine/admin/documents/_reimport.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/_search_form.html.erb +2 -2
- data/app/views/lcms/engine/admin/documents/import.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/index.html.erb +7 -5
- data/app/views/lcms/engine/admin/documents/new.html.erb +6 -2
- data/app/views/lcms/engine/admin/materials/_reimport.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/_search_form.html.erb +2 -2
- data/app/views/lcms/engine/admin/materials/import.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/index.html.erb +26 -22
- data/app/views/lcms/engine/admin/materials/new.html.erb +5 -1
- data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +2 -2
- data/app/views/lcms/engine/admin/resources/_fields.html.erb +4 -0
- data/app/views/lcms/engine/admin/resources/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/resources/_search_form.html.erb +2 -2
- data/app/views/lcms/engine/admin/resources/index.html.erb +7 -5
- data/app/views/lcms/engine/admin/shared/_header.html.erb +12 -12
- data/app/views/lcms/engine/admin/standards/_form.html.erb +3 -1
- data/app/views/lcms/engine/admin/standards/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/index.html.erb +6 -6
- data/app/views/lcms/engine/documents/gdoc/_agenda.html.erb +1 -1
- data/app/views/lcms/engine/documents/show.html.erb +1 -1
- data/app/views/lcms/engine/materials/show.html.erb +1 -1
- data/app/views/lcms/engine/pages/not_found.html.erb +5 -0
- data/app/views/lcms/engine/resources/_download.html.erb +2 -2
- data/app/views/lcms/engine/resources/_unit_bundles.html.erb +2 -2
- data/app/views/lcms/engine/resources/generic.html.erb +0 -4
- data/app/views/lcms/engine/resources/media.html.erb +0 -4
- data/app/views/lcms/engine/resources/show.html.erb +0 -2
- data/config/initializers/airbrake.rb +62 -10
- data/config/initializers/bitly.rb +1 -1
- data/config/initializers/carrier_wave.rb +6 -4
- data/config/initializers/ckeditor.rb +6 -0
- data/config/initializers/elasticsearch.rb +1 -1
- data/config/initializers/resque.rb +2 -2
- data/config/locales/admin/en.yml +1 -2
- data/config/locales/ui/en.yml +1 -0
- data/config/routes.rb +5 -2
- data/db/migrate/.keep +0 -0
- data/db/schema.rb +280 -312
- data/db/seeds.rb +0 -1
- data/docker-compose.ror4.yml +32 -0
- data/docker-compose.yml +6 -3
- data/docs/env-variables.md +40 -40
- data/docs/google-cloud-platform-setup.md +45 -17
- data/docs/how-to-build-and-publish.md +1 -0
- data/lcms-engine.gemspec +28 -20
- data/lib/doc_template/document.rb +3 -4
- data/lib/doc_template/document_toc.rb +2 -2
- data/lib/doc_template/objects/activity_metadata.rb +1 -1
- data/lib/doc_template/objects/agenda_metadata.rb +1 -1
- data/lib/doc_template/objects/metadata_helpers.rb +1 -1
- data/lib/doc_template/objects/toc_helpers.rb +4 -4
- data/lib/doc_template/objects/toc_metadata.rb +4 -6
- data/lib/doc_template/tables/base.rb +3 -2
- data/lib/doc_template/tags/activity_metadata_type_tag.rb +1 -1
- data/lib/doc_template/tags/answer_space_tag.rb +2 -2
- data/lib/doc_template/tags/base_tag.rb +5 -5
- data/lib/doc_template/tags/block_tag.rb +1 -1
- data/lib/doc_template/tags/columns_tag.rb +1 -1
- data/lib/doc_template/tags/def_tag.rb +1 -1
- data/lib/doc_template/tags/expand_tag.rb +1 -0
- data/lib/doc_template/tags/heading_tag.rb +1 -1
- data/lib/doc_template/tags/inset_tag.rb +2 -2
- data/lib/doc_template/tags/latex_tag.rb +1 -1
- data/lib/doc_template/tags/page_break_tag.rb +1 -1
- data/lib/doc_template/tags/pd_tag.rb +4 -4
- data/lib/doc_template/tags/section_tag.rb +2 -2
- data/lib/doc_template/tags/standard_tag.rb +3 -3
- data/lib/doc_template/tags/table_preserve_alignment_tag.rb +1 -1
- data/lib/doc_template/tags/table_tag.rb +1 -1
- data/lib/doc_template/template.rb +1 -1
- data/lib/doc_template.rb +9 -9
- data/lib/document_exporter/gdoc/base.rb +6 -3
- data/lib/document_exporter/pdf/base.rb +1 -1
- data/lib/document_exporter/pdf/document.rb +2 -2
- data/lib/document_exporter/pdf/material.rb +2 -2
- data/lib/document_exporter/pdf/student_material.rb +2 -2
- data/lib/document_exporter/pdf/teacher_material.rb +2 -2
- data/lib/document_renderer/part.rb +4 -6
- data/lib/elasticsearch/persistence/repository/response/results.rb +1 -1
- data/lib/lcms/engine/engine.rb +10 -9
- data/lib/lcms/engine/version.rb +1 -1
- data/lib/lcms/engine.rb +0 -1
- data/lib/lt/lcms/metadata/base_service.rb +2 -1
- data/lib/lt/lcms/metadata/context.rb +58 -54
- data/lib/lt/lcms/metadata/service.rb +6 -3
- data/lib/resque_job.rb +3 -6
- data/lib/standard_importer.rb +4 -4
- data/lib/tasks/cloud66.rake +8 -6
- data/lib/tasks/document.rake +7 -7
- data/lib/tasks/google.rake +29 -14
- data/lib/tasks/lcms/engine_tasks.rake +1 -1
- data/package.json +31 -9
- data/postcss.config.js +12 -0
- data/spec/controllers/admin/association_picker_controller_spec.rb +6 -8
- data/spec/controllers/admin/curriculums_controller_spec.rb +23 -0
- data/spec/controllers/admin/documents_controller_spec.rb +25 -3
- data/spec/controllers/admin/materials_controller_spec.rb +17 -4
- data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +1 -1
- data/spec/controllers/admin/resources_controller_spec.rb +3 -3
- data/spec/controllers/admin/settings_controller_spec.rb +1 -1
- data/spec/controllers/admin/standards_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +12 -10
- data/spec/controllers/resources_controller_spec.rb +3 -3
- data/spec/controllers/welcome_controller_spec.rb +38 -0
- data/spec/dummy/.env.docker +5 -0
- data/spec/dummy/.traceroute.yaml +0 -2
- data/spec/dummy/bin/webpack +18 -0
- data/spec/dummy/bin/webpack-dev-server +18 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +6 -0
- data/spec/dummy/config/lcms-admin.yml +3 -7
- data/spec/dummy/config/puma.rb +3 -3
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/db/schema.rb +5 -5
- data/spec/entities/grades_spec.rb +12 -0
- data/spec/factories/documents.rb +1 -0
- data/spec/factories/downloads.rb +1 -1
- data/spec/factories/resources.rb +2 -2
- data/spec/features/admin/lessons/add_lesson_spec.rb +3 -3
- data/spec/features/admin/materials/add_material_spec.rb +5 -3
- data/spec/features/admin/users_spec.rb +2 -2
- data/spec/forms/document_form_spec.rb +11 -1
- data/spec/{controllers/admin/admin_controller_spec.rb → helpers/path_helper_spec.rb} +6 -6
- data/spec/lib/doc_template/objects/activity_metadata_spec.rb +1 -1
- data/spec/lib/doc_template/objects/agenda_metadata_spec.rb +2 -0
- data/spec/lib/doc_template/objects/toc_metadata_spec.rb +1 -1
- data/spec/lib/doc_template/tables/shared_examples/remove_table.rb +1 -1
- data/spec/lib/doc_template/tags/page_break_tag_spec.rb +1 -1
- data/spec/lib/doc_template/tags/pd_tag_spec.rb +1 -1
- data/spec/models/document_spec.rb +1 -1
- data/spec/models/standard_spec.rb +2 -0
- data/spec/queries/lcms/engine/admin_materials_query_spec.rb +34 -0
- data/spec/rails_helper.rb +8 -2
- data/spec/services/document_build_service_spec.rb +4 -11
- data/spec/services/s3_service_spec.rb +31 -0
- data/spec/support/concerns/navigable.rb +2 -0
- data/spec/support/routes.rb +4 -0
- data/spec/support/shared_examples/content_tag.rb +4 -4
- data/templates/routes.rb +0 -1
- data/yarn.lock +3447 -2993
- metadata +208 -303
- data/app/assets/stylesheets/lcms/engine/application.scss +0 -36
- data/app/assets/stylesheets/lcms/engine/vendors/jquery.tagsinput.css +0 -1
- data/app/exceptions/components_api_error.rb +0 -4
- data/app/exceptions/document_error.rb +0 -4
- data/app/exceptions/material_error.rb +0 -4
- data/app/javascript/packs/admin.js +0 -14
- data/app/models/lcms/engine/component.rb +0 -88
- data/app/presenters/lcms/engine/social_media_presenter.rb +0 -83
- data/app/views/lcms/engine/shared/_social_sharing.html.erb +0 -22
- data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +0 -36
- data/db/migrate/20200218144849_drop_material_parts_table.rb +0 -7
- data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +0 -7
- data/db/migrate/20200429130353_drop_pages.rb +0 -13
- data/db/seeds/pages.seeds.rb +0 -26
- data/lib/document_exporter.rb +0 -6
- data/lib/lcms/engine/migration.rb +0 -16
- data/spec/models/component_spec.rb +0 -60
- data/vendor/assets/javascripts/jquery.tagsinput.js +0 -1
@@ -5,39 +5,35 @@ module Lcms
|
|
5
5
|
module Admin
|
6
6
|
class MaterialsController < AdminController
|
7
7
|
include Lcms::Engine::GoogleCredentials
|
8
|
+
include Lcms::Engine::PathHelper
|
8
9
|
include Reimportable
|
9
10
|
|
10
11
|
before_action :find_selected, only: %i(destroy_selected reimport_selected)
|
12
|
+
before_action :set_query_params
|
11
13
|
|
12
14
|
def index
|
13
|
-
@query = OpenStruct.new
|
15
|
+
@query = OpenStruct.new @query_params # rubocop:disable Style/OpenStructUse
|
14
16
|
@materials = DocTemplate.config['queries']['material'].constantize.call(@query, page: params[:page])
|
15
17
|
render_customized_view
|
16
18
|
end
|
17
19
|
|
18
20
|
def create
|
19
|
-
@material_form = DocumentGenerator.material_form.new(form_params)
|
21
|
+
@material_form = DocumentGenerator.material_form.new(form_params.except(:async))
|
20
22
|
|
21
|
-
return
|
23
|
+
return create_multiple if form_params[:link].match?(RE_GOOGLE_FOLDER)
|
22
24
|
|
23
|
-
|
24
|
-
material = @material_form.material
|
25
|
-
redirect_to AdminController.material_path(material),
|
26
|
-
notice: t('.success', name: material.name)
|
27
|
-
else
|
28
|
-
render :new
|
29
|
-
end
|
25
|
+
form_params[:async].to_i.zero? ? create_sync : create_async
|
30
26
|
end
|
31
27
|
|
32
28
|
def destroy
|
33
29
|
material = Material.find(params[:id])
|
34
30
|
material.destroy
|
35
|
-
redirect_to admin_materials_path(query:
|
31
|
+
redirect_to lcms_engine.admin_materials_path(query: @query_params), notice: t('.success')
|
36
32
|
end
|
37
33
|
|
38
34
|
def destroy_selected
|
39
35
|
count = @materials.destroy_all.count
|
40
|
-
redirect_to admin_materials_path(query:
|
36
|
+
redirect_to lcms_engine.admin_materials_path(query: @query_params), notice: t('.success', count: count)
|
41
37
|
end
|
42
38
|
|
43
39
|
def import_status
|
@@ -56,6 +52,21 @@ module Lcms
|
|
56
52
|
|
57
53
|
private
|
58
54
|
|
55
|
+
def create_async
|
56
|
+
bulk_import(Array.wrap(form_params[:link]))
|
57
|
+
render :import
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_sync
|
61
|
+
if @material_form.save
|
62
|
+
material = @material_form.material
|
63
|
+
redirect_to dynamic_material_path(material),
|
64
|
+
notice: t('lcms.engine.admin.materials.create.success', name: material.name)
|
65
|
+
else
|
66
|
+
render :new
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
59
70
|
def bulk_import(files)
|
60
71
|
jobs = {}
|
61
72
|
files.each do |url|
|
@@ -73,7 +84,7 @@ module Lcms
|
|
73
84
|
end
|
74
85
|
|
75
86
|
def form_params
|
76
|
-
params.require(:material_form).permit(:link, :source_type)
|
87
|
+
params.require(:material_form).permit(:async, :link, :source_type)
|
77
88
|
end
|
78
89
|
|
79
90
|
def gdoc_files_from(url)
|
@@ -89,6 +100,14 @@ module Lcms
|
|
89
100
|
.map { |id| ::Lt::Lcms::Lesson::Downloader::Gdoc.gdoc_file_url(id) }
|
90
101
|
end
|
91
102
|
end
|
103
|
+
|
104
|
+
def set_query_params
|
105
|
+
@query_params = params[:query]
|
106
|
+
&.permit(
|
107
|
+
:course, :lesson, :name_date, :orientation, :search_term, :search_file_name, :sort_by, :title, :type,
|
108
|
+
:unit
|
109
|
+
) || {}
|
110
|
+
end
|
92
111
|
end
|
93
112
|
end
|
94
113
|
end
|
@@ -10,7 +10,7 @@ module Lcms
|
|
10
10
|
if @resources.any?
|
11
11
|
@resource = BulkEditResourcesService.new(@resources).init_sample
|
12
12
|
else
|
13
|
-
redirect_to
|
13
|
+
redirect_to lcms_engine.admin_resources_path, alert: t('.no_resources')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -18,7 +18,7 @@ module Lcms
|
|
18
18
|
BulkEditResourcesService.new(@resources, resource_params).edit!
|
19
19
|
resources_count_msg = t(:resources_count, count: @resources.count)
|
20
20
|
notice = t('.success', count: @resources.count, resources_count: resources_count_msg)
|
21
|
-
redirect_to
|
21
|
+
redirect_to lcms_engine.admin_resources_path, notice: notice
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -4,6 +4,8 @@ module Lcms
|
|
4
4
|
module Engine
|
5
5
|
module Admin
|
6
6
|
class ResourcesController < AdminController
|
7
|
+
include Lcms::Engine::ViewHelper
|
8
|
+
|
7
9
|
CREATE_TAG_KEYS = %i(new_topic_names new_tag_names new_content_source_names
|
8
10
|
new_standard_names).freeze
|
9
11
|
CREATE_TAG_METHODS = {
|
@@ -30,7 +32,7 @@ module Lcms
|
|
30
32
|
|
31
33
|
if @resource.save
|
32
34
|
create_tags
|
33
|
-
redirect_to
|
35
|
+
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
|
34
36
|
else
|
35
37
|
render :new
|
36
38
|
end
|
@@ -50,17 +52,17 @@ module Lcms
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def bundle
|
53
|
-
return redirect_to
|
55
|
+
return redirect_to lcms_engine.admin_resources_path, notice: t('.fail') unless can_bundle?(@resource)
|
54
56
|
|
55
57
|
# see settings loaded via `lcms.yml`
|
56
58
|
generator = DocTemplate.config.dig('bundles', @resource.curriculum_type).constantize
|
57
59
|
generator.perform(@resource)
|
58
|
-
redirect_to
|
60
|
+
redirect_to lcms_engine.admin_resources_path, notice: t('.success')
|
59
61
|
end
|
60
62
|
|
61
63
|
def update
|
62
64
|
unless Settings[:editing_enabled]
|
63
|
-
return redirect_to(
|
65
|
+
return redirect_to(lcms_engine.admin_resources_path, alert: t('admin.common.editing_disabled'))
|
64
66
|
end
|
65
67
|
|
66
68
|
create_tags
|
@@ -69,8 +71,8 @@ module Lcms
|
|
69
71
|
resource_params[:standard_ids] << std.id
|
70
72
|
end
|
71
73
|
|
72
|
-
if @resource.
|
73
|
-
redirect_to
|
74
|
+
if @resource.update(resource_params)
|
75
|
+
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
|
74
76
|
else
|
75
77
|
render :edit
|
76
78
|
end
|
@@ -78,7 +80,7 @@ module Lcms
|
|
78
80
|
|
79
81
|
def destroy
|
80
82
|
@resource.destroy
|
81
|
-
redirect_to
|
83
|
+
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
|
82
84
|
end
|
83
85
|
|
84
86
|
protected
|
@@ -7,7 +7,7 @@ module Lcms
|
|
7
7
|
def toggle_editing_enabled
|
8
8
|
Settings[:editing_enabled] = !Settings[:editing_enabled]
|
9
9
|
notice = Settings[:editing_enabled] ? t('.enabled') : t('.disabled')
|
10
|
-
redirect_to
|
10
|
+
redirect_to lcms_engine.admin_resources_path, notice: notice
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -5,11 +5,12 @@ module Lcms
|
|
5
5
|
module Admin
|
6
6
|
class StandardsController < AdminController
|
7
7
|
before_action :find_standard, except: [:index]
|
8
|
+
before_action :set_query_params
|
8
9
|
|
9
10
|
def edit; end
|
10
11
|
|
11
12
|
def index
|
12
|
-
@query = OpenStruct.new
|
13
|
+
@query = OpenStruct.new @query_params # rubocop:disable Style/OpenStructUse
|
13
14
|
|
14
15
|
scope = Standard.order(:id)
|
15
16
|
scope = scope.search_by_name(@query.name) if @query.name.present?
|
@@ -19,7 +20,7 @@ module Lcms
|
|
19
20
|
|
20
21
|
def update
|
21
22
|
if @standard.update(standard_params)
|
22
|
-
redirect_to admin_standards_path, notice: t('.success')
|
23
|
+
redirect_to lcms_engine.admin_standards_path, notice: t('.success')
|
23
24
|
else
|
24
25
|
render :edit
|
25
26
|
end
|
@@ -31,6 +32,10 @@ module Lcms
|
|
31
32
|
@standard = Standard.find(params[:id])
|
32
33
|
end
|
33
34
|
|
35
|
+
def set_query_params
|
36
|
+
@query_params = params[:query]&.permit(:name) || {}
|
37
|
+
end
|
38
|
+
|
34
39
|
def standard_params
|
35
40
|
params.require(:standard).permit(:description)
|
36
41
|
end
|
@@ -5,9 +5,10 @@ module Lcms
|
|
5
5
|
module Admin
|
6
6
|
class UsersController < AdminController
|
7
7
|
before_action :find_user, except: %i(index new create)
|
8
|
+
before_action :set_query_params
|
8
9
|
|
9
10
|
def index
|
10
|
-
@query = OpenStruct.new
|
11
|
+
@query = OpenStruct.new @query_params # rubocop:disable Style/OpenStructUse
|
11
12
|
@users = users(@query)
|
12
13
|
end
|
13
14
|
|
@@ -20,30 +21,33 @@ module Lcms
|
|
20
21
|
@user.generate_password
|
21
22
|
if @user.save
|
22
23
|
@user.send_reset_password_instructions
|
23
|
-
redirect_to
|
24
|
+
redirect_to lcms_engine.admin_users_path, notice: t('.success', user: @user.email)
|
24
25
|
else
|
25
26
|
render :new
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def edit
|
30
|
+
def edit
|
31
|
+
@url = lcms_engine.admin_user_path(@user)
|
32
|
+
end
|
30
33
|
|
31
34
|
def update
|
32
|
-
if @user.
|
33
|
-
redirect_to
|
35
|
+
if @user.update(user_params)
|
36
|
+
redirect_to lcms_engine.admin_users_path, notice: t('.success', user: @user.email)
|
34
37
|
else
|
38
|
+
@url = lcms_engine.admin_user_path(@user)
|
35
39
|
render :edit
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def destroy
|
40
44
|
@user.destroy
|
41
|
-
redirect_to
|
45
|
+
redirect_to lcms_engine.admin_users_path, notice: t('.success')
|
42
46
|
end
|
43
47
|
|
44
48
|
def reset_password
|
45
49
|
@user.send_reset_password_instructions
|
46
|
-
redirect_to
|
50
|
+
redirect_to lcms_engine.admin_users_path, notice: t('.success')
|
47
51
|
end
|
48
52
|
|
49
53
|
private
|
@@ -52,6 +56,10 @@ module Lcms
|
|
52
56
|
@user = User.find(params[:id])
|
53
57
|
end
|
54
58
|
|
59
|
+
def set_query_params
|
60
|
+
@query_params = params[:query]&.permit(:access_code, :email) || {}
|
61
|
+
end
|
62
|
+
|
55
63
|
def user_params
|
56
64
|
params.require(:user).permit(:access_code, :email, :name, :role)
|
57
65
|
end
|
@@ -7,13 +7,13 @@ module Lcms
|
|
7
7
|
@resource = find_resource
|
8
8
|
|
9
9
|
# redirect to document if resource has it (#161)
|
10
|
-
return redirect_to
|
10
|
+
return redirect_to dynamic_document_path(@resource.document) if @resource.document?
|
11
11
|
|
12
12
|
# redirect grade and module to explore_curriculum (#122)
|
13
|
-
return redirect_to explore_curriculum_index_path(p: @resource.slug, e: 1) if grade_or_module?
|
13
|
+
return redirect_to lcms_engine.explore_curriculum_index_path(p: @resource.slug, e: 1) if grade_or_module?
|
14
14
|
|
15
15
|
# redirect to the path with slug if we are using just the id
|
16
|
-
return redirect_to show_with_slug_path(@resource.slug), status: 301 if using_id?
|
16
|
+
return redirect_to lcms_engine.show_with_slug_path(@resource.slug), status: 301 if using_id?
|
17
17
|
|
18
18
|
@related_instructions = related_instructions
|
19
19
|
@props = CurriculumMap.new(@resource).props
|
@@ -27,14 +27,14 @@ module Lcms
|
|
27
27
|
|
28
28
|
def media
|
29
29
|
resource = Resource.find(params[:id])
|
30
|
-
return redirect_to resource_path(resource) unless resource.media?
|
30
|
+
return redirect_to lcms_engine.resource_path(resource) unless resource.media?
|
31
31
|
|
32
32
|
@resource = MediaPresenter.new(resource)
|
33
33
|
end
|
34
34
|
|
35
35
|
def generic
|
36
36
|
resource = Resource.find(params[:id])
|
37
|
-
return redirect_to resource_path(resource) unless resource.generic?
|
37
|
+
return redirect_to lcms_engine.resource_path(resource) unless resource.generic?
|
38
38
|
|
39
39
|
@resource = GenericPresenter.new(resource)
|
40
40
|
end
|
@@ -3,7 +3,18 @@
|
|
3
3
|
module Lcms
|
4
4
|
module Engine
|
5
5
|
class WelcomeController < Lcms::Engine::ApplicationController
|
6
|
+
skip_before_action :authenticate_user!, if: -> { request.path.index('oauth2callback').present? }
|
7
|
+
|
8
|
+
OAUTH_REFERER = 'https://accounts.google.com/'
|
9
|
+
OAUTH_MESSAGE = 'Copy this code and use it to continue authorization'
|
10
|
+
|
6
11
|
def index; end
|
12
|
+
|
13
|
+
def oauth2callback
|
14
|
+
head(:not_found) && return unless request.referer == OAUTH_REFERER
|
15
|
+
|
16
|
+
render json: { text: OAUTH_MESSAGE, code: params[:code] }
|
17
|
+
end
|
7
18
|
end
|
8
19
|
end
|
9
20
|
end
|
@@ -12,31 +12,42 @@ module Lcms
|
|
12
12
|
|
13
13
|
attr_reader :model
|
14
14
|
|
15
|
+
class << self
|
16
|
+
def grades
|
17
|
+
::Lcms::Engine::Grades::GRADES
|
18
|
+
end
|
19
|
+
|
20
|
+
def grades_abbrevs
|
21
|
+
::Lcms::Engine::Grades::GRADES_ABBR
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
15
25
|
def initialize(model)
|
16
26
|
@model = model
|
17
27
|
end
|
18
28
|
|
19
29
|
def list
|
20
|
-
@list ||=
|
30
|
+
@list ||= case model
|
31
|
+
when Resource
|
21
32
|
Array.wrap model.metadata['grade']
|
22
|
-
|
33
|
+
when Search::Document
|
23
34
|
Array.wrap model.grade.presence
|
24
35
|
else
|
25
36
|
model.grade_list
|
26
|
-
end.sort_by { |g|
|
37
|
+
end.sort_by { |g| self.class.grades.index(g) }
|
27
38
|
end
|
28
39
|
|
29
40
|
def average(abbr: true)
|
30
41
|
return nil if average_number.nil?
|
31
42
|
|
32
|
-
avg =
|
43
|
+
avg = self.class.grades[average_number]
|
33
44
|
abbr ? (grade_abbr(avg) || 'base') : avg
|
34
45
|
end
|
35
46
|
|
36
47
|
def average_number
|
37
48
|
return nil if list.empty?
|
38
49
|
|
39
|
-
list.map { |g|
|
50
|
+
list.map { |g| self.class.grades.index(g) }.sum / (list.size.nonzero? || 1)
|
40
51
|
end
|
41
52
|
|
42
53
|
def grade_abbr(abbr)
|
@@ -62,7 +73,7 @@ module Lcms
|
|
62
73
|
abbr = grade_abbr(g).upcase
|
63
74
|
|
64
75
|
# if the current grade is subsequent we store on the same chain
|
65
|
-
if idx.zero? ||
|
76
|
+
if idx.zero? || self.class.grades.index(g) == self.class.grades.index(prev) + 1
|
66
77
|
chain << abbr
|
67
78
|
else
|
68
79
|
# the grade is not subsequent, so we store the current chain, and create a new one
|
@@ -75,8 +75,7 @@ module Lcms
|
|
75
75
|
val = resource.lesson? ? resource.level_position : nil
|
76
76
|
return val if val
|
77
77
|
|
78
|
-
|
79
|
-
lesson =~ lesson.try(:match, /(\d+)/).try(:[], 1).to_i
|
78
|
+
resource.metadata['lesson'].to_s.match(/(\d+)/)&.captures&.first.to_i
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
@@ -8,7 +8,7 @@ module Lcms
|
|
8
8
|
def self.soundcloud(url, subject)
|
9
9
|
color = SUBJECT_COLORS[subject || :default]
|
10
10
|
oembed_url = "http://soundcloud.com/oembed?url=#{url}&iframe=true&maxheight=166&" \
|
11
|
-
|
11
|
+
"color=#{color}&auto_play=false&format=json"
|
12
12
|
RestClient.get(oembed_url) do |response|
|
13
13
|
if response.code == 200
|
14
14
|
oembed = JSON.parse(response)['html']
|
@@ -26,7 +26,7 @@ module Lcms
|
|
26
26
|
when /vimeo\.com/
|
27
27
|
url.match(%r{https?://(www\.)?vimeo.com/(\d+)}).try(:[], 2)
|
28
28
|
when /youtu\.be/
|
29
|
-
url.match(%r{https?://(www\.)?youtu\.be/([^"
|
29
|
+
url.match(%r{https?://(www\.)?youtu\.be/([^"&?/]+)}).try(:[], 2)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -28,17 +28,21 @@ module Lcms
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def serialize(resources, serializer)
|
31
|
-
options = {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
options = {
|
32
|
+
adapter: :json,
|
33
|
+
each_serializer: serializer,
|
34
|
+
meta_key: {
|
35
|
+
pagination: {
|
36
|
+
total_pages: resources.total_pages,
|
37
|
+
current_page: resources.current_page,
|
38
|
+
per_page: resources.per_page,
|
39
|
+
order: params[:order],
|
40
|
+
total_hits: resources.total_entries
|
41
|
+
}
|
42
|
+
},
|
43
|
+
root: :results
|
39
44
|
}
|
40
|
-
options
|
41
|
-
ActiveModel::Serializer::CollectionSerializer.new(resources, options).as_json
|
45
|
+
ActiveModelSerializers::SerializableResource.new(resources, options).as_json
|
42
46
|
end
|
43
47
|
|
44
48
|
private
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Lcms
|
4
4
|
module Engine
|
5
5
|
class RomanNumerals
|
6
|
-
ROMAN_NUMERALS_RE = /^(M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I)
|
6
|
+
ROMAN_NUMERALS_RE = /^(M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I)/.freeze
|
7
7
|
SYMBOLS = [
|
8
8
|
[1000, 'M'],
|
9
9
|
[900, 'CM'],
|
@@ -28,7 +28,7 @@ module Lcms
|
|
28
28
|
num -= arab
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end.join
|
31
|
+
end.join
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.from_roman(roman)
|
@@ -13,7 +13,7 @@ module Lcms
|
|
13
13
|
validates_presence_of :link, if: -> { link_fs.blank? }
|
14
14
|
validates_presence_of :link_fs, if: -> { link.blank? }
|
15
15
|
|
16
|
-
attr_reader :document
|
16
|
+
attr_reader :document, :service_errors
|
17
17
|
|
18
18
|
def initialize(attributes = {}, opts = {})
|
19
19
|
@is_reimport = attributes.delete(:reimport).present? || false
|
@@ -29,7 +29,7 @@ module Lcms
|
|
29
29
|
@document.update(reimported: true)
|
30
30
|
rescue StandardError => e
|
31
31
|
@document&.update(reimported: false)
|
32
|
-
Rails.logger.error e.message
|
32
|
+
Rails.logger.error "#{e.message}\n #{e.backtrace.join("\n ")}"
|
33
33
|
errors.add(:link, e.message)
|
34
34
|
false
|
35
35
|
end
|
@@ -45,18 +45,23 @@ module Lcms
|
|
45
45
|
def build_document
|
46
46
|
service = document_build_service
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
result =
|
49
|
+
if is_reimport
|
50
|
+
doc = service.build_for(link)
|
51
|
+
doc = service.build_for(link_fs, expand: true) if link_fs.present?
|
52
|
+
doc
|
53
|
+
elsif (full_doc = find_full_document)
|
54
|
+
# if there is a document with the same file_id or foundational_file_id
|
55
|
+
# we need to make full re-import to correctly handle expand process
|
56
|
+
service.build_for(full_doc.file_url)
|
57
|
+
service.build_for(full_doc.file_fs_url, expand: true)
|
58
|
+
else
|
59
|
+
service.build_for link
|
60
|
+
end
|
61
|
+
|
62
|
+
@service_errors = service.errors
|
63
|
+
|
64
|
+
result
|
60
65
|
end
|
61
66
|
|
62
67
|
def document_build_service
|
@@ -11,7 +11,7 @@ module Lcms
|
|
11
11
|
attribute :source_type, String
|
12
12
|
validates :link, presence: true
|
13
13
|
|
14
|
-
attr_accessor :material
|
14
|
+
attr_accessor :material, :service_errors
|
15
15
|
|
16
16
|
def initialize(attributes = {}, opts = {})
|
17
17
|
super(attributes)
|
@@ -28,12 +28,13 @@ module Lcms
|
|
28
28
|
}.compact
|
29
29
|
service = MaterialBuildService.new google_credentials, params
|
30
30
|
@material = service.build link
|
31
|
+
@service_errors = service.errors
|
31
32
|
|
32
33
|
material.update preview_links: {}
|
33
34
|
after_reimport_hook
|
34
35
|
true
|
35
36
|
rescue StandardError => e
|
36
|
-
Rails.logger.error e.message
|
37
|
+
Rails.logger.error "#{e.message}\n #{e.backtrace.join("\n ")}"
|
37
38
|
errors.add(:link, e.message)
|
38
39
|
false
|
39
40
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module Admin
|
4
4
|
module ComponentsHelper
|
5
|
-
HIDDEN_FIELD_RE = /\b(?<=name=")[^"]+(?=")
|
5
|
+
HIDDEN_FIELD_RE = /\b(?<=name=")[^"]+(?=")/.freeze
|
6
6
|
|
7
|
-
def resource_picker_field(form, collection,
|
7
|
+
def resource_picker_field(form, collection, path:, name:, allow_multiple: true)
|
8
8
|
path = path.to_s
|
9
9
|
|
10
10
|
base_name = form.hidden_field(name).scan(HIDDEN_FIELD_RE)[0]
|
@@ -60,7 +60,7 @@ module Admin
|
|
60
60
|
id: resource.parent_id,
|
61
61
|
title: resource.parent.try(:title)
|
62
62
|
},
|
63
|
-
|
63
|
+
path: lcms_engine_url_helpers.children_admin_curriculum_path
|
64
64
|
}
|
65
65
|
end
|
66
66
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lcms
|
4
|
+
module Engine
|
5
|
+
module PathHelper
|
6
|
+
include Rails.application.routes.url_helpers
|
7
|
+
|
8
|
+
def dynamic_path(path, *args)
|
9
|
+
host_engine_path(path, *args).presence || main_app.send(path.to_sym, *args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def dynamic_document_path(*args)
|
13
|
+
host_engine_path(:document_path, *args).presence || main_app.document_path(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def dynamic_material_path(*args)
|
17
|
+
host_engine_path(:material_path, *args).presence || main_app.material_path(*args)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def host_engine_path(key, *args)
|
23
|
+
settings = Lcms::Engine::Admin::AdminController.settings
|
24
|
+
if (host_route = settings.dig(:redirect, :host, key)).present?
|
25
|
+
main_app.send(host_route.to_sym, *args)
|
26
|
+
elsif (engine_route = settings.dig(:redirect, :engine, key)).present?
|
27
|
+
lcms_engine.send(engine_route.to_sym, *args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -97,14 +97,6 @@ module Lcms
|
|
97
97
|
strip_tags(str).squish
|
98
98
|
end
|
99
99
|
|
100
|
-
def set_social_media_sharing(target) # rubocop:disable Naming/AccessorMethodName
|
101
|
-
@social_media_presenter = SocialMediaPresenter.new(target: target, view: self)
|
102
|
-
end
|
103
|
-
|
104
|
-
def social_media
|
105
|
-
@social_media_presenter || SocialMediaPresenter.new(target: nil, view: self)
|
106
|
-
end
|
107
|
-
|
108
100
|
def color_code(model, base: false)
|
109
101
|
subject_color_code = model.try(:subject) || 'default'
|
110
102
|
grade_avg = base ? 'base' : model.grades.average
|
@@ -116,7 +108,7 @@ module Lcms
|
|
116
108
|
return unless selected_ids.present?
|
117
109
|
|
118
110
|
case selected_ids
|
119
|
-
when Array
|
111
|
+
when Array
|
120
112
|
selected_ids.include?(id.to_s)
|
121
113
|
else
|
122
114
|
selected_ids.split(',').include?(id.to_s)
|