summary refs log tree commit diff stats
path: root/boudin.scm
diff options
context:
space:
mode:
authorCase Duckworth2023-09-06 22:45:45 -0500
committerCase Duckworth2023-09-06 22:45:45 -0500
commit59598f42c16cf12e544e5bf2ce9c873fba94238e (patch)
tree055f106b72f289f59d4af417a24448e4983dbec3 /boudin.scm
parentA new start (again) (diff)
downloadboudin-59598f42c16cf12e544e5bf2ce9c873fba94238e.tar.gz
boudin-59598f42c16cf12e544e5bf2ce9c873fba94238e.zip
A newerer beginning
Diffstat (limited to 'boudin.scm')
-rw-r--r--boudin.scm71
1 files changed, 63 insertions, 8 deletions
diff --git a/boudin.scm b/boudin.scm index 7bd741d..4f6a1b3 100644 --- a/boudin.scm +++ b/boudin.scm
@@ -1,14 +1,69 @@
1;;; (boudin) --- A small tasty ssg 1;;; boudin
2 2
3(import (boudin)) 3(import (boudin page)
4 (boudin page instances)
5 (boudin page write)
6 (boudin site)
7 (boudin util)
8 (chicken file)
9 (chicken pathname)
10 (chicken process-context))
4 11
5(define foo (render-string "#,hello from Boudin!" 12(define site-posts
6 (interaction-environment))) 13 (make-parameter '()))
7 14
8(define (main . args) 15(define site-files
9 (print foo) 16 (make-parameter '()))
10 (for-each print args)) 17
18(define (copy-static file)
19 (copy-file file (pathname-replace-directory file (site-dest))))
20
21(define (with-progress message thunk)
22 (edisplay message)
23 (edisplay "...")
24 (thunk)
25 (eprint "Ok."))
26
27(define (go!)
28 (eprint "Building " (site-name) "...")
29 (when (file-exists? (site-config))
30 (with-progress (string-append "Config found, loading: " (site-config))
31 (lambda () (load (site-config)))))
32 (for-each (lambda (f)
33 (with-progress (string-append "Copying " f " to " (site-output))
34 (lambda () (copy-static f)))) (site-files))
35 (let ((posts (map make-post (site-posts))))
36 (for-each (lambda (pg)
37 (with-progress (string-append "Writing " (page-output pg))
38 (lambda () (write-page pg))))
39 (append posts
40 (list (make-index posts)
41 (make-feed posts)))))
42 (eprint "Done!"))
43
44(define (main args)
45 (define *current #f)
46 (let loop ((args args))
47 (cond
48 ((null? args) (go!))
49 ((equal? (car args) "-c")
50 (site-config (cadr args))
51 (loop (cddr args)))
52 ((not *current) ; add to posts by default
53 (site-posts (cons (car args) (site-posts)))
54 (loop (cdr args)))
55 ((equal? (car args) "-p")
56 (set! *current site-posts)
57 (loop (cdr args)))
58 ((equal? (car args) "-f")
59 (set! *current site-files)
60 (loop (cdr args)))
61 (else
62 (*current (cons (car args) (*current)))
63 (loop (cdr args))))))
11 64
12(cond-expand 65(cond-expand
13 (compiling (apply main (command-line))) 66 ((or chicken-script compiling)
67 (import (chicken process-context))
68 (main (command-line-arguments)))
14 (else)) 69 (else))