#!/usr/bin/scsh -s
!#

(define r-s regexp-substitute/global)

;;; to be executed in a directory with dirindex.html
;;; will echo moin markup to stdout
(display
 (let ((file-contents
        (call-with-input-file "dirindex.html"
          (lambda (in)
            (read-string (file-size "dirindex.html") in))))
       (curdir
        (r-s #f
             (rx (: "public_html/fotos/"
                    (submatch (: (= 4 numeric)
                                 "/debianistas/"
                                 (= 4 numeric) "_"
                                 (= 2 numeric) "_"
                                 (= 2 numeric)))))
             (run/string (pwd))
             1 "/")))
   (r-s #f
        (rx (: "<a href=\""
               (submatch (: "cimg" (= 4 numeric) ".html"))
               "\">"
               #\newline
               "<img src=\""
               (submatch (: "cimg" (= 4 numeric) "--thumb.jpg"))
               "\" width="))
        file-contents
        'pre 'post
        "[http://fotos.lefant.net/" curdir 1
        " http://fotos.lefant.net/" curdir 2 "]\n")))

(newline)