aboutsummaryrefslogtreecommitdiff
path: root/Makefile.bookup
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-06-07 21:24:47 +0100
committerSilvio Rhatto <rhatto@riseup.net>2024-06-07 21:24:47 +0100
commitf3b89d42e03a14385d1e32b7aa8450a2698ec076 (patch)
treec058e5cc1ba72027248656a6277fc8fd2b1bb069 /Makefile.bookup
parent08af902dbc822db1754d18339efc83985c65c3c3 (diff)
downloadbookup-f3b89d42e03a14385d1e32b7aa8450a2698ec076.tar.gz
bookup-f3b89d42e03a14385d1e32b7aa8450a2698ec076.tar.bz2
Feat: support for website and notebook
Diffstat (limited to 'Makefile.bookup')
-rw-r--r--Makefile.bookup57
1 files changed, 50 insertions, 7 deletions
diff --git a/Makefile.bookup b/Makefile.bookup
index 0c7c1be..5b72578 100644
--- a/Makefile.bookup
+++ b/Makefile.bookup
@@ -32,7 +32,7 @@ HTML_STYLE ?= bookdown::gitbook
#EXCLUDES = --exclude=.htpasswd
#EXCLUDES = --exclude=Makefile.local
-EXCLUDES = archive
+EXCLUDES = archive slides
#
# Metadata
@@ -52,7 +52,7 @@ YEAR = $(shell date +%Y)
# Default target
#
-all: submodules book clean
+all: submodules book notes assemble clean
@true
#
@@ -104,10 +104,17 @@ compile_book: metadata
@/bin/bash -c 'for file in content/published/*/*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md ; cat $(BOOKUP)/templates/references.md >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
@/bin/bash -c 'for file in $(BOOKUP)/structure/99*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
@sed -i -e "s|%%revision%%|$(REVISION)|g" -e "s|%%date%%|$(DATE)|g" $(OUTPUT).md
- @#sed -i -f snippets/terminology.sed $(OUTPUT).md
+ @test -e snippets/terminology.sed && sed -i -f snippets/terminology.sed $(OUTPUT).md || true
@ln -sf $(OUTPUT).md $(OUTPUT).Rmd
-compile: compile_book move_book
+compile_notes: metadata
+ @rm -f notes.md
+ @/bin/bash -c 'find content/notes -type f | sort | while read file; do cat $$file >> notes.md; echo "" >> notes.md; done; echo "# Bibliografia" >> notes.md'
+ @sed -i -e "s|%%revision%%|$(REVISION)|g" -e "s|%%date%%|$(DATE)|g" notes.md
+ @test -e snippets/terminology.sed && sed -i -f snippets/terminology.sed notes.md || true
+ @ln -s notes.md notes.Rmd
+
+compile: compile_book move_book compile_notes move_note
@true
#
@@ -202,16 +209,52 @@ bookdown: bookdown_clean bookdown_html bookdown_pdf bookdown_epub
move_book:
@mv $(OUTPUT).* compiled/
+assemble:
+ @bin/assemble
+
book: archive compile_book bookdown move_book clean
#
+# Notes
+#
+
+move_notes:
+ @mv notes.* notebook
+
+# Too many section levels (nesting) to produce a PDF output
+#bookdown_notes_pdf:
+# @Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::tufte_book2")'
+
+bookdown_notes_html:
+ # Fix references
+ # Use sed to fix a weird reference issue
+ # Also, "sed -i" yields a permission denied error when running inside a guest VM.
+ @sed -e 's/\\\\citet{\([^}]*\)}/@\1/g' notes.md > notes.new && mv notes.new notes.md
+
+ # Build
+ @#Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::html_book")'
+ @Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::gitbook")'
+
+ # Cleanup old notes
+ @rm -rf notebook
+
+ # Move
+ @mv _book notebook
+
+ # Replace fuse.js from CDN to local
+ # This ensures the HTML output can be browsed offline
+ @find notebook -name *.html -exec sed -i -e 's|https://cdn.jsdelivr.net/npm/fuse.js@[^"]*|../js/fuse.min.js|' {} \;
+
+notes: compile_notes bookdown_clean bookdown_notes_html move_notes clean
+
+#
# Remote copies
#
web_deploy:
- @rsync -avz --delete $(EXCLUDES) ./compiled/ $(WEBSITE):/
- @rsync -avz --delete ./archive/ $(WEBSITE):/archive/
- @rsync -avz --delete ./slides/ $(WEBSITE):/slides/
+ @rsync -avz --delete $(EXCLUDES) ./public/ $(WEBSITE):/
+ @rsync -avz --delete ./archive/ $(WEBSITE):/archive/
+ @rsync -avz --delete ./slides/ $(WEBSITE):/slides/
#
# Offline copies