Add goto button in commit box

Julien LepillerSun Sep 27 23:15:03+0200 2020

342b64c

Add goto button in commit box

gitile/pages.scm

6060
        `(p "Empty repository")
6161
        (if (null? files)
6262
            `(,path-box
63-
	      (div (@ (class "content"))
63+
              (div (@ (class "content"))
6464
                 (p ,(basename path))
65-
		 (p (@ (class "button-row"))
66-
		   (a (@ (href "/" ,repository-name "/raw/" ,(or ref "-")
67-
			       "/" ,path))
68-
		      (img (@ (src "/images/file-type-3.svg"))))))
65+
                 (p (@ (class "button-row"))
66+
                   (a (@ (href "/" ,repository-name "/raw/" ,(or ref "-")
67+
                               "/" ,path))
68+
                      (img (@ (src "/images/file-type-3.svg"))))))
6969
              (pre ,(utf8->string (get-file-content repo path #:ref ref))))
7070
            `(,(last-commit-infobox repository-name repo ref)
7171
              ,path-box

121121
         (commit (last-commit repo ref)))
122122
    (commit-infobox repository-name commit)))
123123
124-
(define (commit-infobox repository-name commit)
124+
(define* (commit-infobox repository-name commit #:key (open? #f))
125125
  `(div (@ (class "commit-info"))
126126
     (p (img (@ (src ,(author-image (commit-author commit))))))
127127
     (div (@ (class "commit"))

138138
             ,(string-take (oid->string (commit-id commit)) 7))
139139
          (button (@ (data-clipboard-copy ,(oid->string (commit-id commit)))
140140
                     (class "copy"))
141-
              (img (@ (src "/images/copy.png")))))))
141+
              (img (@ (src "/images/copy.png"))))
142+
          ,(if open?
143+
               `(a (@ (href "/" ,repository-name "/tree/"
144+
                            ,(oid->string (commit-id commit))))
145+
                    (img (@ (src "/images/go.png"))))
146+
	       '()))))
142147
143148
(define (project-commits repository-name repo ref)
144149
  (let* ((commits (get-commits repo ref))
145150
         (next (cdr commits))
146151
         (commits (car commits)))
147152
    `(,(map (lambda (commit)
148-
              (commit-infobox repository-name commit))
153+
              (commit-infobox repository-name commit #:open? #t))
149154
            commits)
150155
      ,(if next
151156
           `(p (a (@ (href "/" ,repository-name "/commits/"

155160
(define (parent-paths-box repository-name ref path)
156161
  `(div (@ (class "path-box"))
157162
    ,(if (null? (pk 'path path))
158-
	 `(a (@ (href "/" ,repository-name)) ,repository-name)
163+
         `(a (@ (href "/" ,repository-name)) ,repository-name)
159164
         (fold
160165
           (lambda (p res)
161166
             (cons* p "/" res))
162167
           (list `(a ,(car (reverse path))))
163168
           (map
164169
             (lambda (p)
165-
	       (let ((p (if (string-null? p) p (substring p 1)))
166-
		     (base (if (string-null? (basename p))
167-
			       repository-name
168-
			       (basename p))))
170+
               (let ((p (if (string-null? p) p (substring p 1)))
171+
                     (base (if (string-null? (basename p))
172+
                               repository-name
173+
                               (basename p))))
169174
                 `(a (@ (href "/" ,repository-name "/tree/" ,(or ref "-") "/" ,p))
170175
                     ,base)))
171176
             (fold