openstax_kitchen 1.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/devcontainer.json +37 -17
- data/.github/config.yml +14 -0
- data/.github/workflows/tests.yml +5 -15
- data/.gitignore +2 -2
- data/.inch.yml +6 -0
- data/.rubocop.yml +65 -0
- data/CHANGELOG.md +85 -2
- data/Gemfile +5 -3
- data/Gemfile.lock +66 -18
- data/README.md +69 -15
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/docker/Dockerfile +36 -0
- data/docker/Dockerfile.ci +10 -0
- data/docker/bash +5 -1
- data/docker/build +10 -0
- data/docker/ci +15 -0
- data/docker/run +9 -0
- data/docker/tag_and_push_latest +17 -0
- data/lefthook.yml +6 -0
- data/lib/kitchen/ancestor.rb +38 -1
- data/lib/kitchen/book_document.rb +20 -2
- data/lib/kitchen/book_element.rb +40 -5
- data/lib/kitchen/book_element_enumerator.rb +4 -0
- data/lib/kitchen/book_recipe.rb +15 -1
- data/lib/kitchen/chapter_element.rb +43 -6
- data/lib/kitchen/chapter_element_enumerator.rb +9 -1
- data/lib/kitchen/clipboard.rb +35 -4
- data/lib/kitchen/composite_chapter_element.rb +21 -6
- data/lib/kitchen/composite_page_element.rb +35 -7
- data/lib/kitchen/composite_page_element_enumerator.rb +9 -1
- data/lib/kitchen/config.rb +20 -6
- data/lib/kitchen/counter.rb +9 -2
- data/lib/kitchen/debug/print_recipe_error.rb +53 -35
- data/lib/kitchen/directions/.rubocop.yml +22 -0
- data/lib/kitchen/directions/bake_appendix.rb +4 -4
- 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 +7 -7
- 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 +30 -20
- 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 +45 -36
- data/lib/kitchen/directions/bake_chapter_title/main.rb +11 -0
- data/lib/kitchen/directions/bake_chapter_title/v1.rb +24 -0
- 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 +2 -2
- data/lib/kitchen/directions/bake_equations.rb +37 -0
- data/lib/kitchen/directions/bake_example.rb +39 -11
- data/lib/kitchen/directions/bake_figure.rb +8 -5
- data/lib/kitchen/directions/bake_first_elements.rb +16 -0
- data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
- data/lib/kitchen/directions/bake_footnotes/v1.rb +6 -5
- 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/main.rb +2 -2
- data/lib/kitchen/directions/bake_index/v1.rb +46 -18
- data/lib/kitchen/directions/bake_link_placeholders.rb +24 -0
- data/lib/kitchen/directions/bake_math_in_paragraph.rb +5 -3
- 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 +4 -4
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +37 -18
- data/lib/kitchen/directions/bake_page_abstracts.rb +30 -0
- data/lib/kitchen/directions/bake_preface/main.rb +11 -0
- data/lib/kitchen/directions/bake_preface/v1.rb +18 -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 +8 -12
- data/lib/kitchen/directions/bake_suggested_reading.rb +31 -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 +49 -22
- data/lib/kitchen/directions/bake_unit_title/main.rb +11 -0
- data/lib/kitchen/directions/bake_unit_title/v1.rb +23 -0
- data/lib/kitchen/directions/bake_unnumbered_tables.rb +7 -5
- data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
- data/lib/kitchen/directions/book_answer_key_container/main.rb +11 -0
- 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/directions/move_title_text_into_span.rb +2 -2
- data/lib/kitchen/document.rb +83 -13
- data/lib/kitchen/element.rb +20 -3
- data/lib/kitchen/element_base.rb +373 -63
- data/lib/kitchen/element_enumerator.rb +8 -0
- data/lib/kitchen/element_enumerator_base.rb +297 -28
- data/lib/kitchen/element_enumerator_factory.rb +64 -53
- data/lib/kitchen/element_factory.rb +27 -12
- data/lib/kitchen/errors.rb +5 -0
- data/lib/kitchen/example_element.rb +21 -6
- data/lib/kitchen/example_element_enumerator.rb +9 -1
- data/lib/kitchen/exercise_element.rb +42 -0
- data/lib/kitchen/exercise_element_enumerator.rb +21 -0
- data/lib/kitchen/figure_element.rb +36 -5
- data/lib/kitchen/figure_element_enumerator.rb +9 -1
- data/lib/kitchen/metadata_element.rb +34 -0
- data/lib/kitchen/metadata_element_enumerator.rb +21 -0
- data/lib/kitchen/mixins/block_error_if.rb +24 -4
- data/lib/kitchen/note_element.rb +48 -20
- data/lib/kitchen/note_element_enumerator.rb +9 -1
- data/lib/kitchen/oven.rb +66 -15
- data/lib/kitchen/page_element.rb +84 -14
- data/lib/kitchen/page_element_enumerator.rb +9 -1
- data/lib/kitchen/pantry.rb +28 -1
- data/lib/kitchen/patches/nokogiri.rb +19 -2
- data/lib/kitchen/patches/renderable.rb +9 -3
- data/lib/kitchen/patches/string.rb +8 -0
- data/lib/kitchen/recipe.rb +69 -32
- data/lib/kitchen/reference_element.rb +27 -0
- data/lib/kitchen/references_element_enumerator.rb +20 -0
- data/lib/kitchen/search_history.rb +43 -4
- data/lib/kitchen/search_query.rb +106 -0
- data/lib/kitchen/selector.rb +24 -0
- data/lib/kitchen/selectors/base.rb +65 -0
- data/lib/kitchen/selectors/standard_1.rb +21 -0
- data/lib/kitchen/table_element.rb +55 -7
- data/lib/kitchen/table_element_enumerator.rb +9 -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 +15 -4
- data/lib/kitchen/term_element_enumerator.rb +9 -1
- data/lib/kitchen/transliterations.rb +7 -5
- data/lib/kitchen/type_casting_element_enumerator.rb +17 -1
- data/lib/kitchen/unit_element.rb +45 -0
- data/lib/kitchen/unit_element_enumerator.rb +20 -0
- data/lib/kitchen/utils.rb +10 -13
- data/lib/kitchen/version.rb +5 -1
- data/lib/locales/en.yml +18 -7
- data/lib/locales/pl.yml +24 -0
- data/lib/openstax_kitchen.rb +59 -0
- data/openstax_kitchen.gemspec +26 -20
- data/tutorials/00/solution1.rb +9 -0
- data/tutorials/00/solution2.rb +8 -0
- data/tutorials/01/solution1.rb +18 -0
- data/tutorials/01/solution2.rb +26 -0
- data/tutorials/02/solution1.rb +31 -0
- data/tutorials/03/{solution_1.rb → solution1.rb} +6 -4
- data/tutorials/03/solution2.rb +18 -0
- data/tutorials/04/{solution_1.rb → solution1.rb} +4 -2
- data/tutorials/04/{solution_2.rb → solution2.rb} +6 -4
- data/tutorials/05/solution1.rb +11 -0
- data/tutorials/check_it +16 -15
- data/tutorials/setup_my_recipes +7 -6
- metadata +148 -27
- data/Dockerfile +0 -19
- data/bin/normalize +0 -79
- data/books/chemistry2e/bake.rb +0 -133
- data/docker-compose.yml +0 -12
- data/docker/entrypoint +0 -9
- data/lib/kitchen.rb +0 -57
- data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -34
- data/lib/kitchen/directions/bake_exercises.rb +0 -164
- data/lib/kitchen/directions/bake_notes.rb +0 -58
- data/tutorials/00/solution_1.rb +0 -7
- data/tutorials/00/solution_2.rb +0 -6
- data/tutorials/01/solution_1.rb +0 -16
- data/tutorials/01/solution_2.rb +0 -24
- data/tutorials/02/solution_1.rb +0 -29
- data/tutorials/03/solution_2.rb +0 -15
- data/tutorials/05/solution_1.rb +0 -9
@@ -0,0 +1,22 @@
|
|
1
|
+
inherit_from: ../../../.rubocop.yml
|
2
|
+
|
3
|
+
# Directions are supposed to be a big list of steps, so don't let Rubocop penalize
|
4
|
+
# us for that
|
5
|
+
|
6
|
+
Metrics/MethodLength:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/CyclomaticComplexity:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/PerceivedComplexity:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false # module names here are pretty clear
|
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kitchen
|
2
4
|
module Directions
|
3
5
|
module BakeAppendix
|
4
|
-
|
5
6
|
def self.v1(page:, number:)
|
6
7
|
title = page.title
|
7
|
-
title.name =
|
8
|
+
title.name = 'h1'
|
8
9
|
title.replace_children(with:
|
9
10
|
<<~HTML
|
10
11
|
<span class="os-part-text">#{I18n.t(:appendix)} </span>
|
@@ -15,12 +16,11 @@ module Kitchen
|
|
15
16
|
)
|
16
17
|
|
17
18
|
# Make a section with data-depth of X have a header level of X+1
|
18
|
-
page.search(
|
19
|
+
page.search('section').each do |section|
|
19
20
|
title = section.first!("[data-type='title']")
|
20
21
|
title.name = "h#{section['data-depth'].to_i + 1}"
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
# Bake directons for eoc glossary
|
6
|
+
#
|
7
|
+
module BakeChapterGlossary
|
8
|
+
def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: nil)
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
append_to: append_to,
|
13
|
+
uuid_prefix: uuid_prefix
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterGlossary
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
|
7
|
+
def bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '')
|
8
|
+
@metadata = metadata_source.children_to_keep.copy
|
9
|
+
@klass = 'glossary'
|
10
|
+
@title = I18n.t(:eoc_key_terms_title)
|
11
|
+
@uuid_prefix = uuid_prefix
|
12
|
+
|
13
|
+
definitions = chapter.glossaries.search('dl').cut
|
14
|
+
return if definitions.none?
|
15
|
+
definitions.sort_by! do |definition|
|
16
|
+
[definition.first('dt').text.downcase, definition.first('dd').text.downcase]
|
17
|
+
end
|
18
|
+
|
19
|
+
chapter.glossaries.trash
|
20
|
+
|
21
|
+
@content = definitions.paste
|
22
|
+
|
23
|
+
append_to_element = append_to || chapter
|
24
|
+
@in_composite_chapter = append_to_element.is?(:composite_chapter)
|
25
|
+
|
26
|
+
append_to_element.append(child: render(file:
|
27
|
+
'../../templates/eoc_section_title_template.xhtml.erb'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kitchen
|
2
4
|
module Directions
|
3
5
|
module BakeChapterIntroductions
|
4
|
-
|
5
6
|
def self.v1(book:)
|
6
7
|
book.chapters.each do |chapter|
|
7
8
|
outline_items_html = chapter.pages.map do |page|
|
@@ -10,13 +11,13 @@ module Kitchen
|
|
10
11
|
<<~HTML
|
11
12
|
<div class="os-chapter-objective">
|
12
13
|
<a class="os-chapter-objective" href="##{page.title[:id]}">
|
13
|
-
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)-1}</span>
|
14
|
+
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter) - 1}</span>
|
14
15
|
<span class="os-divider"> </span>
|
15
16
|
<span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
|
16
17
|
</a>
|
17
18
|
</div>
|
18
19
|
HTML
|
19
|
-
end.join(
|
20
|
+
end.join('')
|
20
21
|
|
21
22
|
introduction_page = chapter.introduction_page
|
22
23
|
|
@@ -24,16 +25,16 @@ module Kitchen
|
|
24
25
|
introduction_page.search("div[data-type='abstract']").trash
|
25
26
|
|
26
27
|
title = introduction_page.title.cut
|
27
|
-
title.name =
|
28
|
+
title.name = 'h2'
|
28
29
|
MoveTitleTextIntoSpan.v1(title: title)
|
29
30
|
|
30
|
-
intro_content = introduction_page.search("> :not([data-type='metadata']):not(
|
31
|
+
intro_content = introduction_page.search("> :not([data-type='metadata']):not(.splash):not(.has-splash)").cut
|
31
32
|
|
32
33
|
introduction_page.append(child:
|
33
34
|
<<~HTML
|
34
35
|
<div class="intro-body">
|
35
36
|
<div class="os-chapter-outline">
|
36
|
-
<h3 class="os-title"
|
37
|
+
<h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
|
37
38
|
#{outline_items_html}
|
38
39
|
</div>
|
39
40
|
<div class="intro-text">
|
@@ -52,7 +53,6 @@ module Kitchen
|
|
52
53
|
something_with_selectors.selectors.title_in_introduction_page =
|
53
54
|
".intro-text > [data-type='document-title']"
|
54
55
|
end
|
55
|
-
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeChapterKeyConcepts
|
6
|
+
def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
|
7
|
+
V1.new.bake(
|
8
|
+
chapter: chapter,
|
9
|
+
metadata_source: metadata_source,
|
10
|
+
append_to: append_to,
|
11
|
+
uuid_prefix: uuid_prefix
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterKeyConcepts
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
|
7
|
+
@metadata = metadata_source.children_to_keep.copy
|
8
|
+
@klass = 'key-concepts'
|
9
|
+
@title = I18n.t(:eoc_key_concepts)
|
10
|
+
@uuid_prefix = uuid_prefix
|
11
|
+
|
12
|
+
key_concepts_clipboard = Kitchen::Clipboard.new
|
13
|
+
chapter.non_introduction_pages.each do |page|
|
14
|
+
key_concepts = page.key_concepts
|
15
|
+
next if key_concepts.none?
|
16
|
+
|
17
|
+
key_concepts.search('h3').trash
|
18
|
+
title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
|
19
|
+
key_concepts.each do |key_concept|
|
20
|
+
key_concept.prepend(child: title)
|
21
|
+
key_concept.wrap("<div class='os-section-area'>")
|
22
|
+
page.search('.os-section-area').first.cut(to: key_concepts_clipboard)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@content = "<div class=\"os-key-concepts\"> #{key_concepts_clipboard.paste} </div>"
|
27
|
+
|
28
|
+
append_to_element = append_to || chapter
|
29
|
+
@in_composite_chapter = append_to_element.is?(:composite_chapter)
|
30
|
+
|
31
|
+
append_to_element.append(child: render(file:
|
32
|
+
'../../templates/eoc_section_title_template.xhtml.erb'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,30 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kitchen
|
2
4
|
module Directions
|
5
|
+
# Bake directons for eoc key equations
|
6
|
+
#
|
3
7
|
module BakeChapterKeyEquations
|
8
|
+
def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
append_to: append_to,
|
13
|
+
uuid_prefix: uuid_prefix
|
14
|
+
)
|
15
|
+
end
|
4
16
|
|
5
|
-
|
6
|
-
|
7
|
-
|
17
|
+
class V1
|
18
|
+
renderable
|
19
|
+
def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
|
20
|
+
@metadata = metadata_source.children_to_keep.copy
|
21
|
+
@klass = 'key-equations'
|
22
|
+
@title = I18n.t(:eoc_key_equations)
|
23
|
+
@uuid_prefix = uuid_prefix
|
8
24
|
|
9
|
-
|
10
|
-
key_equations = chapter.key_equations.cut
|
25
|
+
chapter.key_equations.search('h3').trash
|
11
26
|
|
12
|
-
|
13
|
-
<<~HTML
|
14
|
-
<div class="os-eoc os-key-equations-container" data-type="composite-page" data-uuid-key=".key-equations">
|
15
|
-
<h2 data-type="document-title">
|
16
|
-
<span class="os-text">#{I18n.t(:eoc_key_equations)}</span>
|
17
|
-
</h2>
|
18
|
-
<div data-type="metadata" style="display: none;">
|
19
|
-
<h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_key_equations)}</h1>
|
20
|
-
#{metadata_elements.paste}
|
21
|
-
</div>
|
22
|
-
#{key_equations.paste}
|
23
|
-
</div>
|
24
|
-
HTML
|
25
|
-
) unless key_equations.none?
|
26
|
-
end
|
27
|
+
return if chapter.key_equations.none?
|
27
28
|
|
29
|
+
@content = chapter.key_equations.cut.paste
|
30
|
+
|
31
|
+
append_to_element = append_to || chapter
|
32
|
+
@in_composite_chapter = append_to_element.is?(:composite_chapter)
|
33
|
+
|
34
|
+
append_to_element.append(child: render(file:
|
35
|
+
'../templates/eoc_section_title_template.xhtml.erb'))
|
36
|
+
end
|
37
|
+
end
|
28
38
|
end
|
29
39
|
end
|
30
40
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterSectionExercises
|
4
|
+
class V1
|
5
|
+
def bake(chapter:)
|
6
|
+
chapter.pages.each do |page|
|
7
|
+
page.search('section.section-exercises').each do |section|
|
8
|
+
section.wrap(
|
9
|
+
%(<div class="os-eos os-section-exercises-container"
|
10
|
+
data-uuid-key=".section-exercises">)
|
11
|
+
)
|
12
|
+
|
13
|
+
section_title = I18n.t(
|
14
|
+
:section_exercises,
|
15
|
+
number: "#{chapter.count_in(:book)}.#{section.count_in(:chapter)}")
|
16
|
+
|
17
|
+
section.prepend(sibling:
|
18
|
+
<<~HTML
|
19
|
+
<h3 data-type="document-title">
|
20
|
+
<span class="os-text">#{section_title}</span>
|
21
|
+
</h3>
|
22
|
+
HTML
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,52 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kitchen
|
2
4
|
module Directions
|
5
|
+
# Bake directions for eoc summary
|
6
|
+
#
|
3
7
|
module BakeChapterSummary
|
8
|
+
def self.v1(chapter:, metadata_source:, klass: 'summary', uuid_prefix: '.')
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
uuid_prefix: uuid_prefix,
|
13
|
+
klass: klass
|
14
|
+
)
|
15
|
+
end
|
4
16
|
|
5
|
-
|
6
|
-
|
7
|
-
|
17
|
+
class V1
|
18
|
+
renderable
|
19
|
+
def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'summary')
|
20
|
+
@metadata = metadata_source.children_to_keep.copy
|
21
|
+
@klass = klass
|
22
|
+
@title = I18n.t(:eoc_summary_title)
|
23
|
+
@uuid_prefix = uuid_prefix
|
8
24
|
|
9
|
-
|
25
|
+
summaries = Clipboard.new
|
10
26
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
27
|
+
# TODO: include specific page types somehow without writing it out
|
28
|
+
chapter.non_introduction_pages.each do |page|
|
29
|
+
summary = page.summary
|
30
|
+
summary.first("[data-type='title']")&.trash # get rid of old title if exists
|
31
|
+
summary_title = page.title.copy
|
32
|
+
summary_title.name = 'h3'
|
33
|
+
summary_title.replace_children(with: <<~HTML
|
18
34
|
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
|
19
35
|
<span class="os-divider"> </span>
|
20
36
|
<span class="os-text" data-type="" itemprop="">#{summary_title.children}</span>
|
21
37
|
HTML
|
22
|
-
|
38
|
+
)
|
23
39
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
40
|
+
summary.prepend(child:
|
41
|
+
<<~HTML
|
42
|
+
<a href="##{page.title.id}">
|
43
|
+
#{summary_title.paste}
|
44
|
+
</a>
|
45
|
+
HTML
|
46
|
+
)
|
47
|
+
summary.cut(to: summaries)
|
48
|
+
end
|
33
49
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
<span class="os-text">#{I18n.t(:eoc_summary_title)}</span>
|
39
|
-
</h2>
|
40
|
-
<div data-type="metadata" style="display: none;">
|
41
|
-
<h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_summary_title)}</h1>
|
42
|
-
#{metadata_elements.paste}
|
43
|
-
</div>
|
44
|
-
#{summaries.paste}
|
45
|
-
</div>
|
46
|
-
HTML
|
47
|
-
) unless summaries.none?
|
48
|
-
end
|
50
|
+
return if summaries.none?
|
51
|
+
|
52
|
+
@content = summaries.paste
|
53
|
+
@in_composite_chapter = false
|
49
54
|
|
55
|
+
chapter.append(child: render(file:
|
56
|
+
'../templates/eoc_section_title_template.xhtml.erb'))
|
57
|
+
end
|
58
|
+
end
|
50
59
|
end
|
51
60
|
end
|
52
61
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterTitle
|
4
|
+
class V1
|
5
|
+
def bake(book:)
|
6
|
+
book.chapters.each do |chapter|
|
7
|
+
fix_up_chapter_title(chapter: chapter)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def fix_up_chapter_title(chapter:)
|
12
|
+
heading = chapter.at('h1[2]')
|
13
|
+
heading[:id] = "chapTitle#{chapter.count_in(:book)}"
|
14
|
+
heading.replace_children(with:
|
15
|
+
<<~HTML
|
16
|
+
<span class="os-part-text">#{I18n.t(:chapter)} </span>
|
17
|
+
<span class="os-number">#{chapter.count_in(:book)}</span>
|
18
|
+
<span class="os-divider"> </span>
|
19
|
+
<span data-type="" itemprop="" class="os-text">#{heading.text}</span>
|
20
|
+
HTML
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|