Phoghorn + awful added by mario-goulart on Wed Aug 22 16:20:51 2012

;; $ ls -l
;; total 4
;; drwxr-xr-x 4 mario mario   96 Ago 22 11:12 galleries
;; -rw-r--r-- 1 mario mario 1355 Ago 22 11:13 gallery.scm
;;
;; $ ls -l galleries/
;; total 1
;; drwxr-xr-x 3 mario mario 664 Ago 22 10:57 foo
;;
;; $ ls -l galleries/foo/
;; total 2729
;; -rw-r--r-- 1 mario mario  60230 Ago 22 10:57 img1.png
;; -rw-r--r-- 1 mario mario  79728 Ago 22 10:57 img2.png
;; -rw-r--r-- 1 mario mario  17985 Ago 22 10:57 img3.png
;;
;; $ awful gallery.scm
;;
;; $ your-favorite-browser http://localhost:8080/index.ssp


(use awful phoghorn sxml-transforms sxml-pagination sxml-shortcuts spiffy)

(define (gallery-index-html content . rules)
  (with-output-to-string
    (lambda ()
      (SRV:send-reply
       (fold (lambda (ruleset content)
               (pre-post-order content ruleset))
              content rules)))))

(define-page "/index.ssp"
  (lambda ()
    (set-page-title!
     (if (current-gallery)
         (string-append "Showing gallery: " (current-gallery))
         "Galleries"))
    (parameterize ((current-file "/index.ssp")) ;; hack: no current-file in awful
      (gallery-index-html '(phoghorn-gallery)
                          phoghorn-rules
                          pagination-rules
                          shortcut-rules
                          universal-conversion-rules))))


(define (zoomed-html content . rules)
  (with-output-to-string
    (lambda ()
      (SRV:send-reply
       (fold (lambda (ruleset content)
               (pre-post-order content ruleset)) content rules)))))

(define-page "/zoomed.ssp"
  (lambda ()
    (set-page-title! (conc "Showing photo: " (current-entry-filename)))
    (parameterize ((current-file "/zoomed.ssp")) ;; hack: no current-file in awful
      (zoomed-html '(phoghorn-zoomed-entry)
                   phoghorn-rules
                   shortcut-rules
                   universal-conversion-rules))))