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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.md +77 -3
  4. data/Gemfile.lock +13 -14
  5. data/README.md +23 -0
  6. data/codecov.yaml +1 -0
  7. data/docker/ci +0 -1
  8. data/lib/kitchen/book_document.rb +1 -1
  9. data/lib/kitchen/book_element.rb +16 -2
  10. data/lib/kitchen/chapter_element.rb +10 -13
  11. data/lib/kitchen/chapter_element_enumerator.rb +1 -1
  12. data/lib/kitchen/composite_chapter_element.rb +7 -11
  13. data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
  14. data/lib/kitchen/composite_page_element.rb +15 -10
  15. data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
  16. data/lib/kitchen/config.rb +14 -0
  17. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  18. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  19. data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
  20. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +16 -0
  21. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +35 -0
  22. data/lib/kitchen/directions/bake_chapter_key_equations.rb +27 -20
  23. data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
  24. data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
  25. data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +11 -0
  26. data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +28 -0
  27. data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
  28. data/lib/kitchen/directions/bake_checkpoint.rb +44 -0
  29. data/lib/kitchen/directions/bake_composite_chapters.rb +14 -0
  30. data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
  31. data/lib/kitchen/directions/bake_equations.rb +37 -0
  32. data/lib/kitchen/directions/bake_example.rb +34 -8
  33. data/lib/kitchen/directions/bake_figure.rb +1 -1
  34. data/lib/kitchen/directions/bake_first_elements.rb +16 -0
  35. data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
  36. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  37. data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
  38. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  39. data/lib/kitchen/directions/bake_further_research.rb +59 -0
  40. data/lib/kitchen/directions/bake_index/v1.rb +35 -14
  41. data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
  42. data/lib/kitchen/directions/bake_non_introduction_pages.rb +26 -0
  43. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +29 -0
  44. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +22 -0
  45. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +51 -0
  46. data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +30 -0
  47. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +15 -0
  48. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +47 -0
  49. data/lib/kitchen/directions/bake_numbered_table/main.rb +2 -2
  50. data/lib/kitchen/directions/bake_numbered_table/v1.rb +18 -4
  51. data/lib/kitchen/directions/bake_page_abstracts.rb +16 -0
  52. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  53. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  54. data/lib/kitchen/directions/bake_stepwise.rb +1 -5
  55. data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
  56. data/lib/kitchen/directions/bake_theorem/main.rb +11 -0
  57. data/lib/kitchen/directions/bake_theorem/v1.rb +28 -0
  58. data/lib/kitchen/directions/bake_toc.rb +10 -2
  59. data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
  60. data/lib/kitchen/directions/{bake_exercises → book_answer_key_container}/main.rb +1 -1
  61. data/lib/kitchen/directions/book_answer_key_container/v1.rb +13 -0
  62. data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
  63. data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
  64. data/lib/kitchen/directions/chapter_review_container/v1.rb +13 -0
  65. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +20 -0
  66. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
  67. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +36 -0
  68. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +49 -0
  69. data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +14 -0
  70. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
  71. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +41 -0
  72. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +63 -0
  73. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +34 -0
  74. data/lib/kitchen/document.rb +3 -0
  75. data/lib/kitchen/element.rb +9 -3
  76. data/lib/kitchen/element_base.rb +118 -16
  77. data/lib/kitchen/element_enumerator_base.rb +118 -8
  78. data/lib/kitchen/element_enumerator_factory.rb +28 -12
  79. data/lib/kitchen/element_factory.rb +3 -3
  80. data/lib/kitchen/example_element.rb +8 -11
  81. data/lib/kitchen/example_element_enumerator.rb +1 -1
  82. data/lib/kitchen/exercise_element.rb +42 -0
  83. data/lib/kitchen/exercise_element_enumerator.rb +21 -0
  84. data/lib/kitchen/figure_element.rb +8 -11
  85. data/lib/kitchen/figure_element_enumerator.rb +1 -1
  86. data/lib/kitchen/metadata_element.rb +8 -2
  87. data/lib/kitchen/metadata_element_enumerator.rb +1 -1
  88. data/lib/kitchen/note_element.rb +25 -27
  89. data/lib/kitchen/note_element_enumerator.rb +1 -1
  90. data/lib/kitchen/oven.rb +2 -0
  91. data/lib/kitchen/page_element.rb +33 -9
  92. data/lib/kitchen/page_element_enumerator.rb +1 -1
  93. data/lib/kitchen/patches/nokogiri.rb +55 -0
  94. data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
  95. data/lib/kitchen/recipe.rb +35 -2
  96. data/lib/kitchen/reference_element.rb +27 -0
  97. data/lib/kitchen/references_element_enumerator.rb +20 -0
  98. data/lib/kitchen/search_query.rb +31 -3
  99. data/lib/kitchen/selector.rb +25 -0
  100. data/lib/kitchen/selectors/base.rb +39 -0
  101. data/lib/kitchen/selectors/standard_1.rb +13 -0
  102. data/lib/kitchen/table_element.rb +8 -11
  103. data/lib/kitchen/table_element_enumerator.rb +1 -1
  104. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  105. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  106. data/lib/kitchen/term_element.rb +5 -8
  107. data/lib/kitchen/term_element_enumerator.rb +1 -1
  108. data/lib/kitchen/unit_element.rb +13 -7
  109. data/lib/kitchen/unit_element_enumerator.rb +1 -1
  110. data/lib/kitchen/version.rb +1 -1
  111. data/lib/locales/en.yml +12 -7
  112. data/lib/locales/pl.yml +24 -0
  113. data/lib/openstax_kitchen.rb +2 -1
  114. metadata +54 -6
  115. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -37
  116. data/lib/kitchen/directions/bake_exercises/v1.rb +0 -166
  117. data/lib/kitchen/directions/bake_notes.rb +0 -58
