summaryrefslogtreecommitdiff
path: root/tissue/tissue.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tissue/tissue.scm')
-rw-r--r--tissue/tissue.scm106
1 files changed, 60 insertions, 46 deletions
diff --git a/tissue/tissue.scm b/tissue/tissue.scm
index e7637b4..9180467 100644
--- a/tissue/tissue.scm
+++ b/tissue/tissue.scm
@@ -22,82 +22,96 @@
#:use-module (srfi srfi-71)
#:use-module (ice-9 match)
#:use-module (tissue git)
+ #:use-module (tissue web themes default)
#:export (tissue-configuration
tissue-configuration?
- tissue-configuration-project
tissue-configuration-aliases
tissue-configuration-indexed-documents
- tissue-configuration-web-css
+ tissue-configuration-web-search-renderer
tissue-configuration-web-files
gemtext-files-in-directory))
(define-record-type <tissue-configuration>
- (make-tissue-configuration project aliases indexed-documents
- web-css web-files)
+ (make-tissue-configuration aliases indexed-documents
+ web-search-renderer web-files)
tissue-configuration?
- (project tissue-configuration-project)
- (aliases tissue-configuration-aliases)
+ (aliases delayed-tissue-configuration-aliases)
(indexed-documents delayed-tissue-configuration-indexed-documents)
- (web-css tissue-configuration-web-css)
+ (web-search-renderer delayed-tissue-configuration-web-search-renderer)
(web-files delayed-tissue-configuration-web-files))
+(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-search-renderer
+ (compose force delayed-tissue-configuration-web-search-renderer))
+
(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 DIRECTORY tracked in the
-current git repository. If DIRECTORY is #f, return the list of all
-gemtext files tracked in the current git repository regardless of
-which directory they are in."
+ "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 (pairify lst)
- "Return a list of pairs of successive elements of LST. For example,
-
-(pairify (list 1 2 3 4 5 6))
-=> ((1 . 2) (3 . 4) (5 . 6))"
- (match lst
- (() '())
- ((first second tail ...)
- (cons (cons first second)
- (pairify tail)))))
-
-(define-syntax tissue-configuration
+(define-syntax define-lazy
(lambda (x)
+ "Define function that lazily evaluates all its arguments."
(syntax-case x ()
- ((_ args ...)
- #`((lambda* (#:key project (aliases '())
- (indexed-documents (delay '()))
- web-css (web-files (delay '())))
- "PROJECT is the name of the project. It is used in the title of the
-generated web pages, among other places.
+ ((_ (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 (aliases '()) (indexed-documents '())
+ (web-search-renderer (default-theme))
+ (web-files '()))
+ "Construct a <tissue-configuration> object. All arguments are
+evaluated lazily.
-ALIASES is a list of aliases used to refer to authors in the
+@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.
-INDEXED-DOCUMENTS is a list of <indexed-documents> objects
-representing documents to index.
+@var{indexed-documents} is a list of @code{<document>} objects (or
+objects of classes inheriting from @code{<document>}) representing
+documents to index.
-WEB-CSS is the path to a CSS stylesheet. It is relative to the
-document root and must begin with a /. If it is #f, no stylesheet is
-used in the generated web pages.
+@var{web-search-renderer} is a function that accepts two arguments---a
+@code{<search-page>} object describing the search page and a
+@code{<tissue-configuration>} object describing the project. It must
+return the rendered SXML.
-WEB-FILES is a list of <file> objects representing files to be written
-to the web output."
- (make-tissue-configuration project aliases
- indexed-documents web-css web-files))
- #,@(append-map (match-lambda
- ((key . value)
- (if (memq (syntax->datum key)
- (list #:indexed-documents #:web-files))
- #`(#,key (delay #,value))
- #`(#,key #,value))))
- (pairify #'(args ...))))))))
+@var{web-files} is a list of @code{<file>} objects representing files to be
+written to the web output."
+ (make-tissue-configuration aliases indexed-documents
+ web-search-renderer web-files))