diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.bookup | 57 | ||||
-rw-r--r-- | TODO.md | 4 | ||||
-rwxr-xr-x | bin/archive | 10 | ||||
-rwxr-xr-x | bin/assemble | 33 | ||||
-rwxr-xr-x | bin/provision-host | 8 | ||||
-rw-r--r-- | content/notes/00-intro/notes.md | 32 | ||||
-rw-r--r-- | content/published/10-structure/structure.md | 2 |
8 files changed, 131 insertions, 16 deletions
@@ -19,3 +19,4 @@ _main_files # Local customizations Makefile.local +public 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 @@ -2,8 +2,8 @@ ## Basic -* [ ] Notebook support. -* [ ] Website support. +* [x] Notebook support. +* [x] Website support. * [ ] Add other features available in the `cybersni` repository. * [ ] Add a small reference to the Bookup website in the book frontmatter? * [ ] Improve the documentation, including: diff --git a/bin/archive b/bin/archive index 27728e4..584ea13 100755 --- a/bin/archive +++ b/bin/archive @@ -10,8 +10,14 @@ BASEDIR="$DIRNAME/.." #ARCHIVE="$BASEDIR/archive" ARCHIVE="archive" REVISION="`git describe --tags 2> /dev/null || git log -1 --format=oneline | cut -d ' ' -f 1`" -#REVFILE="$BASEDIR/compiled/revision" -REVFILE="compiled/revision" + +# Determine the revision file +if [ -e "public/revision" ]; then + #REVFILE="$BASEDIR/public/revision" + REVFILE="public/revision" +else + REVFILE="public/book/revision" +fi # Make sure the archive folder exist mkdir -p $ARCHIVE diff --git a/bin/assemble b/bin/assemble new file mode 100755 index 0000000..cd0836c --- /dev/null +++ b/bin/assemble @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Assembler +# + +# Parameters +BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`" +DIRNAME="`dirname $0`" +BASEDIR="$DIRNAME/.." +SITE="site" +NOTEBOOK="notebook" +PUBLIC="public" + +# Cleanup the previous public folder +rm -rf $PUBLIC + +# Check if there's a site folder +if [ -e "$SITE" ]; then + cp -a $SITE public + + if [ -e "compiled" ]; then + mv compiled public/book + fi +else + if [ -e "compiled" ]; then + mv compiled public + fi +fi + +# Check if there's a notebook +if [ -e "$NOTEBOOK" ]; then + mv $NOTEBOOK public/notes +fi diff --git a/bin/provision-host b/bin/provision-host index 16712fb..13b8a78 100755 --- a/bin/provision-host +++ b/bin/provision-host @@ -44,9 +44,9 @@ cat <<-EOF | $SUDO tee /etc/apache2/sites-available/onion.conf > /dev/null <VirtualHost 127.0.0.1:80> ServerName localhost ServerAlias *.onion - DocumentRoot "/srv/shared/compiled" + DocumentRoot "/srv/shared/public" - <Directory /srv/shared/compiled> + <Directory /srv/shared/public> #AuthType Basic #AuthName "Protected" #AuthUserFile /srv/shared/.htpasswd @@ -62,9 +62,9 @@ EOF cat <<-EOF | $SUDO tee /etc/apache2/sites-available/local.conf > /dev/null <VirtualHost *:80> ServerName ${PROJECT}.local - DocumentRoot "/srv/shared/compiled" + DocumentRoot "/srv/shared/public" - <Directory /srv/shared/compiled> + <Directory /srv/shared/public> #AuthType Basic #AuthName "Protected" #AuthUserFile /srv/shared/.htpasswd diff --git a/content/notes/00-intro/notes.md b/content/notes/00-intro/notes.md new file mode 100644 index 0000000..af00773 --- /dev/null +++ b/content/notes/00-intro/notes.md @@ -0,0 +1,32 @@ +--- +title : "Bookup Notebook" +author : "Silvio Rhatto" +date : "`r Sys.Date()`" +lang : "pt-br" +site : "bookdown::bookdown_site" +publisher: "Bookup" +output: + bookdown::gitbook: + config: + toc: + collapse: section + toolbar: + # Default search indexing is very slow: there's lots of notes to be indexed at each page load + # Because of that, it may be better to disable search by default + #search: no + # Fuse search engine is faster + search: + engine: fuse + sharing: no + fontsettings: + theme: night + family: sans + size: 2 + #split_by: chapter+number + #split_by: section + +--- + +# Caderno de anotações {#index} + +Exemplo de caderno de anotações. diff --git a/content/published/10-structure/structure.md b/content/published/10-structure/structure.md index f413396..cb1fafb 100644 --- a/content/published/10-structure/structure.md +++ b/content/published/10-structure/structure.md @@ -6,7 +6,7 @@ A estrutura de pastas de um projeto usando Bookup é a seguinte: * `content`: o conteúdo do livro. * `drafts`: deixe aqui os textos que ainda estão em composição. * `published`: aqui vai todo o material a ser compilado em livro. -* `notes`: caderno de anotações. + * `notes`: caderno de anotações a ser incluído no material público. * `slides`: slides no formato Markdown. * `site`: HTML opcional usado para o sítio base; se existir, o livro será colocado dentro da pasta `public/book` ou algo assim. |