@@ -13,6 +13,19 @@ module Kitchen
13
13
  self.title_in_page = "./*[@data-type = 'document-title']"
14
14
  self.title_in_introduction_page = "./*[@data-type = 'document-title']"
15
15
  self.page_summary = 'section.summary'
16
+ self.reference = '.reference'
17
+ self.chapter = "div[data-type='chapter']"
18
+ self.page = "div[data-type='page']"
19
+ self.note = "div[data-type='note']"
20
+ self.term = "span[data-type='term']"
21
+ self.table = 'table'
22
+ self.figure = 'figure'
23
+ self.metadata = "div[data-type='metadata']"
24
+ self.composite_page = "div[data-type='composite-page']"
25
+ self.composite_chapter = "div[data-type='composite-chapter']"
26
+ self.example = "div[data-type='example']"
27
+ self.exercise = "div[data-type='exercise']"
28
+ self.unit = "div[data-type='unit']"
16
29
  end
17
30
 
18
31
  end
@@ -13,8 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: TableElementEnumerator,
17
- short_type: :table)
16
+ enumerator_class: TableElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :table
18
24
  end
19
25
 
20
26
  # Returns an element for the title row, if present
@@ -74,14 +80,5 @@ module Kitchen
74
80
  first('caption')
75
81
  end
76
82
 
77
- # Returns true if this class represents the element for the given node
78
- #
79
- # @param node [Nokogiri::XML::Node] the underlying node
80
- # @return [Boolean]
81
- #
82
- def self.is_the_element_class_for?(node)
83
- node.name == 'table'
84
- end
85
-
86
83
  end
87
84
  end
@@ -11,7 +11,7 @@ module Kitchen
11
11
  #
12
12
  def self.factory
13
13
  ElementEnumeratorFactory.new(
14
- default_css_or_xpath: 'table', # TODO: get from config?
14
+ default_css_or_xpath: Selector.named(:table),
15
15
  sub_element_class: TableElement,
16
16
  enumerator_class: self
17
17
  )
@@ -0,0 +1,10 @@
1
+ <div class="os-eob os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
2
+ <h1 data-type="document-title">
3
+ <span class="os-text"><%= @title %></span>
4
+ </h1>
5
+ <div data-type="metadata" style="display: none;">
6
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
7
+ <%= @metadata.paste %>
8
+ </div>
9
+ <%= @content %>
10
+ </div>
@@ -0,0 +1,10 @@
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>
@@ -13,17 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: TermElementEnumerator,
17
- short_type: :term)
16
+ enumerator_class: TermElementEnumerator)
18
17
  end
19
18
 
