;;; tissue --- Text based issue tracker ;;; Copyright © 2022 Arun Isaac ;;; ;;; This file is part of tissue. ;;; ;;; tissue is free software: you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation, either version 3 of the License, or ;;; (at your option) any later version. ;;; ;;; tissue is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with tissue. If not, see . (define-module (tissue tissue) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:use-module (tissue git) #:export (tissue-configuration tissue-configuration? tissue-configuration-project tissue-configuration-aliases tissue-configuration-indexed-documents tissue-configuration-web-css tissue-configuration-web-files gemtext-files-in-directory)) (define-record-type (make-tissue-configuration project aliases indexed-documents web-css web-files) tissue-configuration? (project delayed-tissue-configuration-project) (aliases delayed-tissue-configuration-aliases) (indexed-documents delayed-tissue-configuration-indexed-documents) (web-css delayed-tissue-configuration-web-css) (web-files delayed-tissue-configuration-web-files)) (define tissue-configuration-project (compose force delayed-tissue-configuration-project)) (define tissue-configuration-aliases (compose force delayed-tissue-configuration-aliases)) (define tissue-configuration-indexed-documents (compose force delayed-tissue-configuration-indexed-documents)) (define tissue-configuration-web-css (compose force delayed-tissue-configuration-web-css)) (define tissue-configuration-web-files (compose force delayed-tissue-configuration-web-files)) (define* (gemtext-files-in-directory #:optional directory) "Return a list of all gemtext files in @var{directory} tracked in the current git repository. The returned paths are relative to the top-level directory of the current repository and do not have a leading slash. If @var{directory} is unspecified, return the list of all gemtext files tracked in the current git repository regardless of which directory they are in." (filter (lambda (filename) (and (or (not directory) (string-prefix? directory filename)) (string-suffix? ".gmi" filename))) (git-tracked-files (current-git-repository)))) (define-syntax define-lazy (lambda (x) "Define function that lazily evaluates all its arguments." (syntax-case x () ((_ (name formal-args ...) body ...) (with-syntax ((delayed-formal-args (map (lambda (formal-arg) (syntax-case formal-arg () ((name default-value) #'(name (delay default-value))) (x #'x))) #'(formal-args ...)))) #`(define-syntax name (lambda (x) (with-ellipsis ::: (syntax-case x () ((_ args :::) #`((lambda* delayed-formal-args body ...) #,@(map (lambda (arg) (if (keyword? (syntax->datum arg)) arg #`(delay #,arg))) #'(args :::))))))))))))) (define-lazy (tissue-configuration #:key project (aliases '()) (indexed-documents '()) web-css (web-files '())) "Construct a object. All arguments are evaluated lazily. @var{project} is the name of the project. It is used in the title of the generated web pages, among other places. @var{aliases} is a list of aliases used to refer to authors in the repository. Each element is in turn a list of aliases an author goes by, the first of which is the canonical name of that author. @var{indexed-documents} is a list of @code{} objects representing documents to index. @var{web-css} is the path to a CSS stylesheet. It is relative to the document root and must begin with a @code{\"/\"}. If it is @code{#f}, no stylesheet is used in the generated web pages. @var{web-files} is a list of @code{} objects representing files to be written to the web output. All arguments to @code{tissue-configuration} are evaluated lazily." (make-tissue-configuration project aliases indexed-documents web-css web-files))