aboutsummaryrefslogtreecommitdiff
path: root/org/blog/generate-phlog.scm
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-06-06 03:15:42 -0600
committernathan <nathansmith@disroot.org>2025-06-06 03:15:42 -0600
commit03f020fd64071d5f000fcd0c326a7d1c71b96917 (patch)
tree0ad27af5c82cd16b26ada4de4e85c2833159c3f4 /org/blog/generate-phlog.scm
parent3363c8df1c89c3fe0631e9989e4dbf1f3af8e73e (diff)
Worked on thing more
Diffstat (limited to 'org/blog/generate-phlog.scm')
-rwxr-xr-xorg/blog/generate-phlog.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/org/blog/generate-phlog.scm b/org/blog/generate-phlog.scm
index 17f0778..3b24da5 100755
--- a/org/blog/generate-phlog.scm
+++ b/org/blog/generate-phlog.scm
@@ -4,13 +4,27 @@
(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 article)))
+ (display (get-gophermap-item (cddr article)) fp)
+ (newline fp)))
(cdr (cadr articles))))))
(define (make-blogs articles)
@@ -20,6 +34,9 @@
(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)))))