DATARAMA

Improve commit page layout

January 28, 2016
Project: goon

This patch introduces better commit page layouts, such that the subject line becomes a proper page title rather than just a line of text. Since this removes the project name from the page title, I have put it (as a link to the main project page) into the sidebar, to restore cosmic balance.

There is also a minor cleanup to the sidebar; the parent id is now less ugly to look at.

1 files changed, 16 insertions / 8 deletions

diff --git a/goon.scm b/goon.scm
index fe33bde..7fd0a4e 100755
--- a/goon.scm
+++ b/goon.scm
@@ -497,22 +497,24 @@
         (div (@ (class "sidebar-module"))
              (h2 "date")
              ,(display-time-long (commit-time comm))
+             (h2 "project")
+             (a (@ (href ,(repository-outfile repo "master")))
+                ,(repository-name repo))
              ,(if (commit-parent comm)
                 `(div (h2 "parent")
                       (a (@ (href ,(commit-path (commit-parent comm))))
                    ,(string-append (substring 
                       (oid->string (commit-id (commit-parent comm)))
-                      0 16) "..."))
+                      0 8)))
                       ,(render-changes repo (commit-parent comm) comm))
                 #f))))
 
 (define (commitmsg-first-line comm)
   (car (string-split (commit-message comm) "\n")))
 
-(define (render-commitmain repo comm)
+(define (render-commitmain repo body comm)
   `(div 
-     ,(markdown->sxml (commit-message comm))
-     (hr)
+     ,(if body `(div ,body (hr)) #f)
      ,(if (commit-parent comm)
         (let ((diffs (diff repo 
                            (commit-tree (commit-parent comm)) 
@@ -521,13 +523,19 @@
         #f)))
 
 (define (render-commitpage repo comm)
+  (let* ((pieces (irregex-split "\n\n" (commit-message comm)))
+         (subject (car pieces))
+         (body (if (> (length pieces) 1)
+                 (markdown->sxml (string-join (cdr pieces) "\n\n"))
+                 #f)))
   (if (not (already-rendered? repo (commit-path comm)))
     (output-page repo
-      (prep-output `((header-title  . ,(repository-name repo))
+      (prep-output `((header-title  . ,(string-append (repository-name repo) 
+                                                      ": " subject))
                      (sidebar       . ,(commits-sidebar repo comm))
-                   (title        . (h1 (@ (id "pagetitle")) ,(string-append "Project: " (repository-name repo))))
-                     (content       . ,(render-commitmain repo comm))))
-      (commit-path comm))))
+                     (title         . (h1 (@ (id "pagetitle")) ,subject))
+                     (content       . ,(render-commitmain repo body comm))))
+      (commit-path comm)))))
 
 (define (commitlist-sidebar repo)
   `(div (@ (class "sidebar-module-outer"))
 
Powered by Plutonium