openstax_kitchen 12.2.0 → 13.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 +9 -0
- data/Gemfile.lock +1 -1
- data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_summary.rb +1 -1
- data/lib/kitchen/directions/bake_iframes/v1.rb +2 -0
- data/lib/kitchen/directions/bake_learning_objectives.rb +13 -0
- data/lib/kitchen/directions/bake_references/main.rb +6 -9
- data/lib/kitchen/directions/bake_references/v1.rb +9 -8
- data/lib/kitchen/directions/bake_references/v2.rb +9 -10
- data/lib/kitchen/directions/bake_references/v3.rb +32 -0
- data/lib/kitchen/directions/{eoc_composite_page_container → composite_page_container}/main.rb +1 -1
- data/lib/kitchen/directions/composite_page_container/v1.rb +28 -0
- data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +1 -1
- data/lib/kitchen/element_base.rb +1 -1
- data/lib/kitchen/element_enumerator_base.rb +18 -0
- data/lib/kitchen/section_element.rb +27 -0
- data/lib/kitchen/section_element_enumerator.rb +20 -0
- data/lib/kitchen/selectors/base.rb +3 -0
- data/lib/kitchen/selectors/standard_1.rb +1 -0
- data/lib/kitchen/templates/composite_page_template.xhtml.erb +10 -0
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +3 -0
- data/lib/locales/es.yml +3 -0
- data/lib/locales/pl.yml +3 -0
- metadata +8 -5
- data/lib/kitchen/directions/eoc_composite_page_container/v1.rb +0 -19
- data/lib/kitchen/templates/eoc_section_template.xhtml.erb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0f1212b9bee542b587323cef1fa5ff8dc7437d47921736f58c9c27ef6ee11b8
|
4
|
+
data.tar.gz: ca01c38368dc34a0e637f431caf7873f97d5dd52b465e1ae5411d6f0861b8e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c877a0d30bde86ccc5d0e2191b3e0efe853916294d907c764a088e67a2011f9f3fa03fb018ff8aa9992e1fbaeebb753625b90f593d888d8e8a4473139e9e0f43
|
7
|
+
data.tar.gz: f96e5128a718bf1897c65b5b558d2586e6905767e355cf9119c56b536f128bbbf403c658187e6faefc0bb7e7fc3013218353a81d99c1fc8dfc30a9ffed8354db
|
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
|
+
|
10
|
+
## [13.0.0] - 2021-10-6
|
11
|
+
|
12
|
+
* Add `BakeLearningObjectives` v3 (minor)
|
13
|
+
* Fix `BakeIframes` to skip already-baked iframes (patch)
|
14
|
+
* Add `SectionElement` and `SectionElementEnumerator` classes (minor)
|
15
|
+
* Refactor `EocCompositePageContainer` to be used by `EOB` sections as well (major)
|
16
|
+
* Refactor `bake_references` `v1, v2 and v3` to use `CompositePageContainer` (major)
|
17
|
+
|
9
18
|
## [12.2.0] - 2021-10-1
|
10
19
|
|
11
20
|
* Add `context_lead_text` to translations (minor)
|
data/Gemfile.lock
CHANGED
@@ -41,7 +41,7 @@ module Kitchen::Directions::BakeChapterGlossary
|
|
41
41
|
|
42
42
|
content = @glossary.sort.map { |definition| definition.element.paste }.join
|
43
43
|
|
44
|
-
Kitchen::Directions::
|
44
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
45
45
|
container_key: 'glossary',
|
46
46
|
uuid_key: "#{uuid_prefix}glossary",
|
47
47
|
metadata_source: metadata_source,
|
@@ -11,7 +11,7 @@ module Kitchen::Directions::BakeChapterReferences
|
|
11
11
|
|
12
12
|
content = chapter.pages.references.cut.paste
|
13
13
|
|
14
|
-
Kitchen::Directions::
|
14
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
15
15
|
container_key: klass,
|
16
16
|
uuid_key: "#{uuid_prefix}#{klass}",
|
17
17
|
metadata_source: metadata_source,
|
@@ -23,7 +23,7 @@ module Kitchen::Directions::BakeChapterSolutions
|
|
23
23
|
|
24
24
|
content = solutions_clipboard.paste
|
25
25
|
|
26
|
-
Kitchen::Directions::
|
26
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
27
27
|
container_key: 'solutions',
|
28
28
|
uuid_key: "#{uuid_prefix}solutions",
|
29
29
|
metadata_source: metadata_source,
|
@@ -7,6 +7,8 @@ module Kitchen::Directions::BakeIframes
|
|
7
7
|
return unless iframes.any?
|
8
8
|
|
9
9
|
iframes.each do |iframe|
|
10
|
+
next if iframe.has_class?('os-is-iframe')
|
11
|
+
|
10
12
|
iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
|
11
13
|
iframe.add_class('os-is-iframe')
|
12
14
|
link_ref = iframe[:src]
|
@@ -30,6 +30,19 @@ module Kitchen
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
# Wraps & moves abstract under the corresponding chapter objective in the intro page
|
35
|
+
def self.v3(chapter:)
|
36
|
+
abstracts = chapter.abstracts.map do |abstract|
|
37
|
+
abstract.wrap('<div class="learning-objective">')
|
38
|
+
abstract.parent
|
39
|
+
end
|
40
|
+
|
41
|
+
chapter.introduction_page.search('div.os-chapter-objective') \
|
42
|
+
.each_with_index do |objective, index|
|
43
|
+
objective.append(child: abstracts[index].cut.paste)
|
44
|
+
end
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
35
48
|
end
|
@@ -6,18 +6,15 @@ module Kitchen
|
|
6
6
|
#
|
7
7
|
module BakeReferences
|
8
8
|
def self.v1(book:, metadata_source:, numbered_title: false)
|
9
|
-
V1.new.bake(
|
10
|
-
book: book,
|
11
|
-
metadata_source: metadata_source,
|
12
|
-
numbered_title: numbered_title
|
13
|
-
)
|
9
|
+
V1.new.bake(book: book, metadata_source: metadata_source, numbered_title: numbered_title)
|
14
10
|
end
|
15
11
|
|
16
12
|
def self.v2(book:, metadata_source:)
|
17
|
-
V2.new.bake(
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
V2.new.bake(book: book, metadata_source: metadata_source)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.v3(book:, metadata_source:)
|
17
|
+
V3.new.bake(book: book, metadata_source: metadata_source)
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
@@ -5,11 +5,6 @@ module Kitchen::Directions::BakeReferences
|
|
5
5
|
renderable
|
6
6
|
|
7
7
|
def bake(book:, metadata_source:, numbered_title:)
|
8
|
-
@metadata = metadata_source.children_to_keep.copy
|
9
|
-
@klass = 'reference'
|
10
|
-
@uuid_prefix = '.'
|
11
|
-
@title = I18n.t(:references)
|
12
|
-
|
13
8
|
book.chapters.each do |chapter|
|
14
9
|
chapter.search('[data-type="cite"]').each do |link|
|
15
10
|
link.prepend(child:
|
@@ -44,10 +39,16 @@ module Kitchen::Directions::BakeReferences
|
|
44
39
|
HTML
|
45
40
|
)
|
46
41
|
end
|
42
|
+
|
47
43
|
chapter_area_references = book.chapters.search('.os-chapter-area').cut
|
48
|
-
|
49
|
-
|
50
|
-
'
|
44
|
+
|
45
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
46
|
+
container_key: 'reference',
|
47
|
+
uuid_key: '.reference',
|
48
|
+
metadata_source: metadata_source,
|
49
|
+
content: chapter_area_references.paste,
|
50
|
+
append_to: book.body
|
51
|
+
)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -2,14 +2,7 @@
|
|
2
2
|
|
3
3
|
module Kitchen::Directions::BakeReferences
|
4
4
|
class V2
|
5
|
-
renderable
|
6
|
-
|
7
5
|
def bake(book:, metadata_source:)
|
8
|
-
@metadata = metadata_source.children_to_keep.copy
|
9
|
-
@klass = 'references'
|
10
|
-
@uuid_prefix = '.'
|
11
|
-
@title = I18n.t(:references)
|
12
|
-
|
13
6
|
book.chapters.each do |chapter|
|
14
7
|
|
15
8
|
chapter.references.search('h3').trash
|
@@ -26,10 +19,16 @@ module Kitchen::Directions::BakeReferences
|
|
26
19
|
HTML
|
27
20
|
)
|
28
21
|
end
|
22
|
+
|
29
23
|
chapter_area_references = book.chapters.search('.os-chapter-area').cut
|
30
|
-
|
31
|
-
|
32
|
-
'
|
24
|
+
|
25
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
26
|
+
container_key: 'references',
|
27
|
+
uuid_key: '.references',
|
28
|
+
metadata_source: metadata_source,
|
29
|
+
content: chapter_area_references.paste,
|
30
|
+
append_to: book.body
|
31
|
+
)
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeReferences
|
4
|
+
class V3
|
5
|
+
def bake(book:, metadata_source:)
|
6
|
+
return unless book.references.any?
|
7
|
+
|
8
|
+
book.chapters.pages.each do |page|
|
9
|
+
page.references.each do |reference|
|
10
|
+
reference.titles.trash
|
11
|
+
reference.prepend(child:
|
12
|
+
Kitchen::Directions::EocSectionTitleLinkSnippet.v1(
|
13
|
+
page: page,
|
14
|
+
title_tag: 'h2',
|
15
|
+
wrapper: nil
|
16
|
+
)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
chapter_area_references = book.chapters.references.cut
|
22
|
+
|
23
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
24
|
+
container_key: 'references',
|
25
|
+
uuid_key: '.references',
|
26
|
+
metadata_source: metadata_source,
|
27
|
+
content: chapter_area_references.paste,
|
28
|
+
append_to: book.body
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/kitchen/directions/{eoc_composite_page_container → composite_page_container}/main.rb
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
|
-
module
|
5
|
+
module CompositePageContainer
|
6
6
|
# Creates a wrapper for the given content & appends it to the given element
|
7
7
|
#
|
8
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.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::CompositePageContainer
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
|
7
|
+
def bake(container_key:, uuid_key:, metadata_source:, content:, append_to:)
|
8
|
+
@in_composite_chapter = append_to.is?(:composite_chapter)
|
9
|
+
@is_eoc = append_to.is?(:chapter) || @in_composite_chapter
|
10
|
+
@section = @is_eoc ? 'eoc' : 'eob'
|
11
|
+
@title = I18n.t(:"#{@section}.#{container_key}")
|
12
|
+
@uuid_key = uuid_key
|
13
|
+
@container_class_type = container_key
|
14
|
+
@metadata = metadata_source.children_to_keep.copy
|
15
|
+
@content = content
|
16
|
+
@main_title_tag = 'h1'
|
17
|
+
|
18
|
+
if @in_composite_chapter
|
19
|
+
@main_title_tag = 'h3'
|
20
|
+
elsif @is_eoc
|
21
|
+
@main_title_tag = 'h2'
|
22
|
+
end
|
23
|
+
|
24
|
+
append_to.append(child: render(file:
|
25
|
+
'../../templates/composite_page_template.xhtml.erb'))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -30,7 +30,7 @@ module Kitchen::Directions::MoveCustomSectionToEocContainer
|
|
30
30
|
section_clipboard.paste
|
31
31
|
end
|
32
32
|
|
33
|
-
Kitchen::Directions::
|
33
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
34
34
|
container_key: container_key,
|
35
35
|
uuid_key: uuid_key,
|
36
36
|
metadata_source: metadata_source,
|
data/lib/kitchen/element_base.rb
CHANGED
@@ -754,7 +754,7 @@ module Kitchen
|
|
754
754
|
def_delegators :as_enumerator, :pages, :chapters, :terms, :figures, :notes, :tables, :examples,
|
755
755
|
:metadatas, :non_introduction_pages, :units, :titles, :exercises, :references,
|
756
756
|
:composite_pages, :composite_chapters, :solutions, :injected_questions,
|
757
|
-
:search_with
|
757
|
+
:search_with, :sections
|
758
758
|
|
759
759
|
# Returns this element as an enumerator (over only one element, itself)
|
760
760
|
#
|
@@ -318,6 +318,24 @@ module Kitchen
|
|
318
318
|
css_or_xpath: css_or_xpath, only: only, except: except)
|
319
319
|
end
|
320
320
|
|
321
|
+
# Returns an enumerator that iterates through sections within the scope of this enumerator
|
322
|
+
#
|
323
|
+
# @param css_or_xpath [String] additional selectors to further narrow the element iterated over;
|
324
|
+
# a "$" in this argument will be replaced with the default selector for the element being
|
325
|
+
# iterated over.
|
326
|
+
# @param only [Symbol, Callable] the name of a method to call on an element or a
|
327
|
+
# lambda or proc that accepts an element; elements will only be included in the
|
328
|
+
# search results if the method or callable returns true
|
329
|
+
# @param except [Symbol, Callable] the name of a method to call on an element or a
|
330
|
+
# lambda or proc that accepts an element; elements will not be included in the
|
331
|
+
# search results if the method or callable returns false
|
332
|
+
#
|
333
|
+
def sections(css_or_xpath=nil, only: nil, except: nil)
|
334
|
+
block_error_if(block_given?)
|
335
|
+
chain_to(SectionElementEnumerator,
|
336
|
+
css_or_xpath: css_or_xpath, only: only, except: except)
|
337
|
+
end
|
338
|
+
|
321
339
|
# Returns an enumerator that iterates within the scope of this enumerator
|
322
340
|
#
|
323
341
|
# @param css_or_xpath [String] additional selectors to further narrow the element iterated over
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
# An element for an example
|
5
|
+
#
|
6
|
+
class SectionElement < ElementBase
|
7
|
+
|
8
|
+
# Creates a new +SectionElement+
|
9
|
+
#
|
10
|
+
# @param node [Nokogiri::XML::Node] the node this element wraps
|
11
|
+
# @param document [Document] this element's document
|
12
|
+
#
|
13
|
+
def initialize(node:, document: nil)
|
14
|
+
super(node: node,
|
15
|
+
document: document,
|
16
|
+
enumerator_class: SectionElementEnumerator)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the short type
|
20
|
+
# @return [Symbol]
|
21
|
+
#
|
22
|
+
def self.short_type
|
23
|
+
:section
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
# An enumerator for table elements
|
5
|
+
#
|
6
|
+
class SectionElementEnumerator < ElementEnumeratorBase
|
7
|
+
# Returns a factory for this enumerator
|
8
|
+
#
|
9
|
+
# @return [ElementEnumeratorFactory]
|
10
|
+
#
|
11
|
+
def self.factory
|
12
|
+
ElementEnumeratorFactory.new(
|
13
|
+
default_css_or_xpath: Selector.named(:section),
|
14
|
+
sub_element_class: SectionElement,
|
15
|
+
enumerator_class: self
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="os-<%= @section%> os-<%=@container_class_type%>-container" data-type="composite-page" data-uuid-key="<%= @uuid_key %>">
|
2
|
+
<<%= @main_title_tag %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
|
3
|
+
<span class="os-text"><%= @title %></span>
|
4
|
+
</<%= @main_title_tag %>>
|
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>
|
data/lib/kitchen/version.rb
CHANGED
data/lib/locales/en.yml
CHANGED
data/lib/locales/es.yml
CHANGED
data/lib/locales/pl.yml
CHANGED
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: 13.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-10-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -320,6 +320,7 @@ files:
|
|
320
320
|
- lib/kitchen/directions/bake_references/main.rb
|
321
321
|
- lib/kitchen/directions/bake_references/v1.rb
|
322
322
|
- lib/kitchen/directions/bake_references/v2.rb
|
323
|
+
- lib/kitchen/directions/bake_references/v3.rb
|
323
324
|
- lib/kitchen/directions/bake_stepwise.rb
|
324
325
|
- lib/kitchen/directions/bake_suggested_reading.rb
|
325
326
|
- lib/kitchen/directions/bake_toc.rb
|
@@ -334,8 +335,8 @@ files:
|
|
334
335
|
- lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb
|
335
336
|
- lib/kitchen/directions/chapter_review_container/main.rb
|
336
337
|
- lib/kitchen/directions/chapter_review_container/v1.rb
|
337
|
-
- lib/kitchen/directions/
|
338
|
-
- lib/kitchen/directions/
|
338
|
+
- lib/kitchen/directions/composite_page_container/main.rb
|
339
|
+
- lib/kitchen/directions/composite_page_container/v1.rb
|
339
340
|
- lib/kitchen/directions/eoc_section_title_link_snippet.rb
|
340
341
|
- lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb
|
341
342
|
- lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
|
@@ -393,14 +394,16 @@ files:
|
|
393
394
|
- lib/kitchen/references_element_enumerator.rb
|
394
395
|
- lib/kitchen/search_history.rb
|
395
396
|
- lib/kitchen/search_query.rb
|
397
|
+
- lib/kitchen/section_element.rb
|
398
|
+
- lib/kitchen/section_element_enumerator.rb
|
396
399
|
- lib/kitchen/selector.rb
|
397
400
|
- lib/kitchen/selectors/base.rb
|
398
401
|
- lib/kitchen/selectors/standard_1.rb
|
399
402
|
- lib/kitchen/solution_element_enumerator.rb
|
400
403
|
- lib/kitchen/table_element.rb
|
401
404
|
- lib/kitchen/table_element_enumerator.rb
|
405
|
+
- lib/kitchen/templates/composite_page_template.xhtml.erb
|
402
406
|
- lib/kitchen/templates/eob_section_title_template.xhtml.erb
|
403
|
-
- lib/kitchen/templates/eoc_section_template.xhtml.erb
|
404
407
|
- lib/kitchen/templates/eoc_section_template_old.xhtml.erb
|
405
408
|
- lib/kitchen/term_element.rb
|
406
409
|
- lib/kitchen/term_element_enumerator.rb
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,11 +0,0 @@
|
|
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>
|