diff --git a/.generate-cover.sh b/.generate-cover.sh new file mode 100644 index 0000000..f79f17c --- /dev/null +++ b/.generate-cover.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +json_file_with_title="book.json" +title_font="Courier-10-Pitch" + +font_is_on_system () { + convert -list font | grep -q $title_font +} + +get_title_from_json () { + grep -Po '"title":\s"\K[^"]+' $json_file_with_title +} + +put_padding_into_image () { + local top_border="0" + local left_border="20" + echo "-gravity northwest -splice ${left_border}x${top_border}" +} + +if [ ! -f $json_file_with_title ] +then + echo "The file $json_file_with_title was not found" + exit 1 +fi + +if [ $(get_title_from_json | wc -c) -eq 0 ] +then + echo "The title key was not found into $json_file_with_title file" + exit 1 +fi + +if ! $(font_is_on_system) +then + echo "The font $title_font needs to be installed on the system" + exit 1 +fi + +convert -font $title_font \ + -gravity west \ + -background "#0000" \ + -fill black \ + -size 590x300 \ + caption:"$(get_title_from_json)" \ + $(put_padding_into_image) \ + ./images/clean-cover.png \ + +swap \ + -gravity northwest \ + -composite ./images/cover.png + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b0b085..9d408c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,9 @@ on: branches: - master +env: + BOOK_FILENAME: la-guia-del-profesor-frisby-en-su-mayor-parte-adecuada-para-la-programacion-funcional + jobs: build: runs-on: ubuntu-22.04 @@ -25,27 +28,35 @@ jobs: with: node-version: 10.22.1 + - name: Put title on cover + run: | + sudo apt install -y xfonts-scalable + npm run generate-cover + - name: Setup gitbook run: | npm ci npm run setup + - name: Generate PDF run: | npm run generate-pdf - mv book.pdf mostly-adequate-guide-to-functional-programming-spanish-version.pdf + mv book.pdf ${BOOK_FILENAME}.pdf + - name: Generate EPUB run: | npm run generate-epub - mv book.epub mostly-adequate-guide-to-functional-programming-spanish-version.epub + mv book.epub ${BOOK_FILENAME}.epub + - uses: actions/upload-artifact@v2 with: name: PDF - path: mostly-adequate-guide-to-functional-programming-spanish-version.pdf + path: ${{ env.BOOK_FILENAME }}.pdf - uses: actions/upload-artifact@v2 with: name: EPUB - path: mostly-adequate-guide-to-functional-programming-spanish-version.epub + path: ${{ env.BOOK_FILENAME }}.epub - run: echo "ID=$(git describe --tags --always)" >> $GITHUB_OUTPUT id: release-id @@ -54,5 +65,5 @@ jobs: with: tag_name: ${{ steps.release-id.outputs.ID }} files: | - mostly-adequate-guide-to-functional-programming-spanish-version.pdf - mostly-adequate-guide-to-functional-programming-spanish-version.epub + ${{ env.BOOK_FILENAME }}.pdf + ${{ env.BOOK_FILENAME }}.epub diff --git a/book.json b/book.json index 91c4faf..b0b271f 100644 --- a/book.json +++ b/book.json @@ -1,7 +1,7 @@ { "gitbook": "3.2.2", "root": ".", - "title": "Professor Frisby's Mostly Adequate Guide to Functional Programming", + "title": "La Guía del Profesor Frisby en su Mayor Parte Adecuada para la Programación Funcional", "cover": "images/cover.png", "plugins": [ "exercises@git+https://github.com/MostlyAdequate/plugin-exercises.git", diff --git a/images/clean-cover.png b/images/clean-cover.png new file mode 100644 index 0000000..6f270ca Binary files /dev/null and b/images/clean-cover.png differ diff --git a/images/cover.png b/images/cover.png index c02a5ad..2d5cce1 100644 Binary files a/images/cover.png and b/images/cover.png differ diff --git a/package.json b/package.json index 8ba869d..3fb624f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mostly-adequate-guide-es", "version": "1.0.0", - "description": "The Mostly Adequate Guide to Functional Programming", + "description": "La Guía del Profesor Frisby en su Mayor Parte Adecuada para la Programación Funcional", "dependencies": { "gitbook-plugin-exercises": "git+https://github.com/MostlyAdequate/plugin-exercises.git", "gitbook-plugin-include-codeblock": "^3.2.2" @@ -12,6 +12,7 @@ "scripts": { "setup": "$(npm bin)/gitbook install", "start": "$(npm bin)/gitbook serve", + "generate-cover": "sh ./.generate-cover.sh", "generate-epub": "gitbook epub", "generate-pdf": "gitbook pdf" }, diff --git a/support/README.md b/support/README.md index 714b3b0..3240df1 100644 --- a/support/README.md +++ b/support/README.md @@ -3,7 +3,7 @@ ## Información General Este paquete contiene todas las funciones y estructuras de datos referenciadas en los -apéndices de [La Más Que Adecuada Guía de Programación Funcional](https://github.com/MostlyAdequate/mostly-adequate-guide-es). +apéndices de [La Guía del Profesor Frisby en su Mayor Parte Adecuada para la Programación Funcional](https://github.com/MostlyAdequate/mostly-adequate-guide-es). Estas funciones tienen un propósito pedagógico y no pretenden que sean utilizadas en ningún entorno en producción. Son sin embargo, un buen material de aprendizaje para