Skip to content

Commit 2139955

Browse files
authored
Merge pull request #402 from openstax/pl-nursing-recipe
create pl-nursing recipe
2 parents 5018676 + 092dd9e commit 2139955

File tree

11 files changed

+82063
-2
lines changed

11 files changed

+82063
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
* Create recipe for Polish Nursing book
10+
911
## [v2.28.0] - 2025-09-09
1012

1113
* Add `super` recipe for baking super documents

lib/kitchen/directions/bake_chapter_introductions/main.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def self.v2(
1616
strategy: :default, bake_chapter_outline: false, introduction_order: :v1,
1717
block_target_label: false,
1818
cases: false,
19-
numbering_options: { mode: :chapter_page, separator: '.' }
19+
numbering_options: { mode: :chapter_page, separator: '.' },
20+
authors: false
2021
}
2122
)
2223
options.reverse_merge!(
@@ -25,7 +26,8 @@ def self.v2(
2526
introduction_order: :v1,
2627
block_target_label: false,
2728
cases: false,
28-
numbering_options: { mode: :chapter_page, separator: '.' }
29+
numbering_options: { mode: :chapter_page, separator: '.' },
30+
authors: false
2931
)
3032
V2.new.bake(
3133
book: book,

lib/kitchen/directions/bake_chapter_introductions/v2.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def bake(book:, chapters:, options:)
3333
chapter_intro_html: chapter_intro_html,
3434
title: title
3535
)
36+
37+
bake_authors(introduction_page: introduction_page) if options[:authors]
3638
end
3739

3840
Kitchen::Directions::BakeChapterIntroductions.v1_update_selectors(book)
@@ -158,5 +160,16 @@ def bake_title(introduction_page:)
158160
title.id = "#{introduction_page.id}_titlecreatedbycookbook"
159161
Kitchen::Directions::MoveTitleChildrenIntoSpan.v1(title: title)
160162
end
163+
164+
def bake_authors(introduction_page:)
165+
splash = introduction_page.search('.splash').first
166+
author = introduction_page.search('p.author').cut
167+
168+
splash.prepend(sibling:
169+
<<~HTML
170+
#{author.paste}
171+
HTML
172+
)
173+
end
161174
end
162175
end

lib/recipes/bake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ book_recipes = \
5959
when 'philosophy' then [PHILOSOPHY_RECIPE]
6060
when 'pl-economics' then [PL_ECONOMICS_RECIPE]
6161
when 'pl-marketing' then [PL_MARKETING_RECIPE]
62+
when 'pl-nursing' then [PL_NURSING_RECIPE]
6263
when 'pl-psychology' then [PL_PSYCHOLOGY_RECIPE]
6364
when 'pl-u-physics' then [PL_U_PHYSICS_RECIPE]
6465
when 'political-science' then [POLITICAL_SCIENCE_RECIPE]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pl:
2+
notes:
3+
unfolding-casestudy: Jak postąpisz w tym przypadku?
4+
clinical-tip: Z praktyki klinicznej
5+
eoc:
6+
chapter-summary: Podsumowanie rozdziału
7+
review-questions: Sprawdź się!
8+
suggested-reading: Chcesz wiedzieć więcej?

lib/recipes/pl-nursing/recipe.rb

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# frozen_string_literal: true
2+
3+
PL_NURSING_RECIPE = Kitchen::BookRecipe.new(book_short_name: :plnursing) do |doc, _resources|
4+
include Kitchen::Directions
5+
6+
doc.selectors.override(
7+
reference: 'section.references'
8+
)
9+
book = doc.book
10+
metadata = book.metadata
11+
12+
book.search('cnx-pi').trash
13+
14+
BakeListsWithPara.v1(book: book)
15+
BakeUnnumberedFigure.v1(book: book)
16+
BakePreface.v1(book: book, cases: true)
17+
18+
BakeChapterIntroductions.v2(
19+
book: book, options: {
20+
strategy: :add_objectives,
21+
bake_chapter_outline: true,
22+
introduction_order: :v3,
23+
cases: true,
24+
authors: true
25+
}
26+
)
27+
BakeChapterTitle.v1(book: book, cases: true)
28+
29+
answer_key = BookAnswerKeyContainer.v1(book: book)
30+
31+
book.chapters.each do |chapter|
32+
BakeNonIntroductionPages.v1(chapter: chapter, options: { cases: true })
33+
BakeLearningObjectives.v2(chapter: chapter, add_title: false)
34+
35+
chapter.figures(only: :figure_to_number?).each do |figure|
36+
BakeFigure.v1(figure: figure,
37+
number: "#{chapter.count_in(:book)}.#{figure.count_in(:chapter)}",
38+
cases: true)
39+
end
40+
41+
chapter.tables('$:not(.unnumbered)').each do |table|
42+
BakeNumberedTable.v1(table: table,
43+
number: "#{chapter.count_in(:book)}.#{table.count_in(:chapter)}",
44+
cases: true)
45+
end
46+
47+
# EOC
48+
MoveCustomSectionToEocContainer.v1(
49+
chapter: chapter,
50+
metadata_source: metadata,
51+
container_key: 'chapter-summary',
52+
uuid_key: '.chapter-summary',
53+
section_selector: 'section.chapter-summary'
54+
) do |section|
55+
RemoveSectionTitle.v1(section: section)
56+
end
57+
58+
BakeSortableSection.v1(
59+
chapter: chapter,
60+
metadata_source: metadata,
61+
klass: 'suggested-reading'
62+
)
63+
64+
BakeChapterGlossary.v1(chapter: chapter, metadata_source: metadata, has_para: true)
65+
66+
MoveCustomSectionToEocContainer.v1(
67+
chapter: chapter,
68+
metadata_source: metadata,
69+
container_key: 'review-questions',
70+
uuid_key: '.review-questions',
71+
section_selector: 'section.review-questions'
72+
) do |section|
73+
RemoveSectionTitle.v1(section: section)
74+
end
75+
76+
BakeAllNumberedExerciseTypes.v1(
77+
within: chapter.search('section.review-questions'),
78+
exercise_options: { cases: true }
79+
)
80+
81+
BakeAllNumberedExerciseTypes.v1(
82+
within: chapter.pages.notes('$.unfolding-casestudy'),
83+
exercise_options: { cases: true }
84+
)
85+
86+
answer_key_inner_container = AnswerKeyInnerContainer.v1(
87+
chapter: chapter, metadata_source: metadata, append_to: answer_key, options: { cases: true }
88+
)
89+
90+
Kitchen::Directions::MoveSolutionsFromNumberedNote.v1(
91+
chapter: chapter, append_to: answer_key_inner_container, note_class: 'unfolding-casestudy'
92+
)
93+
94+
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
95+
within: chapter, append_to: answer_key_inner_container, section_class: 'review-questions'
96+
)
97+
98+
chapter.exercises.each do |exercise|
99+
BakeFirstElements.v1(within: exercise)
100+
end
101+
end
102+
103+
note_classes = %w[special-considerations clinical-tip safety-alert
104+
unfolding-casestudy trending-today]
105+
106+
BakeAutotitledNotes.v1(book: book, classes: note_classes, options: { cases: true })
107+
BakeCustomTitledNotes.v1(book: book, classes: %w[media-feature])
108+
BakeUnclassifiedNotes.v1(book: book)
109+
BakeUnnumberedTables.v1(book: book)
110+
BakeTableColumns.v1(book: book)
111+
BakeIframes.v1(book: book)
112+
BakeUnitTitle.v1(book: book)
113+
BakeReferences.v4(book: book, metadata_source: metadata, cases: true)
114+
BakeIndex.v1(book: book, types: %w[name term foreign], uuid_prefix: '.')
115+
BakeCompositePages.v1(book: book)
116+
BakeCompositeChapters.v1(book: book)
117+
BakeToc.v1(book: book, options: { cases: true })
118+
BakeFolio.v1(book: book)
119+
BakeRexWrappers.v1(book: book)
120+
BakeLinks.v1(book: book)
121+
BakeLinkPlaceholders.v1(book: book, cases: true)
122+
end

