openstax_kitchen 9.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fca2eb47435f5ff74342d7de2afc02e2c55eed224f1ae669b440d52a1c50b1b0
4
- data.tar.gz: f22d42bc7618868d1890e149d9e0bf5134945b8fccce5c7742827e6c53589d81
3
+ metadata.gz: df33d6b0ba524fe49e9e5310bcdb730406576a3b88f0462e2eedd932d08fc0cf
4
+ data.tar.gz: 6a23406fdebb4676c22424d14ab805304789814e84302a685aa245e2bf87f846
5
5
  SHA512:
6
- metadata.gz: a457781d0bcb61533c5b96ca0b2ffcde74a69743a54c09f4b901b7e769056d1d616afa736df40067e7472a479c8526505d72fe5d7e9ecf3eca6789581d92c380
7
- data.tar.gz: 9f517fbc86ae32e0fd2bbc108774a9f4b94a63df01675530c7f26d7f9bf9522654f4ddb5d7e1c9d141b1a67a0ccc6a98ac2f8c0cf94719ccf04b67cfbf69f240
6
+ metadata.gz: 3af05295d5045ec827b6e817443a4648591d138bc9d3cf697221187e26088badc6c76048f8b3902a167c073c1e9ee94b4c4f48934171428b649c879e23abd95f
7
+ data.tar.gz: 35ce7b8d16222c5f338d2eb6e9749158980e075b2d09bfa82e034e74bcfad13b748b80bceb1941fc0a8b4d26cf834474a0e7699a7327b55c6e6e42bc1e122024
data/CHANGELOG.md CHANGED
@@ -6,9 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [9.1.0] - 2021-07-16
10
+
11
+ * Add `BakeNoteIFrames` direction (minor)
12
+ * Selector optimization in precalculus `Strategy` & elsewhere (patch)
13
+ * Tweaks inline list seperators to only target labeled items (major?)
14
+ * Add definition of handbook page selector needed for BakeToc, create a link class for this page (minor)
15
+
9
16
  ## [9.0.0] - 2021-07-12
10
17
 
11
- * Refactor `BakeChapterKeyConcepts`, `BakeChapterReferences`, `BakeChapterSolutions`, and `MoveExercisesToEoc` versions 1-3 to use new general eoc directions (major?)
18
+ * Refactor `BakeChapterKeyConcepts`, `BakeChapterReferences`, `BakeChapterSolutions`, and `MoveExercisesToEoc` versions 1-3 to use new general eoc directions (major)
12
19
  * Fixed `BakeExample.v1` to also search inside `.body` for titles (minor)
13
20
  * Add documentation to `MoveCustomSectionToEocContainer` & `EocCompositePageContainer` (minor)
14
21
  * Add a `MoveCustomSectionToEocContainer` to allow for custom sections (minor)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (9.0.0)
