Auto generate cover from book.json fields. 71/9771/1
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 20 Jun 2017 07:47:53 +0000 (09:47 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 20 Jun 2017 07:48:38 +0000 (09:48 +0200)
Change-Id: I8203040b759289b08d5311a74e6df557fe8250bd
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
book.json
docs/resources/make_cover.sh
gendocs.sh

index da8c185..928f393 100644 (file)
--- a/book.json
+++ b/book.json
@@ -1,5 +1,6 @@
 {
     "title": "Application Framework Service",
+    "subtitle": "",
     "description": "Application Framework Service of Automotive Grade Linux",
     "keywords": "AGL, Development, application, framework, service",
     "author": "IoT.Bzh Team",
index 13ba4f0..1026ecb 100755 (executable)
@@ -3,7 +3,7 @@ DOCS_DIR=$(cd $(dirname $0)/.. && pwd)
 BOOKFILE=$DOCS_DIR/../book.json
 
 TITLE=$(grep  '"title":' $BOOKFILE | cut -d'"' -f 4)
-SUBTITLE=""
+SUBTITLE=$(grep  '"subtitle":' $BOOKFILE | cut -d'"' -f 4)
 VERSION="Version $(grep  '"version":' $BOOKFILE | cut -d'"' -f 4)"
 DATE=$(grep  '"published":' $BOOKFILE | cut -d'"' -f 4)
 
@@ -15,6 +15,7 @@ DATE=$(grep  '"published":' $BOOKFILE | cut -d'"' -f 4)
 cat $(dirname $0)/cover.svg | sed -e "s/{title}/$TITLE/g" \
     -e "s/font-size:87.5px/font-size:54px/g" \
     -e "s/{subtitle}/$SUBTITLE/g" \
+    -e "s/font-size:62.5px/font-size:40px/g" \
     -e "s/{version}/$VERSION/g" \
     -e "s/{date}/$DATE/g" \
     > /tmp/cover.svg
index d96802c..4657607 100755 (executable)
@@ -1,9 +1,13 @@
 #!/bin/bash
 
-OUTFILENAME="Application-Framework-Service"
+OUTFILENAME="Application-Framework-Service-Guide"
 
 SCRIPT=$(basename $BASH_SOURCE)
 
+VERSION=$(grep '"version":' $(dirname $BASH_SOURCE)/book.json | cut -d'"' -f 4)
+[ "$VERSION" != "" ] && OUTFILENAME="${OUTFILENAME}_${VERSION}"
+
+
 function usage() {
        cat <<EOF >&2
 Usage: $SCRIPT [options] [pdf|serve|doxygen]
@@ -59,6 +63,10 @@ if [ "$DO_ACTION" = "pdf" -o "$DO_ACTION" = "serve" ]; then
     [ "$?" = "1" ] && { echo "You must install calibre first, using: 'sudo apt install calibre' or refer to https://calibre-ebook.com/download"; exit 1; }
 
     if [ "$DO_ACTION" = "pdf" ]; then
+
+        # Update cover when book.json has been changed
+        [[ $ROOTDIR/book.json -nt $ROOTDIR/docs/cover.jpg ]] && { echo "Update cover files"; $ROOTDIR/docs/resources/make_cover.sh || exit 1; }
+
            OUTFILE=$OUT_DIR/$OUTFILENAME.pdf
         $DRY $GITBOOK pdf $ROOTDIR $OUTFILE $DEBUG_FLAG
         [ "$?" = "0" ] && echo "PDF has been successfully generated in $OUTFILE"