45 Commits
v0.1 ... v0.2

Author SHA1 Message Date
David Thompson
4130a355d3 Fix 'make distcheck'. 2016-04-24 15:08:56 -04:00
David Thompson
3f6eecc8d1 guix: Update development snapshot. 2016-04-24 11:32:41 -04:00
David Thompson
f0a7c2b14a doc: Expand API documentation. 2016-04-23 16:17:53 -04:00
David Thompson
0d67128c3d serve: Catch exceptions when rebuilding site.
Now 'haunt serve --watch' won't crash when you put some bad code in a
post!

* haunt/ui/server.scm (call-with-error-handling): New procedure.
(watch): Wrap build-site call in call-with-error-handling form.
2016-04-21 22:37:44 -04:00
Christopher Allan Webber
473868946f post: Allow posts to set their own slugs.
* haunt/post.scm (post-slug): Allow posts to set their own slug field
  and use that if available.  Otherwise default to previous title-derived
  slug behavior.
2016-04-12 17:19:31 -04:00
Christopher Allan Webber
643b81ebbb builder: Reverse prefix and slash append order in generating post paths.
* haunt/builder/blog.scm (ugly-default-collection-template):
* haunt/builder/blog.scm (post->atom-entry):
  Reverse appending of prefix and slash in generation of paths
  for blog entries.
2016-04-12 17:19:24 -04:00
Christopher Allan Webber
ed1602dc36 builder: atom: Allow atom feeds to correctly set the blog prefix.
* haunt/builder/atom.scm (post->atom-key, atom-feed, atom-feeds-by-tag):
  Add #:blog-prefix keyword.
2016-04-08 08:57:55 -04:00
David Thompson
37b4cde1a3 doc: Start writing API docs. 2016-04-02 17:35:43 -04:00
David Thompson
4d31eb056c doc: Write command-line interface chapter. 2016-04-02 17:08:23 -04:00
Christopher Allan Webber
961f061c4b 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.
2016-04-02 15:58:58 -04:00
David Thompson
a37c3cd585 post: Allow dashes in slugs.
* haunt/post.scm (char-set:slug): New variable.
(post-slug): Use slug char set.
2016-04-02 15:56:19 -04:00
David Thompson
796cb05b57 skribe: utils: Export ol.
* haunt/skribe/utils.scm: Export ol.
2016-04-02 15:55:47 -04:00
David Thompson
10fa2a715f guix: Add pkg-config to environment. 2016-02-15 19:57:41 -05:00
David Thompson
5373877f98 build: Allow building with Guile 2.2.
* Makefile.am (moddir, goddir): Remove hardcoded "2.0".
* configure.ac: Check to 2.2 as well.
2016-02-15 19:56:41 -05:00
Christopher Allan Webber
8b1adf1dcd skribe: Add copyright information for Ludovic Courtès.
Trace origin back to Skribilo.

* haunt/skribe.scm: Added comments and copyright headers.
2016-02-15 19:33:28 -05:00
Mathieu Lirzin
5b09c3c3fe doc: Add support for 'install-info'.
* doc/haunt.texi: Use '@dircategory' and '@direntry'.
2015-12-06 13:46:41 -05:00
David Thompson
b477823964 build: Don't build dvi docs. 2015-12-06 12:21:21 -05:00
David Thompson
e867118e50 reader: texinfo: Remove unused import. 2015-11-10 21:49:10 -05:00
David Thompson
77db0bd3cf Renamed README.md to README. 2015-11-10 21:49:10 -05:00
Mathieu Lirzin
fe264d96c4 build: Declare a dependency for the manual.
This fixes 'make distcheck' failure.

* Makefile.am (doc_haunt_TEXINFOS): New variable.
2015-11-10 21:47:33 -05:00
Mathieu Lirzin
553e8bcec0 build: Fix all the Guix development package references.
* Makefile.am (EXTRA_DIST): Use 'guix.scm' instead of the obsolete file
name 'package.scm'.
* example/posts/baz.skr: Likewise.
2015-11-10 21:47:24 -05:00
David Thompson
65cced1dda reader: Add texinfo support.
* haunt/reader/texinfo.scm: New file.
* Makefile.am (SOURCES): Add it.
* example/haunt.scm: Activate texinfo reader.
* example/posts/quux.scm: New file.
2015-10-15 22:50:18 -04:00
David Thompson
dfad89079b post: Add read-metadata-headers procedure.
* haunt/post.scm (read-metadata-headers): New procedure.
* haunt/reader.scm (read-html-post): Reimplement using
  'read-metadata-headers'.
* tests/post.scm (%tzoffset): New variable.
  ("read-metadata-headers"): New test.
2015-10-15 22:46:30 -04:00
David Thompson
e505a66a1b tests: Add post tests.
* tests/post.scm: New file.
* Makefile.am (TESTS): Add it.
2015-10-15 22:45:10 -04:00
David Thompson
1ca65755df Bump version to 0.2. 2015-10-15 21:09:14 -04:00
David Thompson
17e72708a8 Add beginnings of a reference manual.
* Makefile.am (info_TEXINFOS): New variable.
* doc/haunt.texi: New file.
* doc/fdl-1.3.texi: New file.
* guix.scm [native-inputs]: Add texinfo.
2015-10-15 21:05:11 -04:00
David Thompson
c013ef276c Ignore build-aux/test-driver.
Generated by Automake.  No need to check it into the repo.
2015-10-15 17:10:39 -04:00
David Thompson
397bc485d4 utils: Clean up and add tests.
* haunt/utils.scm (flat-map, string-split-at): Add docstring.
  (file-name-components): Adjust slightly to handle "/".
  (join-file-name-components): Use prefix string join grammar.
  (absolute-file-name): Add docstring.
* test-env.in: New file.
* tests/utils.scm: New file.
* Makefile.am (TESTS, TEST_EXTENSIONS, SCM_LOG_COMPILER,
  AM_SCM_LOG_FLAGS): New variables.
* configure.ac: Add test-env pre-processed file.
* build-aux/test-driver: New file.
2015-10-14 10:50:03 -04:00
David Thompson
32883938eb Update Guix development package. 2015-10-12 20:24:06 -04:00
David Thompson
1ddcff389d Add support for Skribe document format.
* haunt/skribe.scm: New file.
* haunt/skribe/utils.scm: New file.
* haunt/reader/skribe.scm: New file.
* configure.ac: Check for guile-reader.
* Makefile.am (SOURCES): Add Skribe modules when guile-reader is
  available.
* example/haunt.scm: Include Skribe reader.
* example/posts/baz.skr: New file.
* README.md ("Requirements"): Mention guile-reader as optional dependency.
2015-10-12 20:22:28 -04:00
David Thompson
ec79e5ad1f utils: Add make-user-module.
* haunt/utils.scm (make-user-module): New procedure.
2015-10-12 19:29:57 -04:00
David Thompson
288913eff2 ui: Add CWD to Guile load path.
* haunt/ui.scm (haunt-main): Add CWD to Guile load path.
2015-10-12 19:05:50 -04:00
David Thompson
6ab9322709 builder: blog: Export render-post and render-collection.
* haunt/builder/blog.scm: Export render-post and render-collection.
2015-10-08 17:40:05 -04:00
David Thompson
33702f3777 html: Remove 'raw' element type.
* haunt/html.scm (sxml->html): Remove 'raw' element renderer.
* haunt/reader.scm (read-html-post): Parse to SXML, rather than reading
  a raw string.
2015-10-02 20:47:37 -04:00
Ricardo Wurmus
c67e8e924c builder: blog: Export "theme-collection-template".
* haunt/builder/blog.scm: Export "theme-collection-template", not
  "theme-list-template".
2015-09-04 11:16:17 -04:00
David Thompson
03d1309a16 README: Add examples section. 2015-08-18 09:06:31 -04:00
David Thompson
942cf3a801 README: Explain the pre-inst-env script. 2015-08-18 09:06:16 -04:00
David Thompson
9cd45089b7 Add package.scm to release tarballs. 2015-08-12 08:36:10 -04:00
David Thompson
bb4626a77b website: Add license information to home page.
* website/haunt.scm (haunt-theme): Add "License" section to index page.
2015-08-10 09:06:04 -04:00
David Thompson
c3df5ff848 Include example and website directories in release tarballs. 2015-08-10 09:04:42 -04:00
David Thompson
7c491608f8 Include README.md in future release tarballs.
Thanks to Ben Sturmfels for pointing out that it was missing.
2015-08-10 08:38:33 -04:00
David Thompson
081f8b6e9f website: Add Piwik analytics.
* website/haunt.scm (%piwik-code): New variable.
  (haunt-theme): Include Piwik JS on all pages.
