Skip to content

Commit

Permalink
Merge pull request #208 from razeware/WEB-6415
Browse files Browse the repository at this point in the history
WEB-6415: Add initial support for MMLP modules
  • Loading branch information
KapilSachdev authored Sep 27, 2023
2 parents e7e96ec + e7278df commit 123d196
Show file tree
Hide file tree
Showing 44 changed files with 1,728 additions and 98 deletions.
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ REPO_AWS_SECRET_ACCESS_KEY_PRODUCTION=
REPO_AWS_SECRET_ACCESS_KEY_STAGING=
REPO_SLACK_BOT_TOKEN=
REPO_SLACK_WEBHOOK_URL=

1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.0
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gem 'aws-sdk-s3', '~> 1.64'
gem 'concurrent-ruby', '~> 1.1'

# Interacting with github
gem 'octokit', '~> 6'
gem 'octokit', '~> 7'

# Interface with libsodium
gem 'rbnacl'
Expand All @@ -45,6 +45,9 @@ gem 'sass-embedded', '~> 1.58'
gem 'sinatra', '~> 3'
gem 'thin'

# Pinning google-protobuf so that it continues to build on ARM devices
gem 'google-protobuf', '=3.22.0'

# Controlling Chrome to create snapshots
gem 'ferrum'

Expand Down
101 changes: 54 additions & 47 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,36 @@ GIT
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.7.1)
activesupport (= 7.0.7.1)
activesupport (7.0.7.1)
activemodel (7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.4)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
aws-eventstream (1.2.0)
aws-partitions (1.747.0)
aws-sdk-core (3.171.0)
aws-partitions (1.827.0)
aws-sdk-core (3.183.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.63.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.120.1)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-s3 (1.135.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
backport (1.2.0)
base64 (0.1.1)
benchmark (0.2.1)
cli-ui (2.1.0)
cli-ui (2.2.3)
coderay (1.1.3)
commonmarker (0.23.10)
concurrent-ruby (1.2.2)
Expand All @@ -53,24 +54,25 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
faraday (2.7.4)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
faraday-retry (2.1.0)
faraday-retry (2.2.0)
faraday (~> 2.0)
ferrum (0.13)
ferrum (0.14)
addressable (~> 2.5)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (>= 0.6, < 0.8)
ffi (1.15.5)
ffi (1.16.1)
formatador (1.1.0)
git (1.18.0)
addressable (~> 2.8)
rchardet (~> 1.8)
google-protobuf (3.22.0)
guard (2.18.0)
guard (2.18.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
Expand All @@ -88,47 +90,49 @@ GEM
http_parser.rb (0.8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
jaro_winkler (1.5.6)
jmespath (1.6.2)
json (2.6.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.2.8)
lumberjack (1.2.9)
method_source (1.0.0)
mini_magick (4.12.0)
mini_portile2 (2.8.1)
minitest (5.19.0)
mini_portile2 (2.8.4)
minitest (5.20.0)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nenv (0.3.0)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
octokit (6.1.1)
octokit (7.1.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
parallel (1.22.1)
parser (3.2.2.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.1)
racc (1.6.2)
rack (2.2.6.4)
public_suffix (5.0.3)
racc (1.7.1)
rack (2.2.8)
rack-livereload (0.5.1)
rack
rack-protection (3.0.6)
rack
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
Expand All @@ -140,35 +144,37 @@ GEM
ffi
rbs (2.8.4)
rchardet (1.8.0)
regexp_parser (2.7.0)
regexp_parser (2.8.1)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
rubocop (1.50.1)
rexml (3.2.6)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.0.0)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sass-embedded (1.62.0)
sass-embedded (1.62.1)
google-protobuf (~> 3.21)
rake (>= 10.0.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
shellany (0.0.1)
sinatra (3.0.6)
sinatra (3.1.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.6)
rack-protection (= 3.1.0)
tilt (~> 2.0)
slack-notifier (2.4.0)
solargraph (0.49.0)
Expand All @@ -191,17 +197,17 @@ GEM
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.2.1)
tilt (2.1.0)
thor (1.2.2)
tilt (2.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
webrick (1.8.1)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
yard (0.9.34)
zeitwerk (2.6.7)
zeitwerk (2.6.11)

PLATFORMS
ruby
Expand All @@ -217,11 +223,12 @@ DEPENDENCIES
faraday-retry
ferrum
git
google-protobuf (= 3.22.0)
guard (~> 2, >= 2.16.2)
guard-livereload
levenshtein-ffi!
mini_magick
octokit (~> 6)
octokit (~> 7)
rack-livereload
rack-test
rbnacl
Expand All @@ -236,4 +243,4 @@ DEPENDENCIES
zeitwerk (~> 2.3)

BUNDLED WITH
2.4.7
2.4.19
85 changes: 85 additions & 0 deletions app/commands/content_module_cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# frozen_string_literal: true

# CLI for managing content module of a multi model learning path

class ContentModuleCli < Thor
desc 'render', 'renders content modules'
option :module_file, type: :string, desc: 'Location of the module.yaml file'
option :local, type: :boolean
def render
runner.render_content_module(module_file: options['module_file'], local: options['local'])
end

desc 'serve', 'starts local preview server'
option :dev, type: :boolean, desc: 'Run in development mode (watch robles files, not book files)'
def serve
fork do
if options[:dev]
Guard.start(no_interactions: true)
else
Guard.start(guardfile_contents: content_module_guardfile, watchdir: '/data/src', no_interactions: true)
end
end
RoblesContentModuleServer.run!
end

desc 'lint [MODULE_FILE]', 'runs a selection of linters on the module'
option :module_file, type: :string, desc: 'Location of the module.yaml file'
method_options 'without-version': :boolean, aliases: '-e', default: false, desc: 'Run linting without git branch naming check'
method_options silent: :boolean, aliases: '-s', default: false, desc: 'Hide all output'
def lint
output = runner.lint_content_module(module_file: options['module_file'], options:)
exit 1 unless output.validated || ENVIRONMENT == 'staging'
end

desc 'circulate [MODULE_FILE]', 'renders and circulates a content module'
option :module_file, type: :string, desc: 'Location of the module.yaml file'
def circulate
runner.circulate_content_module(module_file: options['module_file'])
end

desc 'slides [MODULE_FILE]', 'generates slides to be inserted at beginning of video'
option :module_file, type: :string, desc: 'Location of the module.yaml file'
option :app_host, type: :string, default: 'app', desc: 'Hostname of host running robles app server'
option :app_port, type: :string, default: '4567', desc: 'Port of host running robles app server'
option :snapshot_host, type: :string, default: 'snapshot', desc: 'Hostname of host running headless chrome'
option :snapshot_port, type: :string, default: '3000', desc: 'Port of host running headless chrome'
option :out_dir, type: :string, default: '/data/src/artwork/slides', desc: 'Location to save the output slides'
def slides
module_file = options.fetch('module_file', runner.default_module_file)
parser = Parser::Circulate.new(file: module_file)
content_module = parser.parse
options.delete('module_file')
args = options.merge(data: content_module.lessons.flat_map(&:segments), snapshot_host: 'localhost').symbolize_keys
snapshotter = Snapshotter::Slides.new(**args)
snapshotter.generate
end


desc 'serve', 'starts local preview server'
option :dev, type: :boolean, desc: 'Run in development mode (watch robles files, not book files)'
def serve
fork do
if options[:dev]
Guard.start(no_interactions: true)
else
Guard.start(guardfile_contents: content_module_guardfile, watchdir: './', no_interactions: true)
end
end
RoblesContentModuleServer.run!
end

private

def runner
Runner::Base.runner
end

def content_module_guardfile
<<~GUARDFILE
guard 'livereload' do
watch(%r{[a-zA-Z0-9-_]+.yaml$})
end
GUARDFILE
end
end
32 changes: 6 additions & 26 deletions app/commands/robles_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,17 @@ def self.exit_on_failure?
true
end

desc 'book SUBCOMMAND ...ARGS', 'manage publication of books'
desc 'book [SUBCOMMAND] ...ARGS', 'manage publication of books'
subcommand 'book', BookCli

desc 'video SUBCOMMAND ...ARGS', 'manage publication of videos'
desc 'video [SUBCOMMAND] ...ARGS', 'manage publication of videos'
subcommand 'video', VideoCli

desc 'pablo SUBCOMMAND ...ARGS', 'manage publication of pablo'
subcommand 'pablo', PabloCli

## We leave these in for now--they're deprecated. They should be removed later
desc 'serve', '[DEPRECATED: use `robles book serve` instead] starts local preview server'
option :dev, type: :boolean, desc: 'Run in development mode (watch robles files, not book files)'
def serve
fork do
if options[:dev]
Guard.start(no_interactions: true)
else
Guard.start(guardfile_contents: book_guardfile, watchdir: '/data/src', no_interactions: true)
end
end
RoblesBookServer.run!
end
desc 'module [SUBCOMMAND] ...ARGS', 'manage publication of content modules'
subcommand 'module', ContentModuleCli

desc 'lint [PUBLISH_FILE]', '[DEPRECATED: use `robles book lint` instead] runs a selection of linters on the book'
option :'publish-file', type: :string, desc: 'Location of the publish.yaml file'
method_options 'without-edition': :boolean, aliases: '-e', default: false, desc: 'Run linting without git branch naming check'
method_options silent: :boolean, aliases: '-s', default: false, desc: 'Hide all output'
def lint
output = runner.lint_book(publish_file: options['publish_file'], options:)
exit 1 unless output.validated || ENVIRONMENT == 'staging'
end
desc 'pablo [SUBCOMMAND] ...ARGS', 'manage publication of pablo'
subcommand 'pablo', PabloCli

private

Expand Down
Loading

0 comments on commit 123d196

Please sign in to comment.