ate pasted by andyjpb on Sun Nov 18 22:06:52 2012

site.scm
--------

(define-reader ".md" markdown->sxml)
(define-renderer my-renderer)
(define-dynamic-pages "(.*)\.dynamic\.md" "\1")
(define-dynamic-pages "(.*)\.dyn\.([^.]*)" "\1" dyn-reader)

(define-page "index"
	     '(contents . (ul
			    (li "Photos")
			    (li "Essays")
			    (li "About me"))
			)
	     another-renderer)

(define-page "photos"
 (part "photos.part.md")
 )

(define-page "about-me"
	     `(contents . `(,(part #f "bio.part.md")
			     ,(part #f "contact-details.part.md"))))


(define (dyn-reader filename)
 ; maybe write something that reads the first line as a list of attribs and then
 ; reads body from the rest of the file, similar to how the existing hyde pages
 ; work.
 (with-input-from-file filename markdown->sxml))


(define (my-renderer defaults-alist page-alist)
 ; return some sxml
)

(define (another-renderer defaults-alist page-alist)
 ; return some sxml
)


photos.part.md
--------------
	Welcome to my photos page!
	Here are a list of the galleries I have made:
	  + Chicken Conf
	  + Roast chicken
	  + Ate chicken


--------------------------------------------------------------------------------

(part <filename>) -> `(contents . <contents-of-filename>)

(part 'navigation <filename>) -> `(navigation . <contents-of-filename>)

(part #f <filename>) -> '(<contents-of-filename)


First we work out the names of all the Pages that we need to generate.

	For each occurance of define-dynamic pages we search for files matching
	the regex in the first argument and define a page for each match thusly:
		With: (define-dynamic-pages glob out #!optional reader renderer)
		(define-page out (renderer <a-file-that-matches-glob>) renderer)
	reader should produce an alist.

	For each occurance of define-page in site.scm we create the page named
	in the first argument. These later pages override pages defined earlier
	with the same name, but we should probably throw some kind of warning
	and give the option to throw an error.
		With: (define-page name-in-out/ alist renderer)
		alist can either be an alist or something that evaluates to one.
		For example, (part <filename>) would try to read <filename>
		with a reader that was chosen based on the file extension.

Once we've got a list of maps from output-pages to alists and renderers we call
the renderer on each member of the list in turn in order to generate the final
page.


Glossary
--------

Output Site
	The contents of the out/ directory.

out/
	Produced as a result of running the program.

Page
	A page corresponds to a *file* in the Output Site.
	i.e. something that occupies a URL when the out/ directory is placed on
	a webserver.

More clever^W general reader / render pipeline pasted by andyjpb on Mon Nov 19 14:48:54 2012


(define-page out in #!optional reader renderer)
	'reader' is called with 'in' as it's only argument.
	A universal reader can be defined as default which tests whether in is
	an string or an sexpr. It if it's a string it reads it as a file with
	a part reader based on mime type or file extension. If it's an sexpr
	then 'reader' just evaluates to 'identity'.
	If the reader detects the filename is one to be copied then it produces
	sxml which represents that and leaves it up to the renderer to do the
	copying.

photo gallery example added by andyjpb on Mon Nov 19 14:55:02 2012


Here's how you might write a photo gallery:

(define-dynamic-pages "(.*)\.jpg" "\1.jpg" reader: copy-file)
(define-dynamic-pages "(.*)\.jpg" "\1.thumb.jpg"
 reader: read-jpeg
 renderer: (cut make-thumbnail 16 16 <>))
	(define-page "index"
	 (map (lambda (f)
	       '(li (a (@ (href ,(conc (match 1 f) ".jpg")))
	            (img (@ (src ,(conc (match 1 f) ".thumb.jpg")))))))
	  (file-list "(.*)\.jpg")))