Skip to content

Commit

Permalink
Merge pull request #45 from ferllop/master
Browse files Browse the repository at this point in the history
Muchas gracias!
  • Loading branch information
EstebanMarin authored Dec 1, 2022
2 parents 74c2910 + 988fee5 commit 02deeab
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 9 deletions.
49 changes: 49 additions & 0 deletions .generate-cover.sh
Original file line number Diff line number Diff line change
@@ -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

23 changes: 17 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion book.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Binary file added images/clean-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02deeab

Please sign in to comment.