summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/create.scm9
-rw-r--r--src/as.scm16
-rw-r--r--src/as/atom.scm12
-rw-r--r--src/as/html.scm11
-rw-r--r--src/atom.scm12
-rw-r--r--src/dates.scm1
-rw-r--r--src/html.scm2
7 files changed, 58 insertions, 5 deletions
diff --git a/scripts/create.scm b/scripts/create.scm
new file mode 100644
index 0000000..6f7f549
--- /dev/null
+++ b/scripts/create.scm
@@ -0,0 +1,9 @@
+(define-module (scripts create)
+ #:use-module ((src atom) #:prefix atom:)
+ #:use-module ((src html) #:prefix html:)
+ #:use-module (src as))
+
+(define root (canonicalize-path (cadr (command-line))))
+
+(define atom-feed (atom:render (as 'atom root)))
+(define html-index (html:render (as 'html root)))
diff --git a/src/as.scm b/src/as.scm
new file mode 100644
index 0000000..b95c096
--- /dev/null
+++ b/src/as.scm
@@ -0,0 +1,16 @@
+(define-module (src as)
+ #:export (as)
+ #:declarative? #f)
+
+(define (call-in-module thunk module)
+ (let* ((curmod (current-module))
+ (_ (set-current-module (resolve-interface module)))
+ (v (thunk))
+ (_ (set-current-module curmod)))
+ v))
+
+(define (load-with-interface path module-name)
+ (call-in-module (lambda () (load path)) module-name))
+
+(define (as what file)
+ (load-with-interface file `(src as ,what)))
diff --git a/src/as/atom.scm b/src/as/atom.scm
new file mode 100644
index 0000000..c1a8424
--- /dev/null
+++ b/src/as/atom.scm
@@ -0,0 +1,12 @@
+(define-module (src as atom)
+ #:use-module ((src atom) #:prefix atom:)
+ #:export (main
+ post
+ person
+ media))
+
+(define main atom:feed)
+(define post atom:entry)
+(define person atom:person)
+(define media atom:media)
+
diff --git a/src/as/html.scm b/src/as/html.scm
new file mode 100644
index 0000000..7ea3095
--- /dev/null
+++ b/src/as/html.scm
@@ -0,0 +1,11 @@
+(define-module (src as html)
+ #:use-module ((src html) #:prefix html:)
+ #:export (main
+ post
+ person
+ media))
+
+(define main html:index)
+(define post html:post)
+(define person html:person)
+(define media html:media)
diff --git a/src/atom.scm b/src/atom.scm
index 9f71f00..229c032 100644
--- a/src/atom.scm
+++ b/src/atom.scm
@@ -74,7 +74,8 @@
(define* (feed #:key (title "")
(subtitle "")
(uri "")
- (entries '()))
+ (entries '())
+ #:allow-other-keys)
(let* ((f (make-feed uri
title
subtitle
@@ -95,7 +96,8 @@
(content-html '())
(categories '())
(contributors '())
- (media '()))
+ (media '())
+ #:allow-other-keys)
(define (id-from-title title)
(string-map (lambda (c)
(if (char-set-contains? char-set:letter c) c #\-))
@@ -113,12 +115,14 @@
media))
(define* (person name #:key (email "")
- (uri ""))
+ (uri "")
+ #:allow-other-keys)
(make-person name email uri))
(define* (media path #:key (title "")
- (uri ""))
+ (uri "")
+ #:allow-other-keys)
(define (type path)
(let* ((extension (car (last-pair (string-split path #\.))))
(type (assoc-ref mime-types extension)))
diff --git a/src/dates.scm b/src/dates.scm
index 0e9a075..edbac1c 100644
--- a/src/dates.scm
+++ b/src/dates.scm
@@ -8,4 +8,3 @@
(define (date->string/RFC3339 date)
(date->string date "~4"))
-
diff --git a/src/html.scm b/src/html.scm
new file mode 100644
index 0000000..7d37fbd
--- /dev/null
+++ b/src/html.scm
@@ -0,0 +1,2 @@
+(define-module (src html)
+ #:use-module (src mime-types))