spec/kitchen_spec/directions/bake_chapter_introductions/v2_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,25 @@
199199
)
200200
end
201201

202+
let(:book_with_authors) do
203+
book_containing(html:
204+
<<~HTML
205+
<div data-type="chapter">
206+
<h1 data-type="document-title">Chapter 1 Title</h1>
207+
<div class="introduction" data-type="page" id="ipId">
208+
<div data-type="document-title">Introduction</div>
209+
<figure class="splash">can't touch this (stop! hammer time)</figure>
210+
<figure>move this</figure>
211+
<div>content</div>
212+
<p>Some paragraph text.</p>
213+
<p>Another paragraph text.</p>
214+
<p class="author">Some author</p>
215+
</div>
216+
</div>
217+
HTML
218+
)
219+
end
220+
202221
context 'when v2 called on book with chapter objectives' do
203222
it 'with chapter outline' do
204223
described_class.v2(
@@ -285,6 +304,20 @@
285304
end
286305
end
287306

307+
context 'when v2 is called on book with authors' do
308+
it 'bakes' do
309+
described_class.v2(
310+
book: book_with_authors, options: {
311+
strategy: :add_objectives,
312+
bake_chapter_outline: true,
313+
introduction_order: :v1,
314+
authors: true
315+
}
316+
)
317+
expect(book_with_authors).to match_snapshot_auto
318+
end
319+
end
320+
288321
context 'when book has added targt labels for introduction pages and does not use gramatical cases' do
289322
it 'stores link text' do
290323
pantry = book_v1.pantry(name: :link_text)

0 commit comments

Comments
 (0)