diff options
Diffstat (limited to 'Makefile.scm')
-rw-r--r-- | Makefile.scm | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/Makefile.scm b/Makefile.scm index cc36c8b..628b6a9 100644 --- a/Makefile.scm +++ b/Makefile.scm @@ -1,11 +1,16 @@ +#| +#!/usr/bin/env sh +exec chibi-scheme -A utils/ $0 $@ +|# (import (chibi) (chibi json) - (chibi filesystem) + (only (chibi filesystem) directory-files create-directory*) (chibi process) - (chibi pathname) - (chibi app) - (chibi string) - (chibi io) + (only (chibi pathname) path-strip-directory path-extension make-path) + ;(chibi app) + (only (chibi string) string-prefix? string-trim-right string-join) + (prefix (chibi io) io:) + (utils cover cover) (srfi 1) (srfi 16) (srfi 95)) @@ -35,7 +40,7 @@ (begin (if debug (display - (string-append "\nDEBUG: In call: " strcall "\n" err) + (string-append "\nDEBUG: Called: " strcall "\n" err) (current-error-port))) out) (error (string-append @@ -45,13 +50,13 @@ "\n" err))))) (define (read-meta file) - (parse-json + (string->json (process->string-or-fail `("./utils/yaml2json.py" ,file) "Error parsing Metadata file"))) (define (pandoc-web-simple lang output input) - (let ((outpath (make-path output "WebSimple")) + (let ((outpath (make-path output lang)) (files (directory-sources lang input)) (metafile (directory-meta lang input))) (create-directory* outpath) @@ -59,7 +64,7 @@ (append `("pandoc" "--to=html" - "-o" ,(make-path outpath (string-append lang ".html")) + "-o" ,(make-path outpath "web-simple.html") "--standalone" "--no-highlight" "--data-dir=." @@ -75,7 +80,7 @@ (define (pandoc-web lang output input) - (let ((outpath (make-path output "Web")) + (let ((outpath (make-path output lang)) (files (directory-sources lang input)) (metafile (directory-meta lang input))) (create-directory* outpath) @@ -83,7 +88,7 @@ (append `("pandoc" "--to=html" - "-o" ,(make-path outpath (string-append lang ".html")) + "-o" ,(make-path outpath "web.html") "--standalone" "--self-contained" "--base-header-level=2" ;"--shift-heading-level-by=-1" is the new way @@ -97,17 +102,17 @@ "--lua-filter=appendixes.lua") files `("--metadata-file" ,metafile)) - "Error in web-page creation"))) + "Error in simple web-page creation"))) (define (pandoc-book lang output input) - (let ((outpath (make-path output "Book")) + (let ((outpath (make-path output lang)) (files (directory-sources lang input)) (metafile (directory-meta lang input))) (create-directory* outpath) (process->string-or-fail (append `("pandoc" - "-o" ,(make-path outpath (string-append lang ".pdf")) + "-o" ,(make-path outpath "book.pdf") "--standalone" "--pdf-engine=xelatex" "--data-dir=." @@ -118,15 +123,34 @@ `("--metadata-file" ,metafile)) "Error in book creation"))) +(define (pandoc-book-simple lang output input) + (let ((outpath (make-path output lang)) + (files (directory-sources lang input)) + (metafile (directory-meta lang input))) + (create-directory* outpath) + (process->string-or-fail + (append + `("pandoc" + "-o" ,(make-path outpath "book-simple.pdf") + "--standalone" + "--pdf-engine=xelatex" + "--data-dir=." + ,(string-append "--resource-path=" input) + "--template=book-simple.latex" + "--lua-filter=appendixes.lua") + files + `("--metadata-file" ,metafile)) + "Error in simple book creation"))) + (define (pandoc-epub lang output input) - (let ((outpath (make-path output "Epub")) + (let ((outpath (make-path output lang)) (files (directory-sources lang input)) (metafile (directory-meta lang input))) (create-directory* outpath) (process->string-or-fail (append `("pandoc" - "-o" ,(make-path outpath (string-append lang ".epub")) + "-o" ,(make-path outpath "book.epub") "--standalone" "--data-dir=." ,(string-append "--resource-path=" input) @@ -135,7 +159,27 @@ "--lua-filter=appendixes.lua") files `("--metadata-file" ,metafile)) - "Error in book creation"))) + "Error in ebook creation"))) + +(define (make-cover lang out input) + (let* ((outpath (make-path output lang)) + (files (directory-sources lang input)) + (metafile (directory-meta lang input)) + (metadata (read-meta metafile)) + (svg-file (make-path outpath "cover.svg"))) + (create-directory* outpath) + (call-with-output-file + svg-file + (lambda (out) + (metadata->svg metadata out))) + (process->string-or-fail + (append + `("inkscape" + "--export-filename" ,(make-path outpath "cover.pdf") + "--export-type=pdf" + ,svg-file)) + "Error in cover creation"))) + ;; RUN THIS LIKE: ;; chibi-scheme Makefile.scm src/BOOK_FOLDER ;; @@ -150,7 +194,8 @@ (pandoc-web "es" output input) (pandoc-web-simple "es" output input) (pandoc-book "es" output input) +(pandoc-book-simple "es" output input) (pandoc-epub "es" output input) +(make-cover "es" output input) -;(display (process->string-or-fail '("./utils/yaml2json.py" "src/Programming_in_Python/es/Metadata.yaml") "")) ;(display (cdr (assoc 'title (read-meta "src/Programming_in_Python/es/Metadata.yaml")))) |