openstax_kitchen 16.0.0 → 17.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +2 -2
- data/lib/kitchen/directions/bake_annotation_classes/v1.rb +11 -2
- data/lib/kitchen/directions/bake_chapter_references/main.rb +8 -0
- data/lib/kitchen/directions/bake_chapter_references/v2.rb +53 -0
- data/lib/kitchen/directions/bake_exercise_prefixes/main.rb +14 -0
- data/lib/kitchen/directions/bake_exercise_prefixes/v1.rb +22 -0
- data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +2 -1
- data/lib/kitchen/element_base.rb +17 -1
- data/lib/kitchen/patches/integer.rb +32 -3
- data/lib/kitchen/patches/nokogiri.rb +0 -7
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774e5af35ed15ba87d97802b8395412003291024053c9ed11aa66eaa4ba20712
|
4
|
+
data.tar.gz: eb371d8b10113005b69b5864c19fe8eed43aa5b9b965329cfcfdcc8a9287b842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4953a8d928e31cf45116cb4ac8f5eb54ab06db3c5d91af038da6acefc1e643ab19a4a585fdfb3cf19de67f24ac3778e36aa972014a3b5f9397734b1c1498829
|
7
|
+
data.tar.gz: ad336376346ed97f0f924ef6fde9e41f0b7735fa920245fc58d1c7c679d88be72867af5dd6722c25bd6185fcdaa0b57708650dbb0ba94d6e3fa3da2b2751e19d
|
data/CHANGELOG.md
CHANGED
@@ -6,12 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [17.0.0] - 2021-12-3
|
10
|
+
|
11
|
+
* Create method in `Integer` class that generate roman numbers up to 100 (minor)
|
12
|
+
* Add more roman numbers to `Integer` class (patch)
|
13
|
+
* Create `V2` for `BakeChapterReferences` (minor)
|
14
|
+
* Create `BakeExercisePrefixes` direction adding prefixes for exercises in selected sections (minor)
|
15
|
+
* Add support for 'text-heavy-top-titled' tables in `BakeTableBody` (minor)
|
16
|
+
* Remove `Nokigiri#previous` patch, `ElementBase#previous` now uses `#previous_element` (minor)
|
17
|
+
* Modifies `BakeAnnotationClasses` for annotations wrapper to be a `span` intead of a `div` (major)
|
9
18
|
|
10
19
|
## [16.0.0] - 2021-11-19
|
11
20
|
|
12
21
|
* Add reference link separator to `BakeReferences.v1` (patch)
|
13
22
|
* Modify `BakeFootnotes` to be more general (minor)
|
14
23
|
* Add `#preceded_by_text` method to element_base and the nokigiri patch (minor)
|
24
|
+
* Remove `Nokigiri#previous` patch, `ElementBase#previous` now uses `#previous_element` (minor)
|
15
25
|
* Broaden caption selection for `BakeNumberedTable#v2` (patch)
|
16
26
|
* Add details of question count to injected exercises in `BakeInjectedExercise` (major)
|
17
27
|
* Add target labels to chapter content module pages option in `BakeNonIntroductionPages`, create a separate directory `BakeLOLinkLabels` to add `.label-text`, `.label-counter` spans wrappers for links with `.lo-reference` class (minor)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openstax_kitchen (
|
4
|
+
openstax_kitchen (17.0.0)
|
5
5
|
activesupport
|
6
6
|
i18n
|
7
7
|
nokogiri
|
@@ -99,7 +99,7 @@ GEM
|
|
99
99
|
tins (~> 1.0)
|
100
100
|
tins (1.26.0)
|
101
101
|
sync
|
102
|
-
twitter_cldr (6.
|
102
|
+
twitter_cldr (6.9.0)
|
103
103
|
camertron-eprun
|
104
104
|
cldr-plurals-runtime-rb (~> 1.1)
|
105
105
|
tzinfo
|
@@ -20,9 +20,18 @@ module Kitchen::Directions::BakeAnnotationClasses
|
|
20
20
|
kinesthetic-icon]
|
21
21
|
annotation_icon_classes.each do |annotation_icon_class|
|
22
22
|
book.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
|
23
|
-
annotation_with_icon_class.search('div.os-icons').first
|
23
|
+
annotation_with_icon_class.search('div.os-icons').first&.name = 'span'
|
24
|
+
|
25
|
+
icon_title = I18n.t(:"annotation_icons.#{annotation_icon_class}.title")
|
26
|
+
|
27
|
+
annotation_with_icon_class.search('span.os-icons').first.append(child:
|
24
28
|
<<~HTML
|
25
|
-
<span
|
29
|
+
<span
|
30
|
+
class = "#{annotation_icon_class}"
|
31
|
+
role="img"
|
32
|
+
title="#{icon_title}"
|
33
|
+
aria-label="#{icon_title}"
|
34
|
+
></span>
|
26
35
|
HTML
|
27
36
|
)
|
28
37
|
end
|
@@ -10,6 +10,14 @@ module Kitchen
|
|
10
10
|
uuid_prefix: uuid_prefix,
|
11
11
|
klass: klass)
|
12
12
|
end
|
13
|
+
|
14
|
+
def self.v2(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
|
15
|
+
V2.new.bake(
|
16
|
+
chapter: chapter,
|
17
|
+
metadata_source: metadata_source,
|
18
|
+
uuid_prefix: uuid_prefix,
|
19
|
+
klass: klass)
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterReferences
|
4
|
+
class V2
|
5
|
+
def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
|
6
|
+
chapter.pages.each do |page|
|
7
|
+
bake_page_cite(page: page)
|
8
|
+
bake_page_references(page: page)
|
9
|
+
end
|
10
|
+
|
11
|
+
return if chapter.pages.references.none?
|
12
|
+
|
13
|
+
content = chapter.pages.references.cut.paste
|
14
|
+
|
15
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
16
|
+
container_key: klass,
|
17
|
+
uuid_key: "#{uuid_prefix}#{klass}",
|
18
|
+
metadata_source: metadata_source,
|
19
|
+
content: content,
|
20
|
+
append_to: chapter
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def bake_page_cite(page:)
|
25
|
+
page.search('[data-type="cite"]').each do |link|
|
26
|
+
link.id = "#{page.id}-endNote#{link.count_in(:chapter)}"
|
27
|
+
|
28
|
+
link.prepend(child:
|
29
|
+
<<~HTML
|
30
|
+
<sup class="os-end-note-number">#{link.count_in(:chapter)}</sup>
|
31
|
+
HTML
|
32
|
+
)
|
33
|
+
|
34
|
+
link.search('.delete-me').trash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def bake_page_references(page:)
|
39
|
+
page.references.each do |reference|
|
40
|
+
Kitchen::Directions::RemoveSectionTitle.v1(section: reference)
|
41
|
+
|
42
|
+
reference.search('a').each do |ref_link|
|
43
|
+
ref_link.replace_children(with:
|
44
|
+
<<~HTML
|
45
|
+
<span>#{ref_link.count_in(:chapter)}.</span>
|
46
|
+
HTML
|
47
|
+
)
|
48
|
+
ref_link.href = "##{page.id}-endNote#{ref_link.count_in(:chapter)}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeExercisePrefixes
|
4
|
+
class V1
|
5
|
+
def bake(chapter:, sections_prefixed:)
|
6
|
+
sections_prefixed.each do |section_key|
|
7
|
+
chapter.composite_pages.each do |composite_page|
|
8
|
+
composite_page.search("section.#{section_key}").exercises.each do |exercise|
|
9
|
+
problem = exercise.problem
|
10
|
+
exercise_prefix =
|
11
|
+
"<span class='os-text'>#{I18n.t(:"sections_prefixed.#{section_key}")}</span>"
|
12
|
+
problem.prepend(child:
|
13
|
+
<<~HTML
|
14
|
+
#{exercise_prefix}
|
15
|
+
HTML
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -44,8 +44,9 @@ module Kitchen
|
|
44
44
|
table.target_label(label_text: 'table', custom_content: number, cases: cases)
|
45
45
|
|
46
46
|
if table.top_titled?
|
47
|
+
klass = table.text_heavy? ? 'text-heavy-top-titled' : 'top-titled'
|
47
48
|
custom_table = CustomBody.new(table: table,
|
48
|
-
klass:
|
49
|
+
klass: klass,
|
49
50
|
fake_title_class: 'os-table-title',
|
50
51
|
fake_title: table.title,
|
51
52
|
to_trash: table.title_row)
|
data/lib/kitchen/element_base.rb
CHANGED
@@ -223,6 +223,22 @@ module Kitchen
|
|
223
223
|
self[:'data-type']
|
224
224
|
end
|
225
225
|
|
226
|
+
# Returns the element's href
|
227
|
+
#
|
228
|
+
# @return [String]
|
229
|
+
#
|
230
|
+
def href
|
231
|
+
self[:href]
|
232
|
+
end
|
233
|
+
|
234
|
+
# Sets the element's href
|
235
|
+
#
|
236
|
+
# @param value [String] the new value for the href
|
237
|
+
#
|
238
|
+
def href=(value)
|
239
|
+
self[:href] = value
|
240
|
+
end
|
241
|
+
|
226
242
|
# A way to set values and chain them
|
227
243
|
#
|
228
244
|
# @param property [String, Symbol] the name of the property to set
|
@@ -511,7 +527,7 @@ module Kitchen
|
|
511
527
|
# nil if there's no previous sibling
|
512
528
|
#
|
513
529
|
def previous
|
514
|
-
prev = raw.
|
530
|
+
prev = raw.previous_element
|
515
531
|
return prev if prev.nil?
|
516
532
|
|
517
533
|
Element.new(
|
@@ -3,7 +3,22 @@
|
|
3
3
|
# Monkey patches for +Integer+
|
4
4
|
#
|
5
5
|
class Integer
|
6
|
-
|
6
|
+
|
7
|
+
@roman_numerals = {
|
8
|
+
100 => 'c',
|
9
|
+
90 => 'xc',
|
10
|
+
50 => 'l',
|
11
|
+
40 => 'xl',
|
12
|
+
10 => 'x',
|
13
|
+
9 => 'ix',
|
14
|
+
5 => 'v',
|
15
|
+
4 => 'iv',
|
16
|
+
1 => 'i'
|
17
|
+
}
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :roman_numerals
|
21
|
+
end
|
7
22
|
|
8
23
|
# Formats as different types of integers, including roman numerals.
|
9
24
|
#
|
@@ -14,11 +29,25 @@ class Integer
|
|
14
29
|
when :arabic
|
15
30
|
to_s
|
16
31
|
when :roman
|
17
|
-
raise 'Unknown conversion to Roman numerals' if self
|
32
|
+
raise 'Unknown conversion to Roman numerals' if self > self.class.roman_numerals.keys.first
|
18
33
|
|
19
|
-
|
34
|
+
to_roman
|
20
35
|
else
|
21
36
|
raise 'Unknown integer format'
|
22
37
|
end
|
23
38
|
end
|
39
|
+
|
40
|
+
def to_roman
|
41
|
+
return 0 if zero?
|
42
|
+
|
43
|
+
roman = ''
|
44
|
+
integer = self
|
45
|
+
self.class.roman_numerals.each do |number, letter|
|
46
|
+
until integer < number
|
47
|
+
roman += letter
|
48
|
+
integer -= number
|
49
|
+
end
|
50
|
+
end
|
51
|
+
roman
|
52
|
+
end
|
24
53
|
end
|
@@ -67,13 +67,6 @@ module Nokogiri
|
|
67
67
|
self[:class]&.split || []
|
68
68
|
end
|
69
69
|
|
70
|
-
def previous
|
71
|
-
prev = previous_element
|
72
|
-
return nil if prev.nil?
|
73
|
-
|
74
|
-
prev.text? ? prev.previous : prev
|
75
|
-
end
|
76
|
-
|
77
70
|
def preceded_by_text?
|
78
71
|
prev = previous_sibling
|
79
72
|
while !prev.nil? && prev.blank? do prev = prev.previous_sibling end
|
data/lib/kitchen/version.rb
CHANGED
data/lib/locales/en.yml
CHANGED
@@ -46,3 +46,18 @@ en:
|
|
46
46
|
reference: References
|
47
47
|
index:
|
48
48
|
main: Index
|
49
|
+
annotation_icons:
|
50
|
+
linguistic-icon:
|
51
|
+
title: Language lens icon
|
52
|
+
culture-icon:
|
53
|
+
title: Culture lens icon
|
54
|
+
dreaming-icon:
|
55
|
+
title: Generating and capturing ideas icon
|
56
|
+
visual-icon:
|
57
|
+
title: Visual learning style icon
|
58
|
+
speech-icon:
|
59
|
+
title: Voice to text icon
|
60
|
+
auditory-icon:
|
61
|
+
title: Auditory learning style icon
|
62
|
+
kinesthetic-icon:
|
63
|
+
title: Kinesthetic learning style icon
|
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:
|
4
|
+
version: 17.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-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/kitchen/directions/bake_chapter_key_equations.rb
|
266
266
|
- lib/kitchen/directions/bake_chapter_references/main.rb
|
267
267
|
- lib/kitchen/directions/bake_chapter_references/v1.rb
|
268
|
+
- lib/kitchen/directions/bake_chapter_references/v2.rb
|
268
269
|
- lib/kitchen/directions/bake_chapter_section_exercises/main.rb
|
269
270
|
- lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
|
270
271
|
- lib/kitchen/directions/bake_chapter_solutions/main.rb
|
@@ -281,6 +282,8 @@ files:
|
|
281
282
|
- lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb
|
282
283
|
- lib/kitchen/directions/bake_equations.rb
|
283
284
|
- lib/kitchen/directions/bake_example.rb
|
285
|
+
- lib/kitchen/directions/bake_exercise_prefixes/main.rb
|
286
|
+
- lib/kitchen/directions/bake_exercise_prefixes/v1.rb
|
284
287
|
- lib/kitchen/directions/bake_figure.rb
|
285
288
|
- lib/kitchen/directions/bake_first_elements.rb
|
286
289
|
- lib/kitchen/directions/bake_folio.rb
|