summaryrefslogtreecommitdiff
path: root/add_books
blob: 9c38ec07bf211627689374d1a05147789cb60181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)