20
- # Returns true if this class represents the element for the given node
19
+ # Returns the short type
20
+ # @return [Symbol]
21
21
  #
22
- # @param node [Nokogiri::XML::Node] the underlying node
23
- # @return [Boolean]
24
- #
25
- def self.is_the_element_class_for?(node)
26
- node['data-type'] == 'term'
22
+ def self.short_type
23
+ :term
27
24
  end
28
25
 
29
26
  end
@@ -11,7 +11,7 @@ module Kitchen
11
11
  #
12
12
  def self.factory
13
13
  ElementEnumeratorFactory.new(
14
- default_css_or_xpath: "span[data-type='term']", # TODO: get from config?
14
+ default_css_or_xpath: Selector.named(:term),
15
15
  sub_element_class: TermElement,
16
16
  enumerator_class: self
17
17
  )
@@ -13,8 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: UnitElementEnumerator,
17
- short_type: :unit)
16
+ enumerator_class: UnitElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :unit
18
24
  end
19
25
 
20
26
  # Get the title in the immediate children, not the one in the metadata. Could use
@@ -27,13 +33,13 @@ module Kitchen
27
33
  first!("./*[@data-type = 'document-title']")
28
34
  end
29
35
 
30
- # Returns true if this class represents the element for the given node
36
+ # Returns the title's text regardless of whether the title has been baked
31
37
  #
32
- # @param node [Nokogiri::XML::Node] the underlying node
33
- # @return [Boolean]
38
+ # @return [String]
34
39
  #
35
- def self.is_the_element_class_for?(node)
36
- node['data-type'] == 'unit'
40
+ def title_text
41
+ title.children.one? ? title.text : title.first('.os-text').text
37
42
  end
43
+
38
44
  end
39
45
  end
@@ -11,7 +11,7 @@ module Kitchen
11
11
  #
12
12
  def self.factory
13
13
  ElementEnumeratorFactory.new(
14
- default_css_or_xpath: "div[data-type='unit']",
14
+ default_css_or_xpath: Selector.named(:unit),
15
15
  sub_element_class: UnitElement,
16
16
  enumerator_class: self
17
17
  )
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '3.0.0'
6
+ VERSION = '4.1.1'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -2,26 +2,31 @@ en:
2
2
  figure: Figure
3
3
  table_label: Table
4
4
  appendix: Appendix
5
+ theorem: Theorem
6
+ solution: Solution
5
7
  chapter_outline: Chapter Outline
6
8
  toc_title: Contents
7
9
  example_label: Example
8
10
  exercise_label: Exercise
11
+ equation: Equation
9
12
  chapter: Chapter
10
13
  unit: Unit
14
+ checkpoint: Checkpoint
15
+ chapter_review: Chapter Review
11
16
  learning_objectives: Learning Objectives
12
17
  stepwise_step_label: Step
18
+ references: References
19
+ eoc_chapter_review: Chapter Review
13
20
  eoc_key_terms_title: Key Terms
14
21
  eoc_summary_title: Summary
15
22
  eoc_exercises_title: Exercises
23
+ eoc_composite_metadata_title: Chapter Review
16
24
  eoc_answer_key_title: Answer Key
25
+ eoc_key_concepts: Key Concepts
17
26
  eoc_key_equations: Key Equations
18
27
  eoc_suggested_reading: Suggestions for Further Study
28
+ eoc_further_research_title: Further Research
19
29
  eob_index_title: Index
20
30
  eob_index_symbols_group: Symbols
21
- notes:
22
- link-to-learning: Link to Learning
23
- sciences-interconnect: How Sciences Interconnect
24
- chemistry:
25
- link-to-learning: Link to Learning
26
- everyday-life: Chemistry in Everyday Life
27
- chemist-portrait: Portrait of a Chemist
31
+ review_exercises: Review Exercises
32
+ section_exercises: ! 'Section %{number} Exercises'
@@ -0,0 +1,24 @@
1
+ pl:
2
+ figure: Rysunek
3
+ table_label: Tabela
4
+ appendix: Dodatek
5
+ theorem: Twierdzenie
6
+ solution: Rozwiązanie
7
+ chapter_outline: Treść rozdziału
8
+ toc_title: Spis treści
9
+ example_label: Przykład
10
+ exercise_label: Ćwiczenie
11
+ equation: Równanie
12
+ chapter: Rozdział
13
+ unit: Część
14
+ chapter_review: Podsumowanie rozdziału
15
+ learning_objectives: Cel dydaktyczny
16
+ stepwise_step_label: Krok
17
+ eoc_chapter_review: Podsumowanie rozdziału
18
+ eoc_key_terms_title: Kluczowe pojęcia
19
+ eoc_summary_title: Podsumowanie
20
+ eoc_answer_key_title: Rozwiązania zadań
21
+ eoc_key_equations: Najważniejsze wzory
22
+ eob_index_title: Skorowidz rzeczowy
23
+ eob_index_symbols_group: Symbole
24
+
@@ -40,6 +40,7 @@ require 'kitchen/oven'
40
40
  require 'kitchen/clipboard'
