From 105bc9d7a13a30e615622af89a18900f391f8669 Mon Sep 17 00:00:00 2001 From: Hendrik Kleinwaechter Date: Fri, 14 Jul 2023 15:47:46 +0200 Subject: [PATCH] Add note to cover page --- book/style.css | 4 ++ website/modify_build.rb | 105 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/book/style.css b/book/style.css index ad23205..03ba5b1 100644 --- a/book/style.css +++ b/book/style.css @@ -300,3 +300,7 @@ div.center { margin-left: 0 !important; margin-right: 0 !important; } + +main.titlepage h2.chapterHead { + margin-top: 0px; +} diff --git a/website/modify_build.rb b/website/modify_build.rb index b50a203..da84cce 100644 --- a/website/modify_build.rb +++ b/website/modify_build.rb @@ -14,6 +14,8 @@ class ModifyBuild build_latex_html end + private + def build_latex_html system("rm -rf #{build_dir}/") system("mkdir #{build_dir}/") @@ -24,8 +26,6 @@ class ModifyBuild end end - private - def modify_file(filename) orig_text = File.read(filename) text = fix_double_slashes(orig_text) @@ -41,6 +41,7 @@ class ModifyBuild text = mark_menu_as_selected_if_on_page(text, extract_file_from_path(filename)) text = add_canonical_for_duplicates(text, extract_file_from_path(filename)) text = include_javascript(text) + text = add_text_to_coverpage(text, extract_file_from_path(filename)) File.open(filename, "w") {|file| file.puts text } end @@ -378,6 +379,106 @@ class ModifyBuild doc.to_html end + def add_text_to_coverpage(text, filename) + return text unless is_cover_page?(filename) + doc = build_doc(text) + content = doc.css(".titlepage")[0] + raise ArgumentError.new(".titlepage not found in HTML") if content.nil? + + content.add_class("main-content") + content.inner_html = "#{build_cover_page_content} #{content.inner_html}" + doc.to_html + end + + def build_cover_page_content + %Q{ +

+ 🍞 The Sourdough Framework 📓 +

+

+ The Sourdough Framework goes beyond just recipes and provides you a solid + knowledge foundation, covering the science of sourdough, the basics of + bread making, and advanced techniques for achieving the perfect sourdough bread at home. +

+ +

+ Creating this book has been a labor of love. My + main goal has always been to spread the joy of baking and empower bread + enthusiasts like yourself. To ensure that the book remains accessible + to everyone, I have decided to make it available as a free digital download. +

+ +

+ However, producing and maintaining resources like this requires + considerable time, effort, and financial investment. If you find value + in "The Sourdough Framework" and appreciate the effort that went into + creating it, I kindly request your support + through a donation or by + considering the purchase of + the hardcover version of this book. +

+ +

+ Your generous contribution will not only help me cover the costs associated + with this project but will also enable me to continue creating more valuable + content in the future. +

+ +

+ If you feel inspired to contribute, please consider making a donation of + any amount through my donation page. + Your support will go a long way in ensuring + that this knowledge can reach even more bread enthusiasts worldwide. +

+ +

+ Remember, your donation is entirely voluntary and any amount you + contribute is deeply appreciated. If you are unable to make a donation at + this time, please know that your readership and support in spreading the + word about "The Sourdough Framework" are invaluable contributions as well. +

+ +

+ Thank you for being a part of this journey, and I hope that + "The Sourdough Framework" enriches your bread-making adventures. + Together, we can continue to share the love of baking and cultivate a + community passionate about the art of sourdough. +

+

+ You can either browse through this page or download the full book directly: +

+

+ PDF: https://www.the-bread-code.io/book.pdf
+ PDF (no serif): https://www.the-bread-code.io/book-sans-serif.pdf +

+ +

+ EPUB: https://www.the-bread-code.io/book.epub
+ EPUB (no serif): https://www.the-bread-code.io/book-sans-serif.epub +

+ +

+ Kindle: https://www.the-bread-code.io/book.azw3
+ Kindle (no serif): https://www.the-bread-code.io/book-sans-serif.azw3 +

+ +

+ The full source code of the book can be found here: + https://www.github.com/hendricius/the-sourdough-framework +

+ +

+ There's also a hardcover version of the book available featuring an even more awesome design. You can read more information here: + https://www.breadco.de/hardcover-book +

+ +

+ Thank you and may the gluten be strong with you,
+ Hendrik +

+ } + end + def build_doc(text) Nokogiri::HTML(text) end