1 | #!/usr/bin/csi -script |
---|
2 | |
---|
3 | (use versions posix regex utils web-scheme (srfi 1 13 69)) |
---|
4 | |
---|
5 | (define snapshots-dir "/var/www/localhost/htdocs/dev-snapshots") |
---|
6 | (define snapshots-output-file "/var/www/localhost/htdocs/dev-snapshots/index.html") |
---|
7 | |
---|
8 | (define (safe-take l n) |
---|
9 | (if (< (length l) n) |
---|
10 | l (take l n))) |
---|
11 | |
---|
12 | (let ((data (with-input-from-pipe |
---|
13 | (string-append "find " snapshots-dir " -name \"chicken-*.tar.gz\" | grep -v linux-x86") |
---|
14 | read-lines))) |
---|
15 | (with-output-to-file snapshots-output-file |
---|
16 | (lambda () |
---|
17 | (let* ((versions/dates |
---|
18 | (map (lambda (item) |
---|
19 | (and-let* ((version (string-match ".*/chicken-([0-9]\\.[0-9]+\\.*[0-9]*)\\.tar\\.gz" item)) |
---|
20 | (version (string->version (cadr version))) |
---|
21 | (date (string-match ".*/([0-9]{4}/[0-9]{2}/[0-9]{2})/.*" item)) |
---|
22 | (date (cadr date))) |
---|
23 | (cons version date))) |
---|
24 | data)) |
---|
25 | (versions (safe-take (sort (delete-duplicates (map car versions/dates)) version>?) 20)) |
---|
26 | (linux-bin (lambda (version) (string-append "chicken-" version "-linux-x86.tar.gz"))) |
---|
27 | ;(win-bin (lambda (version) (string-append "chicken-" version"-mingw32-x86.zip "))) |
---|
28 | (source-tarball (lambda (version) (string-append "chicken-" version ".tar.gz ")))) |
---|
29 | (print |
---|
30 | (ws:page |
---|
31 | (string-append |
---|
32 | (div 'id "header" (h1 "Chicken development snapshots")) |
---|
33 | (div 'style "float: left;" |
---|
34 | (ws:make-table |
---|
35 | (map (lambda (version) |
---|
36 | (let* ((latest (car (sort (filter (lambda (item) |
---|
37 | (equal? (car item) version)) |
---|
38 | versions/dates) |
---|
39 | (lambda (a b) |
---|
40 | (string> (cdr a) (cdr b)))))) |
---|
41 | (version (car latest)) |
---|
42 | (version-string (version->string version)) |
---|
43 | (date (cdr latest)) |
---|
44 | (local-dir (make-pathname snapshots-dir date)) |
---|
45 | (fexists? (lambda (file) (file-exists? (make-pathname local-dir file)))) |
---|
46 | (link-to (lambda (file text) |
---|
47 | (if (and file (fexists? file)) |
---|
48 | (a 'href (string-append "http://chicken.wiki.br/dev-snapshots/" |
---|
49 | date "/" file) text) |
---|
50 | (b text))))) |
---|
51 | (filter-map link-to |
---|
52 | `(#f "NEWS" "chicken.pdf" |
---|
53 | ,(source-tarball version-string) ,(linux-bin version-string)) |
---|
54 | `(,version-string "NEWS" "Manual (PDF)" "Source code" "Linux binary")) |
---|
55 | |
---|
56 | )) |
---|
57 | versions))) |
---|
58 | (div 'style "padding-top: 40px;" |
---|
59 | (ws:itemize |
---|
60 | `(,(a 'href "http://chicken.wiki.br/binary-distributions" |
---|
61 | "How to install and use binary distributions of Chicken") |
---|
62 | ,(a 'href "http://chicken.wiki.br/releases/" |
---|
63 | "Browse releases"))))) |
---|
64 | css-file: "http://galinha.ucpel.tche.br/common-css" |
---|
65 | page-title: "Chicken development snapshots" |
---|
66 | )))))) |
---|