openstax_kitchen 8.0.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/kitchen/chapter_element.rb +0 -8
  5. data/lib/kitchen/directions/.rubocop.yml +3 -0
  6. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +8 -12
  7. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +9 -13
  8. data/lib/kitchen/directions/bake_chapter_key_equations.rb +10 -17
  9. data/lib/kitchen/directions/bake_chapter_references/v1.rb +10 -12
  10. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +8 -12
  11. data/lib/kitchen/directions/bake_chapter_summary.rb +10 -32
  12. data/lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb +11 -0
  13. data/lib/kitchen/directions/bake_further_research.rb +13 -39
  14. data/lib/kitchen/directions/eoc_composite_page_container/main.rb +27 -0
  15. data/lib/kitchen/directions/eoc_composite_page_container/v1.rb +19 -0
  16. data/lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb +37 -0
  17. data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +27 -0
  18. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +10 -27
  19. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +11 -18
  20. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +14 -38
  21. data/lib/kitchen/example_element.rb +1 -1
  22. data/lib/kitchen/templates/eoc_section_template.xhtml.erb +11 -0
  23. data/lib/kitchen/templates/eoc_section_template_old.xhtml.erb +11 -0
  24. data/lib/kitchen/version.rb +1 -1
  25. data/lib/locales/en.yml +7 -5
  26. data/lib/locales/es.yml +6 -4
  27. data/lib/locales/pl.yml +5 -3
  28. metadata +9 -3
  29. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50c444687ca21462df4d8110fd8789f10ba40a439b5d037b3eba8d255b5e16fa
4
- data.tar.gz: 353afbf616ae3f9794ee13594cf9baa244fbc1077e55c78c193aac1a89cefffd
3
+ metadata.gz: fca2eb47435f5ff74342d7de2afc02e2c55eed224f1ae669b440d52a1c50b1b0
4
+ data.tar.gz: f22d42bc7618868d1890e149d9e0bf5134945b8fccce5c7742827e6c53589d81
5
5
  SHA512:
6
- metadata.gz: 0b52d4418f83bdacfac36d7d6c904500cd4bb965795f91e718c6588e0f27c72eb5b73d9b05db9f2bafa60711717c93888a0d09ced10c6986e7ec0a83d7283a31
7
- data.tar.gz: 34ebd35add4868907853f3a3e4cc839f521352d3eadc763350487e5a7f372f947e6e837d0fea7ad198810d968c1e1bfc7a591f515b65218253c084db21b85a45
6
+ metadata.gz: a457781d0bcb61533c5b96ca0b2ffcde74a69743a54c09f4b901b7e769056d1d616afa736df40067e7472a479c8526505d72fe5d7e9ecf3eca6789581d92c380
7
+ data.tar.gz: 9f517fbc86ae32e0fd2bbc108774a9f4b94a63df01675530c7f26d7f9bf9522654f4ddb5d7e1c9d141b1a67a0ccc6a98ac2f8c0cf94719ccf04b67cfbf69f240
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [9.0.0] - 2021-07-12
10
+
11
+ * Refactor `BakeChapterKeyConcepts`, `BakeChapterReferences`, `BakeChapterSolutions`, and `MoveExercisesToEoc` versions 1-3 to use new general eoc directions (major?)
12
+ * Fixed `BakeExample.v1` to also search inside `.body` for titles (minor)
13
+ * Add documentation to `MoveCustomSectionToEocContainer` & `EocCompositePageContainer` (minor)
14
+ * Add a `MoveCustomSectionToEocContainer` to allow for custom sections (minor)
15
+ * Add a `EocCompositePageContainer` direction to handle creation of eoc page wrapper (minor)
16
+ * Refactor `BakeChapterKeyEquations`, `BakeChapterGlossary`, `BakeChapterSummary`, `BakeFurtherResearch` (major)
17
+ * Fix metadata title in composite pages (major)
9
18
 
10
19
  ## [8.0.1] - 2021-06-29