41
41
  require 'kitchen/pantry'
42
42
  require 'kitchen/counter'
43
+ require 'kitchen/selector'
43
44
 
44
45
  require 'kitchen/element_enumerator_base'
45
46
  require 'kitchen/element_enumerator_factory'
@@ -51,7 +52,7 @@ require 'kitchen/element_factory'
51
52
 
52
53
  require_all('kitchen/directions')
53
54
 
54
- I18n.load_path << file_glob('/locales/*.yml')
55
+ I18n.backend.load_translations(file_glob('/locales/*.yml'))
55
56
 
56
57
  I18n.available_locales.each do |available_locale|
57
58
  I18n.backend.store_translations(available_locale, Kitchen::TRANSLITERATIONS)
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: 3.0.0
4
+ version: 4.1.1
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-03-18 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -220,6 +220,7 @@ files:
220
220
  - lib/kitchen/chapter_element_enumerator.rb
221
221
  - lib/kitchen/clipboard.rb
222
222
  - lib/kitchen/composite_chapter_element.rb
223
+ - lib/kitchen/composite_chapter_element_enumerator.rb
223
224
  - lib/kitchen/composite_page_element.rb
224
225
  - lib/kitchen/composite_page_element_enumerator.rb
225
226
  - lib/kitchen/config.rb
@@ -227,36 +228,74 @@ files:
227
228
  - lib/kitchen/debug/print_recipe_error.rb
228
229
  - lib/kitchen/directions/.rubocop.yml
229
230
  - lib/kitchen/directions/bake_appendix.rb
230
- - lib/kitchen/directions/bake_chapter_glossary.rb
231
+ - lib/kitchen/directions/bake_chapter_glossary/main.rb
232
+ - lib/kitchen/directions/bake_chapter_glossary/v1.rb
231
233
  - lib/kitchen/directions/bake_chapter_introductions.rb
234
+ - lib/kitchen/directions/bake_chapter_key_concepts/main.rb
235
+ - lib/kitchen/directions/bake_chapter_key_concepts/v1.rb
232
236
  - lib/kitchen/directions/bake_chapter_key_equations.rb
237
+ - lib/kitchen/directions/bake_chapter_references/main.rb
238
+ - lib/kitchen/directions/bake_chapter_references/v1.rb
239
+ - lib/kitchen/directions/bake_chapter_section_exercises/main.rb
240
+ - lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
233
241
  - lib/kitchen/directions/bake_chapter_summary.rb
234
242
  - lib/kitchen/directions/bake_chapter_title/main.rb
235
243
  - lib/kitchen/directions/bake_chapter_title/v1.rb
244
+ - lib/kitchen/directions/bake_checkpoint.rb
245
+ - lib/kitchen/directions/bake_composite_chapters.rb
236
246
  - lib/kitchen/directions/bake_composite_pages.rb
247
+ - lib/kitchen/directions/bake_equations.rb
237
248
  - lib/kitchen/directions/bake_example.rb
238
- - lib/kitchen/directions/bake_exercises/main.rb
239
- - lib/kitchen/directions/bake_exercises/v1.rb
240
249
  - lib/kitchen/directions/bake_figure.rb
250
+ - lib/kitchen/directions/bake_first_elements.rb
241
251
  - lib/kitchen/directions/bake_footnotes/main.rb
242
252
  - lib/kitchen/directions/bake_footnotes/v1.rb
