;;; GNU Guix web site ;;; Copyright © 2021 Ludovic Courtès ;;; ;;; This file is part of the GNU Guix web site. ;;; ;;; The GNU Guix web site is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU Affero General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; The GNU Guix web site is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU Affero General Public License for more details. ;;; ;;; You should have received a copy of the GNU Affero General Public License ;;; along with the GNU Guix web site. If not, see . (define-module (apps development templates components) #:use-module (apps aux lists) #:use-module (apps aux web) #:use-module (apps base templates components) #:use-module (apps base utils) #:use-module (apps i18n) #:use-module (apps development data) #:use-module (srfi srfi-19) #:export (branch->shtml)) (define (next-deadline date period) "Return DATE or, if DATE is past, DATE + PERIOD. DATE must be a SRFI-19 date and PERIOD is a number of seconds." (let ((now (current-time time-utc)) (then (date->time-utc date))) (if (and (time>? now then) (time> (time-difference now then) (make-time time-utc 0 (* 2 7 3600 24)))) (time-utc->date (make-time time-utc 0 (+ (time-second then) period))) date))) (define (branch->shtml branch) `(div (@ (class "branch-overview")) (div (@ (class "branch-overview-heading")) (a (@ (href ,(branch-git-view-url branch))) (tt ,(branch-name branch))) (a (@ (href ,(branch-build-status-url branch))) (img (@ (alt ,(G_ "branch build status")) (src ,(branch-build-badge-url branch)))))) (div (@ (class "branch-synopsis")) ,(branch-synopsis branch)) (div (@ (class "branch-description")) ,(branch-description branch)) ,@(if (branch-target-date branch) `(,(G_ `(div (@ (class "branch-date")) "target merge date: " ,(date->string (next-deadline (branch-target-date branch) (branch-merge-period branch)) (C_ "SRFI-19 data->string format" "~Y-~m-~d"))))) '())))