11
20
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (8.0.1)
4
+ openstax_kitchen (9.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -52,14 +52,6 @@ module Kitchen
52
52
  search("div[data-type='glossary']")
53
53
  end
54
54
 
55
- # Returns an enumerator for the key equations
56
- #
57
- # @return [ElementEnumerator]
58
- #
59
- def key_equations
60
- search('section.key-equations')
61
- end
62
-
63
55
  # Returns an enumerator for the abstracts
64
56
  #
65
57
  # @return [ElementEnumerator]
@@ -15,6 +15,9 @@ Metrics/CyclomaticComplexity:
15
15
  Metrics/PerceivedComplexity:
16
16
  Enabled: false
17
17
 
18
+ Metrics/ParameterLists:
19
+ Max: 5
20
+
18
21
  Style/ClassAndModuleChildren:
19
22
  Enabled: false
20
23
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterGlossary
4
4
  class V1
5
- renderable
6
-
7
5
  class Definition
8
6
  attr_reader :element
9
7
 
@@ -24,10 +22,6 @@ module Kitchen::Directions::BakeChapterGlossary
24
22
  end
25
23
 
26
24
  def bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '')
27
- @metadata = metadata_source.children_to_keep.copy
28
- @klass = 'glossary'
29
- @title = I18n.t(:eoc_key_terms_title)
30
- @uuid_prefix = uuid_prefix
31
25
  @glossary = []
32
26
 
33
27
  chapter.glossaries.search('dl').each do |definition_element|
@@ -36,13 +30,15 @@ module Kitchen::Directions::BakeChapterGlossary
36
30
 
37
31
  chapter.glossaries.trash
38
32
 
39
- @content = @glossary.sort.map { |definition| definition.element.paste }.join
40
-
41
- append_to_element = append_to || chapter
42
- @in_composite_chapter = append_to_element.is?(:composite_chapter)
33
+ content = @glossary.sort.map { |definition| definition.element.paste }.join
43
34
 
44
- append_to_element.append(child: render(file:
45
- '../../templates/eoc_section_title_template.xhtml.erb'))
35
+ Kitchen::Directions::EocCompositePageContainer.v1(
36
+ container_key: 'glossary',
37
+ uuid_key: "#{uuid_prefix}glossary",
38
+ metadata_source: metadata_source,
39
+ content: content,
40
+ append_to: append_to || chapter
41
+ )
46
42
  end
47
43
  end
48
44
  end
@@ -2,34 +2,30 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterKeyConcepts
4
4
  class V1
5
- renderable
6
5
  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
6
  key_concepts_clipboard = Kitchen::Clipboard.new
13
7
  chapter.non_introduction_pages.each do |page|
14
8
  key_concepts = page.key_concepts
15
9
  next if key_concepts.none?
16
10
 
17
- key_concepts.search('h3').trash
18
11
  title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
19
12
  key_concepts.each do |key_concept|
13
+ Kitchen::Directions::RemoveSectionTitle.v1(section: key_concept)
20
14
  key_concept.prepend(child: title)
21
15
  key_concept.wrap("<div class='os-section-area'>")
22
16
  page.search('div.os-section-area').first.cut(to: key_concepts_clipboard)
23
17
  end
24
18
  end
25
19
 
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)
20
+ content = "<div class=\"os-key-concepts\"> #{key_concepts_clipboard.paste} </div>"
30
21
 
31
- append_to_element.append(child: render(file:
32
- '../../templates/eoc_section_title_template.xhtml.erb'))
22
+ Kitchen::Directions::EocCompositePageContainer.v1(
23
+ container_key: 'key-concepts',
24
+ uuid_key: "#{uuid_prefix}key-concepts",
25
+ metadata_source: metadata_source,
26
+ content: content,
27
+ append_to: append_to || chapter
28
+ )
33
29
  end
34
30
  end
35
31
  end
@@ -15,24 +15,17 @@ module Kitchen
15
15
  end
16
16
 
17
17
  class V1
18
- renderable
19
18
  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
24
-
25
- chapter.key_equations.search('h3').trash
26
-
27
- return if chapter.key_equations.none?
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'))
19
+ MoveCustomSectionToEocContainer.v1(
20
+ chapter: chapter,
21
+ metadata_source: metadata_source,
22
+ container_key: 'key-equations',
23
+ uuid_key: "#{uuid_prefix}key-equations",
24
+ section_selector: 'section.key-equations',
25
+ append_to: append_to
26
+ ) do |section|
27
+ RemoveSectionTitle.v1(section: section)
28
+ end
36
29
  end
