add support to generate multi book
This commit is contained in:
parent
51dbd6c732
commit
609362e475
15
README.md
15
README.md
|
@ -7,10 +7,10 @@ Original sources are downloaded from https://landing.google.com/sre/books
|
||||||
# Books
|
# Books
|
||||||
|
|
||||||
## Site Reliability Engineering
|
## Site Reliability Engineering
|
||||||
<img src="sre-book.jpg" width="320" alt="sre-book" >
|
<img src="cover/sre-book.jpg" width="320" alt="site reliability engineering cover" >
|
||||||
|
|
||||||
## The Site Reliability Workbook
|
## The Site Reliability Workbook
|
||||||
<img src="workbook.jpg" width="320" alt="srw-book" >
|
<img src="cover/workbook.jpg" width="320" alt="the site reliability workbook cover" >
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
|
|
||||||
|
@ -20,8 +20,13 @@ Requirements:
|
||||||
|
|
||||||
- Docker
|
- Docker
|
||||||
|
|
||||||
|
You can generate either of books using `BOOK_SLUG` variable.
|
||||||
|
|
||||||
|
Available values for `BOOK_SLUG`:
|
||||||
|
- `sre_book` Site Reliability Engineering.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ docker run --rm --volume "$(pwd):/output" captn3m0/google-sre-ebook:latest
|
$ docker run --rm --volume "$(pwd):/output" captn3m0/google-sre-ebook:latest -e BOOK_SLUG='sre_book'
|
||||||
```
|
```
|
||||||
|
|
||||||
- You should see the final EPUB/MOBI/PDF files in the `output` directory after the above runs.
|
- You should see the final EPUB/MOBI/PDF files in the `output` directory after the above runs.
|
||||||
|
@ -32,7 +37,7 @@ $ docker run --rm --volume "$(pwd):/output" captn3m0/google-sre-ebook:latest
|
||||||
```
|
```
|
||||||
$ mkdir /tmp/sreoutput
|
$ mkdir /tmp/sreoutput
|
||||||
$ chcon -Rt svirt_sandbox_file_t /tmp/sreoutput
|
$ chcon -Rt svirt_sandbox_file_t /tmp/sreoutput
|
||||||
$ docker run --rm --volume "/tmp/sreoutput:/output" captn3m0/google-sre-ebook:latest
|
$ docker run --rm --volume "/tmp/sreoutput:/output" captn3m0/google-sre-ebook:latest -e BOOK_SLUG='sre_book'
|
||||||
```
|
```
|
||||||
|
|
||||||
The build for the above Docker image can be audited at <https://cloud.docker.com/swarm/captn3m0/repository/docker/captn3m0/google-sre-ebook/builds>.
|
The build for the above Docker image can be audited at <https://cloud.docker.com/swarm/captn3m0/repository/docker/captn3m0/google-sre-ebook/builds>.
|
||||||
|
@ -52,7 +57,7 @@ Requirements:
|
||||||
|
|
||||||
# Known Issues
|
# Known Issues
|
||||||
|
|
||||||
- metadata.xml is not complete. There are just too many authors
|
- metadata is not complete. There are just too many authors
|
||||||
- Foreword/Preface is not part of the index
|
- Foreword/Preface is not part of the index
|
||||||
|
|
||||||
# LICENSE
|
# LICENSE
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Google SRE Books.
|
||||||
|
declare -A BOOKS
|
||||||
|
BOOKS=(
|
||||||
|
|
||||||
|
# Site Reliability Engineering
|
||||||
|
["SRE_BOOK"]=$(
|
||||||
|
echo '
|
||||||
|
BOOK_NAME=sre-book
|
||||||
|
BOOK_NAME_FULL=Site Reliability Engineering
|
||||||
|
BOOK_FILE=google-sre-book
|
||||||
|
BOOK_TOC_URL=https://landing.google.com/sre/sre-book/toc/index.html
|
||||||
|
'
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
32
bootstrap.sh
32
bootstrap.sh
|
@ -1,14 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Get book details.
|
||||||
|
source books.sh
|
||||||
|
export ${BOOKS[${BOOK_SLUG^^}]}
|
||||||
|
|
||||||
|
# Common vars.
|
||||||
|
IMGS_DOMAIN="lh3.googleusercontent.com"
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
# Vars.
|
#
|
||||||
export BOOK_NAME="sre-book"
|
|
||||||
export BOOK_NAME_FULL="Site Reliability Engineering"
|
|
||||||
BOOK_FILE="google-${BOOK_NAME}"
|
|
||||||
TOC_URL="https://landing.google.com/sre/${BOOK_NAME}/toc/index.html"
|
|
||||||
IMGS_DOMAIN="lh3.googleusercontent.com"
|
|
||||||
|
|
||||||
# Make sure that links are relative \
|
# Make sure that links are relative \
|
||||||
# # Remove the /sre/ directories
|
# # Remove the /sre/ directories
|
||||||
# Save stuff in html/ directory
|
# Save stuff in html/ directory
|
||||||
|
@ -27,7 +28,7 @@ wget \
|
||||||
--mirror \
|
--mirror \
|
||||||
--no-verbose \
|
--no-verbose \
|
||||||
--recursive \
|
--recursive \
|
||||||
--domains=${IMGS_DOMAIN},landing.google.com ${TOC_URL}
|
--domains=${IMGS_DOMAIN},landing.google.com ${BOOK_TOC_URL}
|
||||||
|
|
||||||
#
|
#
|
||||||
MODE=${1:-}
|
MODE=${1:-}
|
||||||
|
@ -36,6 +37,7 @@ if [ "$MODE" != "docker" ];then
|
||||||
bundle install
|
bundle install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# Add extension to files.
|
# Add extension to files.
|
||||||
# That because `pandoc` cannot generate the right `mime type` without the extension.
|
# That because `pandoc` cannot generate the right `mime type` without the extension.
|
||||||
# https://github.com/captn3m0/google-sre-ebook/issues/19
|
# https://github.com/captn3m0/google-sre-ebook/issues/19
|
||||||
|
@ -52,19 +54,25 @@ for FILE_NAME_FULL in ${IMGS_FILES}; do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate epub from html.
|
||||||
bundle exec ruby generate.rb
|
bundle exec ruby generate.rb
|
||||||
pushd html/landing.google.com/sre/${BOOK_NAME}/toc
|
pushd html/landing.google.com/sre/${BOOK_NAME}/toc
|
||||||
pandoc --from=html --to=epub \
|
pandoc --from=html --to=epub \
|
||||||
--output=../../../../../${BOOK_FILE}.epub \
|
--output=../../../../../${BOOK_FILE}.epub \
|
||||||
--epub-metadata=../../../../../${BOOK_NAME}.xml \
|
--epub-metadata=../../../../../metadata/${BOOK_NAME}.xml \
|
||||||
--epub-cover-image=../../../../../${BOOK_NAME}.jpg \
|
--epub-cover-image=../../../../../cover/${BOOK_NAME}.jpg \
|
||||||
complete.html
|
complete.html
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate other format from epub.
|
||||||
for EXTENSION in mobi pdf; do
|
for EXTENSION in mobi pdf; do
|
||||||
ebook-convert ${BOOK_FILE}.epub ${BOOK_FILE}.${EXTENSION}
|
ebook-convert ${BOOK_FILE}.epub ${BOOK_FILE}.${EXTENSION}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#
|
||||||
|
# If it works inside docker.
|
||||||
if [ "$1"=="docker" ]; then
|
if [ "$1"=="docker" ]; then
|
||||||
chown -v $(id -u):$(id -g) ${BOOK_FILE}.*
|
chown -v $(id -u):$(id -g) ${BOOK_FILE}.*
|
||||||
mv -f ${BOOK_FILE}.* /output
|
mv -f ${BOOK_FILE}.* /output
|
||||||
|
|
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |
Loading…
Reference in New Issue