Welcome to the CHICKEN Scheme pasting service

bullshit.scm pasted by ente on Wed Oct 3 15:10:46 2012

;;; wiki.scm -- dead simple static HTML "wiki", intended for use with VCS
;;;
;;; Walk over a directory, transforming every markdown-file into HTML.
;;; Then, generate a per-directory index.x?html over the titles (first h1) of
;;; every markdown file and directory within.

(use srfi-1 files posix lowdown ports)

(define html-extension "html")
(define vcs-directories
  '("RCS" "CVS" ".git" ".hg" ".svn" "_darcs" "{arch}"))

(define (markdown-file? e)
  (let ((ext (pathname-extension e)))
    (and ext
       (regular-file? e)
       (string-ci=? ext "md"))))

(define (vcs-directory? e)
  (and (directory? e)
       (member (pathname-strip-directory e) vcs-directories)))

(define (walk filt fun #!optional (path "."))
  (and (filt path)
       (if (directory? path)
         (map 
           (lambda (dirent) (walk filt fun dirent))
           (directory path)) ; FIXME (directory) seems to return names relative to path
         (fun path))))
  
(define (markdown-transform path)
  (let* ((new-path (pathname-replace-extension path html-extension))
         (out-fd   (begin (delete-file* new-path) ; just to be sure
                          (open-output-file new-path)))
         (in-fd    (open-input-file path)))
                     
  ; TODO
  (with-output-to-port out-fd (lambda () (markdown->html in-fd)))))

(define (make-index) '()) ;TODO

(define (transform-.)
  (walk (lambda (x) (not (vcs-directory? x)))
        (lambda (x) (and (markdown-file? x) (markdown-transform x)))))

; vim:set ts=2 et:

simple I/O redirection pasted by C-Keen on Wed Oct 3 15:25:55 2012

#;3> (with-input-from-file "Downloads/ideas.md" (lambda () (markdown->html (current-input-port))))

<h1>Project ideas</h1>
<ul>
<li><a href="rsync.html">library based, compatible rsync replacement</a></li>
<li>UFS file tagging: <a href="ufs.html">Design document</a></li>
<li>improve <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=rcs&amp;sektion=1">OpenRCS</a> and transform it into a library</li>
<li>Use <a href="http://puredata.info/">puredata</a> to make music</li>
<li>mpd library for chicken. Using this, write an mpd client that logs music I
  listen to, collects my favourites and suggests music from the collection I've
  rarely/never listened to in order to raise the possibility to get to know my
  entire collection</li>
<li>increase the performance of GNU CVS for the greater good of *BSD</li></ul>
<h1>Abandoned</h1>
<ul>
<li>replace pkg-config (Obsolete, there's <a href="https://github.com/nenolod/pkgconf">pkgconf</a>)
  which was already adopted by FreeBSD</li></ul>#t
#;4> (with-output-to-file "ideas.html" (lambda () (with-input-from-file "Downloads/ideas.md" (lambda () (markdown->html (current-input-port))))))
#t
#;5> ,s cat ideas.html

<h1>Project ideas</h1>
<ul>
<li><a href="rsync.html">library based, compatible rsync replacement</a></li>
<li>UFS file tagging: <a href="ufs.html">Design document</a></li>
<li>improve <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=rcs&amp;sektion=1">OpenRCS</a> and transform it into a library</li>
<li>Use <a href="http://puredata.info/">puredata</a> to make music</li>
<li>mpd library for chicken. Using this, write an mpd client that logs music I
  listen to, collects my favourites and suggests music from the collection I've
  rarely/never listened to in order to raise the possibility to get to know my
  entire collection</li>
<li>increase the performance of GNU CVS for the greater good of *BSD</li></ul>
<h1>Abandoned</h1>
<ul>
<li>replace pkg-config (Obsolete, there's <a href="https://github.com/nenolod/pkgconf">pkgconf</a>)
  which was already adopted by FreeBSD</li></ul>0

this works added by ente on Wed Oct 3 15:37:39 2012

--- bs1	2012-10-03 15:34:22.000000000 +0200
+++ wiki.scm	2012-10-03 15:35:27.000000000 +0200
@@ -30,12 +30,9 @@
   
 (define (markdown-transform path)
   (let* ((new-path (pathname-replace-extension path html-extension))
-         (out-fd   (begin (delete-file* new-path) ; just to be sure
-                          (open-output-file new-path)))
          (in-fd    (open-input-file path)))
                      
-  ; TODO
-  (with-output-to-port out-fd (lambda () (markdown->html in-fd)))))
+  (with-output-to-file new-path (lambda () (markdown->html in-fd)))))
 
 (define (make-index) '()) ;TODO
 

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the one-argument procedure to check if a list is empty?
Visually impaired? Let me spell it for you (wav file) download WAV