From 76f45b5f7c5a883fe62d59d3c31f9c12f5e9e279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sat, 1 Apr 2023 18:10:50 +0200 Subject: [PATCH] Start replacing member record. --- src/web-static.scm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/web-static.scm b/src/web-static.scm index d4e9b01..a1756fb 100644 --- a/src/web-static.scm +++ b/src/web-static.scm @@ -36,28 +36,32 @@ (chicken base) (chicken format) (chicken string) + (chicken process-context) + (chicken pathname) member-record utils configuration) - ;; Generate all the files in current directory, should be wrapped in - ;; something like with-current-directory. - (define (gen-web-static-member mr) + ;; Generate all the files in specified (default current) directory. + (define (gen-web-static-member mr . dirs) (let ((nick (member-nick mr)) - (id (member-id mr))) - (with-output-to-file (sprintf "~A.id" nick) + (id (member-id mr)) + (dir (if (null? dirs) + (current-directory) + (car dirs)))) + (with-output-to-file (make-pathname dir (sprintf "~A.id" nick)) (lambda () (print id))) - (with-output-to-file (sprintf "~A.balance" nick) + (with-output-to-file (make-pathname dir (sprintf "~A.balance" nick)) (lambda () (print (member-total-balance mr)))) - (with-output-to-file (sprintf "~A.misc" nick) + (with-output-to-file (make-pathname dir (sprintf "~A.misc" nick)) (lambda () (let loop ((lines (member-source mr))) (when (not (null? lines)) (print (car lines)) (loop (cdr lines)))))) - (with-output-to-file (sprintf "~A.log" nick) + (with-output-to-file (make-pathname dir (sprintf "~A.log" nick)) (lambda () (let loop ((lines (get-process-output-lines @@ -73,6 +77,9 @@ ;; Generates all member files in given directory (define (gen-web-static mb dir) - #f) + (let loop ((mb mb)) + (when (not (null? mb)) + (gen-web-static-member (car mb) dir) + (loop (cdr mb))))) )