summaryrefslogtreecommitdiff
path: root/add_books
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2020-12-05 22:51:37 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2020-12-05 22:51:37 +0100
commit58d56dc9dae201d89a4911e125099f1f41780eab (patch)
treea0cc19885b696f7160f9ee57b0920bd604ee6ab5 /add_books
First version of the website
Diffstat (limited to 'add_books')
-rwxr-xr-xadd_books41
1 files changed, 41 insertions, 0 deletions
diff --git a/add_books b/add_books
new file mode 100755
index 0000000..9c38ec0
--- /dev/null
+++ b/add_books
@@ -0,0 +1,41 @@
+#|
+#!/usr/bin/env sh
+exec chibi-scheme -A `dirname $0` $0 $@
+|#
+
+(import
+ (scheme base)
+ (srfi 1)
+ (chibi)
+ (chibi filesystem)
+ (chibi io)
+ (chibi pathname)
+ (chibi sxml))
+
+(define outdir "www")
+(define bookdir "../books/out/")
+(define valid '("book-simple.pdf" "web.html" "web-simple.html" "cover.png"))
+
+(define (copy-books)
+ "Copy books"
+ (directory-fold-tree
+ bookdir
+ #f
+ #f
+ (lambda (file acc)
+ (let ((output (make-path outdir "books" (path-relative-to file bookdir))))
+ (if (member (path-strip-directory file) valid)
+ (begin
+ (display "Loading: ")
+ (display file)
+ (display " to:")
+ (display output)
+ (newline)
+ (create-directory* (path-directory output))
+ (call-with-output-file output
+ (lambda (x)
+ (send-file file x)))))))
+ #\null))
+
+
+(copy-books)