summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--haunt.scm52
-rw-r--r--skribe-utils.scm62
2 files changed, 62 insertions, 52 deletions
diff --git a/haunt.scm b/haunt.scm
index 7a1466b..157935b 100644
--- a/haunt.scm
+++ b/haunt.scm
@@ -32,58 +32,6 @@
'(a blockquote p img h1 h2 h3 code pre strong em ul li dl dt dd))
-(define (email address)
- "Obfuscate a given email ADDRESS."
- `(span (@ (class "obfuscated"))
- ,(string-map (lambda (c) (integer->char (+ 1 (char->integer c))))
- address)))
-
-(define (~)
- "Non-breaking space."
- (string #\240))
-
-(define* (table #:key (align '()) headers rows)
- "Build HTML tables more easily."
- (let ((alignment (append align
- (make-list (- (length headers)
- (length align))
- "left"))))
- (define (make-row fields)
- `(tr ,(map (match-lambda
- ((field alignment)
- `(td (@ (align ,alignment)) ,field)))
- (zip fields alignment))))
- (define (make-header fields)
- `(tr (@ (class "header"))
- ,(map (match-lambda
- ((field alignment)
- `(th (@ (align ,alignment)) ,field)))
- (zip fields alignment))))
- `(table
- (thead ,(make-header headers))
- (tbody ,(map make-row rows)))))
-
-(define (lyrics . contents)
- `(pre (@ (class "lyrics")) ,contents))
-
-(define (ref url text)
- `(a (@ (href ,url)) ,text))
-
-(define (figure file caption)
- `(div (@ (class "figure"))
- (img (@ (src ,(if (string-prefix? "/" file)
- file
- (string-append "/images/posts/" file)))
- (alt ,caption)))
- (p (@ (class "caption")) ,caption)))
-
-(define (wide-img file alt)
- `(img (@ (class "full stretch")
- (src ,(if (string-prefix? "/" file)
- file
- (string-append "/images/posts/" file)))
- (alt ,alt))))
-
(define (photo-snippet post)
(let ((meta (post-ref post 'photo)))
(if meta
diff --git a/skribe-utils.scm b/skribe-utils.scm
new file mode 100644
index 0000000..3bdc2d8
--- /dev/null
+++ b/skribe-utils.scm
@@ -0,0 +1,62 @@
+(define-module (skribe-utils)
+ #:use-module (ice-9 match) ; match-lambda
+ #:use-module (srfi srfi-1) ; list stuff
+ #:export (email
+ ~
+ table
+ lyrics
+ ref
+ figure
+ wide-img))
+
+(define (email address)
+ "Obfuscate a given email ADDRESS."
+ `(span (@ (class "obfuscated"))
+ ,(string-map (lambda (c) (integer->char (+ 1 (char->integer c))))
+ address)))
+
+(define (~)
+ "Non-breaking space."
+ (string #\240))
+
+(define* (table #:key (align '()) headers rows)
+ "Build HTML tables more easily."
+ (let ((alignment (append align
+ (make-list (- (length headers)
+ (length align))
+ "left"))))
+ (define (make-row fields)
+ `(tr ,(map (match-lambda
+ ((field alignment)
+ `(td (@ (align ,alignment)) ,field)))
+ (zip fields alignment))))
+ (define (make-header fields)
+ `(tr (@ (class "header"))
+ ,(map (match-lambda
+ ((field alignment)
+ `(th (@ (align ,alignment)) ,field)))
+ (zip fields alignment))))
+ `(table
+ (thead ,(make-header headers))
+ (tbody ,(map make-row rows)))))
+
+(define (lyrics . contents)
+ `(pre (@ (class "lyrics")) ,contents))
+
+(define (ref url text)
+ `(a (@ (href ,url)) ,text))
+
+(define (figure file caption)
+ `(div (@ (class "figure"))
+ (img (@ (src ,(if (string-prefix? "/" file)
+ file
+ (string-append "/images/posts/" file)))
+ (alt ,caption)))
+ (p (@ (class "caption")) ,caption)))
+
+(define (wide-img file alt)
+ `(img (@ (class "full stretch")
+ (src ,(if (string-prefix? "/" file)
+ file
+ (string-append "/images/posts/" file)))
+ (alt ,alt))))