diff --git a/src/Makefile b/src/Makefile index 1d94204..69e7aab 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,7 +55,7 @@ HACKERBASE-OBJS=hackerbase.o testing.o listing.o cal-month.o \ sgr-list.o sgr-block.o table-processor.o table-border.o \ table-style.o sgr-state.o util-utf8.o sgr-cell.o \ template-list-expander.o box-drawing.o util-list.o \ - export-web-static.o + export-web-static.o util-dir.o .PHONY: imports imports: $(HACKERBASE-DEPS) @@ -236,7 +236,7 @@ members-payments.import.scm: $(MEMBERS-PAYMENTS-SOURCES) EXPORT-WIKI-COMPAT-SOURCES=export-wiki-compat.scm brmember.import.scm \ configuration.import.scm members-payments.import.scm \ mbase.import.scm util-git.import.scm progress.import.scm \ - util-list.import.scm + util-list.import.scm util-dir.import.scm export-wiki-compat.o: export-wiki-compat.import.scm export-wiki-compat.import.scm: $(EXPORT-WIKI-COMPAT-SOURCES) @@ -474,3 +474,8 @@ EXPORT-WEB-STATIC-SOURCES=export-web-static.scm brmember.import.scm export-web-static.o: export-web-static.import.scm export-web-static.import.scm: $(EXPORT-WEB-STATIC-SOURCES) + +UTIL-DIR-SOURCES=util-dir.scm + +util-dir.o: util-dir.import.scm +util-dir.import.scm: $(UTIL-DIR-SOURCES) diff --git a/src/export-web-static.scm b/src/export-web-static.scm index 6b484c3..ca799a3 100644 --- a/src/export-web-static.scm +++ b/src/export-web-static.scm @@ -51,7 +51,7 @@ (let ((fname (format "~A.html" (brmember-id mr)))) #f)) - (define (gen-html-members mb) + (define (gen-html-members mb dir) #f) ) diff --git a/src/export-wiki-compat.scm b/src/export-wiki-compat.scm index 7164159..0cd5924 100644 --- a/src/export-wiki-compat.scm +++ b/src/export-wiki-compat.scm @@ -46,7 +46,8 @@ members-payments mbase util-git - progress) + progress + util-dir) ;; Generate all the files in specified (default current) directory. (define (gen-web-static-member mr . dirs) @@ -79,11 +80,7 @@ ;; Generates all member files in given directory (define (gen-web-static mb dir) - (when (and (file-exists? dir) - (regular-file? dir)) - (error 'gen-web-static "Directory is a file:" dir)) - (when (not (directory-exists? dir)) - (create-directory dir)) + (ensure-directory dir) (let* ((members-list (find-members-by-predicate mb brmember-existing?)) (mlen0 (length members-list)) (mlen (if (> mlen0 0) diff --git a/src/hackerbase.scm b/src/hackerbase.scm index 28453d4..b6ded1e 100644 --- a/src/hackerbase.scm +++ b/src/hackerbase.scm @@ -46,7 +46,8 @@ util-git util-dict-list util-stdout - table) + table + export-web-static) ;; Command-line options and configurable parameters (define -needs-bank- (make-parameter #f)) @@ -324,7 +325,8 @@ (repl)) ((genweb) (log-info "Generating static web files") - (gen-web-static MB (-web-dir-))) + (gen-web-static MB (-web-dir-)) + (gen-html-members MB (-web-dir-))) ((edit) (if mr (edit-file (brmember-file-path mr)) diff --git a/src/util-dir.scm b/src/util-dir.scm new file mode 100644 index 0000000..c1716fe --- /dev/null +++ b/src/util-dir.scm @@ -0,0 +1,46 @@ +;; +;; util-dir.scm +;; +;; Common directory manipulation utilities. +;; +;; ISC License +;; +;; Copyright 2023 Brmlab, z.s. +;; Dominik Pantůček +;; +;; Permission to use, copy, modify, and/or distribute this software +;; for any purpose with or without fee is hereby granted, provided +;; that the above copyright notice and this permission notice appear +;; in all copies. +;; +;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +;; + +(declare (unit util-dir)) + +(module + util-dir + ( + ensure-directory + ) + + (import scheme + (chicken base) + (chicken file) + (chicken file posix)) + + (define (ensure-directory dir) + (when (and (file-exists? dir) + (regular-file? dir)) + (error 'gen-web-static "Directory is a file:" dir)) + (when (not (directory-exists? dir)) + (create-directory dir))) + + )