From 46087a2503032443d7f0613e5aeb2a5195c27850 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 8 Jun 2024 10:05:30 +0100 Subject: Fix: misc improvements --- .gitignore | 4 +-- Makefile.bookup | 32 +++++++++++++---------- TODO.md | 5 +++- bin/archive | 11 ++++---- bin/assemble | 19 +++++++------- bin/provision-host | 8 +++--- content/published/00-intro/intro.md | 19 -------------- content/published/05-workflow/funcionamento.md | 9 ------- content/published/10-structure/structure.md | 21 --------------- content/published/15-installation/installation.md | 22 ---------------- content/sections/00-intro/intro.md | 19 ++++++++++++++ content/sections/05-workflow/funcionamento.md | 9 +++++++ content/sections/10-structure/structure.md | 21 +++++++++++++++ content/sections/15-installation/installation.md | 22 ++++++++++++++++ structure/99-end.tex | 8 +++--- 15 files changed, 119 insertions(+), 110 deletions(-) delete mode 100644 content/published/00-intro/intro.md delete mode 100644 content/published/05-workflow/funcionamento.md delete mode 100644 content/published/10-structure/structure.md delete mode 100644 content/published/15-installation/installation.md create mode 100644 content/sections/00-intro/intro.md create mode 100644 content/sections/05-workflow/funcionamento.md create mode 100644 content/sections/10-structure/structure.md create mode 100644 content/sections/15-installation/installation.md diff --git a/.gitignore b/.gitignore index 6b6d3ea..28ecae4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ # Assets archive/* backups/* -compiled/* -public/* +book/* +build/* slides/*.pdf _main_files diff --git a/Makefile.bookup b/Makefile.bookup index 7eb93e8..327558a 100644 --- a/Makefile.bookup +++ b/Makefile.bookup @@ -17,6 +17,9 @@ PROJECT ?= bookup # Output file names (prefix) OUTPUT ?= book +# Output folder +OUTPUT_FOLDER ?= $(OUTPUT) + # Destination website hostname (for rsync+ssh) WEBSITE ?= $(PROJECT) @@ -101,8 +104,9 @@ compile_book: metadata @/bin/bash -c 'cat _biblio.yml >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md' @/bin/bash -c 'for file in $(BOOKUP)/structure/00*.yml; do cat $$file >> $(OUTPUT).md ; echo "---" >> $(OUTPUT).md; done' @/bin/bash -c 'for file in $(BOOKUP)/structure/00*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done' - @/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 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 content/sections/*/*.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 content/sections/*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md ; cat $(BOOKUP)/templates/references.md >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done' + @/bin/bash -c 'find content/sections -type f | sort | while read file; 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 @test -e snippets/terminology.sed && sed -i -f snippets/terminology.sed $(OUTPUT).md || true @@ -131,7 +135,7 @@ bookdown_html: # Cleanup @#rm -rf $(OUTPUT)/html $(OUTPUT)/$(OUTPUT).html - @rm -rf compiled + @rm -rf $(OUTPUT_FOLDER) # Fix references # Use sed to fix a weird reference issue on fig.cap inside knitr blocks that are not properly converted. @@ -151,23 +155,23 @@ bookdown_html: #@cd _book && ln -s "início.html" index.html @#mv _book $(OUTPUT)/html @#mv index.html.old index.html - @mv _book compiled + @mv _book $(OUTPUT_FOLDER) # Replace fuse.js from CDN to local # This ensures the HTML output can be browsed offline #@find $(OUTPUT)/html -name *.html -exec sed -i -e 's|https://cdn.jsdelivr.net/npm/fuse.js@[^"]*|../../vendor/Fuse.js/dist/fuse.min.js|' {} \; - @mkdir compiled/js - @cp vendor/bookup/vendor/Fuse.js/dist/fuse.min.js compiled/js - @find compiled -name *.html -exec sed -i -e 's|https://cdn.jsdelivr.net/npm/fuse.js@[^"]*|js/fuse.min.js|' {} \; + @mkdir $(OUTPUT_FOLDER)/js + @cp vendor/bookup/vendor/Fuse.js/dist/fuse.min.js $(OUTPUT_FOLDER)/js + @find $(OUTPUT_FOLDER) -name *.html -exec sed -i -e 's|https://cdn.jsdelivr.net/npm/fuse.js@[^"]*|js/fuse.min.js|' {} \; # Add revision information - @echo $(REVISION) > compiled/revision + @echo $(REVISION) > $(OUTPUT_FOLDER)/revision # Add symlink to the archive and to the slides # This symlink is useful for checking things in localhost # But it tends to be replaced during remote deployment - @cd compiled > /dev/null && ln -s ../archive - @cd compiled > /dev/null && ln -s ../slides + @cd $(OUTPUT_FOLDER) > /dev/null && ln -s ../archive + @cd $(OUTPUT_FOLDER) > /dev/null && ln -s ../slides bookdown_pdf: # Cleanup old builds @@ -179,7 +183,7 @@ bookdown_pdf: # Move @#mv _main.pdf $(OUTPUT).pdf @#mv _book/_main.pdf $(OUTPUT)/$(OUTPUT).pdf - @mv _book/_main.pdf compiled/$(OUTPUT).pdf + @mv _book/_main.pdf $(OUTPUT_FOLDER)/$(OUTPUT).pdf # Use sed to convert tufte::margin_note to marginfigure # Also, "sed -i" yields a permission denied error when running inside a guest VM. @@ -195,7 +199,7 @@ bookdown_epub: # Move @##mv _book/_main.epub $(OUTPUT)/$(OUTPUT).epub - @#mv _book/_main.epub compiled/$(OUTPUT)s.epub + @#mv _book/_main.epub $(OUTPUT_FOLDER)/$(OUTPUT)s.epub # Cleanup @#rm _book/reference-keys.txt @@ -208,7 +212,7 @@ bookdown: bookdown_clean bookdown_html bookdown_pdf bookdown_epub # move_book: - @mv $(OUTPUT).* compiled/ + @mv $(OUTPUT).* $(OUTPUT_FOLDER)/ assemble: @$(BOOKUP)/bin/assemble @@ -260,7 +264,7 @@ site: # web_deploy: - @rsync -avz --delete $(EXCLUDES) ./public/ $(WEBSITE):/ + @rsync -avz --delete $(EXCLUDES) ./build/ $(WEBSITE):/ @rsync -avz --delete ./archive/ $(WEBSITE):/archive/ @rsync -avz --delete ./slides/ $(WEBSITE):/slides/ diff --git a/TODO.md b/TODO.md index 9aedc76..1bb46f5 100644 --- a/TODO.md +++ b/TODO.md @@ -2,8 +2,10 @@ ## Basic +* [x] Use `book` instead of `compiled`. +* [x] Use `content/sections` instead of `content/published`. +* [ ] Use `build` instead of `public`. * [ ] Move `slides` to `content/slides`. -* [ ] Use `content/sections` instead of `content/published`. * [ ] Add other features available in the `cybersni` repository. * [ ] Add a small reference to the Bookup website in the book frontmatter? * [ ] Improve the documentation, including: @@ -20,6 +22,7 @@ ## Issues +* [ ] List of definitions and etimologies breaks build if they're empty. * [ ] Bug no `pandoc` ou `citeproc` ignorando citações dentro de blocos LaTeX. Afetando o formato PDF. Vide projeto `test`, em `~/code/test/pandoc`. Considerar um relatório upstream. diff --git a/bin/archive b/bin/archive index 584ea13..8949268 100755 --- a/bin/archive +++ b/bin/archive @@ -9,14 +9,15 @@ DIRNAME="`dirname $0`" BASEDIR="$DIRNAME/.." #ARCHIVE="$BASEDIR/archive" ARCHIVE="archive" +ASSETS="build" REVISION="`git describe --tags 2> /dev/null || git log -1 --format=oneline | cut -d ' ' -f 1`" # Determine the revision file -if [ -e "public/revision" ]; then - #REVFILE="$BASEDIR/public/revision" - REVFILE="public/revision" +if [ -e "$ASSETS/revision" ]; then + #REVFILE="$BASEDIR/$ASSETS/revision" + REVFILE="$ASSETS/revision" else - REVFILE="public/book/revision" + REVFILE="$ASSETS/book/revision" fi # Make sure the archive folder exist @@ -41,7 +42,7 @@ if git tag | grep -q "^${OLD_REVISION}"; then # Check if archive does not exists if [ ! -d "$ARCHIVE/$OLD_REVISION" ]; then echo "# $BASENAME: archiving $OLD_REVISION..." - cp -alf compiled $ARCHIVE/$OLD_REVISION + cp -alf $ASSETS $ARCHIVE/$OLD_REVISION else echo "# $BASENAME: revision $OLD_REVISION already archived" fi diff --git a/bin/assemble b/bin/assemble index cd0836c..3b5b287 100755 --- a/bin/assemble +++ b/bin/assemble @@ -8,26 +8,27 @@ BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`" DIRNAME="`dirname $0`" BASEDIR="$DIRNAME/.." SITE="site" +BOOK="book" NOTEBOOK="notebook" -PUBLIC="public" +BUILD="build" -# Cleanup the previous public folder -rm -rf $PUBLIC +# Cleanup the previous build folder +rm -rf $BUILD # Check if there's a site folder if [ -e "$SITE" ]; then - cp -a $SITE public + cp -a $SITE $BUILD - if [ -e "compiled" ]; then - mv compiled public/book + if [ -e "$BOOK" ]; then + mv $BOOK $BUILD/book fi else - if [ -e "compiled" ]; then - mv compiled public + if [ -e "$BOOK" ]; then + mv $BOOK $BUILD fi fi # Check if there's a notebook if [ -e "$NOTEBOOK" ]; then - mv $NOTEBOOK public/notes + mv $NOTEBOOK $BUILD/notes fi diff --git a/bin/provision-host b/bin/provision-host index 13b8a78..81cf602 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 ServerName localhost ServerAlias *.onion - DocumentRoot "/srv/shared/public" + DocumentRoot "/srv/shared/build" - + #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 ServerName ${PROJECT}.local - DocumentRoot "/srv/shared/public" + DocumentRoot "/srv/shared/build" - + #AuthType Basic #AuthName "Protected" #AuthUserFile /srv/shared/.htpasswd diff --git a/content/published/00-intro/intro.md b/content/published/00-intro/intro.md deleted file mode 100644 index 5e5c7d0..0000000 --- a/content/published/00-intro/intro.md +++ /dev/null @@ -1,19 +0,0 @@ -# Introdução {#intro} - -Bookup é um conjunto de templates, programas e fluxos de trabalho para a -autoria de livros em formatos HTML, PDF e EPUB. - -Ele é um componente de software modular baseado em [Bookdown][]. - -Foi criado para resolver o problema de editar muitos livros simultaneamente: -Bookup ajuda a manter um esquema uniforme, ao invés de ter que implementar e -corrigir funcionalidades paralelamente em muitos repositórios. - -Com ele, a produção de conteúdo fica parecida com o trabalho com outros -códigos. - -Não foi priorizado investir tempo em generalizar tudo ao máximo. O mais -importante foi criar uma base comum para os meus livros, e talvez aos poucos -generalizar para que possa ser usado por outras iniciativas. - -[Bookdown]: https://bookdown.org diff --git a/content/published/05-workflow/funcionamento.md b/content/published/05-workflow/funcionamento.md deleted file mode 100644 index 66ff216..0000000 --- a/content/published/05-workflow/funcionamento.md +++ /dev/null @@ -1,9 +0,0 @@ -# Funcionamento {#funcionamento} - -Bookup opera através da _compilação_ de arquivos: - -``` - /--> Livro PDF -Arquivos fonte em Markdown --> Compilação --> - \--> Livro HTML -``` diff --git a/content/published/10-structure/structure.md b/content/published/10-structure/structure.md deleted file mode 100644 index cb1fafb..0000000 --- a/content/published/10-structure/structure.md +++ /dev/null @@ -1,21 +0,0 @@ -# Estrutura de pastas {#estrutura} - -A estrutura de pastas de um projeto usando Bookup é a seguinte: - -* `archive`: armazena versões antigas do livro. -* `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 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. -* `public`: o livro compilado (HTML, PDF e outros formatos): - * `notes`: caderno de notas compilado. - * `book`: o livro compilado, se houver uma pasta `site`, caso contrário o - conteúdo dolivro será colocado na pasta raíz do diretório `public`. -* `biblio`: bibliografia. -* `images`: pasta de imagens. -* `vendor/bookup`: - * `content`: documentação do Bookup. - * `vendor/{Fuse.js,}`: dependências. diff --git a/content/published/15-installation/installation.md b/content/published/15-installation/installation.md deleted file mode 100644 index 9024b41..0000000 --- a/content/published/15-installation/installation.md +++ /dev/null @@ -1,22 +0,0 @@ -# Instalação {#instalacao} - -Procedimento de instalação do Bookup. - -## Vendorização - -* Vendorização (repositórios `bookup` e de bibliografia). - -## Links simbólicos - -* `_bookdown.yml`. -* `output.yml`. - -## Arquivos requeridos - -* `.gitignore`. -* `images/cover.png`. -* `_bookup.yml`. -* `_biblio.yml`. -* `LICENSE`. -* `DISCLAIMER`. -* `snippets/{contact,cover,keywords,project,url,volume}.txt`. diff --git a/content/sections/00-intro/intro.md b/content/sections/00-intro/intro.md new file mode 100644 index 0000000..5e5c7d0 --- /dev/null +++ b/content/sections/00-intro/intro.md @@ -0,0 +1,19 @@ +# Introdução {#intro} + +Bookup é um conjunto de templates, programas e fluxos de trabalho para a +autoria de livros em formatos HTML, PDF e EPUB. + +Ele é um componente de software modular baseado em [Bookdown][]. + +Foi criado para resolver o problema de editar muitos livros simultaneamente: +Bookup ajuda a manter um esquema uniforme, ao invés de ter que implementar e +corrigir funcionalidades paralelamente em muitos repositórios. + +Com ele, a produção de conteúdo fica parecida com o trabalho com outros +códigos. + +Não foi priorizado investir tempo em generalizar tudo ao máximo. O mais +importante foi criar uma base comum para os meus livros, e talvez aos poucos +generalizar para que possa ser usado por outras iniciativas. + +[Bookdown]: https://bookdown.org diff --git a/content/sections/05-workflow/funcionamento.md b/content/sections/05-workflow/funcionamento.md new file mode 100644 index 0000000..66ff216 --- /dev/null +++ b/content/sections/05-workflow/funcionamento.md @@ -0,0 +1,9 @@ +# Funcionamento {#funcionamento} + +Bookup opera através da _compilação_ de arquivos: + +``` + /--> Livro PDF +Arquivos fonte em Markdown --> Compilação --> + \--> Livro HTML +``` diff --git a/content/sections/10-structure/structure.md b/content/sections/10-structure/structure.md new file mode 100644 index 0000000..98b2f91 --- /dev/null +++ b/content/sections/10-structure/structure.md @@ -0,0 +1,21 @@ +# Estrutura de pastas {#estrutura} + +A estrutura de pastas de um projeto usando Bookup é a seguinte: + +* `archive`: armazena versões antigas do livro. +* `content`: o conteúdo do livro. + * `drafts`: deixe aqui os textos que ainda estão em composição. + * `sections`: aqui vai todo o material a ser compilado em livro. + * `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. +* `build`: o livro compilado (HTML, PDF e outros formatos): + * `notes`: caderno de notas compilado. + * `book`: o livro compilado, se houver uma pasta `site`, caso contrário o + conteúdo dolivro será colocado na pasta raíz do diretório `public`. +* `biblio`: bibliografia. +* `images`: pasta de imagens. +* `vendor/bookup`: + * `content`: documentação do Bookup. + * `vendor/{Fuse.js,}`: dependências. diff --git a/content/sections/15-installation/installation.md b/content/sections/15-installation/installation.md new file mode 100644 index 0000000..9024b41 --- /dev/null +++ b/content/sections/15-installation/installation.md @@ -0,0 +1,22 @@ +# Instalação {#instalacao} + +Procedimento de instalação do Bookup. + +## Vendorização + +* Vendorização (repositórios `bookup` e de bibliografia). + +## Links simbólicos + +* `_bookdown.yml`. +* `output.yml`. + +## Arquivos requeridos + +* `.gitignore`. +* `images/cover.png`. +* `_bookup.yml`. +* `_biblio.yml`. +* `LICENSE`. +* `DISCLAIMER`. +* `snippets/{contact,cover,keywords,project,url,volume}.txt`. diff --git a/structure/99-end.tex b/structure/99-end.tex index b50d1b7..f1657bd 100644 --- a/structure/99-end.tex +++ b/structure/99-end.tex @@ -16,14 +16,14 @@ Listas de tabelas, figuras etc. % Print the list of definitions % See https://latex.org/forum/viewtopic.php?t=17679 % https://ctan.org/pkg/thmtools -\renewcommand\listtheoremname{Lista de Definições} -\listoftheorems[ignoreall,show={definition}] +%\renewcommand\listtheoremname{Lista de Definições} +%\listoftheorems[ignoreall,show={definition}] % Print the list of etimologies % The "proposition" theorem type is allocated for etimologies in this book % See the _bookdown.yml at the top-level project folder for more information -\renewcommand\listtheoremname{Lista de Etimologias} -\listoftheorems[ignoreall,show={proposition}] +%\renewcommand\listtheoremname{Lista de Etimologias} +%\listoftheorems[ignoreall,show={proposition}] % Print the index \printindex -- cgit v1.2.3