37
30
  end
38
31
  end
@@ -2,25 +2,22 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterReferences
4
4
  class V1
5
- renderable
6
-
7
5
  def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
8
- @metadata = metadata_source.children_to_keep.copy
9
- @klass = klass
10
- @title = I18n.t(:references)
11
- @uuid_prefix = uuid_prefix
12
-
13
- chapter.references.search('h3').trash
14
-
15
6
  bake_page_references(page: chapter.introduction_page)
16
7
 
17
8
  chapter.non_introduction_pages.each do |page|
18
9
  bake_page_references(page: page)
19
10
  end
20
11
 
21
- @content = chapter.pages.references.cut.paste
22
- chapter.append(child: render(file:
23
- '../../templates/eoc_section_title_template.xhtml.erb'))
12
+ content = chapter.pages.references.cut.paste
13
+
14
+ Kitchen::Directions::EocCompositePageContainer.v1(
15
+ container_key: klass,
16
+ uuid_key: "#{uuid_prefix}#{klass}",
17
+ metadata_source: metadata_source,
18
+ content: content,
19
+ append_to: chapter
20
+ )
24
21
  end
25
22
 
26
23
  def bake_page_references(page:)
@@ -42,6 +39,7 @@ module Kitchen::Directions::BakeChapterReferences
42
39
  end
43
40
 
44
41
  references.each do |reference|
42
+ Kitchen::Directions::RemoveSectionTitle.v1(section: reference)
45
43
  reference.prepend(child: title)
46
44
  end
47
45
  end
@@ -2,14 +2,7 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterSolutions
4
4
  class V1
5
- renderable
6
-
7
5
  def bake(chapter:, metadata_source:, uuid_prefix: '')
8
- @metadata = metadata_source.children_to_keep.copy
9
- @klass = 'solutions'
10
- @title = I18n.t(:eoc_solutions_title)
11
- @uuid_prefix = uuid_prefix
12
-
13
6
  solutions_clipboard = Kitchen::Clipboard.new
14
7
 
15
8
  chapter.search('section.free-response').each do |free_response_question|
@@ -26,12 +19,15 @@ module Kitchen::Directions::BakeChapterSolutions
26
19
  end
27
20
  end
28
21
 
29
- @content = solutions_clipboard.paste
30
-
31
- @in_composite_chapter = false
22
+ content = solutions_clipboard.paste
32
23
 
33
- chapter.append(child: render(file:
34
- '../../templates/eoc_section_title_template.xhtml.erb'))
24
+ Kitchen::Directions::EocCompositePageContainer.v1(
25
+ container_key: 'solutions',
26
+ uuid_key: "#{uuid_prefix}solutions",
27
+ metadata_source: metadata_source,
28
+ content: content,
29
+ append_to: chapter
30
+ )
35
31
  end
36
32
  end
37
33
  end
@@ -15,52 +15,30 @@ module Kitchen
15
15
  end
16
16
 
17
17
  class V1
18
- renderable
19
18
  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
24
-
25
19
  summaries = Clipboard.new
26
20
 
27
- # TODO: include specific page types somehow without writing it out
28
21
  chapter.non_introduction_pages.each do |page|
29
22
  summary = page.summary
30
23
 
31
24
  next if summary.nil?
32
25
 
33
26
  summary.first("[data-type='title']")&.trash # get rid of old title if exists
34
- summary_title = page.title.copy
35
- summary_title.name = 'h3'
36
-
37
- unless summary_title.children.search('span.os-number').present?
38
- summary_title.replace_children(with:
39
- <<~HTML
40
- <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
41
- <span class="os-divider"> </span>
42
- <span class="os-text" data-type="" itemprop="">#{summary_title.children}</span>
43
- HTML
44
- )
45
- end
46
-
47
- summary.prepend(child:
48
- <<~HTML
49
- <a href="##{page.title.id}">
50
- #{summary_title.paste}
51
- </a>
52
- HTML
53
- )
27
+ title = EocSectionTitleLinkSnippet.v1(page: page)
28
+ summary.prepend(child: title)
29
+ summary.first('h3')[:itemprop] = 'name'
54
30
  summary.cut(to: summaries)
55
31
  end
56
32
 
