Display README after directory content
gitile/pages.scm
52 | 52 | "/") | |
53 | 53 | path)) | |
54 | 54 | ||
55 | + | (define (file-content repo path ref repository-name) | |
56 | + | `((div (@ (class "content")) | |
57 | + | (p ,(basename path)) | |
58 | + | (p (@ (class "button-row")) | |
59 | + | (a (@ (href "/" ,repository-name "/raw/" ,(or ref "-") | |
60 | + | "/" ,path)) | |
61 | + | (img (@ (src "/images/file-type-3.svg")))))) | |
62 | + | (pre ,(utf8->string (get-file-content repo path #:ref ref))))) | |
63 | + | ||
55 | 64 | (define* (project-files repository-name repo #:key (ref "-") (path '())) | |
56 | 65 | (let* ((ref (if (equal? ref "-") #f ref)) | |
57 | 66 | (path-box (parent-paths-box repository-name ref path)) | |
… | |||
59 | 68 | (dir-path (if (string-null? path) path (string-append path "/"))) | |
60 | 69 | (files (sort (get-files repo #:ref ref #:path dir-path) | |
61 | 70 | (lambda (f1 f2) | |
62 | - | (string<=? (file-name f1) (file-name f2)))))) | |
71 | + | (string<=? (file-name f1) (file-name f2))))) | |
72 | + | (readme (filter | |
73 | + | (lambda (f) | |
74 | + | (or (string-ci=? (file-name f) "README.md") | |
75 | + | (string-ci=? (file-name f) "README"))) | |
76 | + | files))) | |
63 | 77 | (if (and (string-null? path) (null? files)) | |
64 | 78 | `(p "Empty repository") | |
65 | 79 | (if (null? files) | |
66 | 80 | `(,path-box | |
67 | - | (div (@ (class "content")) | |
68 | - | (p ,(basename path)) | |
69 | - | (p (@ (class "button-row")) | |
70 | - | (a (@ (href "/" ,repository-name "/raw/" ,(or ref "-") | |
71 | - | "/" ,path)) | |
72 | - | (img (@ (src "/images/file-type-3.svg")))))) | |
73 | - | (pre ,(utf8->string (get-file-content repo path #:ref ref)))) | |
81 | + | ,(file-content repo path ref repository-name)) | |
74 | 82 | `(,(last-commit-infobox repository-name repo ref) | |
75 | 83 | ,path-box | |
76 | 84 | (table | |
… | |||
95 | 103 | (commit-id commit)))) | |
96 | 104 | ,(commit-summary commit))) | |
97 | 105 | (td ,(time->date-string (commit-time commit))))))) | |
98 | - | files)))))))) | |
106 | + | files))) | |
107 | + | ,@(if (null? readme) | |
108 | + | '() | |
109 | + | (file-content | |
110 | + | repo | |
111 | + | (string-append path (if (equal? path "") "" "/") | |
112 | + | (file-name (car readme))) | |
113 | + | ref | |
114 | + | repository-name))))))) | |
99 | 115 | ||
100 | 116 | (define get-config-string | |
101 | 117 | (let ((proc (libgit2->procedure int "git_config_get_string" '(* * *)))) |