From c7dde38d90e9525ccb360fa379667087cecfd687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 1 Jun 2019 21:31:37 +0200 Subject: Move get-git-version to new git module. --- module/git.scm | 12 ++++++++++++ module/output/html.scm | 15 +++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 module/git.scm diff --git a/module/git.scm b/module/git.scm new file mode 100644 index 00000000..dfb60526 --- /dev/null +++ b/module/git.scm @@ -0,0 +1,12 @@ +(define-module (git) + :use-module (util) + :use-module ((ice-9 rdelim) :select (read-line)) + :use-module ((ice-9 popen) :select (open-input-pipe)) + :export (get-git-version)) + +(define (get-git-version) + (-> "git rev-parse HEAD" + open-input-pipe + read-line)) + + diff --git a/module/output/html.scm b/module/output/html.scm index 6239e3d5..3df48159 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -13,6 +13,7 @@ #:use-module (ice-9 getopt-long) + #:use-module (git) #:use-module (parameters) #:use-module (config)) @@ -212,12 +213,7 @@ (cons `(tr ,@w) (recur rest))))))))) -(define *repo-url* "https://git.hornquist.se") - -(define (get-git-version) - (symbol->string - (read ((@ (ice-9 popen) open-input-pipe) - "git rev-parse HEAD")))) +(define repo-url (make-parameter "https://git.hornquist.se")) (define-public (html-generate calendars events start end) (define evs (get-groups-between (group-stream events) @@ -236,7 +232,7 @@ (content "Calendar for the dates between " ,(date->string start) " and " ,(date->string end)))) ,(include-css "static/style.css") - ;; (script (@ (src "static/script.js")) "") + (script (@ (src "static/script.js")) "") (style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%.CAL_bg_~a { border-color: ~a }~%~}" (map (lambda (c) (let* ((name (html-attr (attr c 'NAME))) @@ -254,11 +250,11 @@ (div (@ (class "days")) ,@(stream->list (stream-map lay-out-day evs)))) (footer (span "Page generated " ,(date->string (current-date))) - (span (a (@ (href ,*repo-url* "/calparse")) + (span (a (@ (href ,(repo-url) "/calparse")) "Source Code")) ,(let* ((hash (get-git-version)) (url (format #f "~a/calparse/commit/?id=~a" - *repo-url* hash))) + (repo-url) hash))) `(span "Version " (a (@ (href ,url)) ,hash))))) (aside (@ (class "sideinfo")) (div (@ (class "about")) @@ -272,7 +268,6 @@ (define start (parse-freeform-date (option-ref opts 'from "2019-04-15"))) (define end (parse-freeform-date (option-ref opts 'to "2019-05-10"))) - (html-generate calendars events start end)) -- cgit v1.2.3