#! /usr/bin/guile \ -e main -s !# (use-modules (sxml simple)) (define (format-gophermap-filename file) (let ((file-length (string-length file))) (string-append (substring file 0 (- file-length 4)) ".txt"))) (define (get-gophermap-item article) (let ((title (cadr (list-ref article 0))) (pub-date (cadr (list-ref article 4))) (file (cadr (list-ref article 6)))) (string-append "0" pub-date " - " title "\t" file))) (define (make-gophermap articles) (call-with-output-file "phlog/gophermap" (lambda (fp) (for-each (lambda (article) (if (list? article) (display (get-gophermap-item (cddr article)) fp) (newline fp))) (cdr (cadr articles)))))) (define (make-blogs articles) '()) (define (generate-phlog) (call-with-input-file "articles.xml" (lambda (fp) (let ((articles (xml->sxml fp))) (unless (file-exists? "phlog") (mkdir "phlog") (mkdir "phlog/articles")) (make-gophermap articles) (make-blogs articles))))) (define (main args) (generate-phlog))