57
33
  return if summaries.none?
58
34
 
59
- @content = summaries.paste
60
- @in_composite_chapter = false
61
-
62
- chapter.append(child: render(file:
63
- '../templates/eoc_section_title_template.xhtml.erb'))
35
+ EocCompositePageContainer.v1(
36
+ container_key: klass,
37
+ uuid_key: "#{uuid_prefix}#{klass}",
38
+ metadata_source: metadata_source,
39
+ content: summaries.paste,
40
+ append_to: chapter
41
+ )
64
42
  end
65
43
  end
66
44
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module RemoveSectionTitle
6
+ def self.v1(section:)
7
+ section.first('[data-type="title"]')&.trash
8
+ end
9
+ end
10
+ end
11
+ end
@@ -13,47 +13,21 @@ module Kitchen
13
13
  end
14
14
 
15
15
  class V1
16
- renderable
17
16
  def bake(chapter:, metadata_source:, uuid_prefix: '.')
18
- @metadata = metadata_source.children_to_keep.copy
19
- @klass = 'further-research'
20
- @title = I18n.t(:eoc_further_research_title)
21
- @uuid_prefix = uuid_prefix
22
-
23
- further_researches = Clipboard.new
24
-
25
- chapter.non_introduction_pages.each do |page|
26
- further_research = page.first('.further-research')
27
- next unless further_research.present?
28
-
29
- further_research.first("[data-type='title']")&.trash # get rid of old title if exists
30
- further_research_title = page.title.copy
31
- further_research_title.name = 'h3'
32
- further_research_title.replace_children(with: <<~HTML
33
- <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
34
- <span class="os-divider"> </span>
35
- <span class="os-text" data-type="" itemprop="">#{further_research_title.children}</span>
36
- HTML
37
- )
38
-
39
- further_research.prepend(child:
40
- <<~HTML
41
- <a href="##{page.title.id}">
42
- #{further_research_title.paste}
43
- </a>
44
- HTML
45
- )
46
- further_research.cut(to: further_researches)
17
+ MoveCustomSectionToEocContainer.v1(
18
+ chapter: chapter,
19
+ metadata_source: metadata_source,
20
+ container_key: 'further-research',
21
+ uuid_key: "#{uuid_prefix}further-research",
22
+ section_selector: 'section.further-research',
23
+ append_to: nil,
24
+ include_intro_page: false
25
+ ) do |further_research|
26
+ RemoveSectionTitle.v1(section: further_research)
27
+ title = EocSectionTitleLinkSnippet.v1(page: further_research.ancestor(:page))
28
+ further_research.prepend(child: title)
29
+ further_research.first('h3')[:itemprop] = 'name'
47
30
  end
48
-
49
- return if further_researches.none?
50
-
51
- @content = further_researches.paste
52
-
53
- @in_composite_chapter = false
54
-
55
- chapter.append(child: render(file:
56
- '../templates/eoc_section_title_template.xhtml.erb'))
57
31
  end
58
32
  end
