From c6215b9545bffea8350714e5c94d03b611688547 Mon Sep 17 00:00:00 2001 From: Sam Davies Date: Wed, 13 Mar 2024 08:56:24 +0000 Subject: [PATCH 1/3] WEB-6880: Adding module_type and program_shortcode to module + lesson This introduces info and study modules. Study is the default, info has some different types. --- app/lib/parser/content_module.rb | 2 +- app/lib/parser/lesson_metadata.rb | 2 +- app/lib/runner/base.rb | 2 +- app/models/content_module.rb | 10 ++++++---- app/models/lesson.rb | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/lib/parser/content_module.rb b/app/lib/parser/content_module.rb index a9ecb9c..d30bcf7 100644 --- a/app/lib/parser/content_module.rb +++ b/app/lib/parser/content_module.rb @@ -12,7 +12,7 @@ class ContentModule professional difficulty platform language editor domains categories who_is_this_for_md module_outcomes_md covered_concepts_md git_commit_hash featured_banner_image twitter_card_image - access_personal access_team].freeze + access_personal access_team module_type].freeze attr_accessor :content_module diff --git a/app/lib/parser/lesson_metadata.rb b/app/lib/parser/lesson_metadata.rb index 190bd23..4019261 100644 --- a/app/lib/parser/lesson_metadata.rb +++ b/app/lib/parser/lesson_metadata.rb @@ -5,7 +5,7 @@ module Parser class LessonMetadata include SimpleAttributes - VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free].freeze + VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free program_shortcode].freeze attr_accessor :lesson, :metadata diff --git a/app/lib/runner/base.rb b/app/lib/runner/base.rb index c5398d3..7a10e0d 100644 --- a/app/lib/runner/base.rb +++ b/app/lib/runner/base.rb @@ -134,7 +134,7 @@ def render_content_module(module_file:, local: false) image_provider&.process renderer = Renderer::ContentModule.new(content_module, image_provider:) renderer.render - content_module + p content_module end def lint_content_module(module_file:, options: {}) diff --git a/app/models/content_module.rb b/app/models/content_module.rb index f0635c6..ac15863 100644 --- a/app/models/content_module.rb +++ b/app/models/content_module.rb @@ -12,7 +12,7 @@ class ContentModule :platform, :language, :editor, :domains, :categories, :who_is_this_for_md, :module_outcomes_md, :covered_concepts_md, :authors, :lessons, :git_commit_hash, :featured_banner_image, :twitter_card_image, :root_path, :access_personal, - :access_team + :access_team, :module_type attr_markdown :who_is_this_for, source: :who_is_this_for_md, file: false attr_markdown :covered_concepts, source: :covered_concepts_md, file: false @@ -21,10 +21,11 @@ class ContentModule attr_image :featured_banner_image_url, source: :featured_banner_image, variants: %i[original w750 w225 w90] attr_image :twitter_card_image_url, source: :twitter_card_image, variants: %i[original w1800] - validates :shortcode, :version, :title, :version_description, :description_md, :domains, - :categories, presence: true + validates :shortcode, :version, :title, :version_description, :description_md, presence: true + validates_presence_of :domains, :categories, unless: -> { module_type == 'info' } validates_inclusion_of :difficulty, in: %w[beginner intermediate advanced] validates_inclusion_of :professional, :access_personal, :access_team, in: [true, false] + validates_inclusion_of :module_type, in: %w[study info] validates :lessons, length: { minimum: 1 }, allow_blank: false, lessons: true validates_each :domains do |record, attr, value| value.each do |domain| @@ -35,6 +36,7 @@ class ContentModule def initialize(attributes = {}) super @lessons ||= [] + @module_type ||= 'study' end # Used for serialisation @@ -44,7 +46,7 @@ def attributes professional: nil, difficulty: nil, platform: nil, language: nil, editor: nil, domains: [], categories: [], who_is_this_for: nil, covered_concepts: nil, outcomes: nil, authors: [], lessons: [], git_commit_hash: nil, featured_banner_image_url: [], - twitter_card_image_url: [], access_personal: nil, access_team: nil }.stringify_keys + twitter_card_image_url: [], access_personal: nil, access_team: nil, module_type: nil }.stringify_keys end # Used for linting diff --git a/app/models/lesson.rb b/app/models/lesson.rb index ce70093..48dbb26 100644 --- a/app/models/lesson.rb +++ b/app/models/lesson.rb @@ -7,7 +7,7 @@ class Lesson include Concerns::ImageAttachable include Concerns::MarkdownRenderable - attr_accessor :title, :description_md, :ordinal, :ref, :segments, :learning_objectives_md, :free + attr_accessor :title, :description_md, :ordinal, :ref, :segments, :learning_objectives_md, :free, :program_shortcode attr_markdown :description, source: :description_md, file: false attr_markdown :learning_objectives, source: :learning_objectives_md, file: false @@ -26,7 +26,7 @@ def slug # Used for serialisation def attributes - { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil, free: false }.stringify_keys + { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil, free: false, program_shortcode: nil }.stringify_keys end # Used for linting From b580e0d9993b700d6fd1472e21154c139ae0a1f7 Mon Sep 17 00:00:00 2001 From: Sam Davies Date: Wed, 13 Mar 2024 08:58:07 +0000 Subject: [PATCH 2/3] WEB-6880: Updating checkout version --- .github/workflows/build-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 09ad545..f3aae15 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Run tests run: | @@ -62,7 +62,7 @@ jobs: status: STARTING color: warning - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 From 1df60f4c0415010e7b2da6ab41a50af4fdcca7c6 Mon Sep 17 00:00:00 2001 From: Sam Davies Date: Wed, 13 Mar 2024 20:54:32 +0000 Subject: [PATCH 3/3] WEB-6880: Removing an extra print statement --- app/lib/runner/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/runner/base.rb b/app/lib/runner/base.rb index 7a10e0d..c5398d3 100644 --- a/app/lib/runner/base.rb +++ b/app/lib/runner/base.rb @@ -134,7 +134,7 @@ def render_content_module(module_file:, local: false) image_provider&.process renderer = Renderer::ContentModule.new(content_module, image_provider:) renderer.render - p content_module + content_module end def lint_content_module(module_file:, options: {})