openstax_kitchen 11.2.0 → 12.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/lib/kitchen/chapter_element.rb +7 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/main.rb +11 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/v1.rb +28 -0
- data/lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb +2 -2
- data/lib/kitchen/directions/bake_example.rb +1 -1
- data/lib/kitchen/directions/bake_free_response/v1.rb +1 -1
- data/lib/kitchen/directions/{bake_page_abstracts.rb → bake_learning_objectives.rb} +10 -5
- data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +24 -4
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +2 -0
- data/lib/kitchen/directions/bake_references/main.rb +3 -2
- data/lib/kitchen/directions/bake_references/v1.rb +8 -3
- data/lib/kitchen/directions/bake_stepwise.rb +1 -1
- data/lib/kitchen/exercise_element.rb +34 -0
- data/lib/kitchen/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc1370c1b05b52bdf0df2f0a7cd4624b1725f39aae33f57f9715e091a358f8d
|
4
|
+
data.tar.gz: fcd328b3dd9c091f2461e3acd22db036c02c4005bb5c8f31071096ed96461179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd04ee2890144c697d9ab1ff10f97b9593f594eca116856bc6f26edb51f28e6330a0daca42c23e29d7bc08f2d336e764c957dcf93d6f638a22be1572a3ab939c
|
7
|
+
data.tar.gz: bb270311e092585ef966c4f2ba76d8847d7fbaedaae9c102274363ac5c21bbf411a6af5ebd7689c6b8ffd02d81ea46b586cd2273eab26320f21c559d28019bcb
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [12.0.0] - 2021-09-21
|
10
|
+
|
11
|
+
* Fixes `BakeStepwise` to skip nested lists (patch)
|
12
|
+
* Adds an optional selector to `RemoveSectionTitles` (minor)
|
13
|
+
* Patches `BakeFreeResponse` to only delete the first h3, not all h3s (patch)
|
14
|
+
* Lets `BakeExample` not count titles in lists as commentary titles (minor)
|
15
|
+
* Renames `BakePageAbstracts` to `BakeLearningObjectives` and adds optional parameter for titles in `v2` (major)
|
16
|
+
* Gets rid of extraneous titles in `BakeAutoTitledNotes` when subtitles are off (minor)
|
17
|
+
* Adds `BakeAutotitledExercise` direction and the option to `bake_unclassified_exercises` within `BakeAutotitledNotes`
|
18
|
+
* Adds optional numbering for `BakeReferences.v1` (minor)
|
19
|
+
* Patches`BakeNumberedNotes.v3` to suppress solutions outside examples when suppress_solutions is true (minor)
|
20
|
+
|
9
21
|
## [11.2.0] - 2021-09-10
|
10
22
|
|
11
23
|
* Adds `BakeAccessibilityFixes` direction for (minor)
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeAutotitledExercise
|
4
|
+
class V1
|
5
|
+
def bake(exercise:, number:)
|
6
|
+
exercise.add_class('unnumbered') unless number
|
7
|
+
|
8
|
+
# bake problem
|
9
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
10
|
+
exercise.problem.prepend(child:
|
11
|
+
<<~HTML
|
12
|
+
<h4 class="exercise-title" data-type="title">#{exercise.autogenerated_title}</h4>
|
13
|
+
HTML
|
14
|
+
)
|
15
|
+
return unless exercise.solution
|
16
|
+
|
17
|
+
# bake solution in place
|
18
|
+
exercise.solution.wrap_children('div', class: 'os-solution-container')
|
19
|
+
exercise.solution.prepend(child:
|
20
|
+
<<~HTML
|
21
|
+
<h4 class="solution-title" data-type="title">
|
22
|
+
<span class="os-text">#{I18n.t(:"exercises.solution")}</span>
|
23
|
+
</h4>
|
24
|
+
HTML
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -53,7 +53,7 @@ module Kitchen
|
|
53
53
|
next unless commentary.present?
|
54
54
|
|
55
55
|
commentary_title = commentary.titles.first
|
56
|
-
next unless commentary_title.present?
|
56
|
+
next unless commentary_title.present? && commentary_title.parent['data-type'] != 'list'
|
57
57
|
|
58
58
|
commentary_title.name = 'h4'
|
59
59
|
commentary_title['data-type'] = 'commentary-title'
|
@@ -12,7 +12,7 @@ module Kitchen::Directions::BakeFreeResponse
|
|
12
12
|
free_response_questions = page.free_response
|
13
13
|
next if free_response_questions.none?
|
14
14
|
|
15
|
-
free_response_questions.search('h3')
|
15
|
+
free_response_questions.search('h3')&.first&.trash
|
16
16
|
title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
|
17
17
|
free_response_questions.each do |free_response_question|
|
18
18
|
free_response_question.prepend(child: title)
|
@@ -2,17 +2,22 @@
|
|
2
2
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
|
-
|
6
|
-
module BakePageAbstracts
|
5
|
+
module BakeLearningObjectives
|
7
6
|
def self.v1(chapter:)
|
8
7
|
chapter.abstracts.each do |abstract|
|
9
8
|
abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
def self.v2(chapter:)
|
14
|
-
|
15
|
-
|
12
|
+
def self.v2(chapter:, add_title: true)
|
13
|
+
learning_objectives =
|
14
|
+
chapter.abstracts.any? ? chapter.abstracts : chapter.learning_objectives
|
15
|
+
|
16
|
+
learning_objectives.each do |abstract|
|
17
|
+
if add_title
|
18
|
+
abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
|
19
|
+
end
|
20
|
+
|
16
21
|
ul = abstract.first!('ul')
|
17
22
|
ul.add_class('os-abstract')
|
18
23
|
ul.search('li').each_with_index do |li, index|
|
@@ -3,19 +3,24 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeAutotitledNotes
|
6
|
-
def self.v1(book:, classes:, bake_subtitle: true, cases: false)
|
6
|
+
def self.v1(book:, classes:, bake_subtitle: true, cases: false, bake_exercises: false)
|
7
7
|
book.notes.each do |note|
|
8
8
|
next unless (note.classes & classes).any?
|
9
9
|
|
10
|
-
bake_note(
|
10
|
+
bake_note(
|
11
|
+
note: note, bake_subtitle: bake_subtitle, cases: cases, bake_exercises: bake_exercises)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
def self.bake_note(note:, bake_subtitle:, cases:)
|
15
|
+
def self.bake_note(note:, bake_subtitle:, cases:, bake_exercises:)
|
15
16
|
Kitchen::Directions::BakeIframes.v1(outer_element: note)
|
16
17
|
note.wrap_children(class: 'os-note-body')
|
17
18
|
|
18
|
-
|
19
|
+
if bake_subtitle
|
20
|
+
BakeNoteSubtitle.v1(note: note, cases: cases)
|
21
|
+
else
|
22
|
+
note.title&.trash
|
23
|
+
end
|
19
24
|
|
20
25
|
note.prepend(child:
|
21
26
|
<<~HTML
|
@@ -24,6 +29,21 @@ module Kitchen
|
|
24
29
|
</h3>
|
25
30
|
HTML
|
26
31
|
)
|
32
|
+
|
33
|
+
bake_unclassified_exercises(note: note) if bake_exercises
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bake_unclassified_exercises(note:)
|
37
|
+
note.exercises.each do |exercise|
|
38
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
39
|
+
|
40
|
+
exercise.problem.prepend(child:
|
41
|
+
<<~HTML
|
42
|
+
<span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
|
43
|
+
<span class="os-number">#{exercise.count_in(:note)}</span>
|
44
|
+
HTML
|
45
|
+
)
|
46
|
+
end
|
27
47
|
end
|
28
48
|
end
|
29
49
|
end
|
@@ -32,6 +32,8 @@ module Kitchen::Directions
|
|
32
32
|
note.injected_questions.each do |question|
|
33
33
|
BakeNumberedNotes.bake_note_injected_question(note: note, question: question)
|
34
34
|
end
|
35
|
+
|
36
|
+
note.search("div[data-type='solution']").each&.trash if suppress_solution
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -5,10 +5,11 @@ module Kitchen
|
|
5
5
|
# Bake directions for EOB references
|
6
6
|
#
|
7
7
|
module BakeReferences
|
8
|
-
def self.v1(book:, metadata_source:)
|
8
|
+
def self.v1(book:, metadata_source:, numbered_title: false)
|
9
9
|
V1.new.bake(
|
10
10
|
book: book,
|
11
|
-
metadata_source: metadata_source
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
numbered_title: numbered_title
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
@@ -4,7 +4,7 @@ module Kitchen::Directions::BakeReferences
|
|
4
4
|
class V1
|
5
5
|
renderable
|
6
6
|
|
7
|
-
def bake(book:, metadata_source:)
|
7
|
+
def bake(book:, metadata_source:, numbered_title:)
|
8
8
|
@metadata = metadata_source.children_to_keep.copy
|
9
9
|
@klass = 'reference'
|
10
10
|
@uuid_prefix = '.'
|
@@ -28,12 +28,17 @@ module Kitchen::Directions::BakeReferences
|
|
28
28
|
end
|
29
29
|
|
30
30
|
chapter_references = chapter.pages.references.cut
|
31
|
-
|
31
|
+
|
32
|
+
chapter_title = if numbered_title
|
33
|
+
chapter.title.search('.os-number, .os-divider, .os-text')
|
34
|
+
else
|
35
|
+
chapter.title.search('.os-text')
|
36
|
+
end
|
32
37
|
|
33
38
|
chapter.append(child:
|
34
39
|
<<~HTML
|
35
40
|
<div class="os-chapter-area">
|
36
|
-
<h2 data-type="document-title">#{
|
41
|
+
<h2 data-type="document-title">#{chapter_title}</h2>
|
37
42
|
#{chapter_references.paste}
|
38
43
|
</div>
|
39
44
|
HTML
|
@@ -54,5 +54,39 @@ module Kitchen
|
|
54
54
|
def baked?
|
55
55
|
search('div.os-problem-container').any?
|
56
56
|
end
|
57
|
+
|
58
|
+
# Returns true if the exercise's title is autogenerated
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
#
|
62
|
+
def indicates_autogenerated_title?
|
63
|
+
detected_exercise_title_key != 0 && detected_exercise_title_key.present?
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get the autogenerated title for this note
|
67
|
+
#
|
68
|
+
# @return [String]
|
69
|
+
#
|
70
|
+
def autogenerated_title
|
71
|
+
if indicates_autogenerated_title?
|
72
|
+
I18n.t(:"exercises.#{detected_exercise_title_key}")
|
73
|
+
else
|
74
|
+
"unknown title for exercise with classes #{classes}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def detected_exercise_title_key
|
79
|
+
@detected_exercise_title_key ||= begin
|
80
|
+
return 0 if classes.empty? || !I18n.t('.').key?(:exercises)
|
81
|
+
|
82
|
+
possible_keys = I18n.t(:exercises).keys.map(&:to_s)
|
83
|
+
keys = possible_keys & classes
|
84
|
+
|
85
|
+
raise("too many translation keys: #{keys.join(', ')}") if keys.many?
|
86
|
+
return 0 if keys.empty?
|
87
|
+
|
88
|
+
keys.first
|
89
|
+
end
|
90
|
+
end
|
57
91
|
end
|
58
92
|
end
|
data/lib/kitchen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 12.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -247,6 +247,8 @@ files:
|
|
247
247
|
- lib/kitchen/directions/bake_annotation_classes/main.rb
|
248
248
|
- lib/kitchen/directions/bake_annotation_classes/v1.rb
|
249
249
|
- lib/kitchen/directions/bake_appendix.rb
|
250
|
+
- lib/kitchen/directions/bake_autotitled_exercise/main.rb
|
251
|
+
- lib/kitchen/directions/bake_autotitled_exercise/v1.rb
|
250
252
|
- lib/kitchen/directions/bake_chapter_glossary/main.rb
|
251
253
|
- lib/kitchen/directions/bake_chapter_glossary/v1.rb
|
252
254
|
- lib/kitchen/directions/bake_chapter_introductions/bake_chapter_objectives.rb
|
@@ -294,6 +296,7 @@ files:
|
|
294
296
|
- lib/kitchen/directions/bake_injected_exercise.rb
|
295
297
|
- lib/kitchen/directions/bake_injected_exercise_question.rb
|
296
298
|
- lib/kitchen/directions/bake_inline_lists.rb
|
299
|
+
- lib/kitchen/directions/bake_learning_objectives.rb
|
297
300
|
- lib/kitchen/directions/bake_link_placeholders.rb
|
298
301
|
- lib/kitchen/directions/bake_lists_with_para.rb
|
299
302
|
- lib/kitchen/directions/bake_math_in_paragraph.rb
|
@@ -311,7 +314,6 @@ files:
|
|
311
314
|
- lib/kitchen/directions/bake_numbered_table/main.rb
|
312
315
|
- lib/kitchen/directions/bake_numbered_table/v1.rb
|
313
316
|
- lib/kitchen/directions/bake_numbered_table/v2.rb
|
314
|
-
- lib/kitchen/directions/bake_page_abstracts.rb
|
315
317
|
- lib/kitchen/directions/bake_preface/main.rb
|
316
318
|
- lib/kitchen/directions/bake_preface/v1.rb
|
317
319
|
- lib/kitchen/directions/bake_references/main.rb
|