59
33
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module EocCompositePageContainer
6
+ # Creates a wrapper for the given content & appends it to the given element
7
+ #
8
+ # @param container_key [String] Appended to 'eoc.' to form the I18n key for the container title; also used as part of a class on the container.
9
+ # @param uuid_key [String] the uuid key for the wrapper class, e.g. `'.summary'`
10
+ # @param metadata_source [MetadataElement] metadata for the book
11
+ # @param content [String] the content to be contained by the wrapper
12
+ # @param append_to [ElementBase] the element to be appended, usually either a `ChapterElement` or a `CompositeChapterElement`
13
+ # @return [ElementBase] the append_to element with container appended
14
+ #
15
+ def self.v1(container_key:, uuid_key:, metadata_source:, content:,
16
+ append_to:)
17
+ V1.new.bake(
18
+ container_key: container_key,
19
+ uuid_key: uuid_key,
20
+ metadata_source: metadata_source,
21
+ content: content,
22
+ append_to: append_to
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::EocCompositePageContainer
4
+ class V1
5
+ renderable
6
+
7
+ def bake(container_key:, uuid_key:, metadata_source:, content:, append_to:)
8
+ @title = I18n.t(:"eoc.#{container_key}")
9
+ @uuid_key = uuid_key
10
+ @container_class_type = container_key
11
+ @metadata = metadata_source.children_to_keep.copy
12
+ @content = content
13
+ @in_composite_chapter = append_to.is?(:composite_chapter)
14
+
15
+ append_to.append(child: render(file:
16
+ '../../templates/eoc_section_template.xhtml.erb'))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/ParameterLists
4
+ # More parameters are ok here because these generic classes DRY up a lot of other code
5
+ module Kitchen
6
+ module Directions
7
+ module MoveCustomSectionToEocContainer
8
+ # Creates a custom eoc composite page for a section within the given chapter.
9
+ # The sections are moved into this composite page, and can be transformed before the moved by an optional block argument.
10
+ #
11
+ # @param chapter [ChapterElement] the chapter in which the section to be moved is contained
12
+ # @param metadata_source [MetadataElement] metadata for the book
13
+ # @param container_key [String] Appended to 'eoc.' to form the I18n key for the container title; also used as part of a class on the container.
14
+ # @param uuid_key [String] the uuid key for the wrapper class, e.g. `'.summary'`
15
+ # @param section_selector [String] the selector for the section to be moved, e.g. `'section.summary'`
16
+ # @param append_to [ElementBase] the element to be appended. Defaults to the value of `chapter` param if none given.
17
+ # @param include_intro_page [Boolean] control the introduction page for the chapter should be searched for a section to move, default is true
18
+ # @return [ElementBase] the append_to element with container appended
19
+ #
20
+ def self.v1(chapter:, metadata_source:, container_key:, uuid_key:,
21
+ section_selector:, append_to: nil, include_intro_page: true)
22
+ V1.new.bake(
23
+ chapter: chapter,
24
+ metadata_source: metadata_source,
25
+ container_key: container_key,
26
+ uuid_key: uuid_key,
27
+ section_selector: section_selector,
28
+ append_to: append_to || chapter,
29
+ include_intro_page: include_intro_page
30
+ ) do |section|
31
+ yield section if block_given?
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ # rubocop:enable Metrics/ParameterLists
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/ParameterLists
4
+ # More parameters are ok here because these generic classes DRY up a lot of other code
5
+ module Kitchen::Directions::MoveCustomSectionToEocContainer
6
+ class V1
7
+ def bake(chapter:, metadata_source:, container_key:, uuid_key:,
8
+ section_selector:, append_to:, include_intro_page:, &block)
9
+ section_clipboard = Kitchen::Clipboard.new
10
+ pages = include_intro_page ? chapter.pages : chapter.non_introduction_pages
11
+ sections = pages.search(section_selector)
12
+ sections.each(&block)
13
+ sections.cut(to: section_clipboard)
14
+
15
+ return if section_clipboard.none?
16
+
17
+ Kitchen::Directions::EocCompositePageContainer.v1(
18
+ container_key: container_key,
19
+ uuid_key: uuid_key,
20
+ metadata_source: metadata_source,
21
+ content: section_clipboard.paste,
22
+ append_to: append_to || chapter
23
+ )
24
+ end
25
+ end
26
+ end
27
+ # rubocop:enable Metrics/ParameterLists
@@ -2,35 +2,18 @@
2
2
 
3
3
  module Kitchen::Directions::MoveExercisesToEOC
4
4
  class V1
5
- renderable
6
-
7
5
  def bake(chapter:, metadata_source:, klass:, append_to: nil, uuid_prefix: '.')
8
- @klass = klass
9
- @metadata = metadata_source.children_to_keep.copy
10
- @title = I18n.t(:"eoc.#{klass}")
11
- @uuid_prefix = uuid_prefix
12
-
13
- exercise_clipboard = Kitchen::Clipboard.new
14
-
15
- chapter.non_introduction_pages.each do |page|
16
- sections = page.search("section.#{@klass}")
17
-
18
- sections.each do |exercise_section|
19
- exercise_section.first("[data-type='title']")&.trash
20
-
21
- exercise_section.cut(to: exercise_clipboard)
22
- end
6
+ Kitchen::Directions::MoveCustomSectionToEocContainer.v1(
7
+ chapter: chapter,
8
+ metadata_source: metadata_source,
9
+ container_key: klass,
10
+ uuid_key: "#{uuid_prefix}#{klass}",
11
+ section_selector: "section.#{klass}",
12
+ append_to: append_to || chapter,
13
+ include_intro_page: false
14
+ ) do |exercise_section|
15
+ Kitchen::Directions::RemoveSectionTitle.v1(section: exercise_section)
23
16
  end
24
-
25
- return if exercise_clipboard.none?
26
-
27
- @content = exercise_clipboard.paste
28
-
29
- append_to_element = append_to || chapter
30
- @in_composite_chapter = append_to_element.is?(:composite_chapter)
31
-
32
- append_to_element.append(child: render(file:
33
- '../../templates/eoc_section_title_template.xhtml.erb'))
34
17
  end
35
18
  end
36
19
  end
@@ -4,25 +4,16 @@ module Kitchen::Directions::MoveExercisesToEOC
4
4
  # Main difference from v1 is the presence of a section title
5
5
  # and some additional wrappers
6
6
  class V2
7
- renderable
8
-
9
7
  def bake(chapter:, metadata_source:, klass:, append_to: nil, uuid_prefix: '.')
10
- @klass = klass
11
- @metadata = metadata_source.children_to_keep.copy
12
- @title = I18n.t(:"eoc.#{klass}")
13
- @uuid_prefix = uuid_prefix
14
-
15
8
  exercise_clipboard = Kitchen::Clipboard.new
16
9
 
17
10
  chapter.non_introduction_pages.each do |page|
18
- sections = page.search("section.#{@klass}")
11
+ sections = page.search("section.#{klass}")
19
12
 
20
13
  sections.each do |exercise_section|
21
- exercise_section.first("[data-type='title']")&.trash
22
-
14
+ Kitchen::Directions::RemoveSectionTitle.v1(section: exercise_section)
23
15
  # Get parent page title
24
16
  section_title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
25
-
26
17
  # Configure section title & wrappers
27
18
  exercise_section.prepend(child: section_title)
28
19
  exercise_section.wrap('<div class="os-section-area">')
@@ -33,17 +24,19 @@ module Kitchen::Directions::MoveExercisesToEOC
33
24
 
34
25
  return if exercise_clipboard.none?
35
26
 
36
- @content = <<~HTML
37
- <div class="os-#{@klass}">
27
+ content = <<~HTML
28
+ <div class="os-#{klass}">
38
29
  #{exercise_clipboard.paste}
39
30
  </div>
40
31
  HTML
41
32
 
42
- append_to_element = append_to || chapter
43
- @in_composite_chapter = append_to_element[:'data-type'] == 'composite-chapter'
44
-
45
- append_to_element.append(child: render(file:
46
- '../../templates/eoc_section_title_template.xhtml.erb'))
33
+ Kitchen::Directions::EocCompositePageContainer.v1(
34
+ container_key: klass,
35
+ uuid_key: "#{uuid_prefix}#{klass}",
36
+ metadata_source: metadata_source,
37
+ content: content,
38
+ append_to: append_to || chapter
39
+ )
47
40
  end
48
41
  end
49
42
  end
@@ -4,46 +4,22 @@ module Kitchen::Directions::MoveExercisesToEOC
4
4
  # The difference from v1 is the presence of a section title
5
5
  # and from v2 the lack of additional "os-section-area" and os-#{@klass} wrappers
6
6
  class V3
7
- renderable
8
-
9
7
  def bake(chapter:, metadata_source:, klass:, append_to: nil, uuid_prefix: '.')
10
- @klass = klass
11
- @metadata = metadata_source.children_to_keep.copy
12
- @title = I18n.t(:"eoc.#{klass}")
13
- @uuid_prefix = uuid_prefix
14
-
15
- exercise_clipboard = Kitchen::Clipboard.new
16
-
17
- chapter.non_introduction_pages.each do |page|
18
- sections = page.search("section.#{@klass}")
19
-
20
- sections.each do |exercise_section|
21
- exercise_section.first("[data-type='title']")&.trash
22
-
23
- section_title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
24
-
25
- exercise_section.exercises.each do |exercise|
26
- exercise.document.pantry(name: :link_text).store(
27
- "#{I18n.t(:exercise_label)} #{chapter.count_in(:book)}.#{exercise.count_in(:chapter)}",
28
- label: exercise.id
29
- )
30
- end
31
-
32
- # Configure section title
33
- exercise_section.prepend(child: section_title)
34
- exercise_section.cut(to: exercise_clipboard)
35
- end
8
+ Kitchen::Directions::MoveCustomSectionToEocContainer.v1(
9
+ chapter: chapter,
10
+ metadata_source: metadata_source,
11
+ container_key: klass,
12
+ uuid_key: "#{uuid_prefix}#{klass}",
13
+ section_selector: "section.#{klass}",
14
+ append_to: append_to || chapter,
15
+ include_intro_page: false
16
+ ) do |exercise_section|
17
+ Kitchen::Directions::RemoveSectionTitle.v1(section: exercise_section)
18
+ title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(
19
+ page: exercise_section.ancestor(:page)
20
+ )
21
+ exercise_section.prepend(child: title)
36
22
  end
37
-
38
- return if exercise_clipboard.none?
39
-
40
- @content = exercise_clipboard.paste
41
-
42
- append_to_element = append_to || chapter
43
- @in_composite_chapter = append_to_element.is?(:composite_chapter)
44
-
45
- append_to_element.append(child: render(file:
46
- '../../templates/eoc_section_title_template.xhtml.erb'))
47
23
  end
48
24
  end
49
25
  end
@@ -28,7 +28,7 @@ module Kitchen
28
28
  # @return [ElementEnumerator]
29
29
  #
30
30
  def titles
31
- search("span[data-type='title']")
31
+ search("[data-type='title']")
32
32
  end
33
33
 
34
34
  end
@@ -0,0 +1,11 @@
1
+ <% main_title_tag = @in_composite_chapter ? 'h3' : 'h2' %>
2
+ <div class="os-eoc os-<%=@container_class_type%>-container" data-type="composite-page" data-uuid-key="<%= @uuid_key %>">
3
+ <<%= main_title_tag %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
4
+ <span class="os-text"><%= @title %></span>
5
+ </<%= main_title_tag %>>
6
+ <div data-type="metadata" style="display: none;">
7
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
8
+ <%= @metadata.paste %>
9
+ </div>
10
+ <%= @content %>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <% main_title_tag = @in_composite_chapter ? 'h3' : 'h2' %>
2
+ <div class="os-eoc os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
3
+ <<%= main_title_tag %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
4
+ <span class="os-text"><%= @title %></span>
5
+ </<%= main_title_tag %>>
6
+ <div data-type="metadata" style="display: none;">
7
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
8
+ <%= @metadata.paste %>
9
+ </div>
10
+ <%= @content %>
11
+ </div>
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '8.0.1'
6
+ VERSION = '9.0.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -18,16 +18,18 @@ en:
18
18
  references: References
19
19
  answer_key_title: Answer Key
20
20
  eoc_chapter_review: Chapter Review
21
- eoc_key_terms_title: Key Terms
22
- eoc_summary_title: Summary
23
21
  eoc_exercises_title: Exercises
24
22
  eoc_composite_metadata_title: Chapter Review
25
23
  eoc_solutions_title: Solutions
26
- eoc_key_concepts: Key Concepts
27
- eoc_key_equations: Key Equations
28
24
  eoc_suggested_reading: Suggestions for Further Study
29
- eoc_further_research_title: Further Research
30
25
  eob_index_title: Index
31
26
  eob_index_symbols_group: Symbols
32
27
  review_exercises: Review Exercises
33
28
  section_exercises: ! 'Section %{number} Exercises'
29
+ eoc:
30
+ glossary: Key Terms
31
+ key-equations: Key Equations
32
+ summary: Summary
33
+ further-research: Further Research
34
+ key-concepts: Key Concepts
35
+ references: References
data/lib/locales/es.yml CHANGED
@@ -18,16 +18,18 @@ es:
18
18
  references: Referencias
19
19
  answer_key_title: Clave de Respuestas
20
20
  eoc_chapter_review: Revisión Del Capítulo
21
- eoc_key_terms_title: Términos Clave
22
- eoc_summary_title: Resumen
23
21
  eoc_exercises_title: Ejercicios
24
22
  eoc_composite_metadata_title: Revisión Del Capítulo
25
23
  eoc_solutions_title: Soluciones
26
24
  eoc_key_concepts: Conceptos Clave
27
- eoc_key_equations: Ecuaciones Clave
28
25
  eoc_suggested_reading: Sugerencias Para Estudios Adicionales
29
- eoc_further_research_title: Investigación Adicional
30
26
  eob_index_title: Índice
31
27
  eob_index_symbols_group: Símbolos
32
28
  review_exercises: Ejercicios De Repaso
33
29
  section_exercises: ! 'Sección %{number} Ejercicios'
30
+ eoc:
31
+ glossary: Términos Clave
32
+ key-equations: Ecuaciones Clave
33
+ summary: Resumen
34
+ further-research: Investigación Adicional
35
+ references: Referencias
data/lib/locales/pl.yml CHANGED
@@ -16,11 +16,13 @@ pl:
16
16
  stepwise_step_label: Krok
17
17
  answer_key_title: Rozwiązania zadań
18
18
  eoc_chapter_review: Podsumowanie rozdziału
19
- eoc_key_terms_title: Kluczowe pojęcia
20
19
  eoc_solutions_title: Rozwiązania
21
- eoc_summary_title: Podsumowanie
22
- eoc_key_equations: Najważniejsze wzory
23
20
  eob_index_title: Skorowidz rzeczowy
24
21
  eob_index_symbols_group: Symbole
25
22
  references: Bibliografia
23
+ eoc:
24
+ glossary: Kluczowe pojęcia
25
+ key-equations: Najważniejsze wzory
26
+ summary: Podsumowanie
27
+ references: Bibliografia
26
28
 
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: 8.0.1
4
+ version: 9.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-06-29 00:00:00.000000000 Z
11
+ date: 2021-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -263,6 +263,7 @@ files:
263
263
  - lib/kitchen/directions/bake_checkpoint.rb
264
264
  - lib/kitchen/directions/bake_composite_chapters.rb
265
265
  - lib/kitchen/directions/bake_composite_pages.rb
266
+ - lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb
266
267
  - lib/kitchen/directions/bake_equations.rb
267
268
  - lib/kitchen/directions/bake_example.rb
268
269
  - lib/kitchen/directions/bake_figure.rb
@@ -313,7 +314,11 @@ files:
313
314
  - lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb
314
315
  - lib/kitchen/directions/chapter_review_container/main.rb
315
316
  - lib/kitchen/directions/chapter_review_container/v1.rb
317
+ - lib/kitchen/directions/eoc_composite_page_container/main.rb
318
+ - lib/kitchen/directions/eoc_composite_page_container/v1.rb
316
319
  - lib/kitchen/directions/eoc_section_title_link_snippet.rb
320
+ - lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb
321
+ - lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
317
322
  - lib/kitchen/directions/move_exercises_to_eoc/main.rb
318
323
  - lib/kitchen/directions/move_exercises_to_eoc/v1.rb
319
324
  - lib/kitchen/directions/move_exercises_to_eoc/v2.rb
@@ -368,7 +373,8 @@ files:
368
373
  - lib/kitchen/table_element.rb
369
374
  - lib/kitchen/table_element_enumerator.rb
370
375
  - lib/kitchen/templates/eob_section_title_template.xhtml.erb
371
- - lib/kitchen/templates/eoc_section_title_template.xhtml.erb
376
+ - lib/kitchen/templates/eoc_section_template.xhtml.erb
377
+ - lib/kitchen/templates/eoc_section_template_old.xhtml.erb
372
378
  - lib/kitchen/term_element.rb
373
379
  - lib/kitchen/term_element_enumerator.rb
374
380
  - lib/kitchen/type_casting_element_enumerator.rb
@@ -1,10 +0,0 @@
1
- <div class="os-eoc os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
2
- <<%= @in_composite_chapter ? 'h3' : 'h2' %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
3
- <span class="os-text"><%= @title %></span>
4
- </<%= @in_composite_chapter ? 'h3' : 'h2' %>>
5
- <div data-type="metadata" style="display: none;">
6
- <h1 data-type="document-title" itemprop="name"><%= @in_composite_chapter ? I18n.t(:eoc_composite_metadata_title) : @title %></h1>
7
- <%= @metadata.paste %>
8
- </div>
9
- <%= @content %>
10
- </div>