openstax_kitchen 3.0.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +77 -3
- data/Gemfile.lock +13 -14
- data/README.md +23 -0
- data/codecov.yaml +1 -0
- data/docker/ci +0 -1
- data/lib/kitchen/book_document.rb +1 -1
- data/lib/kitchen/book_element.rb +16 -2
- data/lib/kitchen/chapter_element.rb +10 -13
- data/lib/kitchen/chapter_element_enumerator.rb +1 -1
- data/lib/kitchen/composite_chapter_element.rb +7 -11
- data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
- data/lib/kitchen/composite_page_element.rb +15 -10
- data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
- data/lib/kitchen/config.rb +14 -0
- data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
- data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
- data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +16 -0
- data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +35 -0
- data/lib/kitchen/directions/bake_chapter_key_equations.rb +27 -20
- data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
- data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +11 -0
- data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +28 -0
- data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
- data/lib/kitchen/directions/bake_checkpoint.rb +44 -0
- data/lib/kitchen/directions/bake_composite_chapters.rb +14 -0
- data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
- data/lib/kitchen/directions/bake_equations.rb +37 -0
- data/lib/kitchen/directions/bake_example.rb +34 -8
- data/lib/kitchen/directions/bake_figure.rb +1 -1
- data/lib/kitchen/directions/bake_first_elements.rb +16 -0
- data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
- data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
- data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
- data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
- data/lib/kitchen/directions/bake_further_research.rb +59 -0
- data/lib/kitchen/directions/bake_index/v1.rb +35 -14
- data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
- data/lib/kitchen/directions/bake_non_introduction_pages.rb +26 -0
- data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +29 -0
- data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +22 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +51 -0
- data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +30 -0
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +15 -0
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +47 -0
- data/lib/kitchen/directions/bake_numbered_table/main.rb +2 -2
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +18 -4
- data/lib/kitchen/directions/bake_page_abstracts.rb +16 -0
- data/lib/kitchen/directions/bake_references/main.rb +16 -0
- data/lib/kitchen/directions/bake_references/v1.rb +48 -0
- data/lib/kitchen/directions/bake_stepwise.rb +1 -5
- data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
- data/lib/kitchen/directions/bake_theorem/main.rb +11 -0
- data/lib/kitchen/directions/bake_theorem/v1.rb +28 -0
- data/lib/kitchen/directions/bake_toc.rb +10 -2
- data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
- data/lib/kitchen/directions/{bake_exercises → book_answer_key_container}/main.rb +1 -1
- data/lib/kitchen/directions/book_answer_key_container/v1.rb +13 -0
- data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
- data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
- data/lib/kitchen/directions/chapter_review_container/v1.rb +13 -0
- data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +20 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +36 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +49 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +14 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +41 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +63 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +34 -0
- data/lib/kitchen/document.rb +3 -0
- data/lib/kitchen/element.rb +9 -3
- data/lib/kitchen/element_base.rb +118 -16
- data/lib/kitchen/element_enumerator_base.rb +118 -8
- data/lib/kitchen/element_enumerator_factory.rb +28 -12
- data/lib/kitchen/element_factory.rb +3 -3
- data/lib/kitchen/example_element.rb +8 -11
- data/lib/kitchen/example_element_enumerator.rb +1 -1
- data/lib/kitchen/exercise_element.rb +42 -0
- data/lib/kitchen/exercise_element_enumerator.rb +21 -0
- data/lib/kitchen/figure_element.rb +8 -11
- data/lib/kitchen/figure_element_enumerator.rb +1 -1
- data/lib/kitchen/metadata_element.rb +8 -2
- data/lib/kitchen/metadata_element_enumerator.rb +1 -1
- data/lib/kitchen/note_element.rb +25 -27
- data/lib/kitchen/note_element_enumerator.rb +1 -1
- data/lib/kitchen/oven.rb +2 -0
- data/lib/kitchen/page_element.rb +33 -9
- data/lib/kitchen/page_element_enumerator.rb +1 -1
- data/lib/kitchen/patches/nokogiri.rb +55 -0
- data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
- data/lib/kitchen/recipe.rb +35 -2
- data/lib/kitchen/reference_element.rb +27 -0
- data/lib/kitchen/references_element_enumerator.rb +20 -0
- data/lib/kitchen/search_query.rb +31 -3
- data/lib/kitchen/selector.rb +25 -0
- data/lib/kitchen/selectors/base.rb +39 -0
- data/lib/kitchen/selectors/standard_1.rb +13 -0
- data/lib/kitchen/table_element.rb +8 -11
- data/lib/kitchen/table_element_enumerator.rb +1 -1
- data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/term_element.rb +5 -8
- data/lib/kitchen/term_element_enumerator.rb +1 -1
- data/lib/kitchen/unit_element.rb +13 -7
- data/lib/kitchen/unit_element_enumerator.rb +1 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +12 -7
- data/lib/locales/pl.yml +24 -0
- data/lib/openstax_kitchen.rb +2 -1
- metadata +54 -6
- data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -37
- data/lib/kitchen/directions/bake_exercises/v1.rb +0 -166
- data/lib/kitchen/directions/bake_notes.rb +0 -58
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeNumberedNotes
|
6
|
+
def self.v1(book:, classes:)
|
7
|
+
classes.each do |klass|
|
8
|
+
book.chapters.notes("$.#{klass}").each do |note|
|
9
|
+
bake_note(note: note)
|
10
|
+
note.exercises.each do |exercise|
|
11
|
+
bake_note_exercise(note: note, exercise: exercise)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.bake_note(note:)
|
18
|
+
note.wrap_children(class: 'os-note-body')
|
19
|
+
|
20
|
+
chapter_count = note.ancestor(:chapter).count_in(:book)
|
21
|
+
note_count = note.count_in(:chapter)
|
22
|
+
note.prepend(child:
|
23
|
+
<<~HTML
|
24
|
+
<h3 class="os-title">
|
25
|
+
<span class="os-title-label">#{note.autogenerated_title}</span>
|
26
|
+
<span class="os-number">#{chapter_count}.#{note_count}</span>
|
27
|
+
<span class="os-divider"> </span>
|
28
|
+
</h3>
|
29
|
+
HTML
|
30
|
+
)
|
31
|
+
|
32
|
+
return unless note['use-subtitle']
|
33
|
+
|
34
|
+
BakeNoteSubtitle.v1(note: note)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.bake_note_exercise(note:, exercise:)
|
38
|
+
exercise.add_class('unnumbered')
|
39
|
+
# bake problem
|
40
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
41
|
+
exercise.problem.first('strong')&.trash
|
42
|
+
exercise.search('[data-type="commentary"]').each(&:trash)
|
43
|
+
return unless exercise.solution
|
44
|
+
|
45
|
+
# bake solution in place
|
46
|
+
BakeNumberedExercise.bake_solution_v1(
|
47
|
+
exercise: exercise, number: note.first('.os-number').text, divider: ' ')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeUnclassifiedNotes
|
6
|
+
def self.v1(book:)
|
7
|
+
book.notes.each do |note|
|
8
|
+
next unless note.classes.empty?
|
9
|
+
|
10
|
+
bake_note(note: note)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.bake_note(note:)
|
15
|
+
note.wrap_children(class: 'os-note-body')
|
16
|
+
|
17
|
+
title = note.title&.cut
|
18
|
+
return unless title
|
19
|
+
|
20
|
+
note.prepend(child:
|
21
|
+
<<~HTML
|
22
|
+
<h3 class="os-title" data-type="title">
|
23
|
+
<span class="os-title-label" data-type="" id="#{title[:id]}">#{title.children}</span>
|
24
|
+
</h3>
|
25
|
+
HTML
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeNumberedExercise
|
6
|
+
def self.v1(exercise:, number:, suppress_solution: false)
|
7
|
+
V1.new.bake(exercise: exercise, number: number, suppress_solution: suppress_solution)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.bake_solution_v1(exercise:, number:, divider: '. ')
|
11
|
+
V1.new.bake_solution(exercise: exercise, number: number, divider: divider)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeNumberedExercise
|
4
|
+
class V1
|
5
|
+
def bake(exercise:, number:, suppress_solution: false)
|
6
|
+
problem = exercise.problem
|
7
|
+
solution = exercise.solution
|
8
|
+
|
9
|
+
exercise.pantry(name: :link_text).store(
|
10
|
+
"#{I18n.t(:exercise_label)} #{exercise.ancestor(:chapter).count_in(:book)}.#{number}",
|
11
|
+
label: exercise.id
|
12
|
+
)
|
13
|
+
problem_number = "<span class='os-number'>#{number}</span>"
|
14
|
+
|
15
|
+
if solution.present?
|
16
|
+
if suppress_solution
|
17
|
+
solution.trash
|
18
|
+
else
|
19
|
+
problem_number = "<a class='os-number' href='##{exercise.id}-solution'>#{number}</a>"
|
20
|
+
bake_solution(exercise: exercise, number: number)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
problem.replace_children(with:
|
25
|
+
<<~HTML
|
26
|
+
#{problem_number}
|
27
|
+
<span class='os-divider'>. </span>
|
28
|
+
<div class="os-problem-container">#{problem.children}</div>
|
29
|
+
HTML
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def bake_solution(exercise:, number:, divider: '. ')
|
34
|
+
solution = exercise.solution
|
35
|
+
solution.id = "#{exercise.id}-solution"
|
36
|
+
exercise.add_class('os-hasSolution')
|
37
|
+
|
38
|
+
solution.replace_children(with:
|
39
|
+
<<~HTML
|
40
|
+
<a class='os-number' href='##{exercise.id}'>#{number}</a>
|
41
|
+
<span class='os-divider'>#{divider}</span>
|
42
|
+
<div class="os-solution-container">#{solution.children}</div>
|
43
|
+
HTML
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeNumberedTable
|
6
|
-
def self.v1(table:, number:)
|
7
|
-
V1.new.bake(table: table, number: number)
|
6
|
+
def self.v1(table:, number:, always_caption: false)
|
7
|
+
V1.new.bake(table: table, number: number, always_caption: always_caption)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module Kitchen::Directions::BakeNumberedTable
|
4
4
|
class V1
|
5
5
|
|
6
|
-
def bake(table:, number:)
|
6
|
+
def bake(table:, number:, always_caption: false)
|
7
7
|
table.wrap(%(<div class="os-table">))
|
8
8
|
|
9
9
|
table_label = "#{I18n.t(:table_label)} #{number}"
|
10
|
-
table.
|
10
|
+
table.pantry(name: :link_text).store table_label, label: table.id
|
11
11
|
|
12
12
|
if table.top_titled?
|
13
13
|
table.parent.add_class('os-top-titled-container')
|
@@ -22,14 +22,28 @@ module Kitchen::Directions::BakeNumberedTable
|
|
22
22
|
table.parent.add_class('os-column-header-container') if table.column_header?
|
23
23
|
|
24
24
|
# TODO: extra spaces added here to match legacy implementation, but probably not meaningful?
|
25
|
-
new_summary = "#{table_label}
|
25
|
+
new_summary = "#{table_label} "
|
26
26
|
new_caption = ''
|
27
|
+
caption_title = ''
|
28
|
+
|
29
|
+
if (title = table.first("span[data-type='title']")&.cut)
|
30
|
+
new_summary += title.text
|
31
|
+
caption_title = <<~HTML
|
32
|
+
\n<span class="os-title" data-type="title">#{title.children}</span>
|
33
|
+
HTML
|
34
|
+
end
|
35
|
+
|
36
|
+
new_summary += ' '
|
27
37
|
|
28
38
|
if (caption = table.caption&.cut)
|
29
39
|
new_summary += caption.text
|
30
40
|
new_caption = <<~HTML
|
31
41
|
\n<span class="os-caption">#{caption.children}</span>
|
32
42
|
HTML
|
43
|
+
elsif always_caption
|
44
|
+
new_caption = <<~HTML
|
45
|
+
\n<span class="os-caption"></span>
|
46
|
+
HTML
|
33
47
|
end
|
34
48
|
|
35
49
|
table[:summary] = new_summary
|
@@ -41,7 +55,7 @@ module Kitchen::Directions::BakeNumberedTable
|
|
41
55
|
<div class="os-caption-container">
|
42
56
|
<span class="os-title-label">#{I18n.t(:table_label)} </span>
|
43
57
|
<span class="os-number">#{number}</span>
|
44
|
-
<span class="os-divider"> </span
|
58
|
+
<span class="os-divider"> </span>#{caption_title}
|
45
59
|
<span class="os-divider"> </span>#{new_caption}
|
46
60
|
</div>
|
47
61
|
HTML
|
@@ -9,6 +9,22 @@ module Kitchen
|
|
9
9
|
abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.v2(chapter:)
|
14
|
+
chapter.abstracts.each do |abstract|
|
15
|
+
abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
|
16
|
+
ul = abstract.first!('ul')
|
17
|
+
ul.add_class('os-abstract')
|
18
|
+
ul.search('li').each_with_index do |li, index|
|
19
|
+
li.replace_children(with:
|
20
|
+
<<~HTML
|
21
|
+
<span class="os-abstract-token">#{chapter.count_in(:book)}.#{abstract.count_in(:chapter)}.#{index + 1}</span>
|
22
|
+
<span class="os-abstract-content">#{li.children}</span>
|
23
|
+
HTML
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
12
28
|
end
|
13
29
|
end
|
14
30
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
# Bake directions for EOB references
|
6
|
+
#
|
7
|
+
module BakeReferences
|
8
|
+
def self.v1(book:, metadata_source:)
|
9
|
+
V1.new.bake(
|
10
|
+
book: book,
|
11
|
+
metadata_source: metadata_source
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeReferences
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
|
7
|
+
def bake(book:, metadata_source:)
|
8
|
+
@metadata = metadata_source.children_to_keep.copy
|
9
|
+
@klass = 'reference'
|
10
|
+
@uuid_prefix = '.'
|
11
|
+
@title = I18n.t(:references)
|
12
|
+
|
13
|
+
book.chapters.each do |chapter|
|
14
|
+
chapter.search('[data-type="cite"]').each do |link|
|
15
|
+
link.prepend(child:
|
16
|
+
<<~HTML
|
17
|
+
<sup class="os-citation-number">#{link.count_in(:chapter)}</sup>
|
18
|
+
HTML
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
chapter.references.each do |reference|
|
23
|
+
reference.prepend(child:
|
24
|
+
<<~HTML.chomp
|
25
|
+
<span class="os-reference-number">#{reference.count_in(:chapter)}. </span>
|
26
|
+
HTML
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
chapter_references = chapter.pages.references.cut
|
31
|
+
chapter_title_no_num = chapter.title.search('.os-text')
|
32
|
+
|
33
|
+
chapter.append(child:
|
34
|
+
<<~HTML
|
35
|
+
<div class="os-chapter-area">
|
36
|
+
<h2 data-type="document-title">#{chapter_title_no_num}</h2>
|
37
|
+
#{chapter_references.paste}
|
38
|
+
</div>
|
39
|
+
HTML
|
40
|
+
)
|
41
|
+
end
|
42
|
+
chapter_area_references = book.chapters.search('.os-chapter-area').cut
|
43
|
+
@content = chapter_area_references.paste
|
44
|
+
book.body.append(child: render(file:
|
45
|
+
'../../templates/eob_section_title_template.xhtml.erb'))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -9,11 +9,7 @@ module Kitchen
|
|
9
9
|
ol.add_class('os-stepwise')
|
10
10
|
|
11
11
|
ol.search('li').each_with_index do |li, ii|
|
12
|
-
li.
|
13
|
-
<<~HTML
|
14
|
-
<span class="os-stepwise-content">#{li.children}</span>
|
15
|
-
HTML
|
16
|
-
)
|
12
|
+
li.wrap_children('span', class: 'os-stepwise-content')
|
17
13
|
li.prepend(child:
|
18
14
|
<<~HTML
|
19
15
|
<span class="os-stepwise-token">#{I18n.t(:stepwise_step_label)} #{ii + 1}. </span>
|
@@ -6,6 +6,7 @@ module Kitchen
|
|
6
6
|
#
|
7
7
|
module BakeSuggestedReading
|
8
8
|
def self.v1(book:)
|
9
|
+
metadata_elements = book.metadata.children_to_keep.copy
|
9
10
|
book.chapters.each do |chapter|
|
10
11
|
suggested_reading = chapter.search('section.suggested-reading').cut
|
11
12
|
|
@@ -15,6 +16,10 @@ module Kitchen
|
|
15
16
|
<h2 data-type="document-title">
|
16
17
|
<span class="os-text">#{I18n.t(:eoc_suggested_reading)}</span>
|
17
18
|
</h2>
|
19
|
+
<div data-type="metadata" style="display: none;">
|
20
|
+
<h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_suggested_reading)}</h1>
|
21
|
+
#{metadata_elements.paste}
|
22
|
+
</div>
|
18
23
|
#{suggested_reading.paste}
|
19
24
|
</div>
|
20
25
|
HTML
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeTheorem
|
4
|
+
class V1
|
5
|
+
def bake(theorem:, number:)
|
6
|
+
theorem['use-subtitle'] = true
|
7
|
+
new_subtitle = theorem.title.cut
|
8
|
+
|
9
|
+
theorem.wrap_children(class: 'os-note-body')
|
10
|
+
note_body = theorem.first('.os-note-body')
|
11
|
+
|
12
|
+
note_body.prepend(sibling:
|
13
|
+
<<~HTML
|
14
|
+
<div class="os-title">
|
15
|
+
<span class="os-title-label">#{I18n.t(:theorem)} </span>
|
16
|
+
<span class="os-number">#{number}</span>
|
17
|
+
<span class="os-divider"> </span>
|
18
|
+
</div>
|
19
|
+
HTML
|
20
|
+
)
|
21
|
+
|
22
|
+
new_subtitle.name = 'h4'
|
23
|
+
new_subtitle.add_class('os-subtitle')
|
24
|
+
new_subtitle.children.wrap('<span class="os-subtitle-label">')
|
25
|
+
note_body.prepend(child: new_subtitle.paste)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -31,9 +31,9 @@ module Kitchen
|
|
31
31
|
<<~HTML
|
32
32
|
<li cnx-archive-uri="" cnx-archive-shortid="" class="os-toc-unit">
|
33
33
|
<a href="#">
|
34
|
-
<span class="os-number"><span class="os-part-text">#{I18n.t(:unit)} </span
|
34
|
+
<span class="os-number"><span class="os-part-text">#{I18n.t(:unit)} </span>#{unit.count_in(:book)}</span>
|
35
35
|
<span class="os-divider"> </span>
|
36
|
-
<span data-type itemprop class="os-text"
|
36
|
+
<span data-type itemprop class="os-text">#{unit.title_text}</span>
|
37
37
|
</a>
|
38
38
|
<ol class="os-unit">
|
39
39
|
#{chapters.map { |chapter| li_for_chapter(chapter) }.join("\n")}
|
@@ -59,6 +59,7 @@ module Kitchen
|
|
59
59
|
|
60
60
|
def self.li_for_chapter(chapter)
|
61
61
|
pages = chapter.element_children.only(PageElement, CompositePageElement)
|
62
|
+
inner_composite_chapters = chapter.element_children.only(CompositeChapterElement)
|
62
63
|
|
63
64
|
<<~HTML
|
64
65
|
<li class="os-toc-chapter" cnx-archive-shortid="" cnx-archive-uri="">
|
@@ -69,6 +70,11 @@ module Kitchen
|
|
69
70
|
</a>
|
70
71
|
<ol class="os-chapter">
|
71
72
|
#{pages.map { |page| li_for_page(page) }.join("\n")}
|
73
|
+
#{
|
74
|
+
inner_composite_chapters.map do |composite_chapter|
|
75
|
+
li_for_composite_chapter(composite_chapter)
|
76
|
+
end.join("\n")
|
77
|
+
}
|
72
78
|
</ol>
|
73
79
|
</li>
|
74
80
|
HTML
|
@@ -90,6 +96,8 @@ module Kitchen
|
|
90
96
|
when CompositePageElement
|
91
97
|
if page.is_index?
|
92
98
|
'os-toc-index'
|
99
|
+
elsif page.is_reference?
|
100
|
+
'os-toc-reference'
|
93
101
|
elsif page.has_ancestor?(:composite_chapter) || page.has_ancestor?(:chapter)
|
94
102
|
'os-toc-chapter-composite-page'
|
95
103
|
else
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<div class="os-eob os-solutions-container" data-type="composite-chapter" data-uuid-key=".solutions">
|
2
|
+
<h1 data-type="document-title">
|
3
|
+
<span class="os-text"><%= I18n.t(:eoc_answer_key_title) %></span>
|
4
|
+
</h1>
|
5
|
+
<div data-type="metadata" style="display: none;">
|
6
|
+
<h1 data-type="document-title" itemprop="name"><%= I18n.t(:eoc_answer_key_title) %></h1>
|
7
|
+
<%= @metadata.paste %>
|
8
|
+
</div>
|
9
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BookAnswerKeyContainer
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
|
7
|
+
def bake(book:)
|
8
|
+
@metadata = book.metadata.children_to_keep.copy
|
9
|
+
book.body.append(child: render(file: 'eob_solutions_container.xhtml.erb'))
|
10
|
+
book.body.first('div.os-eob.os-solutions-container')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|