* website/js/piwik.js: New file.
2015-08-09 10:21:53 -04:00
David Thompson
a02ac9238d Add THANKS file. 2015-08-09 10:13:18 -04:00
David Thompson
d24d29fc19 README: Fix Guile version requirements.
Thanks to Ben Sturmfels for pointing it out.
2015-08-09 10:11:22 -04:00
David Thompson
c1b96c94a9 website: Add real SHA1 checksum for 0.1 release. 2015-08-08 10:03:11 -04:00
32 changed files with 2283 additions and 171 deletions

18
.gitignore vendored
View File

@@ -1,8 +1,7 @@
/Makefile
/Makefile.in
Makefile
Makefile.in
/aclocal.m4
/autom4te.cache/
/build-aux/
/config.log
/config.status
/configure
@@ -15,3 +14,16 @@
/scripts/haunt
*.tar.gz
/website/site
/test-env
*.log
*.trs
/build-aux/install-sh
/build-aux/missing
/build-aux/mdate-sh
/build-aux/texinfo.tex
/build-aux/test-driver
/doc/.dirstamp
/doc/haunt.html/
/doc/haunt.info
/doc/stamp-vti
/doc/version.texi

View File

@@ -1,5 +1,6 @@
## Haunt --- Static site generator for GNU Guile
## Copyright © 2015 David Thompson <davet@gnu.org>
## Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
##
## This file is part of Haunt.
##
@@ -29,15 +30,14 @@ nobase_go_DATA = $(GOBJECTS)
guile_install_go_files = install-nobase_goDATA
$(guile_install_go_files): install-nobase_modDATA
CLEANFILES = $(GOBJECTS)
EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES)
GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
SUFFIXES = .scm .go
.scm.go:
$(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE_TOOLS) compile $(GUILE_WARNINGS) -o "$@" "$<"
moddir=$(prefix)/share/guile/site/2.0
godir=$(libdir)/guile/2.0/ccache
moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION)
godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache
bin_SCRIPTS = \
scripts/haunt
@@ -46,7 +46,6 @@ SOURCES = \
haunt/config.scm \
haunt/utils.scm \
haunt/post.scm \
haunt/reader.scm \
haunt/page.scm \
haunt/asset.scm \
haunt/site.scm \
@@ -54,10 +53,45 @@ SOURCES = \
haunt/builder/assets.scm \
haunt/builder/atom.scm \
haunt/builder/blog.scm \
haunt/reader.scm \
haunt/reader/texinfo.scm \
haunt/ui.scm \
haunt/ui/build.scm \
haunt/ui/serve.scm \
haunt/serve/mime-types.scm \
haunt/serve/web-server.scm
EXTRA_DIST += pre-inst-env.in
if HAVE_GUILE_READER
SOURCES += \
haunt/skribe.scm \
haunt/skribe/utils.scm \
haunt/reader/skribe.scm
endif
TESTS = \
tests/post.scm \
tests/utils.scm
TEST_EXTENSIONS = .scm
SCM_LOG_COMPILER = $(top_builddir)/test-env $(GUILE)
AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)"
info_TEXINFOS = doc/haunt.texi
doc_haunt_TEXINFOS = doc/fdl-1.3.texi
dvi: # Don't build dvi docs
EXTRA_DIST += \
pre-inst-env.in \
README \
guix.scm \
$(TESTS)
SUBDIRS = \
example \
website
CLEANFILES = \
$(GOBJECTS) \
$(TESTS:tests/%.scm=%.log)

87
README Normal file
View File

@@ -0,0 +1,87 @@
-*- mode: org -*-
Haunt is a static site generator written in Guile Scheme. It's
simple, functional, and extensible.
* Features
- Easy blog and Atom feed generation
- Supports any markup language that can be parsed to SXML
- Simple development server
- Purely functional build process
- User extensible
* Example Configuration
#+BEGIN_SRC scheme
(use-modules (haunt site)
(haunt reader)
(haunt builder blog)
(haunt builder atom)
(haunt builder assets))
(site #:title "Built with Guile"
#:domain "example.com"
#:default-metadata
'((author . "Eva Luator")
(email . "eva@example.com"))
#:readers (list sxml-reader html-reader)
#:builders (list (blog)
(atom-feed)
(atom-feeds-by-tag)
(static-directory "images"))
#+END_SRC
* Usage
Write a configuration file named =haunt.scm=. Add your posts to a
directory named =posts=. Then run =haunt build=!
To view your creation, run =haunt serve= and browse to
=localhost:8080=. For quicker development cycles, run =haunt serve
--watch= to automatically rebuild the site when things change.
* Requirements
- GNU Guile >= 2.0.11
Optional:
- guile-reader (for Skribe support)
* Building from Git
Haunt uses the familiar GNU build system. GNU automake, autoconf, and
make are required to build from a git checkout.
#+BEGIN_SRC sh
./bootstrap && ./configure && make
#+END_SRC
Once Haunt is built, it can be run directly from the source tree (no
need to run =make install=) via the =pre-inst-env= script:
#+BEGIN_SRC sh
./pre-inst-env haunt --help
#+END_SRC
GNU Guix users can quickly create a build environment with all of the
necessary dependencies using the handy =guix environment= tool:
#+BEGIN_SRC sh
guix environment -l guix.scm
#+END_SRC
* Example
An example Haunt site can be found in the =example= directory. To
build it, run:
#+BEGIN_SRC sh
cd example
../pre-inst-env haunt build
#+END_SRC
* License
GNU GPLv3 or later. See =COPYING= for the full license text.

View File

@@ -1,75 +0,0 @@
Haunt
=====
About
-----
Haunt is a static site generator written in Guile Scheme. It's
simple, functional, and extensible.
Features
--------
* Easy blog and Atom feed generation
* Supports any markup language that can be parsed to SXML
* Simple development server
* Purely functional build process
* User extensible
Example Configuration
---------------------
```
(use-modules (haunt site)
(haunt reader)
(haunt builder blog)
(haunt builder atom)
(haunt builder assets))
(site #:title "Built with Guile"
#:domain "example.com"
#:default-metadata
'((author . "Eva Luator")
(email . "eva@example.com"))
#:readers (list sxml-reader html-reader)
#:builders (list (blog)
(atom-feed)
(atom-feeds-by-tag)
(static-directory "images"))
```
Usage
-----
Write a configuration file named `haunt.scm`. Add your posts to a
directory named `posts`. Then run `haunt build`!
To view your creation, run `haunt serve` and browse to
`localhost:8080`.
Requirements
------------
GNU Guile >= 2.0.9
Building from Git
-----------------
Haunt uses the familiar GNU build system. GNU automake, autoconf, and
make are required to build from a git checkout.
```
./bootstrap && ./configure && make
```
GNU Guix users can create a build environment with all necessary
dependencies using the handy `guix environment` tool:
```
guix environment -l package.scm
```
License
-------
GNU GPLv3 or later

1
THANKS Normal file
View File

@@ -0,0 +1 @@
Ben Sturmfels <ben@sturm.com.au>

View File

@@ -1,15 +1,21 @@
dnl -*- Autoconf -*-
AC_INIT(Haunt, 0.1)
AC_INIT(Haunt, 0.2)
AC_CONFIG_SRCDIR(haunt)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign])
AM_SILENT_RULES([yes])
AC_CONFIG_FILES([Makefile haunt/config.scm])
AC_CONFIG_FILES([Makefile example/Makefile website/Makefile haunt/config.scm])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
AC_CONFIG_FILES([test-env], [chmod +x test-env])
AC_CONFIG_FILES([scripts/haunt], [chmod +x scripts/haunt])
GUILE_PROGS([2.0.11])
GUILE_PKG([2.2 2.0])
GUILE_PROGS
dnl Guile-reader is needed for Skribe support
GUILE_MODULE_AVAILABLE([have_guile_reader], [(system reader)])
AM_CONDITIONAL([HAVE_GUILE_READER], [test "x$have_guile_reader" = "xyes"])
AC_OUTPUT

505
doc/fdl-1.3.texi Normal file
View File

@@ -0,0 +1,505 @@
@c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, La@TeX{} input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.''@: line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

865
doc/haunt.texi Normal file
View File

