From d78c29ba664de2ee987f47ea5f5bd9d46706a61c Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 30 Dec 2024 23:50:38 +0000 Subject: [PATCH 1/3] Fix a bug on make clean We were deleting the .table files by mistake with clean/mrproper --- book/makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book/makefile b/book/makefile index 7e77c33..05a0889 100644 --- a/book/makefile +++ b/book/makefile @@ -34,7 +34,9 @@ chapters = baking basics bread-types cover flour-types history intro mix-ins\ src_tables := $(wildcard tables/table-*.tex) src_figures := $(wildcard figures/fig-*.tex) figures/flowcharts_tikz.tex +src_figures += $(wildcard plots/fig-*.tex) src_recipes := $(wildcard recipes/*.tex) +src_plots := $(wildcard plots/*.table) src_tex := $(foreach directory, $(chapters), $(wildcard $(directory)/*.tex)) src_tex += book.tex book_sans_serif.tex references.bib figures/vars.tex @@ -58,7 +60,7 @@ bw_images := $(addprefix bw-book-epub/OEBPS/, $(images)) # images to lower resolution low_res_images := $(addprefix low-res-book-epub/OEBPS/, $(images)) -src_all := $(src_tex) $(src_figures) $(src_tables) $(images) +src_all := $(src_tex) $(src_figures) $(src_tables) $(images) $(src_plots) ebook_src := $(src_all) tex4ebook.cfg book.mk4 book-ebook.css From 32d600005c899165696ebf277c6a279e92b66d2d Mon Sep 17 00:00:00 2001 From: Stoneguard001 Date: Tue, 31 Dec 2024 11:05:52 -0500 Subject: [PATCH 2/3] reduce epub file size with ower res pics (#406) * epub - use the lower resolution colour as release epub * Add in check for epub size, will fail if too big (>50MB) * added folders ebook and website build folders to .gitignore --- .gitignore | 2 ++ book/makefile | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6c35385..79db794 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ book/book-epub/ book/bw-book-epub/* book/release/* book/low-res-book-epub/* +book/epub_build/* +book/website_build/* diff --git a/book/makefile b/book/makefile index 05a0889..dc4dcce 100644 --- a/book/makefile +++ b/book/makefile @@ -10,9 +10,10 @@ REDUCE_PIC := -resize '800x800>' \ -strip -interlace Plane -gaussian-blur 0.05 -quality 85\% \ -set colorspace Gray -separate -evaluate-sequence Mean REDUCE_PIC_COLOR := -quality 80\% -RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg' --exclude '*.png' +RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg' GIT := git --no-pager SPELL_CHECK := hunspell -t -l -d en_US +EPUBSIZE := `du -sb epub/low_res_book.epub | cut -f1` # We want bash as shell SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ @@ -111,15 +112,15 @@ book_serif/book.pdf: $(src_all) book_sans_serif/book_sans_serif.pdf: $(src_all) $(LATEX) -output-directory=book_sans_serif book_sans_serif.tex -.PHONY: copy_ebook_files copy_ebook_files_cl +.PHONY: copy_ebook_files copy_ebook_files_low_res epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb $(EBOOK) $< copy_ebook_files: build_ebook - $(RSYNC) epub_build/book-epub/ bw-book-epub/ + $(RSYNC) --exclude '*.png' epub_build/book-epub/ bw-book-epub/ -copy_ebook_files_cl: build_ebook +copy_ebook_files_low_res: build_ebook $(RSYNC) epub_build/book-epub/ low-res-book-epub/ # We do not convert SVG to B&W or lower res for now as they are super small @@ -136,15 +137,11 @@ low-res-book-epub/OEBPS/%.jpg: %.jpg mkdir -p $(dir $@) $(CONVERT_PIC) $< $(REDUCE_PIC_COLOR) $@ -low-res-book-epub/OEBPS/%.png: %.png - mkdir -p $(dir $@) - $(CONVERT_PIC) $< $(REDUCE_PIC_COLOR) $@ - epub/bw_book.epub: copy_ebook_files $(bw_images) cd bw-book-epub; zip -q0X ../epub/bw_book.epub mimetype cd bw-book-epub; zip -q9XrD ../epub/bw_book.epub ./ -epub/low_res_book.epub: copy_ebook_files_cl $(low_res_images) +epub/low_res_book.epub: copy_ebook_files_low_res $(low_res_images) cd low-res-book-epub; zip -q0X ../epub/low_res_book.epub mimetype cd low-res-book-epub; zip -q9XrD ../epub/low_res_book.epub ./ @@ -305,9 +302,12 @@ release: release_serif: build_serif_pdf build_ebook build_bw_ebook build_low_res_ebook | release cp book_serif/book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf - cp epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub cp epub/bw_book.epub release/TheBreadCode-The-Sourdough-Framework-black-and-white.epub - cp epub/low_res_book.epub release/TheBreadCode-The-Sourdough-Framework-reduced-size.epub + cp epub/low_res_book.epub release/TheBreadCode-The-Sourdough-Framework.epub + @if [ $(EPUBSIZE) -gt 49500000 ]; then \ + echo "ERROR: epub File too big"; \ + exit 1; \ + fi release_sans_serif: build_sans_serif_pdf | release cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf From 6202f448811ab8e0499bf575aab56b09fa63b523 Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 31 Dec 2024 17:04:28 +0000 Subject: [PATCH 3/3] Fix missing dependency for low-res epub the png files will be provided by rsync but make does not know that so just removing them from dependency list for now. TODO: Is there a better fix? --- book/makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/book/makefile b/book/makefile index dc4dcce..788fa6f 100644 --- a/book/makefile +++ b/book/makefile @@ -57,9 +57,10 @@ images += $(foreach directory, $(chapters), $(wildcard $(directory)/*/*.png)) # images to lower resolution and greyscale bw_images := $(addprefix bw-book-epub/OEBPS/, $(images)) -# Reduced ebook, we will just re-zip directory after converting the -# images to lower resolution +# For lower res colour ebook we would not convert png as it only get worst +# we will copy them instead... so remove them as a dependency. low_res_images := $(addprefix low-res-book-epub/OEBPS/, $(images)) +low_res_images := $(filter-out %.png, $(low_res_images)) src_all := $(src_tex) $(src_figures) $(src_tables) $(images) $(src_plots)