summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-12-25 15:58:35 +0000
committerArun Isaac2022-12-25 23:33:04 +0000
commit806205382950bf3273d18872987b516f30c3d11f (patch)
tree6690917a019f7fd89bf5f03309c5a1c53527c338
parentdf7c2f672d5b413fb8bf5bc4811b5dff9d56c919 (diff)
downloadtissue-806205382950bf3273d18872987b516f30c3d11f.tar.gz
tissue-806205382950bf3273d18872987b516f30c3d11f.tar.lz
tissue-806205382950bf3273d18872987b516f30c3d11f.zip
web: static: Introduce functional html engine customizer.
* tissue/web/static.scm (engine-custom-set): New function. (html-engine): New public function. (gemtext-exporter, skribe-exporter): Use html-engine in default value of engine.
-rwxr-xr-xbin/tissue1
-rw-r--r--tissue/web/static.scm32
2 files changed, 23 insertions, 10 deletions
diff --git a/bin/tissue b/bin/tissue
index 5be9e7b..c3f5b24 100755
--- a/bin/tissue
+++ b/bin/tissue
@@ -418,7 +418,6 @@ HOSTNAME."
(lambda (temporary-output-directory)
(build-website (git-top-level)
temporary-output-directory
- (tissue-configuration-web-css config)
(tissue-configuration-web-files config))
(delete-file-recursively website-directory)
(rename-file temporary-output-directory
diff --git a/tissue/web/static.scm b/tissue/web/static.scm
index 38a7d42..587799d 100644
--- a/tissue/web/static.scm
+++ b/tissue/web/static.scm
@@ -40,6 +40,7 @@
file-writer
replace-extension
copier
+ html-engine
gemtext-reader
gemtext-exporter
skribe-exporter
@@ -77,6 +78,25 @@ read from and the output port to write to."
get-bytevector-some
in))))
+(define (engine-custom-set engine key value)
+ "Set custom @var{key} of @var{engine} to @var{value}. This is a purely
+functional setter that operates on a copy of @var{engine}. It does not
+mutate @var{engine}."
+ (let ((clone (copy-engine (engine-ident engine) engine)))
+ (engine-custom-set! clone key value)
+ clone))
+
+(define* (html-engine #:key css)
+ "Return a new HTML engine.
+
+@var{css} is the URI to a CSS stylesheet. If it is @code{#f}, no
+stylesheet is included in the generated web pages."
+ (if css
+ (engine-custom-set (find-engine 'html)
+ 'css
+ (list css))
+ (find-engine 'html)))
+
(define (gemtext-reader)
"Return a skribilo reader for gemtext."
((reader:make (lookup-reader 'gemtext))
@@ -84,7 +104,7 @@ read from and the output port to write to."
#:join-lines? #t))
(define* (gemtext-exporter file #:key (reader (gemtext-reader))
- (engine (find-engine 'html)))
+ (engine (html-engine)))
"Return a writer function that reads gemtext @var{file} using
@var{reader} and exports it using @var{engine}."
(exporter file
@@ -95,7 +115,7 @@ read from and the output port to write to."
engine)))))
(define* (skribe-exporter file #:key (reader (make-reader 'skribe))
- (engine (find-engine 'html)))
+ (engine (html-engine)))
"Return a writer function that reads skribe @var{file} using
@var{reader} and exports it using @var{engine}."
(exporter file
@@ -113,21 +133,15 @@ original current directory."
thunk
(cut chdir previous-current-directory))))
-(define* (build-website repository-top-level output-directory css files
+(define* (build-website repository-top-level output-directory files
#:key (log-port (current-error-port)))
"Export git repository with REPOSITORY-TOP-LEVEL to OUTPUT-DIRECTORY
as a website.
-CSS is the path to a CSS stylesheet. If it is #f, no stylesheet is
-included in the generated web pages.
-
FILES is a list of <file> objects representing files to be written to
the web output.
Log to LOG-PORT. When LOG-PORT is #f, do not log."
- ;; Set CSS.
- (when css
- (engine-custom-set! (find-engine 'html) 'css css))
;; Create output directory.
(make-directories output-directory)
;; Write each of the <file> objects.