~whereiseveryone/website

7181b6ffb380c3300abff88bfd70f100b41cfdc8 — jgart 7 months ago 6af0ca7 master
Move pipe code to separate function
1 files changed, 9 insertions(+), 5 deletions(-)

M website.scm
M website.scm => website.scm +9 -5
@@ 27,6 27,13 @@
  (let ((file (location-file (package-location package))))
    (string-prefix? "guixrus/" file)))

(define (commit-hash)
  "Get HEAD commit hash for website."
  (let* ((commit (open-input-pipe "git rev-parse HEAD"))
         (str  (get-string-all commit)))
    (close-pipe commit)
    str))

;;; HTML generator.

(define (package->sxml package)


@@ 41,9 48,6 @@

(define (sxml-page packages)
  "Returns the guixrus HTML page for PACKAGES as an SXML tree."
  (let* ((commit (open-input-pipe "git rev-parse HEAD"))
         (str  (get-string-all commit)))
    (close-pipe commit)
    `(html (@ (lang "en"))
       (meta (@ (charset "utf-8")))
       (head


@@ 51,8 55,8 @@
                  (href "style.css")))
         (title ,(number->string (length packages))))
       (ol ,@(map package->sxml packages))
       (a (@ (href ,(string-append "https://git.sr.ht/~whereiseveryone/website/commit/" str))) 
         ,(string-take str 7))))) ; Get short commit hash.
       (a (@ (href ,(string-append "https://git.sr.ht/~whereiseveryone/website/commit/" (commit-hash)))) 
         ,(string-take (commit-hash) 7)))) ; Get short commit hash.

(define (write-html-page packages port)
  "Write the HTML page for PACKAGES to PORT."