253
+ - lib/kitchen/directions/bake_free_response/free_response.xhtml.erb
254
+ - lib/kitchen/directions/bake_free_response/main.rb
255
+ - lib/kitchen/directions/bake_free_response/v1.rb
256
+ - lib/kitchen/directions/bake_further_research.rb
243
257
  - lib/kitchen/directions/bake_index/main.rb
244
258
  - lib/kitchen/directions/bake_index/v1.rb
245
259
  - lib/kitchen/directions/bake_index/v1.xhtml.erb
246
260
  - lib/kitchen/directions/bake_link_placeholders.rb
247
261
  - lib/kitchen/directions/bake_math_in_paragraph.rb
248
- - lib/kitchen/directions/bake_notes.rb
262
+ - lib/kitchen/directions/bake_non_introduction_pages.rb
263
+ - lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
264
+ - lib/kitchen/directions/bake_notes/bake_note_subtitle.rb
265
+ - lib/kitchen/directions/bake_notes/bake_numbered_notes.rb
266
+ - lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb
267
+ - lib/kitchen/directions/bake_numbered_exercise/main.rb
268
+ - lib/kitchen/directions/bake_numbered_exercise/v1.rb
249
269
  - lib/kitchen/directions/bake_numbered_table/main.rb
250
270
  - lib/kitchen/directions/bake_numbered_table/v1.rb
251
271
  - lib/kitchen/directions/bake_page_abstracts.rb
252
272
  - lib/kitchen/directions/bake_preface/main.rb
253
273
  - lib/kitchen/directions/bake_preface/v1.rb
274
+ - lib/kitchen/directions/bake_references/main.rb
275
+ - lib/kitchen/directions/bake_references/v1.rb
254
276
  - lib/kitchen/directions/bake_stepwise.rb
255
277
  - lib/kitchen/directions/bake_suggested_reading.rb
278
+ - lib/kitchen/directions/bake_theorem/main.rb
279
+ - lib/kitchen/directions/bake_theorem/v1.rb
256
280
  - lib/kitchen/directions/bake_toc.rb
257
281
  - lib/kitchen/directions/bake_unit_title/main.rb
258
282
  - lib/kitchen/directions/bake_unit_title/v1.rb
259
283
  - lib/kitchen/directions/bake_unnumbered_tables.rb
284
+ - lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb
285
+ - lib/kitchen/directions/book_answer_key_container/main.rb
286
+ - lib/kitchen/directions/book_answer_key_container/v1.rb
287
+ - lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb
288
+ - lib/kitchen/directions/chapter_review_container/main.rb
289
+ - lib/kitchen/directions/chapter_review_container/v1.rb
290
+ - lib/kitchen/directions/eoc_section_title_link_snippet.rb
291
+ - lib/kitchen/directions/move_exercises_to_eoc/main.rb
292
+ - lib/kitchen/directions/move_exercises_to_eoc/v1.rb
293
+ - lib/kitchen/directions/move_exercises_to_eoc/v2.rb
294
+ - lib/kitchen/directions/move_solutions_to_answer_key/main.rb
295
+ - lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb
296
+ - lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb
297
+ - lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb
298
+ - lib/kitchen/directions/move_solutions_to_answer_key/v1.rb
260
299
  - lib/kitchen/directions/move_title_text_into_span.rb
261
300
  - lib/kitchen/document.rb
262
301
  - lib/kitchen/element.rb
@@ -268,6 +307,8 @@ files:
268
307
  - lib/kitchen/errors.rb
269
308
  - lib/kitchen/example_element.rb
270
309
  - lib/kitchen/example_element_enumerator.rb
310
+ - lib/kitchen/exercise_element.rb
311
+ - lib/kitchen/exercise_element_enumerator.rb
271
312
  - lib/kitchen/figure_element.rb
272
313
  - lib/kitchen/figure_element_enumerator.rb
273
314
  - lib/kitchen/metadata_element.rb
@@ -280,15 +321,21 @@ files:
280
321
  - lib/kitchen/page_element_enumerator.rb
281
322
  - lib/kitchen/pantry.rb
282
323
  - lib/kitchen/patches/nokogiri.rb
324
+ - lib/kitchen/patches/nokogiri_profiling.rb
283
325
  - lib/kitchen/patches/renderable.rb
284
326
  - lib/kitchen/patches/string.rb
