DATARAMA

Add changelog

April 27, 2016
Project: plutonium

There's now an autogenerated changelog, replacing the front page feed.

1 files changed, 40 insertions / 37 deletions

diff --git a/plutonium.scm b/plutonium.scm
index f3ed280..7e794fb 100755
--- a/plutonium.scm
+++ b/plutonium.scm
@@ -173,24 +173,6 @@
 
 (define rx/recent (irregex '(: "%RECENT")))
 
-; == Front page activity ====
-(define (render-fp-activity-entry entry)
-  (string-append
-    "<li><a href=\""
-    (uri-encode-string (archive-entry-page entry))
-    ".html\">"
-    (if (link-rating (archive-entry-page entry)) "Review: " "")
-    (archive-entry-title entry)
-    "<span class=\"date\">"
-    (date->string (archive-entry-date entry) date-format/front)
-    "</span></a></li>"))
-
-(define (render-fp-activity feed)
-  (string-append
-    "<ul class=\"fp_feed\">"
-    (apply string-append (map render-fp-activity-entry feed))
-    "</ul>"))
-
 (define (vw-insert-recent txt)
   (let ((feed (generate-feed)))
     (irregex-replace/all
@@ -273,29 +255,50 @@
     `(div (@ (class ,class)) ,content)
     ""))
 
-; == Site Archive =============================================================
-(define (archive-entry page title date) (cons page (cons date title)))
-(define (archive-entry-page entry) (car entry))
-(define (archive-entry-date entry) (cadr entry))
-(define (archive-entry-title entry) (cddr entry))
+; == Site Changelog ===========================================================
+(define (changelog-entry page title date) (cons page (cons date title)))
+(define (changelog-entry-page entry) (car entry))
+(define (changelog-entry-date entry) (cadr entry))
+(define (changelog-entry-title entry) (cddr entry))
+
+(define (generate-changelog-page changelog)
+  (prep-output
+    (cons `(content . ,(render-changelogfeed feed))
+          (page-fields (string-append "Changelog." extension)))))
 
 (define (generate-feed)
-  (sort (map (lambda (x) (archive-entry (filepath:take-base-name x)
+  (sort (map (lambda (x) (changelog-entry (filepath:take-base-name x)
                                         (page-title x)
                                         (page-date x)))
              (filter (lambda (x) (and (string-suffix? ".pu" x) (page-date x)))
                      (directory)))
-        (lambda (x y) (date>? (archive-entry-date x) (archive-entry-date y)))))
+        (lambda (x y) (date>? (changelog-entry-date x) (changelog-entry-date y)))))
 
-(define (render-archivefeed feed)
-  (render-fp-activity feed))
+(define (render-changelogfeed feed)
+  `(ul ,(map render-feed-entry feed)))
 
 (define (render-feed-entry entry)
   `(li (span (@ (class "date"))
-             ,(date->string (archive-entry-date entry) date-format/html))
-       (a (@ (href ,(string-append (archive-entry-page entry) ".html")))
-          ,(if (link-rating (archive-entry-page entry)) "Review: " "")
-          ,(archive-entry-title entry))))
+             ,(date->string (changelog-entry-date entry) date-format/front))
+       (a (@ (href ,(string-append (uri-encode-string (changelog-entry-page entry)) ".html")))
+          (span (@ (class "title")) ,(changelog-entry-title entry)))))
+
+(define (render-fp-activity-entry entry)
+  (string-append
+    "<li><a href=\""
+    (uri-encode-string (changelog-entry-page entry))
+    ".html\">"
+    (if (link-rating (changelog-entry-page entry)) "Review: " "")
+    (changelog-entry-title entry)
+    "<span class=\"date\">"
+    (date->string (changelog-entry-date entry) date-format/front)
+    "</span></a></li>"))
+
+(define (render-fp-activity feed)
+  (string-append
+    "<ul class=\"fp_feed\">"
+    (apply string-append (map render-fp-activity-entry feed))
+    "</ul>"))
 
 ; == Association Maps =========================================================      
 (define (amap-entry file)
@@ -306,7 +309,7 @@
   (map amap-entry 
        (filter 
          (lambda (x) (and (not (string=? x "index.pu"))
-                          (not (string=? x "archive.pu"))
+                          (not (string=? x "Changelog.pu"))
                           (string-suffix? ".pu" x)))
          (directory))))
   
@@ -437,10 +440,10 @@
 (define (generate-page inpath)
   (prep-output (page-fields inpath)))
 
-(define (generate-archive-page feed)
+(define (generate-changelog-page feed)
   (prep-output
-      (cons `(content . ,(render-archivefeed feed))
-            (page-fields (string-append "archive." extension)))))
+      (cons `(content . ,(render-changelogfeed feed))
+            (page-fields (string-append "Changelog." extension)))))
 
 (define (generate-front-page)
   (prep-output (page-fields (string-append "index." extension))))
@@ -490,7 +493,7 @@
          (input-dir  (filepath:take-directory input-file))
          (outpath    (output-path input-file output-dir))
          (outpath/front (filepath:combine output-dir "index.html"))
-         (outpath/archive (filepath:combine output-dir "archive.html")))
+         (outpath/changelog (filepath:combine output-dir "Changelog.html")))
     (if (string=? syntax "markdown")
       (begin
         (change-directory input-dir)
@@ -504,7 +507,7 @@
             (read (open-input-file 
                     (filepath:combine input-dir template-path)))))
         (output-page (generate-page input-file) outpath)
-        (output-page (generate-front-page) outpath/front)
+        (output-page (generate-changelog-page (generate-feed)) outpath/changelog)
         
         (if (not (string=? (filepath:take-base-name input-file) "index"))
           (regenerate-entries  
 
Powered by Plutonium