summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--haunt/page.scm49
2 files changed, 50 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index eafc93f..b1924da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ SOURCES = \
haunt/config.scm \
haunt/post.scm \
haunt/reader.scm \
+ haunt/page.scm \
haunt/ui.scm \
haunt/ui/serve.scm \
haunt/serve/mime-types.scm \
diff --git a/haunt/page.scm b/haunt/page.scm
new file mode 100644
index 0000000..4d9fa69
--- /dev/null
+++ b/haunt/page.scm
@@ -0,0 +1,49 @@
+;;; Haunt --- Static site generator for GNU Guile
+;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;;
+;;; This file is part of Haunt.
+;;;
+;;; Haunt is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; Haunt is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Haunt. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Page data type.
+;;
+;;; Code:
+
+(define-module (haunt page)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-26)
+ #:use-module (haunt build html)
+ #:export (make-page
+ page?
+ page-file-name
+ page-contents
+ page-writer
+ write-page))
+
+(define-record-type <page>
+ (make-page file-name sxml writer)
+ page?
+ (file-name page-file-name)
+ (sxml page-sxml)
+ (writer page-writer))
+
+(define (write-page page output-directory)
+ "Write PAGE to OUTPUT-DIRECTORY."
+ (match page
+ (($ <page> file-name sxml writer)
+ (let ((output (string-append output-directory "/" file-name)))
+ (call-with-output-file output (cut writer sxml <>))))))