@@ -0,0 +1,865 @@
\input texinfo
@c -*-texinfo-*-
@c %**start of header
@setfilename haunt.info
@documentencoding UTF-8
@settitle Haunt Reference Manual
@c %**end of header
@include version.texi
@copying
Copyright @copyright{} 2015 David Thompson@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled ``GNU Free
Documentation License''.
@end copying
@dircategory Web development
@direntry
* Haunt: (haunt). Haunt, the functional static site generator.
@end direntry
@titlepage
@title Haunt Reference Manual
@subtitle Using Haunt
@author The Haunt Developers
@page
@vskip 0pt plus 1filll
Edition @value{EDITION} @*
@value{UPDATED} @*
@insertcopying
@end titlepage
@contents
@node Top
@top Haunt
This document describes Haunt version @value{VERSION}, an extensible,
functional static site generator.
@menu
* Introduction:: About Haunt.
* Installation:: Installing Haunt.
* Tutorial:: How to get started quickly.
* Command-line Interface:: Using Haunt from the command-line.
* Programming Interface:: Using the Haunt API in Scheme.
* Contributing:: How to contribute to Haunt.
* GNU Free Documentation License:: The license of this manual.
* Concept Index:: Concepts.
* Programming Index:: Data types, procedures, syntax, and variables.
@detailmenu
--- The Detailed Node Listing ---
Installation
* Downloading:: Downloading the source code.
* Requirements:: Software needed to build and run Haunt.
* Building:: Building from source code.
@end detailmenu
@end menu
@node Introduction
@chapter Introduction
Haunt is a hackable static site generator written in Guile Scheme. A
static site generator assists an author with generating the HTML pages
that they publish on the web. Unlike ``content management systems''
such as Wordpress or Drupal, static site generators are not dynamic
web applications (complete with a relational database) that build
pages on-the-fly. Instead, web pages are built in advance, on the
author's computer, and copied to a web server when it is time to
publish changes. The consequence of this design is that the web
server no longer needs to run a complex, potentially insecure web
application that connects to a database to retrieve data. Static
files can be served easily by any generic web server. Since there is
no web application or database server to deal with, static websites
are easier to maintain, more secure, and resistant to high web traffic
(``slashdotting.'') Furthermore, the entire website is stored in
plain text, which allows the files to be version-controlled rather
than kept in a relational database with no concept of history that
needs to be backed up regularly.
At the time that Haunt was conceived, there existed literally hundreds
of other static site generators. Why add another one? Haunt
differentiates itself from most other static site generators in that
it aspires to the Emacs philosophy of ``practical software freedom.''
Not only is the source code available under a Free Software license,
as most static site generators are, it is designed to be easily hacked
and extended without altering the core source code. Haunt
purposefully blurs the line between document and program, author and
programmer, by embracing the notion of data as code. A Haunt-based
website is not simply data, but a computer program. This design
strategy encourages authors to automate repetitive tasks and empowers
them to extend the software with their own ideas.
To make such a system work well, a general-purpose, extensible
programming language is needed. A traditional configuration file
format simply will not do. The programming language that we feel is
best suited to this task is Scheme, a clean and elegant dialect of
Lisp. We believe that by giving authors the full expressive power of
Scheme, they will be able to produce better websites and make better
use of their time than with less programmable systems and less capable
programming languages. Authors should feel empowered to hack the
system to make it do what they want rather than what some programmer
decided they should want. And perhaps most importantly, building
websites with Haunt should be @emph{fun}.
Websites written in Haunt are described as purely functional programs
that accept ``posts'', text documents containing arbitrary metadata,
as input and transform them into complete HTML pages using Scheme
procedures. Haunt has no opinion about what markup language authors
should use to write their posts and will happily work with any format
for which a ``reader'' procedure exists. Likewise, Haunt also has no
opinion about how authors should structure their sites, but has sane
defaults. Currently, there exist helpful ``builder'' procedures that
do common tasks such as generating a blog or Atom feed. While the
built-in features may be enough for some, they surely will not be
enough for all. Haunt's Scheme API empowers authors to easily tweak
existing components, write replacements, or add entirely new features
that do things no else has thought to do yet.
Happy haunting!
@node Installation
@chapter Installation
@menu
* Downloading:: Downloading the source code.
* Requirements:: Software needed to build and run Haunt.
* Building:: Building from source code.
@end menu
@node Downloading
@section Downloading
Official Haunt source code release tarballs can be found on the
@url{http://haunt.dthompson.us/downloads.html, downloads page} of
Haunt's website, along with their associated checksums.
@node Requirements
@section Requirements
Haunt depends on the following packages:
@itemize
@item
@url{https://gnu.org/software/guile, GNU Guile} version 2.0.11 or
later
@end itemize
The following dependencies are optional:
@itemize
@item
@url{http://www.nongnu.org/guile-reader/, Guile-Reader} version 0.6 or
later (for Skribe support)
@end itemize
@node Building
@section Building
Haunt uses the standard GNU build system, so the basic installation
procedure looks like this:
@example
./configure
make
make install
@end example
@node Tutorial
@chapter Tutorial
The goal of this tutorial is to quickly create a barebones blog with
Haunt in order to demonstrate the basic workflow and key concepts.
First, create a directory for the new site:
@example
mkdir haunt-tutorial
cd haunt-tutorial
@end example
Next, create the site configuration file @file{haunt.scm}. This is
where all of the code for building the website will go.
Here's what a simple Haunt configuration looks like:
@example
(use-modules (haunt asset)
(haunt site)
(haunt builder blog)
(haunt builder atom)
(haunt reader skribe))
(site #:title "My First Haunt Site"
#:domain "example.com"
#:default-metadata
'((author . "Eva Luator")
(email . "eva@@example.com"))
#:readers (list skribe-reader)
#:builders (list (blog)
(atom-feed)
(atom-feeds-by-tag)))
@end example
Haunt represents the full configuration of the website using the
@code{site} procedure. Site objects specify things like the site
title, the default metadata to use for posts, which markup formats are
supported, and which builders are used to generate web pages.
With the above code saved into the @file{haunt.scm} file, the next
step is to create a @file{posts} directory and populate it with
articles to publish. Put the text below into a file named
@file{posts/hello.skr}:
@example
(post
:title "Hello, World!"
:date (make-date* 2015 10 15)
:tags '("hello")
(h1 [Hello, World!])
(p [This is my very first Skribe document!]))
@end example
This is a
@url{http://www.nongnu.org/skribilo/doc/user-3.html#skribe-syntax,
Skribe} document. Skribe is one of the built-in languages that Haunt
knows how to work with. It's basically Scheme, but with support for
writing literal text without quoting it all by enclosing it in square
brackets. The code above defines a post named ``Hello, World!'' with
a publishing date of 2015-10-15, whose contents are just a single
heading and a paragraph.
To build the site, run @command{haunt build} to compile all of the
HTML pages. To view the results, run @command{haunt serve} and visit
@url{http://localhost:8080} in a web browser. @command{haunt serve}
is a handy utility that serves the contents of the website using
Guile's built-in HTTP server. Since the blog builder was specified in
@file{haunt.scm}, the default index page is a simple listing of all
posts, which for now is a single post. Clicking on the post title
will display a page with only that post's contents.
In addition to the basic blog builder, the @file{haunt.scm} file
specifies two additional builders for Atom feeds. The
@code{atom-feed} builder creates a feed of all posts located at
@url{http://localhost:8080/feed.xml}. The @code{atom-feeds-by-tag}
builder creates one feed for each unique tag specified in the post
metadata. There's only one tag right now, ``hello'', and its feed is
located at @url{http://localhost/feeds/tags/hello.xml}.
Tweaking a post, rebuilding the site, and viewing the results in a web
browser is the typical Haunt workflow. However, having to run
@command{haunt build} every after each edit is tedious. To address
this, run @command{haunt serve --watch}. The Haunt web server, in
addition to serving web pages, will now watch for changes to important
files and automatically rebuild the site when they are edited. This
streamlines the workflow into an edit, save, view loop.
Now that we've introduced the basic utilities and concepts, continue
reading this manual to learn more about Haunt's command-line and
programming interfaces.
@node Command-line Interface
@chapter Command-line Interface
@menu
* Invoking haunt build:: Build the website.
* Invoking haunt serve:: Serve the website over HTTP.
@end menu
The Haunt command-line interface is composed of many subcommands. The
general syntax for all Haunt commands is:
@example
haunt @var{subcommand} @var{options}@dots{}
@end example
@node Invoking haunt build
@section Invoking @command{haunt build}
The @command{haunt build} command realizes a Haunt site configuration
file by compiling web pages and copying static assets to the output
directory. For details on how to configure a Haunt site,
@pxref{Sites}.
Example:
@example
haunt build --config=haunt.scm
@end example
@table @code
@item --config=@var{configuration-file}
@itemx -c @var{configuration-file}
Load the Haunt site declaration from @var{configuration-file}.
@end table
@node Invoking haunt serve
@section Invoking @command{haunt serve}
The @command{haunt serve} command allows one to quickly view a local
preview of the generated website before publishing the finished
product to a remote web server. When @command{haunt serve} runs, a
local HTTP server is spawned. Visit the server using a web browser to
inspect the results of the build. By default, the web server listens
on port 8080, so the URL to visit would be
@url{http://localhost:8080}.
While developing, it is common to rebuild the site frequently to view
the results of incremental changes. Rather than manually running
@command{haunt build} (@ref{Invoking haunt build}) each time changes
are made, the @code{--watch} flag can be used to automatically rebuild
the site when a source file changes on disk.
@table @code
@item --config=@var{configuration-file}
@itemx -c @var{configuration-file}
Load the Haunt site declaration from @var{configuration-file}.
@item --port=@var{port}
@itemx -p @var{port}
Listen for HTTP requests on @var{port}.
@item --watch
@itemx -w
Automatically rebuild the site when source files change.
@end table
@node Programming Interface
@chapter Programming Interface
@menu
* Sites:: Description of the site and how to build it.
* Posts:: Articles, prose, blog posts, etc.
* Readers:: Post interpreters.
* Pages:: HTML/XML pages.
* Assets:: Images, stylesheets, etc.
* Builders:: Web page builders.
@end menu
Haunt is a fully-programmable system composed of several Guile Scheme
modules. This section documents the public API.
@node Sites
@section Sites
@example
(use-modules (haunt site))
@end example
A site object defines all of the properties for a Haunt website: The
site name, domain name, where blog posts are found, what post formats
are understood, which procedures are used to build the site, where the
output files are written to, etc.
@deffn {Scheme Procedure} site [#:title "This Place is Haunted"] @
[#:domain "example.com"] [#:posts-directory "posts"] @
[#:file-filter @code{default-file-filter}] @
[#:build-directory "site"] [#:default-metadata '()] @
[#:make-slug @code{post-slug}] [#:readers '()] @
[#:builders '()]
Create a new site object. All arguments are optional:
@table @var
@item title
The name of the site.
@item posts-directory
The directory where posts are found.
@item file-filter
A predicate procedure that returns @code{#f} when a post file should
be ignored, and @code{#t} otherwise. Emacs temporary files are
ignored by default.
@item build-directory
The directory that generated pages are stored in.
@item default-metadata
An alist of arbitrary default metadata for posts whose keys are
symbols.
@item make-slug
A procedure generating a file name slug from a post.
@item readers
A list of reader objects for processing posts.
@item builders
A list of procedures for building pages from posts.
@end table
@end deffn
@deffn {Scheme Procedure} site? @var{obj}
Return @code{#t} if @var{obj} is a site object.
@end deffn
@deffn {Scheme Procedure} site-title @var{site}
Return the title of @var{site}.
@end deffn
@deffn {Scheme Procedure} site-domain @var{site}
Return the domain of @var{site}.
@end deffn
@deffn {Scheme Procedure} site-posts-directory @var{site}
Return the posts directory for @var{site}.
@end deffn
@deffn {Scheme Procedure} site-file-filter @var{site}
Return the file filter procedure for @var{site}.
@end deffn
@deffn {Scheme Procedure} site-build-directory @var{site}
Return the build directory of @var{site}.
@end deffn
@deffn {Scheme Procedure} site-make-slug @var{site}
Return the slug constructor for @var{site}.
@end deffn
@deffn {Scheme Procedure} site-readers @var{site}
Return the list of reader procedures for @var{site}.
@end deffn
@deffn {Scheme Procedure} site-builders @var{site}
Return the list of builder procedures for @var{site}.
@end deffn
@node Posts
@section Posts
@example
(use-modules (haunt post))
@end example
Posts represent the articles that are kept in a site's post directory
and written in a markup format that Haunt can
understand. @pxref{Readers}) for how files on disk can be transformed
into posts.
@deffn {Scheme Procedure} make-post @var{file-name} @var{metadata} @var{sxml}
Create a new post object that represents the contents of the file
@var{file-name}. The body of the post, @var{sxml}, is represented as
an SXML tree (@pxref{SXML, SXML,, guile, GNU Guile Reference Manual})
and the metadata is an association list (@pxref{Association Lists,
Association Lists,, guile, GNU Guile Reference Manual}) of arbitrary
key/value pairs.
@end deffn
@deffn {Scheme Procedure} post? @var{object}
Return @code{#t} if @var{object} is a post.
@end deffn
@deffn {Scheme Procedure} post-file-name @var{post}
Return the file name for @var{post}.
@end deffn
@deffn {Scheme Procedure} post-metadata @var{post}
Return the metadata association list for @var{post}.
@end deffn
@deffn {Scheme Procedure} post-sxml @var{post}
Return the SXML tree for @var{post}.
@end deffn
@deffn {Scheme Procedure} post-ref @var{post} @var{key}
Return the metadata value corresponding to @var{key} within
@var{post}.
@end deffn
@deffn {Scheme Procedure} post-slug @var{post}
Transform the title of @var{post} into a URL slug suitable for the
file name of a web page.
@end deffn
@defvr {Scheme Variable} %default-date
The default date of a post when no other date is specified in the
metadata association list.
@end defvr
@deffn {Scheme Procedure} post-data @var{post}
Return the date for @var{post}, or @code{%default-date} if no date is
specified.
@end deffn
@deffn {Scheme Procedure} posts/reverse-chronological @var{posts}
Sort @var{posts}, a list of posts, in reverse chronological order.
@end deffn
@deffn {Scheme Procedure} posts/group-by-tag @var{posts}
Create an association list of tags mapped to the posts in the list
@var{posts} that used them.
@end deffn
@node Readers
@section Readers
@example
(use-modules (haunt reader))
@end example
The purpose of a reader is to translate the markup within a post file
into an SXML tree representing the HTML structure and associate some
metadata with it.
@deffn {Scheme Procedure} make-reader @var{matcher} @var{proc}
Create a new reader. The reader is to be activated when
@var{matcher}, a procedure that accepts a file name as its only
argument, returns @code{#t}. When a post file matches, the procedure
@var{proc}, which also accepts a file name as its only argument, reads
the contents and returns a post object (@pxref{Posts}).
@end deffn
@deffn {Scheme Procedure} reader? @var{object}
Return @code{#t} if @var{object} is a reader.
@end deffn
@deffn {Scheme Procedure} reader-matcher @var{reader}
Return the match procedure for @var{reader}.
@end deffn
@deffn {Scheme Procedure} reader-matcher @var{reader}
Return the read procedure for @var{reader}.
@end deffn
@deffn {Scheme Procedure} reader-match? @var{reader} @var{file-name}
Return @code{#t} if @var{file-name} is a file supported by
@var{reader}.
@end deffn
@deffn {Scheme Procedure} read-post @var{reader} @var{file-name} [@var{default-metadata}]
Read a post object from @var{file-name} using @var{reader}, merging
its metadata with @var{default-metadata}, or the empty list if not
specified.
@end deffn
@deffn {Scheme Procedure} read-posts @var{directory} @var{keep?} @var{readers} [@var{default-metadata}]
Read all of the files in @var{directory} that match @var{keep?} as
post objects. The @var{readers} list must contain a matching reader
for every post.
@end deffn
@deffn {Scheme Procedure} make-file-extension-matcher @var{ext}
Create a procedure that returns @code{#t} when a file name ends with
``.ext''.
@end deffn
@defvr {Scheme Procedure} sxml-reader
A basic reader for posts written as Scheme code that evaluates to an
an association list. The special key @code{content} contains the post
body as an SXML tree.
Example:
@example
(use-modules (haunt utils))
`((title . "Hello, world!")
(date . ,(string->date* "2015-04-10 23:00"))
(tags "foo" "bar")
(summary . "Just a test")
(content
((h2 "Hello!")
(p "This is Haunt. A static site generator for GNU Guile."))))
@end example
@end defvr
@defvr {Scheme Procedure} html-reader
A basic reader for posts written in plain ol' HTML. Metadata is
encoded as the @code{key: value} pairs, one per line, at the beginning
of the file. A line with the @code{---} sentinel marks the end of the
metadata section and the rest of the file is encoded as HTML.
Example:
@example
title: A Foo Walks Into a Bar
date: 2015-04-11 20:00
tags: bar
---
<p>
This is an example using raw HTML, because Guile doesn't have a
Markdown parser.
</p>
@end example
@end defvr
@node Pages
@section Pages
@example
(use-modules (haunt page))
@end example
Page objects represent files that have yet to be written to disk.
Their contents may be any arbitrary object that their writer procedure
knows how to serialize. In practice, pages are almost always written
to disk as HTML or XML.
@deffn {Scheme Procedure} make-page @var{file-name} @var{contents} @var{writer}
Create a new page object. The string @var{file-name} specifies where
the page should be written to in the file system. The procedure
@var{writer} is responsible for serializing @var{contents}.
@end deffn
@deffn {Scheme Procedure} page? @var{object}
Return @code{#t} if @var{object} is a page object.
@end deffn
@deffn {Scheme Procedure} page-file-name @var{page}
Return the file name string for @var{page}.
@end deffn
@deffn {Scheme Procedure} page-contents @var{page}
Return the contents of @var{page}.
@end deffn
@deffn {Scheme Procedure} page-writer @var{page}
Return the writer procedure @var{page}.
@end deffn
@deffn {Scheme Procedure} write-page @var{page} @var{output-directory}
Write @var{page} to @var{output-directory}.
@end deffn
@node Assets
@section Assets
@example
(use-modules (haunt asset))
@end example
Assets represent files on disk that should be copied verbatim to a
site's output directory. Common types of assets include CSS,
JavaScript, images, and fonts.
@deffn {Scheme Procedure} make-asset @var{source} @var{target}
Create a new asset object. The @var{source} and @var{target}
arguments are file names that are relative to a site source and target
directory, respectively (@pxref{Sites}).
@end deffn
@deffn {Scheme Procedure} asset? @var{object}
Return @code{#t} if @var{object} is an asset object.
@end deffn
@deffn {Scheme Procedure} asset-source @var{asset}
Return the source file name for @var{asset}.
@end deffn
@deffn {Scheme Procedure} asset-target @var{asset}
Return the target file name for @var{asset}.
@end deffn
@deffn {Scheme Procedure} install-asset @var{asset} @var{prefix}
Install the source file of @var{asset} into the target directory
within @var{prefix}.
@end deffn
@deffn {Scheme Procedure} directory-assets @var{directory} @var{keep?} @var{dest}
Create a list of asset objects to be stored within @var{dest} for all
files in @var{directory} that match @var{keep?}, recursively.
@end deffn
@node Builders
@section Builders
@menu
* Static Assets:: Images, CSS, JavaScript, etc.
* Blog:: Dear diary...
* Atom:: Atom feeds.
@end menu
Builders are procedures that return one or more page objects
(@pxref{Pages}) when applied. A builder accepts two arguments: A site
(@pxref{Sites} and a list of posts (@pxref{Posts}).
Haunt comes with a few convenient builders to help users who want to
create a simple blog with an Atom feed.
@node Static Assets
@subsection Static Assets
@example
(use-modules (haunt builder assets))
@end example
@deffn {Scheme Procedure} static-directory @var{directory} @
[@var{dest} @var{directory}]
Create a builder procedure that recursively copies all of the files in
@var{directory}, a file names relative to a site's source directory,
and copies them into @var{dest}, a prefix relative to a site's target
output directory. By default, @var{dest} is @var{directory}.
@end deffn
@node Blog
@subsection Blog
@example
(use-modules (haunt builder blog))
@end example
@deffn {Scheme Procedure} theme [#:name #:layout #:post-template #:collection-template]
Create a new theme named @var{name}.
The procedure @var{layout} accepts three arguments: a site, a page
title string, and an SXML tree. Its purpose is to wrap the contents
of a post with the theme's header/footer and return the complete SXML
tree for a web page.
The procedure @var{post-template} accepts a single argument: a post.
Its purpose is to return an SXML tree containing the contents of the
post, applying any desired post-processing operations. The values
returned from this procedure will be wrapped in the theme's layout.
The procedure @var{collection-template} accepts four arguments: a
site, a title string, a list of posts, and a URL prefix string. Its
purpose is to return an SXML tree containing the body of the
collection page. The values returned from this procedure will be
wrapped in the theme's layout.
@end deffn
@deffn {Scheme Procedure} theme? @var{object}
Return @code{#t} if @var{object} is a theme object.
@end deffn
@deffn {Scheme Procedure} blog [#:theme #:prefix #:collections]
Create a builder procedure that transforms a list of posts into pages
decorated by @var{theme}, a theme object, whose URLs start with
@var{prefix}.
Additionally, this builder creates pages that aggregate previews of
many posts corresponding to what is specified in the list
@var{collections}. Each collection is a three element list in the
form @code{(title file-name filter)}.
@table @var
@item title
The human readable name of the collection.
@item file-name
The HTML file that will contain the rendered collection.
@item filter
A procedure that accepts a list of posts as its only argument and
returns a new list of posts. The filter procedure is used to remove
and/or sort the posts into the desired form for the collection. For
example, a filter could sort posts in reverse chronological order or
select all posts that are written by a particular author.
@end table
By default, a single collection is created that lists posts in reverse
chronological order and writes to @file{index.html}.
The default theme is intended only for testing purposes.
@end deffn
@node Atom
@subsection Atom
@example
(use-modules (haunt builder atom))
@end example
@deffn {Scheme Procedure} atom-feed [#:file-name #:subtitle #:filter #:max-entries #:blog-prefix]
Return a builder procedure that renders a site's posts as an Atom
feed. All arguments are optional:
@table @var
@item file-name:
The page file name. The default is @file{feed.xml}.
@item subtitle
The feed subtitle. The default is ``Recent Posts''.
@item filter
The procedure called to manipulate the posts list before rendering.
The default is to keep all posts and sort them in reverse
chronological order.
@item max-entries
The maximum number of posts to render in the feed. The default is 20.
@end table
@end deffn
@deffn {Scheme Procedure} atom-feeds-by-tag [#:prefix #:filter #:max-entries #:blog-prefix]
Return a builder procedure that renders an atom feed for every tag
used in a post. All arguments are optional:
@table @var
@item prefix
The directory in which to write the feeds. The default is
@file{feeds/tags}.
@item filter
The procedure called to manipulate the posts list before rendering.
The default is to keep all posts and sort them in reverse
chronological order.
@item max-entries
The maximum number of posts to render in each feed. The default is
20.
@end table
@end deffn
@node Contributing
@chapter Contributing
@c *********************************************************************
@node GNU Free Documentation License
@appendix GNU Free Documentation License
@include fdl-1.3.texi
@c *********************************************************************
@node Concept Index
@unnumbered Concept Index
@printindex cp
@node Programming Index
@unnumbered Programming Index
@syncodeindex tp fn
@syncodeindex vr fn
@printindex fn
@bye
@c Local Variables:
@c ispell-local-dictionary: "american";
@c End:

24
example/Makefile.am Normal file
View File

@@ -0,0 +1,24 @@
## 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/>.
exampledir = $(pkgdatadir)/example
nobase_dist_example_DATA = \
haunt.scm \
images/guile-banner.small.png \
posts/foo.sxml \
posts/bar.html

View File

@@ -1,16 +1,18 @@
(use-modules (haunt site)
(haunt reader)
(haunt asset)
(use-modules (haunt asset)
(haunt builder blog)
(haunt builder atom)
(haunt builder assets))
(haunt builder assets)
(haunt reader)
(haunt reader skribe)
(haunt reader texinfo)
(haunt site))
(site #:title "Built with Guile"
#:domain "example.com"
#:default-metadata
'((author . "Eva Luator")
(email . "eva@example.com"))
#:readers (list sxml-reader html-reader)
#:readers (list texinfo-reader skribe-reader sxml-reader html-reader)
#:builders (list (blog)
(atom-feed)
(atom-feeds-by-tag)

29
example/posts/baz.skr Normal file
View File

@@ -0,0 +1,29 @@
(post
:title "Hello, Skribe!"
:date (make-date* 2015 10 09 23 00)
:tags '("foo" "bar" "baz")
(h1 [Hello!])
(p [This is a Skribe document!])
(p [Skribe is a ,(em [really]) cool document authoring format that
provides all the power of Scheme whilst giving the user a
means to write literal text without stuffing it into a string
literal. If this sort of thing suits you, be sure to check out
,(anchor "Skribilo" "http://www.nongnu.org/skribilo/"), too.])
(p [Here's a simple list generated by Scheme code:])
(ul (map li '("foo" "bar" "baz")))
(p [And here's a code snippet of how I build Haunt using GNU Guix:])
(source-code
"guix environment -l guix.scm
./configure
make")
(p [And finally, here's an image:])
(image "/images/guile-banner.small.png"))

32
example/posts/quux.texi Normal file
View File

@@ -0,0 +1,32 @@
title: Hello, Texi!
date: 2015-10-15 22:00
tags: foo, bar
---
This is a test of the @emph{texinfo} reader for Haunt. I sure hope it
works well. Here is a URL to the @url{http://haunt.dthompson.us,
Haunt home page}.
@example
(use-modules (haunt asset)
(haunt builder blog)
(haunt builder atom)
(haunt builder assets)
(haunt reader)
(haunt reader skribe)
(haunt reader texinfo)
(haunt site))
(site #:title "Built with Guile"
#:domain "example.com"
#:default-metadata
'((author . "Eva Luator")
(email . "eva@@example.com"))
#:readers (list texinfo-reader skribe-reader sxml-reader html-reader)
#:builders (list (blog)
(atom-feed)
(atom-feeds-by-tag)
(static-directory "images")))
@end example
This is another paragraph.

View File

@@ -20,11 +20,11 @@
;;
;; GNU Guix development package. To build and install, run:
;;
;; guix package -e '(primitive-load "package.scm")'
;; guix package -f guix.scm
;;
;; To use as the basis for a development environment, run:
;;
;; guix environment -l package.scm
;; guix environment -l guix.scm
;;
;;; Code:
@@ -34,19 +34,21 @@
(guix build-system gnu)
(gnu packages)
(gnu packages autotools)
(gnu packages guile))
(gnu packages guile)
(gnu packages pkg-config)
(gnu packages texinfo))
(package
(name "haunt")
(version "0.1")
(version "0.2")
(source (origin
(method git-fetch)
(uri (git-reference
(url "git://dthompson.us/haunt.git")
(commit "f012747")))
(commit "f0a7c2b14a201448432d3564d851ee0686d5b1b1")))
(sha256
(base32
"0gj4xw79g3q87m6js0mbvv437zf7df5d2xg4sx65mpgc85j7zafs"))))
"1dnzsw18blhr8admw48zbl3ilz3iiqmb149i37y820h0imqfli0v"))))
(build-system gnu-build-system)
(arguments
'(#:phases
@@ -55,9 +57,13 @@
(lambda _ (zero? (system* "sh" "bootstrap")))))))
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)))
("automake" ,automake)
("pkg-config" ,pkg-config)
("texinfo" ,texinfo)))
(inputs
`(("guile" ,guile-2.0)))
(propagated-inputs
`(("guile-reader" ,guile-reader)))
(synopsis "Functional static site generator")
(description "Haunt is a static site generator written in Guile
Scheme. Haunt features a functional build system and an extensible

View File

@@ -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.
;;;
@@ -44,7 +45,7 @@
"Convert date to ISO-8601 formatted string."
(date->string date "~4"))
(define (post->atom-entry site post)
(define* (post->atom-entry site post #:key (blog-prefix ""))
"Convert POST into an Atom <entry> XML node."
`(entry
(title ,(post-ref post 'title))
@@ -53,7 +54,8 @@
,(let ((email (post-ref post 'email)))
(if email `(email ,email) '())))
(updated ,(date->string* (post-date post)))
(link (@ (href ,(string-append "/" (site-post-slug site post) ".html"))
(link (@ (href ,(string-append blog-prefix "/"
(site-post-slug site post) ".html"))
(rel "alternate")))
(summary (@ (type "html"))
,(sxml->html-string (post-sxml post)))))
@@ -62,7 +64,8 @@
(file-name "feed.xml")
(subtitle "Recent Posts")
(filter posts/reverse-chronological)
(max-entries 20))
(max-entries 20)
(blog-prefix ""))
"Return a builder procedure that renders a list of posts as an Atom
feed. All arguments are optional:
@@ -79,14 +82,16 @@ MAX-ENTRIES: The maximum number of posts to render in the feed"
(link (@ (href ,(string-append "/" file-name))
(rel "self")))
(link (@ (href ,(site-domain site))))
,@(map (cut post->atom-entry site <>)
,@(map (cut post->atom-entry site <>
#:blog-prefix blog-prefix)
(take-up-to max-entries (filter posts))))
sxml->xml*)))
(define* (atom-feeds-by-tag #:key
(prefix "feeds/tags")
(filter posts/reverse-chronological)
(max-entries 20))
(max-entries 20)
(blog-prefix ""))
"Return a builder procedure that renders an atom feed for every tag
used in a post. All arguments are optional:
@@ -100,6 +105,7 @@ MAX-ENTRIES: The maximum number of posts to render in each feed"
((atom-feed #:file-name (string-append prefix "/" tag ".xml")
#:subtitle (string-append "Tag: " tag)
#:filter filter
#:max-entries max-entries)
#:max-entries max-entries
#:blog-prefix blog-prefix)
site posts)))
tag-groups))))

View File

@@ -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.
;;;
@@ -36,8 +37,10 @@
theme-name
theme-layout
theme-post-template
theme-list-template
theme-collection-template
with-layout
render-post
render-collection
date->string*
@@ -51,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)
@@ -76,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

View File

@@ -113,9 +113,6 @@ list ATTRS and the child nodes in BODY."
(() *unspecified*)
(('doctype type)
(doctype->html type port))
;; Unescaped, raw HTML output.
(('raw html)
(display html port))
(((? symbol? tag) ('@ attrs ...) body ...)
(element->html tag attrs body port))
(((? symbol? tag) body ...)

View File

@@ -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.
;;;
@@ -23,6 +24,8 @@
;;; Code:
(define-module (haunt post)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-19)
@@ -40,7 +43,8 @@
posts/group-by-tag
register-metdata-parser!
parse-metadata))
parse-metadata
read-metadata-headers))
(define-record-type <post>
(make-post file-name metadata sxml)
@@ -53,13 +57,17 @@
"Return the metadata corresponding to KEY within POST."
(assq-ref (post-metadata post) key))
(define char-set:slug
(char-set-union char-set:letter+digit (char-set #\-)))
(define (post-slug post)
"Transform the title of POST into a URL slug."
(or (post-ref post 'slug)
(string-join (map (lambda (s)
(string-filter char-set:letter+digit s))
(string-filter char-set:slug s))
(string-split (string-downcase (post-ref post 'title))
char-set:whitespace))
"-"))
"-")))
(define %default-date
(make-date 0 0 0 0 1 1 1970 0)) ; UNIX epoch
@@ -107,6 +115,20 @@ specified."
(define (parse-metadata key value)
((metadata-parser key) value))
(define (read-metadata-headers port)
(let loop ((metadata '()))
(let ((line (read-line port)))
(cond
((eof-object? line)
(error "end of file while reading metadata: " (port-filename port)))
((string=? line "---")
metadata)
(else
(match (map string-trim-both (string-split-at line #\:))
(((= string->symbol key) value)
(loop (alist-cons key (parse-metadata key value) metadata)))
(_ (error "invalid metadata format: " line))))))))
(register-metadata-parser!
'tags
(lambda (str)

View File

@@ -30,7 +30,7 @@
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (ice-9 rdelim)
#:use-module (sxml simple)
#:use-module (haunt post)
#:use-module (haunt utils)
#:export (make-reader
@@ -104,18 +104,9 @@ post."
(assq-ref contents 'content))))))
(define (read-html-post port)
(let loop ((metadata '()))
(let ((line (read-line port)))
(cond
((eof-object? line)
(error "end of file while reading metadata: " (port-filename port)))
((string=? line "---")
(values metadata `(raw ,(read-string port))))
(else
(match (map string-trim-both (string-split-at line #\:))
(((= string->symbol key) value)
(loop (alist-cons key (parse-metadata key value) metadata)))
(_ (error "invalid metadata format: " line))))))))
(values (read-metadata-headers port)
(match (xml->sxml port)
(('*TOP* sxml) sxml))))
(define html-reader
(make-reader (make-file-extension-matcher "html")

44
haunt/reader/skribe.scm Normal file
View File

@@ -0,0 +1,44 @@
;;; 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:
;;
;; Skribe post reader.
;;
;;; Code:
(define-module (haunt reader skribe)
#:use-module (haunt reader)
#:use-module (haunt skribe)
#:use-module (haunt skribe utils)
#:use-module (haunt utils)
#:export (make-skribe-reader
skribe-reader))
(define* (make-skribe-reader #:key (modules '((haunt skribe utils))))
"Return a new Skribe post reader that imports MODULES by default
before reading a document."
(make-reader (make-file-extension-matcher "skr")
(lambda (file)
(let ((file (absolute-file-name file)))
(save-module-excursion
(lambda ()
(set-current-module (make-user-module modules))
(load file %skribe-reader)))))))
(define skribe-reader (make-skribe-reader))

42
haunt/reader/texinfo.scm Normal file
View File

@@ -0,0 +1,42 @@
;;; 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:
;;
;; Texinfo post reader.
;;
;;; Code:
(define-module (haunt reader texinfo)
#:use-module (texinfo)
#:use-module (texinfo html)
#:use-module (haunt post)
#:use-module (haunt reader)
#:use-module (haunt utils)
#:export (texinfo-reader))
(define texi->shtml
(compose stexi->shtml texi-fragment->stexi))
(define texinfo-reader
(make-reader (make-file-extension-matcher "texi")
(lambda (file)
(call-with-input-file file
(lambda (port)
(values (read-metadata-headers port)
(texi->shtml port)))))))

84
haunt/skribe.scm Normal file
View File

@@ -0,0 +1,84 @@
;;; Haunt --- Static site generator for GNU Guile
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright 2005, 2006 Ludovic Courtès <ludovic.courtes@laas.fr>
;;;
;;; 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:
;;
;; Skribe reader.
;; Much code taken from the excellent Skribilo project.
;;
;;; Code:
(define-module (haunt skribe)
#:use-module ((system reader) #:renamer (symbol-prefix-proc 'r:))
#:export (%skribe-reader))
;; Taken from Skribilo
(define (make-colon-free-token-reader tr)
;; Stolen from `guile-reader' 0.3.
"If token reader @var{tr} handles the @code{:} (colon) character, remove it
from its specification and return the new token reader."
(let* ((spec (r:token-reader-specification tr))
(proc (r:token-reader-procedure tr)))
(r:make-token-reader (filter (lambda (chr)
(not (char=? chr #\:)))
spec)
proc)))
(define &sharp-reader
;; The reader for what comes after a `#' character.
(let* ((dsssl-keyword-reader ;; keywords à la `#!key'
(r:make-token-reader #\!
(r:token-reader-procedure
(r:standard-token-reader 'keyword)))))
(r:make-reader (cons dsssl-keyword-reader
(map r:standard-token-reader
'(character srfi-4 vector
number+radix boolean
srfi30-block-comment
srfi62-sexp-comment)))
#f ;; use default fault handler
'reader/record-positions)))
(define (make-skribe-reader)
(let ((colon-keywords ;; keywords à la `:key' fashion
(r:make-token-reader #\:
(r:token-reader-procedure
(r:standard-token-reader 'keyword))))
(symbol-misc-chars-tr
;; Make sure `:' is handled only by the keyword token reader.
(make-colon-free-token-reader
(r:standard-token-reader 'r6rs-symbol-misc-chars))))
;; Note: we use the `r6rs-symbol-*' and `r6rs-number' token readers since
;; they consider square brackets as delimiters.
(r:make-reader (cons* (r:make-token-reader #\# &sharp-reader)
colon-keywords
symbol-misc-chars-tr
(map r:standard-token-reader
`(whitespace
sexp string r6rs-number
r6rs-symbol-lower-case
r6rs-symbol-upper-case
quote-quasiquote-unquote
semicolon-comment
skribe-exp)))
#f ;; use the default fault handler
'reader/record-positions)))
(define %skribe-reader (make-skribe-reader))

85
haunt/skribe/utils.scm Normal file
View File

@@ -0,0 +1,85 @@
;;; 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:
;;
;; Skribe helper procedures.
;;
;;; Code:
(define-module (haunt skribe utils)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:export (post
p blockquote em
h1 h2 h3 h4
code pre strong
ul ol li dl dt dd
anchor
image
source-code
make-date*))
(define (post . metadata+sxml)
"Create a new Skribe post by parsing out the metadata and SXML
contents from METADATA+SXML."
(let loop ((stuff metadata+sxml)
(metadata '()))
(match stuff
(() (values metadata '()))
(((and (? keyword?) (= keyword->symbol key)) value . rest)
(loop rest (alist-cons key value metadata)))
(_ (values metadata stuff)))))
;; Basic SXML constructors.
(define-syntax-rule (define-simple-sxml-constructors tag ...)
(begin
(define (tag . contents)
`(tag ,@contents)) ...))
(define-simple-sxml-constructors
p blockquote
em strong
code samp pre kbd var
cite dfn abbr
h1 h2 h3 h4
ul ol li dl dt dd)
(define (anchor text uri)
"Return an anchor SXML node that contains TEXT and points to to URI."
`(a (@ (href ,uri)) ,text))
(define* (image uri #:key (alt-text ""))
"Return an image SXML node that points to a URI for an image.
Optionally, the ALT-TEXT keyword argument may be a string that
contains a description of the image."
`(img (@ (src ,uri) (alt ,alt-text))))
(define (source-code . code)
"Return an SXML node that wraps CODE in a 'pre' and 'code' tag to
create a code block."
`(pre (code ,code)))
(define* (make-date* year month day #:optional (hour 0) (minute 0))
"Create a SRFI-19 date for the given YEAR, MONTH, DAY, HOUR (24-hour
format), and MINUTE."
(let ((tzoffset (tm:gmtoff (localtime (time-second (current-time))))))
(make-date 0 0 minute hour day month year tzoffset)))

View File

@@ -124,6 +124,9 @@ There is NO WARRANTY, to the extent permitted by law.~%"
(apply command-main args))))
(define* (haunt-main arg0 . args)
;; Add haunt site directory to Guile's load path so that user's can
;; easily import their own modules.
(add-to-load-path (getcwd))
(setlocale LC_ALL "")
(match args
(()

View File

@@ -70,6 +70,19 @@ Start an HTTP server for the current site.~%")
(cons '(port . 8080)
%default-common-options))
(define (call-with-error-handling thunk)
(catch #t
thunk
(lambda (key . args)
(let ((cep (current-error-port))
(stack (make-stack #t 1)))
(display "ERROR: site rebuild failed\n\n" cep)
(display "Backtrace:\n" cep)
(display-backtrace stack cep)
(newline cep)
(apply display-error (stack-ref stack 0) cep args)
(newline cep)))))
;; XXX: Make this less naive.
(define (watch config-file check-dir? check-file?)
"Watch the current working directory for changes to any of its files
@@ -100,7 +113,9 @@ site."
(let loop ((time (current-time)))
(when (any-files-changed? time)
(display "rebuilding...\n")
(build-site (load-config config-file)))
(call-with-error-handling
(lambda ()
(build-site (load-config config-file)))))
(let ((next-time (current-time)))
(sleep 1)
(loop next-time))))

View File

@@ -38,7 +38,8 @@
delete-file-recursively
mkdir-p
string->date*
take-up-to))
take-up-to
make-user-module))
(define* (flatten lst #:optional depth)
"Return a list that recursively concatenates the sub-lists of LST,
@@ -56,9 +57,18 @@ flattened."
lst)))
(define (flat-map proc . lsts)
"Apply PROC to each element of each list in LSTS and return a new
list in which nested lists are concatenated into the result.
For example, the list (1 2 (3)) would be flattened to (1 2 3)."
(flatten (apply map proc lsts) 1))
(define (string-split-at str char-pred)
"Split STR at the first character that matches CHAR-PRED and return
a list of one or two strings. Two strings are returned if the string
was able to be split, with the character matching CHAR-PRED removed.
A list containing only STR is returned if CHAR-PRED does not match any
charcter."
(let ((i (string-index str char-pred)))
(if i
(list (string-take str i)
@@ -67,15 +77,20 @@ flattened."
(define (file-name-components file-name)
"Split FILE-NAME into the components delimited by '/'."
(if (string-null? file-name)
'()
(string-split file-name #\/)))
(match file-name
("" '())
("/" '(""))
(_ (remove string-null? (string-split file-name #\/)))))
(define (join-file-name-components components)
"Join COMPONENTS into a file name string."
(string-join components "/"))
(string-join components "/" 'prefix))
(define (absolute-file-name file-name)
"Return a an absolute file name string relative to the current
working directory for FILE-NAME, a relative file name string. If
FILE-NAME happens to already be absolute, FILE-NAME is returned
as-is."
(if (absolute-file-name? file-name)
file-name
(string-append (getcwd) "/" file-name)))
@@ -146,3 +161,11 @@ are fewer than N elements."
(() '())
((head . tail)
(cons head (take-up-to (1- n) tail))))))
(define (make-user-module modules)
"Return a new user module with the additional MODULES loaded."
(let ((module (make-fresh-user-module)))
(for-each (lambda (iface)
(module-use! module (resolve-interface iface)))
modules)
module))

23
test-env.in Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
# 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/>.
"@abs_top_builddir@/pre-inst-env" "$@"
exit $?

84
tests/post.scm Normal file
View File

@@ -0,0 +1,84 @@
;;; 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/>.
(define-module (test-post)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-64)
#:use-module (haunt post))
(test-begin "post")
(define (make-date* year month day)
(make-date 0 0 0 0 day month year 0))
(define %tzoffset (date-zone-offset (current-date)))
(test-equal "post-ref"
'(hello test)
(post-ref (make-post "foo.skr" '((tags hello test)) '()) 'tags))
(test-equal "post-slug"
"hello-world"
(post-slug (make-post "foo.skr" '((title . "Hello, world!")) '())))
(test-equal "post-date, no date metadata"
%default-date
(post-date (make-post "foo.skr" '() '())))
(let ((date (make-date* 2015 10 15)))
(test-equal "post-date, date metadata"
date
(post-date (make-post "foo.skr" `((date . ,date)) '()))))
(let ((oldest (make-post "foo.skr" `((date . ,(make-date* 2015 10 13))) '()))
(newest (make-post "bar.skr" `((date . ,(make-date* 2015 10 15))) '()))
(middle (make-post "baz.skr" `((date . ,(make-date* 2015 10 14))) '())))
(test-equal "posts/reverse-chronological"
(list newest middle oldest)
(posts/reverse-chronological (list oldest newest middle))))
(let ((foo-post (make-post "foo.skr" '((tags "foo")) '()))
(another-foo-post (make-post "another-foo.skr" '((tags "foo")) '()))
(bar-post (make-post "bar.skr" '((tags "bar")) '())))
(test-equal "posts/group-by-tag"
`(("foo" ,foo-post ,another-foo-post) ("bar" ,bar-post))
(posts/group-by-tag (list another-foo-post foo-post bar-post))))
(test-equal "parse-metadata, tags"
'("foo" "bar" "baz")
(parse-metadata 'tags "foo, bar, baz"))
(test-equal "parse-metadata, date"
(make-date 0 0 30 22 15 10 2015 %tzoffset)
(parse-metadata 'date "2015-10-15 22:30"))
(test-equal "read-metadata-headers"
`((tags "foo" "bar" "baz")
(date . ,(make-date 0 0 30 22 15 10 2015 %tzoffset))
(title . "Hello, World!"))
(pk 'meta (call-with-input-string "title: Hello, World!
date: 2015-10-15 22:30
tags: foo, bar, baz
---
"
read-metadata-headers)))
(test-end)
(exit (zero? (test-runner-fail-count (test-runner-current))))

85
tests/utils.scm Normal file
View File

@@ -0,0 +1,85 @@
;;; 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/>.
(define-module (test-utils)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-64)
#:use-module (haunt utils))
(test-begin "utils")
(test-equal "flatten, all"
'(1 2 3 4 5 6)
(flatten '(1 (2 3 (4) (5 (6))))))
(test-equal "flatten, limited depth"
'(1 2 3 4 5 (6))
(flatten '(1 (2 3 (4) (5 (6)))) 2))
(test-equal "flat-map"
'(5 7 9)
(flat-map (compose list +) '(1 2 3) '(4 5 6)))
(test-equal "string-split-at, no match"
'("foo")
(string-split-at "foo" #\z))
(test-equal "string-split-at, match"
'("foo" "bar")
(string-split-at "foo/bar" #\/))
(test-equal "file-name-components, empty string"
'()
(file-name-components ""))
(test-equal "file-name-components, root directory"
'("")
(file-name-components "/"))
(test-equal "file-name-components, full file name"
'("share" "haunt")
(file-name-components "/share/haunt"))
(test-equal "join-file-name-components"
"/share/haunt/info/haunt.info"
(join-file-name-components '("share" "haunt" "info" "haunt.info")))
(test-equal "absolute-file-name, already absolute"
"/share/haunt"
(absolute-file-name "/share/haunt"))
(test-equal "absolute-file-name, relative file name"
(string-append (getcwd) "/share/haunt")
(absolute-file-name "share/haunt"))
(test-equal "take-up-to, less than n elements"
'(1 2 3)
(take-up-to 4 '(1 2 3)))
(test-equal "take-up-to, more than n elements"
'(1 2)
(take-up-to 2 '(1 2 3)))
(test-equal "string->date*"
(make-date 0 0 15 06 05 09 2015 (date-zone-offset (current-date)))
(string->date* "2015-09-05 06:15"))
(test-end)
(exit (zero? (test-runner-fail-count (test-runner-current))))

View File

@@ -1,2 +0,0 @@
publish:
rsync -P -rvz --delete site/ blog@dthompson.us:/var/www/haunt --cvs-exclude

28
website/Makefile.am Normal file
View File

@@ -0,0 +1,28 @@
## 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/>.
dist_noinst_DATA = \
haunt.scm \
css/main.css \
css/reset.css \
images/haunt.png \
js/piwik.js \
posts/0.1-release.sxml
publish:
rsync -P -rvz --delete site/ blog@dthompson.us:/var/www/haunt --cvs-exclude

View File

@@ -32,7 +32,7 @@
(web uri))
(define %releases
'(("0.1" "1f751f234e382ed0f13d79e4c106373e9ae55c23")))
'(("0.1" "c81dbcdf33f9b0a19442d3701cffa3b60c8891ce")))
(define (tarball-url version)
(string-append "http://files.dthompson.us/haunt/haunt-"
@@ -68,6 +68,13 @@
'(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/"))
"Creative Commons Attribution Share-Alike 4.0 International"))
(define %piwik-code
'((script (@ (type "text/javascript") (src "/js/piwik.js")))
(noscript
(p (img (@ (src "//stats.dthompson.us/piwik.php?idsite=3")
(style "border:0;")
(alt "")))))))
(define haunt-theme
(theme #:name "Haunt"
#:layout
@@ -77,7 +84,8 @@
(meta (@ (charset "utf-8")))
(title ,(string-append title " — " (site-title site)))
,(stylesheet "reset")
,(stylesheet "main"))
,(stylesheet "main")
,%piwik-code)
(body
(header (@ (class "navbar"))
(div (@ (class "container"))
@@ -153,6 +161,15 @@ without needing to upload the generated files to a web server.")
,(date->string* (post-date post)))))
(posts/reverse-chronological posts)))
(h2 "License")
(p "Haunt is "
(a (@ (href "https://www.gnu.org/philosophy/free-sw.html"))
"Free Software")
" available under the "
(a (@ (href "https://www.gnu.org/licenses/gpl.html"))
"GNU General Public License")
" version 3 or later.")
(h2 "Contributing")
(p "Patches to fix bugs or add new functionality are
highly encouraged. In lieu of a mailing list, please send patches
@@ -200,4 +217,5 @@ the official git repository:")
(atom-feeds-by-tag)
downloads-page
(static-directory "images")
(static-directory "css")))
(static-directory "css")
(static-directory "js")))

30
website/js/piwik.js Normal file
View File

@@ -0,0 +1,30 @@
/*
* |@licstart The following is the entire license notice for the JavaScript code in this page.|
*
* Copyright 2012 Matthieu Aubry.
*
* This program 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.
*
* This program 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 this program. If not, see http://www.gnu.org/licenses/.
*
* |@licend The above is the entire license notice for the JavaScript code in this page.|
*/
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.dthompson.us/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 3]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();