aboutsummaryrefslogtreecommitdiff
path: root/blog/generate_html.scm
diff options
context:
space:
mode:
authornathansmith <nathansmith@posteo.com>2025-05-23 07:43:34 -0600
committernathansmith <nathansmith@posteo.com>2025-05-23 07:43:34 -0600
commit4e749697600bab526b1cf51bcca493f6d31d2e34 (patch)
tree10a0274c96667d1482dd7f07d768feaf518d6187 /blog/generate_html.scm
parentd194694f31002068868a378d121ed0e2db01c378 (diff)
Almost done with this stupidness
Diffstat (limited to 'blog/generate_html.scm')
-rwxr-xr-xblog/generate_html.scm71
1 files changed, 0 insertions, 71 deletions
diff --git a/blog/generate_html.scm b/blog/generate_html.scm
deleted file mode 100755
index 2d9baeb..0000000
--- a/blog/generate_html.scm
+++ /dev/null
@@ -1,71 +0,0 @@
-#! /usr/bin/guile \
--e main -s
-!#
-
-(use-modules (sxml simple))
-
-;; Loads an entire text file into a string
-(define (read-entire-file file)
- (call-with-input-file file
- (lambda (fp)
- (letrec ((read-characters
- (lambda (fp)
- (let ((character (read-char fp)))
- (cond
- ((eof-object? character) "")
- (else (string-append (string character)
- (read-characters fp))))))))
- (read-characters fp)))))
-
-;; Make a link for the article
-(define (make-article-list-link article)
- (let ((title (cadr (list-ref article 0)))
- (name (cadr (list-ref article 2))))
- (string-append " <li><a href=\"#" name "\">" title "</a></li/>\n")))
-
-;; Reads the article file and formats some stuff out
-(define (get-raw-article file)
- (letrec ((article (read-entire-file file))
- (article-open (string-contains article "<article>"))
- (article-close (string-contains article "</article>")))
- (substring article (+ article-open 9) article-close)))
-
-;; Makes a card for the article
-(define (make-article-card article)
- (let ((title (cadr (list-ref article 0)))
- (name (cadr (list-ref article 2)))
- (pub-date (cadr (list-ref article 4)))
- (file (cadr (list-ref article 6))))
- (string-append
- "\n<table border=\"1\" width=\"60%\">\n"
- " <tr><td><h2 id=\"" name "\">" title "</h2>--- " pub-date
- "</td></tr>\n"
- " <tr><td>" (get-raw-article file) " </td></tr>\n"
- "</table>\n")))
-
-;; Generates a html blog from xml data
-(define (generate-html)
- (let ((template (read-entire-file "template.html"))
- (article-list "<ul>\n")
- (article-cards "")
- (articles (call-with-input-file "articles.xml"
- (lambda (fp)
- (xml->sxml fp)))))
- (for-each (lambda (article)
- (when (list? article)
- ;; Add a article link
- (set! article-list
- (string-append article-list
- (make-article-list-link
- (cddr article))))
- ;; Add article card
- (set! article-cards
- (string-append article-cards
- (make-article-card
- (cddr article))))))
- (cdr (cadr articles)))
- (set! article-list (string-append article-list "</ul>\n"))
- (format #t template article-list article-cards)))
-
-(define (main args)
- (generate-html))