HomeAboutCodePastes

Paste on 2021-02-18T21:00:29

(thread-start!
 (lambda ()
   (init!)
   (create-directory (make-pathname (root-path) "paste"))
   (add-watch! (make-pathname (root-path) "paste/plain") '(move create delete))
   (let watch-paste ()
     (next-events!)
     (call-with-output-file (make-pathname (root-path) "paste/index" "html")
       (lambda (p)
         (display (serialize-sxml
                   (with-default-sxml
                    head: '((title "Pastes"))
                    body:
                    '((h1 (@ (class "title"))
                          "diego's pastes")))) p)
         (newline p)
         (for-each
          (lambda (f)
            (let ((f (pathname-file f)))
              (display (serialize-sxml  `(p (@ (style "font-family:monospace;"))
                                            (a (@ (href ,f)) ,f))) p)
              (newline p)))
          (sort (directory (make-pathname (root-path) "paste/plain")) string>?))))
     (watch-paste))))

plain