285
327
  - lib/kitchen/recipe.rb
328
+ - lib/kitchen/reference_element.rb
329
+ - lib/kitchen/references_element_enumerator.rb
286
330
  - lib/kitchen/search_history.rb
287
331
  - lib/kitchen/search_query.rb
332
+ - lib/kitchen/selector.rb
288
333
  - lib/kitchen/selectors/base.rb
289
334
  - lib/kitchen/selectors/standard_1.rb
290
335
  - lib/kitchen/table_element.rb
291
336
  - lib/kitchen/table_element_enumerator.rb
337
+ - lib/kitchen/templates/eob_section_title_template.xhtml.erb
338
+ - lib/kitchen/templates/eoc_section_title_template.xhtml.erb
292
339
  - lib/kitchen/term_element.rb
293
340
  - lib/kitchen/term_element_enumerator.rb
294
341
  - lib/kitchen/transliterations.rb
@@ -298,6 +345,7 @@ files:
298
345
  - lib/kitchen/utils.rb
299
346
  - lib/kitchen/version.rb
300
347
  - lib/locales/en.yml
348
+ - lib/locales/pl.yml
301
349
  - lib/notes.md
302
350
  - lib/openstax_kitchen.rb
303
351
  - openstax_kitchen.gemspec
@@ -1,37 +0,0 @@
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:)
9
- metadata_elements = metadata_source.children_to_keep.copy
10
-
11
- definitions = chapter.glossaries.search('dl').cut
12
- definitions.sort_by! do |definition|
13
- [definition.first('dt').text.downcase, definition.first('dd').text.downcase]
14
- end
15
-
16
- chapter.glossaries.trash
17
-
18
- return if definitions.none?
19
-
20
- chapter.append(child:
21
- <<~HTML
22
- <div class="os-eoc os-glossary-container" data-type="composite-page" data-uuid-key="glossary">
23
- <h2 data-type="document-title">
24
- <span class="os-text">#{I18n.t(:eoc_key_terms_title)}</span>
25
- </h2>
26
- <div data-type="metadata" style="display: none;">
27
- <h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_key_terms_title)}</h1>
28
- #{metadata_elements.paste}
29
- </div>
30
- #{definitions.paste}
31
- </div>
32
- HTML
33
- )
34
- end
35
- end
36
- end
37
- end
@@ -1,166 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kitchen::Directions::BakeExercises
4
- class V1
5
- def bake(book:)
6
- metadata_elements = book.metadata.children_to_keep.copy
7
-
8
- solutions_clipboards = []
9
-
10
- book.chapters.each do |chapter|
11
- exercise_clipboard = Kitchen::Clipboard.new
12
- solution_clipboard = Kitchen::Clipboard.new
13
- solutions_clipboards.push(solution_clipboard)
14
-
15
- chapter.pages('$:not(.introduction)').each do |page|
16
- exercise_section = page.exercises
17
- exercise_section.first("[data-type='title']")&.trash
18
- exercise_section_title = page.title.copy
19
- exercise_section_title.name = 'h3'
20
- exercise_section_title.replace_children(with: <<~HTML
21
- <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
22
- <span class="os-divider"> </span>
23
- <span class="os-text" data-type="" itemprop="">#{exercise_section_title.children}</span>
24
- HTML
25
- )
26
-
27
- exercise_section.prepend(child:
28
- <<~HTML
29
- <a href="##{page.title.id}">
30
- #{exercise_section_title.paste}
31
- </a>
32
- HTML
33
- )
34
-
35
- exercise_section.search("[data-type='exercise']").each do |exercise|
36
- exercise.document.pantry(name: :link_text).store(
37
- "#{I18n.t(:exercise_label)} #{chapter.count_in(:book)}.#{exercise.count_in(:chapter)}",
38
- label: exercise.id
39
- )
40
-
41
- bake_exercise_in_place(exercise: exercise)
42
- exercise.first("[data-type='solution']")&.cut(to: solution_clipboard)
43
- end
44
-
45
- exercise_section.cut(to: exercise_clipboard)
46
- end
47
-
48
- next if exercise_clipboard.none?
49
-
50
- chapter.append(child:
51
- <<~HTML
52
- <div class="os-eoc os-exercises-container" data-type="composite-page" data-uuid-key=".exercises">
53
- <h2 data-type="document-title">
54
- <span class="os-text">#{I18n.t(:eoc_exercises_title)}</span>
55
- </h2>
56
- <div data-type="metadata" style="display: none;">
57
- <h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_exercises_title)}</h1>
58
- #{metadata_elements.paste}
59
- </div>
60
- #{exercise_clipboard.paste}
61
- </div>
62
- HTML
63
- )
64
- end
65
-
66
- # Store a paste here to use at end so that uniquifyied IDs match legacy baking
67
- eob_metadata = metadata_elements.paste
68
-
69
- solutions = solutions_clipboards.map.with_index do |solution_clipboard, index|
70
- <<~HTML
71
- <div class="os-eob os-solution-container " data-type="composite-page" data-uuid-key=".solution#{index + 1}">
72
- <h2 data-type="document-title">
73
- <span class="os-text">#{I18n.t(:chapter)} #{index + 1}</span>
74
- </h2>
75
- <div data-type="metadata" style="display: none;">
76
- <h1 data-type="document-title" itemprop="name">#{I18n.t(:chapter)} #{index + 1}</h1>
77
- #{metadata_elements.paste}
78
- </div>
79
- #{solution_clipboard.paste}
80
- </div>
81
- HTML
82
- end
83
-
84
- return if solutions.none?
85
-
86
- book.first('body').append(child:
87
- <<~HTML
88
- <div class="os-eob os-solution-container " data-type="composite-chapter" data-uuid-key=".solution">
89
- <h1 data-type="document-title" id="composite-chapter-1">
90
- <span class="os-text">#{I18n.t(:eoc_answer_key_title)}</span>
91
- </h1>
92
- <div data-type="metadata" style="display: none;">
93
- <h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_answer_key_title)}</h1>
94
- #{eob_metadata}
95
- </div>
96
- #{solutions.join("\n")}
97
- </div>
98
- HTML
99
- )
100
- end
101
-
102
- def bake_exercise_in_place(exercise:)
103
- # Bake an exercise in place going from:
104
- #
105
- # <div data-type="exercise" id="exerciseId">
106
- # <div data-type="problem" id="problemId">
107
- # Problem Content
108
- # </div>
109
- # <div data-type="solution" id="solutionId">
110
- # Solution Content
111
- # </div>
112
- # </div>
113
- #
114
- # to
115
- #
116
- # <div data-type="exercise" id="exerciseId" class="os-hasSolution">
117
- # <div data-type="problem" id="problemId">
118
- # <a class="os-number" href="#exerciseId-solution">1</a>
119
- # <span class="os-divider">. </span>
120
- # <div class="os-problem-container ">
121
- # Problem Content
122
- # </div>
123
- # </div>
124
- # <div data-type="solution" id="exerciseId-solution">
125
- # <a class="os-number" href="#exerciseId">1</a>
126
- # <span class="os-divider">. </span>
127
- # <div class="os-solution-container ">
128
- # Solution Content
129
- # </div>
130
- # </div>
131
- # </div>
132
- #
133
- # If there is no solution, don't add the 'os-hasSolution' class and don't
134
- # link the number.
135
-
136
- problem = exercise.first("[data-type='problem']")
137
- solution = exercise.first("[data-type='solution']")
138
-
139
- problem_number = "<span class='os-number'>#{exercise.count_in(:chapter)}</span>"
140
-
141
- if solution.present?
142
- solution.id = "#{exercise.id}-solution"
143
-
144
- exercise.add_class('os-hasSolution')
145
- problem_number =
146
- "<a href='##{solution.id}' class='os-number' >#{exercise.count_in(:chapter)}</a>"
147
-
148
- solution.replace_children(with:
149
- <<~HTML
150
- <a class="os-number" href="##{exercise.id}">#{exercise.count_in(:chapter)}</a>
151
- <span class="os-divider">. </span>
152
- <div class="os-solution-container ">#{solution.children}</div>
153
- HTML
154
- )
155
- end
156
-
157
- problem.replace_children(with:
158
- <<~HTML
159
- #{problem_number}
160
- <span class="os-divider">. </span>
161
- <div class="os-problem-container ">#{problem.children}</div>
162
- HTML
163
- )
164
- end
165
- end
166
- end