summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2016-02-16 10:44:22 -0800
committerDavid Thompson <dthompson2@worcester.edu>2016-04-02 15:58:58 -0400
commit961f061c4b063c2aea81827b3b48a1ba13db59f5 (patch)
tree9d610698bc1b0e555ae80d899980069e92f644ca
parenta37c3cd58525be76705ea930551f3935a232790e (diff)
builder: blog: Set default values for 'theme' keywords.
Previously if a user did not provide a value for any of the theme keyword arguments, there would be an error. Instead, provide defaults from ugly-theme. * haunt/builder/blog.scm: (ugly-default-layout, ugly-default-post-template, ugly-default-collection-template): New variables. (theme): New defaults to keyword arguments.
-rw-r--r--haunt/builder/blog.scm70
1 files changed, 37 insertions, 33 deletions
diff --git a/haunt/builder/blog.scm b/haunt/builder/blog.scm
index 21b53b9..7a9d661 100644
--- a/haunt/builder/blog.scm
+++ b/haunt/builder/blog.scm
@@ -1,5 +1,6 @@
;;; Haunt --- Static site generator for GNU Guile
;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;;
;;; This file is part of Haunt.
;;;
@@ -53,11 +54,41 @@
(post-template theme-post-template)
(collection-template theme-collection-template))
+(define (ugly-default-layout site title body)
+ `((doctype "html")
+ (head
+ (meta (@ (charset "utf-8")))
+ (title ,(string-append title " — " (site-title site))))
+ (body
+ (h1 ,(site-title site))
+ ,body)))
+
+(define (ugly-default-post-template post)
+ `((h2 ,(post-ref post 'title))
+ (h3 "by " ,(post-ref post 'author)
+ " — " ,(date->string* (post-date post)))
+ (div ,(post-sxml post))))
+
+(define (ugly-default-collection-template site title posts prefix)
+ (define (post-uri post)
+ (string-append "/" (or prefix "")
+ (site-post-slug site post) ".html"))
+
+ `((h3 ,title)
+ (ul
+ ,@(map (lambda (post)
+ `(li
+ (a (@ (href ,(post-uri post)))
+ ,(post-ref post 'title)
+ " — "
+ ,(date->string* (post-date post)))))
+ posts))))
+
(define* (theme #:key
(name "Untitled")
- layout
- post-template
- collection-template)
+ (layout ugly-default-layout)
+ (post-template ugly-default-post-template)
+ (collection-template ugly-default-collection-template))
(make-theme name layout post-template collection-template))
(define (with-layout theme site title body)
@@ -78,36 +109,9 @@
(define ugly-theme
(theme #:name "Ugly"
- #:layout
- (lambda (site title body)
- `((doctype "html")
- (head
- (meta (@ (charset "utf-8")))
- (title ,(string-append title " — " (site-title site))))
- (body
- (h1 ,(site-title site))
- ,body)))
- #:post-template
- (lambda (post)
- `((h2 ,(post-ref post 'title))
- (h3 "by " ,(post-ref post 'author)
- " — " ,(date->string* (post-date post)))
- (div ,(post-sxml post))))
- #:collection-template
- (lambda (site title posts prefix)
- (define (post-uri post)
- (string-append "/" (or prefix "")
- (site-post-slug site post) ".html"))
-
- `((h3 ,title)
- (ul
- ,@(map (lambda (post)
- `(li
- (a (@ (href ,(post-uri post)))
- ,(post-ref post 'title)
- " — "
- ,(date->string* (post-date post)))))
- posts))))))
+ #:layout ugly-default-layout
+ #:post-template ugly-default-post-template
+ #:collection-template ugly-default-collection-template))
(define* (blog #:key (theme ugly-theme) prefix
(collections