show available snapshots on main page
This commit is contained in:
parent
28fc893c70
commit
580a6cd24a
|
@ -32,18 +32,21 @@
|
||||||
(printf "Removing old \"current\" link\n")
|
(printf "Removing old \"current\" link\n")
|
||||||
(delete-file link-file))
|
(delete-file link-file))
|
||||||
|
|
||||||
(define snapshots (for/list ([p (in-list (directory-list snapshots-dir))]
|
(define (get-snapshots)
|
||||||
|
(for/list ([p (in-list (directory-list snapshots-dir))]
|
||||||
#:when (directory-exists? (build-path snapshots-dir p)))
|
#:when (directory-exists? (build-path snapshots-dir p)))
|
||||||
(path-element->string p)))
|
(path-element->string p)))
|
||||||
|
|
||||||
(define n (hash-ref config '#:max-snapshots 5))
|
(define n (hash-ref config '#:max-snapshots 5))
|
||||||
(when (n . < . (length snapshots))
|
|
||||||
|
(let ([snapshots (get-snapshots)])
|
||||||
|
(when (n . < . (length snapshots))
|
||||||
(define remove-snapshots (remove
|
(define remove-snapshots (remove
|
||||||
current-snapshot
|
current-snapshot
|
||||||
(list-tail (sort snapshots string>?) n)))
|
(list-tail (sort snapshots string>?) n)))
|
||||||
(for ([s (in-list remove-snapshots)])
|
(for ([s (in-list remove-snapshots)])
|
||||||
(printf "Removing snapshot ~a\n" s)
|
(printf "Removing snapshot ~a\n" s)
|
||||||
(delete-directory/files (build-path snapshots-dir s))))
|
(delete-directory/files (build-path snapshots-dir s)))))
|
||||||
|
|
||||||
(printf "Creating \"current\" link\n")
|
(printf "Creating \"current\" link\n")
|
||||||
(make-file-or-directory-link current-snapshot link-file)
|
(make-file-or-directory-link current-snapshot link-file)
|
||||||
|
@ -58,4 +61,16 @@
|
||||||
#:post-content `((p "Snapshot ID: "
|
#:post-content `((p "Snapshot ID: "
|
||||||
(a ((href ,(string-append current-snapshot
|
(a ((href ,(string-append current-snapshot
|
||||||
"/index.html")))
|
"/index.html")))
|
||||||
,current-snapshot))))
|
,current-snapshot))
|
||||||
|
,@(let ([snapshots (get-snapshots)])
|
||||||
|
(if ((length snapshots) . < . 2)
|
||||||
|
null
|
||||||
|
`((div ([class "detail"])
|
||||||
|
"Other available snapshots:"
|
||||||
|
,@(for/list ([s (remove "current"
|
||||||
|
(remove current-snapshot
|
||||||
|
(sort snapshots string>?)))])
|
||||||
|
`(span ([class "detail"])
|
||||||
|
nbsp
|
||||||
|
(a ([href ,(string-append s "/index.html")])
|
||||||
|
,s)))))))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user