Move index-page to pages
gitile/handler.scm
| 91 | 91 | (name project-name) | |
| 92 | 92 | (description project-description)) | |
| 93 | 93 | ||
| 94 | - | (define (index-page projects base-git-url title intro footer) | |
| 95 | - | (pk 'projects projects) | |
| 96 | - | `(html | |
| 97 | - | (head | |
| 98 | - | (meta (@ (charset "UTF-8"))) | |
| 99 | - | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) | |
| 100 | - | (link (@ (rel "stylesheet") (href "/css/git.css"))) | |
| 101 | - | (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32"))) | |
| 102 | - | (title ,title)) | |
| 103 | - | (body (@ (lang "en")) | |
| 104 | - | (header (@ (id "intro")) | |
| 105 | - | (h1 "Every project") | |
| 106 | - | ,@intro | |
| 107 | - | (p (@ (id "mire")) | |
| 108 | - | (span (@ (class "blue")) "") | |
| 109 | - | (span (@ (class "red")) "") | |
| 110 | - | (span (@ (class "green")) "") | |
| 111 | - | (span (@ (class "orange")) ""))) | |
| 112 | - | (div (@ (id "content")) | |
| 113 | - | (div (@ (id "project-list")) | |
| 114 | - | ,@(map | |
| 115 | - | (lambda (project) | |
| 116 | - | `(div (@ (class "project")) | |
| 117 | - | (h1 (a (@ (href ,(string-append "/" (project-slug project)))) | |
| 118 | - | ,(project-name project))) | |
| 119 | - | ,@(match (xml->sxml (string-append "<d>" (project-description project) "</d>")) | |
| 120 | - | (('*TOP* ('d content ...)) | |
| 121 | - | content)) | |
| 122 | - | (div (@ (class "instructions")) | |
| 123 | - | (code "git clone " ,base-git-url "/" | |
| 124 | - | ,(project-slug project))))) | |
| 125 | - | projects))) | |
| 126 | - | (footer ,@footer)))) | |
| 127 | - | ||
| 128 | 94 | (define* (show page #:key (code 200)) | |
| 129 | 95 | (values (build-response #:code code #:headers '((content-type . (text/html)))) | |
| 130 | 96 | (with-output-to-string (lambda _ (sxml->xml page))))) | |
… | |||
| 240 | 206 | (let-values (((project-name path) (find-project-component request))) | |
| 241 | 207 | (match (cons project-name path) | |
| 242 | 208 | (("" . ()) | |
| 243 | - | (show (index-page (projects) base-git-url index-title intro footer))) | |
| 209 | + | (show (index-page (projects) <project> base-git-url index-title intro footer))) | |
| 244 | 210 | ((project-name) | |
| 245 | 211 | (call-with-repo project-name | |
| 246 | 212 | (lambda (repo) | |
gitile/pages.scm
| 31 | 31 | #:use-module (rnrs bytevectors) | |
| 32 | 32 | #:use-module (srfi srfi-1) | |
| 33 | 33 | #:use-module (srfi srfi-19) | |
| 34 | + | #:use-module (sxml simple) | |
| 34 | 35 | #:use-module (system foreign) | |
| 35 | 36 | #:use-module (web uri) | |
| 36 | - | #:export (project-file-raw | |
| 37 | + | #:export (index-page | |
| 38 | + | style | |
| 39 | + | project-file-raw | |
| 37 | 40 | project-files | |
| 38 | 41 | project-index | |
| 39 | 42 | project-commits | |
| 40 | 43 | project-commit | |
| 41 | - | project-tags | |
| 42 | - | style)) | |
| 44 | + | project-tags)) | |
| 45 | + | ||
| 46 | + | (define (index-page projects project-type base-git-url title intro footer) | |
| 47 | + | `(html | |
| 48 | + | (head | |
| 49 | + | (meta (@ (charset "UTF-8"))) | |
| 50 | + | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) | |
| 51 | + | (link (@ (rel "stylesheet") (href "/css/git.css"))) | |
| 52 | + | (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32"))) | |
| 53 | + | (title ,title)) | |
| 54 | + | (body (@ (lang "en")) | |
| 55 | + | (header (@ (id "intro")) | |
| 56 | + | (h1 "Every project") | |
| 57 | + | ,@intro | |
| 58 | + | (p (@ (id "mire")) | |
| 59 | + | (span (@ (class "blue")) "") | |
| 60 | + | (span (@ (class "red")) "") | |
| 61 | + | (span (@ (class "green")) "") | |
| 62 | + | (span (@ (class "orange")) ""))) | |
| 63 | + | (div (@ (id "content")) | |
| 64 | + | (div (@ (id "project-list")) | |
| 65 | + | ,@(map | |
| 66 | + | (match-lambda | |
| 67 | + | (($ project-type slug name description) | |
| 68 | + | `(div (@ (class "project")) | |
| 69 | + | (h1 (a (@ (href ,(string-append "/" slug))) | |
| 70 | + | ,(if (string-null? name) slug name))) | |
| 71 | + | ,@(match (xml->sxml (string-append "<d>" description "</d>")) | |
| 72 | + | (('*TOP* ('d content ...)) | |
| 73 | + | content)) | |
| 74 | + | (div (@ (class "instructions")) | |
| 75 | + | (code "git clone " ,base-git-url "/" ,slug))))) | |
| 76 | + | projects))) | |
| 77 | + | (footer ,@footer)))) | |
| 78 | + | ||
| 79 | + | (define (style page project ref footer) | |
| 80 | + | `(html | |
| 81 | + | (head | |
| 82 | + | (meta (@ (charset "UTF-8"))) | |
| 83 | + | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) | |
| 84 | + | (link (@ (rel "stylesheet") (href "/css/gitile.css"))) | |
| 85 | + | (link (@ (rel "stylesheet") (href "/css/highlight.css"))) | |
| 86 | + | (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32"))) | |
| 87 | + | (script (@ (src "/js/gitile.js")) "") | |
| 88 | + | (title ,project)) | |
| 89 | + | (body | |
| 90 | + | (header | |
| 91 | + | (nav | |
| 92 | + | (ul | |
| 93 | + | (li (@ (class "first")) (a (@ (href "/")) "Projects")) | |
| 94 | + | (li (a (@ (href "/" ,project)) "Repository")) | |
| 95 | + | (li (a (@ (href "/" ,project "/tree/" ,ref)) "Files")) | |
| 96 | + | (li (a (@ (href "/" ,project "/commits")) "Commits")) | |
| 97 | + | (li (a (@ (href "/" ,project "/tags")) "Tags"))))) | |
| 98 | + | (div (@ (id "content")) | |
| 99 | + | ,@page) | |
| 100 | + | (footer ,@footer)))) | |
| 43 | 101 | ||
| 44 | 102 | (define* (project-file-raw repo path #:key (ref "-")) | |
| 45 | 103 | (let* ((ref (if (equal? ref "-") #f ref)) | |
… | |||
| 337 | 395 | (loop lines (+ old-line 1) (+ new-line 1)))))) | |
| 338 | 396 | 0)) | |
| 339 | 397 | (append content (cons file-header `((table (@ (class "file-diff")) ,file-content)))))) | |
| 340 | - | ||
| 341 | - | (define (style page project ref footer) | |
| 342 | - | `(html | |
| 343 | - | (head | |
| 344 | - | (meta (@ (charset "UTF-8"))) | |
| 345 | - | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) | |
| 346 | - | (link (@ (rel "stylesheet") (href "/css/gitile.css"))) | |
| 347 | - | (link (@ (rel "stylesheet") (href "/css/highlight.css"))) | |
| 348 | - | (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32"))) | |
| 349 | - | (script (@ (src "/js/gitile.js")) "") | |
| 350 | - | (title ,project)) | |
| 351 | - | (body | |
| 352 | - | (header | |
| 353 | - | (nav | |
| 354 | - | (ul | |
| 355 | - | (li (@ (class "first")) (a (@ (href "/")) "Projects")) | |
| 356 | - | (li (a (@ (href "/" ,project)) "Repository")) | |
| 357 | - | (li (a (@ (href "/" ,project "/tree/" ,ref)) "Files")) | |
| 358 | - | (li (a (@ (href "/" ,project "/commits")) "Commits")) | |
| 359 | - | (li (a (@ (href "/" ,project "/tags")) "Tags"))))) | |
| 360 | - | (div (@ (id "content")) | |
| 361 | - | ,@page) | |
| 362 | - | (footer ,@footer)))) | |