lcms-engine 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -1
- data/Dockerfile +28 -0
- data/Gemfile +2 -1
- data/README.md +23 -17
- data/app/assets/config/lcms_engine_manifest.js +1 -8
- data/app/assets/javascripts/lcms/engine/admin/application.js +6 -3
- data/app/assets/javascripts/lcms/engine/application.js +0 -2
- data/app/assets/javascripts/lcms/engine/application_lti.js +0 -2
- data/app/assets/stylesheets/lcms/engine/components/_instruction-cards.scss +0 -3
- data/app/controllers/lcms/engine/admin/admin_controller.rb +4 -4
- data/app/helpers/lcms/engine/view_helper.rb +0 -4
- data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +2 -0
- data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +2 -0
- data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +1 -1
- data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +1 -1
- data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +2 -2
- data/app/javascript/components/paginate/PaginationBoxView.jsx +1 -1
- data/app/javascript/components/paginate/PaginationListView.jsx +1 -1
- data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -1
- data/app/jobs/lcms/engine/material_generate_job.rb +1 -1
- data/app/models/concerns/lcms/engine/partable.rb +27 -0
- data/app/models/lcms/engine/document.rb +3 -7
- data/app/models/lcms/engine/document_part.rb +1 -1
- data/app/models/lcms/engine/material.rb +2 -6
- data/app/presenters/lcms/engine/content_presenter.rb +9 -5
- data/app/presenters/lcms/engine/document_presenter.rb +7 -11
- data/app/presenters/lcms/engine/material_presenter.rb +1 -11
- data/app/services/lcms/engine/document_build_service.rb +1 -17
- data/app/services/lcms/engine/material_build_service.rb +3 -12
- data/app/views/layouts/lcms/engine/application.html.erb +0 -4
- data/app/views/layouts/lcms/engine/lti.html.erb +0 -4
- data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +36 -0
- data/db/migrate/20200218144849_drop_material_parts_table.rb +7 -0
- data/db/schema.rb +9 -22
- data/docker-compose.yml +29 -0
- data/lcms-engine.gemspec +25 -26
- data/lib/doc_template/tags/base_tag.rb +1 -1
- data/lib/document_exporter/base.rb +1 -4
- data/lib/lcms/engine/engine.rb +5 -4
- data/lib/lcms/engine/version.rb +1 -1
- data/lib/lt/lcms/metadata/context.rb +1 -1
- data/spec/controllers/admin/admin_controller_spec.rb +31 -0
- data/spec/dummy/.env.docker +5 -0
- data/spec/dummy/config/database.yml +1 -1
- data/spec/dummy/config/lcms-admin.yml +3 -3
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +10 -23
- data/spec/factories/document_parts.rb +1 -1
- data/spec/lib/doc_template/tags/base_tag_spec.rb +36 -0
- data/yarn.lock +3 -3
- metadata +131 -121
- data/app/assets/javascripts/lcms/engine/generated/translations.js +0 -40
- data/app/assets/javascripts/lcms/engine/pdf_js_preview.js +0 -52
- data/vendor/assets/javascripts/pdf.js +0 -10902
- data/vendor/assets/javascripts/pdf.worker.js +0 -43104
- data/vendor/assets/javascripts/pdfobject.js +0 -254
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231320b0501e5b869cb18ddfbd9303ff59a46f5cbe4d1c1dde514e3e142d0fbc
|
4
|
+
data.tar.gz: f9a52a55bcdfe1ac8d35a094a744489ab22e683a3ddfab0dc65c8c5fe65f7123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d864539ad2e681823e9801be80b1ee16051970d4610a197e49e662953bba740a38aa86476a6e43f11427623a3bc6cab63186964792e9452fcaac769f64f23281
|
7
|
+
data.tar.gz: 996c695e355795f92897b07c39788c9aa1fbe1d9a666d82089175b96a850b847533557f8b7ee2dd7f6347c4a5b10a570a8355a706230077eeb25943ad45437d5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.7
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,23 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [
|
7
|
+
## [0.1.2](https://github.com/learningtapestry/lcms-engine/compare/v0.1.0...v0.1.2) - 2020.04.23
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- Add Docker support [@paranoicsan](https://github.com/paranoicsan)
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Assets optimization [@paranoicsan](https://github.com/paranoicsan)
|
14
|
+
- Replace [capybara-selenium](https://github.com/dsaenztagarro/capybara-selenium) with [selenium-webdriver](https://rubygems.org/gems/selenium-webdriver) [@paranoicsan](https://github.com/paranoicsan)
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
- Remove [I18n.js gem](https://github.com/fnando/i18n-js) [@paranoicsan](https://github.com/paranoicsan)
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Fix preview path on admin panel documents and materials index page [@paranoicsan](https://github.com/paranoicsan)
|
21
|
+
- Fix parse loop when content of the tag contains tag name [@paranoicsan](https://github.com/paranoicsan)
|
22
|
+
- Fix possible grade leading zeros [@shlag3n](https://github.com/shlag3n)
|
23
|
+
- Fix nested jobs concern [@shlag3n](https://github.com/shlag3n)
|
8
24
|
|
9
25
|
## [0.1.0] - 2020.01.13
|
10
26
|
|
data/Dockerfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
FROM ruby:2.5.7
|
2
|
+
|
3
|
+
ENV APP_PATH /app/
|
4
|
+
|
5
|
+
WORKDIR $APP_PATH
|
6
|
+
|
7
|
+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
8
|
+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
|
9
|
+
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
|
10
|
+
&& apt-get update -qqy \
|
11
|
+
&& apt-get install -y --no-install-recommends nodejs yarn \
|
12
|
+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
13
|
+
|
14
|
+
# Add codebase
|
15
|
+
ADD . $APP_PATH
|
16
|
+
|
17
|
+
# Install gems
|
18
|
+
ADD lcms-engine.gemspec $APP_PATH
|
19
|
+
ADD Gemfile* $APP_PATH
|
20
|
+
RUN gem install bundler -v 1.17.3 \
|
21
|
+
&& bundle install --jobs `expr $(cat /proc/cpuinfo | grep -c "cpu cores") - 1` --retry 3 \
|
22
|
+
&& rm -rf /usr/local/bundle/cache/*.gem \
|
23
|
+
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
|
24
|
+
&& find /usr/local/bundle/gems/ -name "*.o" -delete
|
25
|
+
|
26
|
+
# Install yarn packages
|
27
|
+
COPY package.json yarn.lock $APP_PATH
|
28
|
+
RUN yarn install
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,11 @@ separately, simplifying the client applications in the process.
|
|
11
11
|
|
12
12
|
## Current development
|
13
13
|
|
14
|
+
|Branch|Rails version|
|
15
|
+
|------|-------------|
|
16
|
+
|master|Rails 5.2.4.2|
|
17
|
+
|0.1.x|Rails 4.2.11|
|
18
|
+
|
14
19
|
This is still a [work in progress](https://github.com/learningtapestry/lcms-engine/issues/3). The
|
15
20
|
initial phase of the project consisted in extracting as much code as possible from the client
|
16
21
|
projects and set the engine as the core foundation for further development and optimizations.
|
@@ -26,18 +31,6 @@ options.
|
|
26
31
|
The following are a few recommendations and guidelines to keep in mind when modifying code in the
|
27
32
|
engine as well as making the client projects aware of these changes.
|
28
33
|
|
29
|
-
## Targeting Rails versions
|
30
|
-
|
31
|
-
For the most part, the engine targets Rails version 5, but it's also compatible with version 4.2.
|
32
|
-
|
33
|
-
So far, we have not encountered any major obstacles to guarantee compatibility with both versions,
|
34
|
-
but in some cases we can all agree that total compatibility can be difficult to achieve.
|
35
|
-
|
36
|
-
Overall, it's fine to add a few conditionals here and there to check the running version of the
|
37
|
-
framework, like [in this case](https://github.com/learningtapestry/lcms-engine/blob/master/lib/lcms/engine/migration.rb).
|
38
|
-
However, when you feel you're adding too many conditionals, perhaps it's time to consider creating
|
39
|
-
specific versions that cater to individual Rails releases.
|
40
|
-
|
41
34
|
## Use of separate gems
|
42
35
|
|
43
36
|
In our opinion, the creation of separate gems in a given project only makes sense when the features
|
@@ -90,14 +83,14 @@ the same files, overwriting the ones provided by the engine.
|
|
90
83
|
|
91
84
|
## Requirements
|
92
85
|
- Ruby 2.5 or higher
|
93
|
-
- Rails 4.2
|
86
|
+
- Rails 4.2.11.x
|
94
87
|
- Postgres 9.6 or higher
|
95
88
|
|
96
89
|
## Installation
|
97
90
|
Include the gem in your Gemfile:
|
98
91
|
|
99
92
|
```ruby
|
100
|
-
gem 'lcms-engine', git: 'https://github.com/learningtapestry/lcms-engine.git', branch: '
|
93
|
+
gem 'lcms-engine', git: 'https://github.com/learningtapestry/lcms-engine.git', branch: '0.1.x'
|
101
94
|
```
|
102
95
|
|
103
96
|
And then execute:
|
@@ -192,7 +185,7 @@ All migrations included in the gem are already available for you to run from ins
|
|
192
185
|
|
193
186
|
You need to run special rake task if default routes were overridden
|
194
187
|
```bash
|
195
|
-
bundle exec rake js-routes:generate
|
188
|
+
$ bundle exec rake js-routes:generate
|
196
189
|
```
|
197
190
|
|
198
191
|
## Developing and testing
|
@@ -206,10 +199,23 @@ connection (see `spec/dummy/.env` as a template)
|
|
206
199
|
`chromedriver` is required to run feature specs. You may find OS-specific instructions [here](https://sites.google.com/a/chromium.org/chromedriver/getting-started).
|
207
200
|
For macOS it can be installed with Homebrew:
|
208
201
|
|
202
|
+
```bash
|
203
|
+
$ brew tap homebrew/cask
|
204
|
+
$ brew cask install chromedriver
|
205
|
+
```
|
206
|
+
|
207
|
+
#### Using Docker
|
208
|
+
|
209
|
+
Launch the containers
|
210
|
+
```sh
|
211
|
+
$ docker-compose start app
|
212
|
+
```
|
213
|
+
|
214
|
+
Start the specs
|
209
215
|
```sh
|
210
|
-
|
211
|
-
brew cask install chromedriver
|
216
|
+
$ docker-compose exec app sh -c 'bundle exec rspec'
|
212
217
|
```
|
213
218
|
|
219
|
+
|
214
220
|
## License
|
215
221
|
The gem is available as open source under the terms of the [Apache License](https://github.com/learningtapestry/lcms-engine/blob/master/LICENSE).
|
@@ -1,15 +1,8 @@
|
|
1
1
|
// JS and CSS bundles
|
2
2
|
|
3
|
-
//= link lcms/engine/application.js
|
4
|
-
//= link lcms/engine/application_lti.js
|
5
|
-
//= link lcms/engine/pdf_js_preview.js
|
6
|
-
//= link pdf.worker.js
|
3
|
+
//= link lcms/engine/admin/application.js
|
7
4
|
|
8
|
-
// TODO: Need to rebundle according to requirements
|
9
|
-
//= link lcms/engine/application.scss
|
10
5
|
//= link lcms/engine/admin.scss
|
11
|
-
//= link lcms/engine/pdf.scss
|
12
|
-
//= link lcms/engine/pdf_plain.scss
|
13
6
|
|
14
7
|
// Images and fonts so that views can link to them
|
15
8
|
//
|
@@ -2,7 +2,6 @@
|
|
2
2
|
//= require jquery2
|
3
3
|
//= require jquery_ujs
|
4
4
|
//= require jquery_nested_form
|
5
|
-
//= require i18n/translations
|
6
5
|
//= require lodash
|
7
6
|
//= require foundation.initialize
|
8
7
|
//= require ckeditor/init
|
@@ -14,7 +13,6 @@
|
|
14
13
|
//= require jquery.tagsinput
|
15
14
|
//= require jstree
|
16
15
|
//= require js-routes
|
17
|
-
//= require ../initializers/google_analytics
|
18
16
|
|
19
17
|
document.addEventListener('turbolinks:load', function () {
|
20
18
|
$(document).initFoundation();
|
@@ -24,5 +22,10 @@ document.addEventListener('turbolinks:load', function () {
|
|
24
22
|
plugins: ['remove_button']
|
25
23
|
});
|
26
24
|
|
27
|
-
window.
|
25
|
+
if (window.ga) {
|
26
|
+
ga('set', 'location', location.href.split('#')[0]);
|
27
|
+
ga('send', 'pageview', {
|
28
|
+
"title": document.title
|
29
|
+
});
|
30
|
+
}
|
28
31
|
});
|
@@ -1,10 +1,8 @@
|
|
1
1
|
//= require turbolinks
|
2
2
|
//= require jquery2
|
3
3
|
//= require jquery_ujs
|
4
|
-
//= require i18n/translations
|
5
4
|
//= require modernizr-custom
|
6
5
|
//= require swiper.jquery
|
7
|
-
//= require pdfobject.js
|
8
6
|
//= require smoothscrolling
|
9
7
|
//= require lodash
|
10
8
|
//= require foundation
|
@@ -1,10 +1,8 @@
|
|
1
1
|
//= require turbolinks
|
2
2
|
//= require jquery2
|
3
3
|
//= require jquery_ujs
|
4
|
-
//= require i18n/translations
|
5
4
|
//= require modernizr-custom
|
6
5
|
//= require swiper.jquery
|
7
|
-
//= require pdfobject.js
|
8
6
|
//= require smoothscrolling
|
9
7
|
//= require lodash
|
10
8
|
//= require foundation.initialize
|
@@ -25,11 +25,11 @@ module Lcms
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def document_path(*args)
|
28
|
-
host_engine_path(:document_path, args).presence || url_helpers.document_path(args)
|
28
|
+
host_engine_path(:document_path, *args).presence || url_helpers.document_path(*args)
|
29
29
|
end
|
30
30
|
|
31
31
|
def material_path(*args)
|
32
|
-
host_engine_path(:material_path, args).presence || url_helpers.material_path(args)
|
32
|
+
host_engine_path(:material_path, *args).presence || url_helpers.material_path(*args)
|
33
33
|
end
|
34
34
|
|
35
35
|
def root_path
|
@@ -38,9 +38,9 @@ module Lcms
|
|
38
38
|
|
39
39
|
def host_engine_path(key, *args)
|
40
40
|
if (host_route = settings.dig(:redirect, :host, key)).present?
|
41
|
-
Rails.application.routes.url_helpers.send(host_route, args)
|
41
|
+
Rails.application.routes.url_helpers.send(host_route, *args)
|
42
42
|
elsif (engine_route = settings.dig(:redirect, :engine, key)).present?
|
43
|
-
engine_klass.routes.url_helpers.send(engine_route, args)
|
43
|
+
engine_klass.routes.url_helpers.send(engine_route, *args)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -99,10 +99,6 @@ module Lcms
|
|
99
99
|
strip_tags(str).squish
|
100
100
|
end
|
101
101
|
|
102
|
-
def generic_page?
|
103
|
-
controller.controller_name == 'resources' && controller.action_name == 'generic'
|
104
|
-
end
|
105
|
-
|
106
102
|
def set_social_media_sharing(target) # rubocop:disable Naming/AccessorMethodName
|
107
103
|
@social_media_presenter = SocialMediaPresenter.new(target: target, view: self)
|
108
104
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import ReactDOM from 'react-dom'
|
3
3
|
import ResourcePickerWindow from './ResourcePickerWindow'
|
4
|
-
|
5
|
-
|
4
|
+
import ResourcePickerResource from './ResourcePickerResource'
|
5
|
+
import PickerButton from '../picker/PickerButton'
|
6
6
|
import pickerWindowWrapper from '../picker/pickerWindowWrapper'
|
7
7
|
import pickerModal from '../picker/pickerModal'
|
8
8
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import React from 'react'
|
4
4
|
import PropTypes from 'prop-types'
|
5
|
-
|
5
|
+
import PaginationListView from './PaginationListView'
|
6
6
|
import classNames from 'classnames'
|
7
7
|
|
8
8
|
class PaginationBoxView extends React.Component {
|
@@ -7,7 +7,7 @@ module Lcms
|
|
7
7
|
|
8
8
|
class_methods do # rubocop:disable Metrics/BlockLength
|
9
9
|
def queued_or_running_nested?(job_id, current_job_id = -1)
|
10
|
-
check_child = ->(j) { j['arguments'][1]
|
10
|
+
check_child = ->(j) { j['arguments'][1]&.dig('initial_job_id') == job_id && j['job_id'] != current_job_id }
|
11
11
|
job_klasses = self::NESTED_JOBS + [name]
|
12
12
|
job_klasses.each do |job_klass|
|
13
13
|
queued = find_in_queue_by_payload(job_klass, &check_child) ||
|
@@ -9,7 +9,7 @@ module Lcms
|
|
9
9
|
|
10
10
|
def perform(material, document)
|
11
11
|
if document.math?
|
12
|
-
material.
|
12
|
+
material.document_parts.default.each { |p| p.update!(content: EmbedEquations.call(p.content)) }
|
13
13
|
end
|
14
14
|
|
15
15
|
DocumentGenerator.material_generators.each do |klass|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lcms
|
4
|
+
module Engine
|
5
|
+
module Partable
|
6
|
+
def create_parts_for(template)
|
7
|
+
template.parts.each do |part|
|
8
|
+
document_parts.create!(
|
9
|
+
active: true,
|
10
|
+
anchor: part[:anchor],
|
11
|
+
content: part[:content],
|
12
|
+
context_type: part[:context_type],
|
13
|
+
data: part[:data],
|
14
|
+
materials: part[:materials],
|
15
|
+
optional: part[:optional],
|
16
|
+
part_type: part[:part_type],
|
17
|
+
placeholder: part[:placeholder]
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def layout(context_type)
|
23
|
+
document_parts.where(part_type: :layout, context_type: DocumentPart.context_types[context_type.to_sym]).last
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,10 +3,11 @@
|
|
3
3
|
module Lcms
|
4
4
|
module Engine
|
5
5
|
class Document < ActiveRecord::Base
|
6
|
+
include Partable
|
6
7
|
GOOGLE_URL_PREFIX = 'https://docs.google.com/document/d'
|
7
8
|
|
8
9
|
belongs_to :resource
|
9
|
-
has_many :document_parts, dependent: :delete_all
|
10
|
+
has_many :document_parts, as: :renderer, dependent: :delete_all
|
10
11
|
has_and_belongs_to_many :materials
|
11
12
|
|
12
13
|
before_save :clean_curriculum_metadata
|
@@ -98,11 +99,6 @@ module Lcms
|
|
98
99
|
materials.gdoc.pluck(:id)
|
99
100
|
end
|
100
101
|
|
101
|
-
def layout(context_type)
|
102
|
-
# TODO: Move to concern with the same method in `Material`
|
103
|
-
document_parts.where(part_type: :layout, context_type: DocumentPart.context_types[context_type.to_sym]).last
|
104
|
-
end
|
105
|
-
|
106
102
|
def materials_anchors
|
107
103
|
{}.tap do |materials_with_anchors|
|
108
104
|
toc.collect_children.each do |x|
|
@@ -140,7 +136,7 @@ module Lcms
|
|
140
136
|
metadata['subject'] = metadata['subject']&.downcase
|
141
137
|
|
142
138
|
/(\d+)/.match(metadata['grade']) do |m|
|
143
|
-
metadata['grade'] = "grade #{m[1]}"
|
139
|
+
metadata['grade'] = "grade #{m[1].to_i}"
|
144
140
|
end
|
145
141
|
|
146
142
|
# store only the lesson number
|
@@ -6,11 +6,12 @@ module Lcms
|
|
6
6
|
module Engine
|
7
7
|
class Material < ActiveRecord::Base
|
8
8
|
include PgSearch::Model
|
9
|
+
include Partable
|
9
10
|
|
10
11
|
validates :file_id, presence: true
|
11
12
|
validates :identifier, uniqueness: true
|
12
13
|
|
13
|
-
has_many :
|
14
|
+
has_many :document_parts, as: :renderer, dependent: :delete_all
|
14
15
|
has_and_belongs_to_many :documents
|
15
16
|
|
16
17
|
store_accessor :metadata
|
@@ -33,11 +34,6 @@ module Lcms
|
|
33
34
|
"https://docs.google.com/#{pdf? ? 'file' : 'document'}/d/#{file_id}"
|
34
35
|
end
|
35
36
|
|
36
|
-
def layout(context_type)
|
37
|
-
# TODO: Move to concern with the same method in `Document`
|
38
|
-
material_parts.where(part_type: :layout, context_type: DocumentPart.context_types[context_type.to_sym]).last
|
39
|
-
end
|
40
|
-
|
41
37
|
# Material is optional if it's included in optional activity only
|
42
38
|
def optional_for?(document)
|
43
39
|
general_ids = document.document_parts.general.pluck(:materials).flatten
|