4
+ openstax_kitchen (9.1.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -29,10 +29,8 @@ module Kitchen
29
29
  # @return [Element]
30
30
  #
31
31
  def title
32
- # Get the title in the immediate children, not the one in the metadata. Could use
33
- # CSS of ":not([data-type='metadata']) > [data-type='document-title'], [data-type='document-title']"
34
- # but xpath is shorter
35
- first!("./*[@data-type = 'document-title' or @data-type = 'title']")
32
+ first!('h3[data-type="title"], h2[data-type="document-title"],' \
33
+ 'h1[data-type="document-title"]')
36
34
  end
37
35
 
38
36
  # Returns true if this page is a book index
@@ -54,7 +54,7 @@ module Kitchen
54
54
 
55
55
  exercise.add_class('unnumbered')
56
56
 
57
- commentary = exercise.first('[data-type="commentary"]')
57
+ commentary = exercise.first('div[data-type="commentary"]')
58
58
  next unless commentary.present?
59
59
 
60
60
  commentary_title = commentary.titles.first
@@ -10,7 +10,7 @@ module Kitchen
10
10
  SEPARATOR_CLASS = '-os-inline-list-separator'
11
11
 
12
12
  def self.v1(book:)
13
- inline_lists = book.search('span[data-display="inline"][data-type="list"]')
13
+ inline_lists = book.search('span[data-display="inline"][data-list-type="labeled-item"]')
14
14
  inline_lists.each do |list|
15
15
  list.search('span[data-type="item"]')[0..-2].each do |item|
16
16
  item.append(child: "<span class=\"#{SEPARATOR_CLASS}\">#{LIST_SEPARATOR}</span>")
@@ -12,6 +12,7 @@ module Kitchen
12
12
  end
13
13
 
14
14
  def self.bake_note(note:)
15
+ BakeNoteIFrames.v1(note: note)
15
16
  note.wrap_children(class: 'os-note-body')
16
17
 
17
18
  BakeNoteSubtitle.v1(note: note)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNoteIFrames
6
+ def self.v1(note:)
7
+ iframes = note.search('iframe')
8
+ return unless iframes.any?
9
+
10
+ iframes.each do |iframe|
11
+ iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
12
+ iframe.add_class('os-is-iframe')
13
+ link_ref = iframe[:src]
14
+ next unless link_ref
15
+
16
+ iframe = iframe.parent
17
+ iframe.add_class('os-has-link')
18
+ iframe.prepend(child:
19
+ <<~HTML
20
+ <a class="os-is-link" href="#{link_ref}" target="_window">#{I18n.t(:iframe_link_text)}</a>
21
+ HTML
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -90,6 +90,8 @@ module Kitchen
90
90
  'os-toc-appendix'
91
91
  elsif page.is_preface?
92
92
  'os-toc-preface'
93
+ elsif page.is_handbook?
94
+ 'os-toc-handbook'
93
95
  else
94
96
  raise "do not know what TOC class to use for page with classes #{page.classes}"
95
97
  end
@@ -24,8 +24,8 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
24
24
 
25
25
  def bake_section(chapter:, append_to:, klass:, number: nil)
26
26
  section_solutions_set = Kitchen::Clipboard.new
27
- chapter.search(".#{klass}").each do |section|
28
- section.search('[data-type="solution"]').each do |solution|
27
+ chapter.search("section.#{klass}").each do |section|
28
+ section.search('div[data-type="solution"]').each do |solution|
29
29
  solution.cut(to: section_solutions_set)
30
30
  end
31
31
  end
@@ -56,7 +56,7 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
56
56
  page.notes('$.try').each do |note|
57
57
  note.exercises.each do |exercise|
58
58
  solution = exercise.solution
59
- solution&.cut(to: solutions) #if solution
59
+ solution&.cut(to: solutions)
60
60
  end
61
61
  end
62
62
  next if solutions.items.empty?
@@ -64,7 +64,7 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
64
64
  title_snippet = Kitchen::Directions::EocSectionTitleLinkSnippet.v2(page: page)
65
65
 
66
66
  append_solution_area(title: title_snippet, solutions: solutions,
67
- append_to: append_to.search('.os-try-solution-area').first)
67
+ append_to: append_to.search('div.os-try-solution-area').first)
68
68
  end
69
69
  end
70
70
 
@@ -27,8 +27,8 @@ module Kitchen
27
27
  # @return [ElementEnumerator]
28
28
  #
29
29
  def children_to_keep
30
- search(%w([data-type='revised'] .authors .publishers .print-style .permissions
31
- [data-type='subject']))
30
+ search(%w(span[data-type='revised'] div.authors div.publishers div.print-style div.permissions
31
+ div[data-type='subject']))
32
32
  end
33
33
  end
34
34
  end
@@ -119,5 +119,13 @@ module Kitchen
119
119
  search('section.free-response')
120
120
  end
121
121
 
122
+ # Returns true if this page is a handbook
123
+ #
124
+ # @return [Boolean]
125
+ #
126
+ def is_handbook?
127
+ has_class?('handbook')
128
+ end
129
+
122
130
  end
123
131
  end
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '9.0.0'
6
+ VERSION = '9.1.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -26,6 +26,7 @@ en:
26
26
  eob_index_symbols_group: Symbols
27
27
  review_exercises: Review Exercises
28
28
  section_exercises: ! 'Section %{number} Exercises'
29
+ iframe_link_text: Click to view content
29
30
  eoc:
30
31
  glossary: Key Terms
31
32
  key-equations: Key Equations
@@ -33,3 +34,4 @@ en:
33
34
  further-research: Further Research
34
35
  key-concepts: Key Concepts
35
36
  references: References
37
+ solutions: Solutions
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: 9.0.0
4
+ version: 9.1.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-07-12 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -282,6 +282,7 @@ files:
282
282
  - lib/kitchen/directions/bake_math_in_paragraph.rb
283
283
  - lib/kitchen/directions/bake_non_introduction_pages.rb
284
284
  - lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
285
+ - lib/kitchen/directions/bake_notes/bake_note_iframes.rb
285
286
  - lib/kitchen/directions/bake_notes/bake_note_subtitle.rb
286
287
  - lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb
287
288
  - lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb