DATARAMA

Add project page regen tool

May 02, 2016
Project: plutonium

This revision adds a little script that automatically regenerates all project pages (pages that set the %project vwcode). It needs to be configured before use (defaults are my file locations), and works best if put into a script that runs goon.

1 files changed, 31 insertions / 0 deletions

diff --git a/regen-project-pages.scm b/regen-project-pages.scm
new file mode 100755
index 0000000..6f7f43e
--- /dev/null
+++ b/regen-project-pages.scm
@@ -0,0 +1,31 @@
+#!/bin/csi -s
+
+; A little convenience script for Goon/Plutonium integration. Might end up 
+; being absorbed into Plutonium proper.
+
+(use irregex utils posix srfi-1)
+
+(define pu-dir "/home/simon/notes/")
+(define out-dir "/home/simon/www/")
+
+(define (get-project-pages)
+  (filter (lambda (x) (read-vwcode "%project" (read-all (string-append pu-dir "/" x))))
+          (filter (lambda (x) (and (not (string=? x "index.pu"))
+                                   (not (string=? x "Changelog.pu"))
+                                   (string-suffix? ".pu" x)))
+                  (directory pu-dir))))
+                 
+(define (read-vwcode code txt)
+    (let ((cmatch (irregex-search
+                    (irregex `(seq bol ,code (submatch-named found (*? any)) eol))
+                    txt)))
+      (if cmatch (string-trim-both (irregex-match-substring cmatch 'found))
+        #f)))
+
+(for-each
+  (lambda (x) 
+    (let ((cmd (string-append "plutonium 1 markdown pu " out-dir " " pu-dir "/" x)))
+      (display cmd) (newline)
+      (system cmd)
+      ))
+  (get-project-pages))
 
Powered by Plutonium